]> _ Git - ccgm.git/commitdiff
WIP #2340 @6.25
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 31 Jan 2019 17:52:35 +0000 (17:52 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 31 Jan 2019 17:52:35 +0000 (17:52 +0000)
framework/application/Bootstrap.php
framework/application/controllers/ResearchCategoriesController.php
framework/application/forms/CMS/Research.php
framework/application/views/helpers/ResearchCategories.php [new file with mode: 0644]
framework/application/views/scripts/research-categories/index.phtml
framework/application/views/scripts/templates/research.phtml
js/research.js [new file with mode: 0644]
less/research.less [new file with mode: 0644]

index 2f9008c8d8bdaddb56acd11ec96cf0aeb85db332..c98a85460c3a92d1ea331aa01461f234de848c95 100644 (file)
@@ -99,6 +99,10 @@ class Bootstrap extends CubeIT_Bootstrap {
         }
     }
 
+    // URL template used for research study pages
+    public static function getResearchCategoriesURLTemplate() {
+        return '/Recherche-clinique/%name%'; // Important: must have leading slash or pages will show as not found!
+    }
 
     /**
      *
@@ -108,7 +112,7 @@ class Bootstrap extends CubeIT_Bootstrap {
         //$datas = $this->getCMSDatasOfNavigationPage($page);
 
         // How the URLs should be formed for the research category pages
-        $URL_template = '/Recherche-clinique/%name%'; // Important: must have leading slash or pages will show as not found!
+        $URL_template = self::getResearchCategoriesURLTemplate();
 
         $db = Zend_Db_Table::getDefaultAdapter();
         $s = $db->select()->from('research_categories')
index 7bac7c2c5b56e9550f292dac6f97b36ab64209f8..3f10fb8117cad63df7f6991b5674e6fda302ea22 100644 (file)
@@ -4,17 +4,20 @@ class ResearchCategoriesController extends CubeIT_Controller_PageController {
 
     public function indexAction() {
 
+        $this->view->headScript()->addScriptAndStyle('research');
+
         $parent = $this->view->currentPage->getParent();
         $parent_data = $this->getBootstrap()->getCMSDatasOfNavigationPage($parent);
         $this->view->datas = $parent_data;
 
-        // Todo: inner join for category name etc?
-
         $db = Zend_Db_Table::getDefaultAdapter();
-        $s = $db->select()->from('research_studies')
-            ->order('id DESC')
-            ->where('category = ?', $this->getRequest()->getParam('research_category_id'));
-        $q = $s->query();
+        $select = $db->select()->from(['s' => 'research_studies'])
+                ->joinInner(['c' => 'research_categories'], 'c.id = s.category', ['c.name AS category_name'])
+                ->order('s.id DESC')
+                ->where('s.category = ?', $this->getRequest()->getParam('research_category_id'));
+        $query = $select->query();
+
+        //echo 'QUERY: '. (string) $select;
 
 //        if (!$q->rowCount()) {
 //            $this->_404();
@@ -24,8 +27,16 @@ class ResearchCategoriesController extends CubeIT_Controller_PageController {
 //        $r = CubeIT_Util_Cms::unserialize($q->fetch());
         $this->view->parent_title = $parent_data['shortTitle'];
         $this->view->sidebar = $parent_data['sidebar'];
-//        $this->view->titre = $r->titre;
-        $this->view->studies = $q->fetchAll();
+        $this->view->studies = $query->fetchAll();
+
+        // Get specialities data
+        $specialities = [];
+        $query_specialities = $db->select()->from('research_specialities')->query();
+        while ($speciality = $query_specialities->fetch()) {
+            $specialities[$speciality->id] = CubeIT_Util_Object::toArray($speciality);
+        }
+
+        $this->view->specialities = $specialities;
     }
 
 }
index 540ce159dab4372bbcac81fba18b2ce624f416ea..de8103d2f270eabbc28ca6b3a734d25123bc644a 100644 (file)
@@ -4,6 +4,11 @@ class CCGM_Form_CMS_Research extends CCGM_Form_CMS_Text {
        public function init() {\r
                parent::init();\r
 \r
+        $intro = new CCGM_Form_Element_Markitup('studies_intro');\r
+        $intro->setLabel("Texte d'introduction pour les études");\r
+        $intro->setAttrib('rows', 10);\r
+        $this->addElement($intro);\r
+\r
                $studies = new CCGM_Form_CMS_Element_ResearchStudies('studies');\r
                $studies->setLabel('Gestion des études cliniques');\r
                $this->addElement($studies);\r
diff --git a/framework/application/views/helpers/ResearchCategories.php b/framework/application/views/helpers/ResearchCategories.php
new file mode 100644 (file)
index 0000000..851f72c
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+class CCGM_View_Helper_ResearchCategories extends CubeIT_View_Helper_Abstract {
+
+    public function ResearchCategories() {
+
+        $this->headScript()->addScriptAndStyle('research');
+
+        $db = Zend_Db_Table::getDefaultAdapter();
+        $table = 'research_categories';
+
+        //SELECT c.*, COUNT(s.id) as study_count FROM research_categories c INNER JOIN research_studies s ON c.id = s.category GROUP BY c.id
+        // Get distinct list of categories present in the table
+        $select = $db->select()
+            ->from($table, [$table.'.*'])
+            ->joinInner('research_studies', $table.'.id = research_studies.category', ['COUNT(research_studies.id) AS study_count'])
+            ->group($table.'.id')
+            ->order($table.'.sort_order ASC');
+
+        //echo 'QUERY: '. (string) $select;
+
+        $query = $select->query();
+
+        $res = '<div class="research-categories">';
+
+        while ($row = $query->fetch()) {
+
+            $URL = CubeIT_Navigation_Page::generateAutoUri($row, Bootstrap::getResearchCategoriesURLTemplate());
+
+            $res .= '<a href="'. $URL .'" class="research-categories-link">';
+            $res .= '<div class="research-categories-icon">';
+            $res .= '<img src="'. CubeIT_View_Helper_ImageCms::getPath($row->icon) .'">';
+            $res .= '</div>'; // .research-categories-icon
+            $res .= '<span class="research-categories-name">'. $row->name .'</span>';
+            $res .= '</a>';
+
+        }
+
+        $res .= '</div>';
+
+        echo $res;
+    }
+
+
+}
index d9686f4f60e4ffa65a868a64c3226295bf83ca3b..28728ed1ef4dc2dc6dff92789675d2a586fad2b1 100644 (file)
@@ -10,9 +10,30 @@ $this->showsidebar = false;
         <h1><?= $this->parent_title ?></h1>
         <h2><?= $this->currentPage->label ?></h2>
 
-        <pre>
-        <?php print_r($this->studies); ?>
-        </pre>
+        <?php if (count($this->studies) == 0) echo __('Aucun résultat trouvé.'); ?>
+
+        <?php foreach($this->studies as $study): ?>
+
+            <div class="research-study">
+                <div class="study-main">
+                    <div class="study-title"><?= $study->title ?></div>
+                    <div class="study-description"><?= nl2br($study->description) ?></div>
+
+                    <a href="mailto:camille.laurent@oncoclem.org?subject=<?= urlencode("Essai clinique : {$study->title}") ?>" class="study-contact">Nous contacter</a>
+                </div>
+                <div class="study-details">
+                    <p><strong>Pathologie :</strong> <?= $study->pathology ?></p>
+                    <p><strong>Investigateur :</strong> <?= $study->investigator ?></p>
+                    <p>
+                        <strong style="vertical-align: bottom">Spécialité(s) :</strong>
+                        <?php foreach(CubeIT_Util_Cms::unserialize($study->specialities) as $specialityID): ?>
+                        <img src="<?= CubeIT_View_Helper_ImageCms::getPath($this->specialities[$specialityID]['icon']) ?>" data-tooltip="<?= $this->specialities[$specialityID]['name'] ?>" style="margin-right:0.5em; height: 30px">
+                        <?php endforeach; ?>
+                    </p>
+                </div>
+            </div>
+
+        <?php endforeach; ?>
 
     </div>
     <?php echo $this->rightbar() ?>
index bdd0ec1bdf8d0b7d226ae69725661bee7f329fba..0e03fd65224ddf421a1f5dc10a6f8c4c61150d22 100644 (file)
@@ -6,6 +6,8 @@ $this->contentWidth = 662;
 <section id="content">\r
        <div id="c">\r
                <?php\r
+        echo $this->markupDotclear($this->studies_intro);\r
+        echo $this->ResearchCategories();\r
                echo $this->markupDotclear($this->text);\r
                ?>\r
        </div>\r
diff --git a/js/research.js b/js/research.js
new file mode 100644 (file)
index 0000000..6a55159
--- /dev/null
@@ -0,0 +1,42 @@
+TO_LOAD_ONCE[TO_LOAD_ONCE.length] = 'load_research();';
+
+function load_research() {
+
+  var maxHeight = 100, // 20px line height so 100 is 5 lines
+      more = 'En savoir plus',
+      less = 'Réduire';
+
+  $('.study-description').each(function() {
+    var originalHeight = $(this).height();
+
+    $(this).data('height', originalHeight); // Keep full height so we can animate to this when revealing
+
+    if (originalHeight > maxHeight) {
+
+      $(this).css({
+        'maxHeight': maxHeight,
+        'overflow': 'hidden',
+        'transition': 'max-height 0.4s' // animate when max-height changes
+      });
+      $(this).after('<a href="#" class="toggle-description" data-less="'+ less +'" data-more="'+ more +'">'+ more +'</a>')
+    }
+  });
+
+  $(document).on('click', '.toggle-description', function(event) {
+    event.preventDefault();
+
+    var $link = $(this),
+        $description = $link.parent().find('.study-description');
+
+    $link.toggleClass('open');
+
+    if ($link.hasClass('open')) {
+      $link.text($link.data('less'));
+      $description.css('maxHeight', $description.data('height'));
+    } else {
+      $link.text($link.data('more'));
+      $description.css('maxHeight', maxHeight);
+    }
+  });
+
+}
diff --git a/less/research.less b/less/research.less
new file mode 100644 (file)
index 0000000..44c152b
--- /dev/null
@@ -0,0 +1,92 @@
+@import "constants.less";
+
+.research-categories {
+  display: flex;
+  flex-wrap: wrap;
+  margin: 2em 0;
+
+
+  &-link {
+    flex-basis: 33%;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    margin-bottom: 2em;
+    color: #AFBC19;
+    &:hover {
+      color: #0EA6DB;
+      text-decoration: none;
+    }
+  }
+
+  &-icon {
+    display: block;
+    background-color: currentColor;
+    width: 140px;
+    height: 140px;
+    border-radius: 50%;
+    padding: 15px;
+    box-sizing: border-box;
+    margin: 0 1em 1em;
+
+    img {
+      width: 100%;
+      height: auto;
+    }
+  }
+
+  &-name {
+    display: inline-block;
+  }
+}
+
+.research-study {
+  display: flex;
+  padding-bottom: 1.5em;
+  border-bottom: 1px solid #0EA6DB;
+  margin-bottom: 2em;
+}
+
+.study {
+  &-main {
+    flex: 1 0 64%;
+    padding-right: 10px;
+  }
+
+  &-details {
+    flex: 1 1 36%;
+
+    p {
+      margin-top: 0 !important;
+    }
+
+    strong {
+      color: #0EA6DB;
+      font-weight: 500;
+    }
+  }
+
+  &-title {
+    color: #0EA6DB;
+    font-size: 20px;
+    font-weight: 500;
+    text-transform: uppercase;
+    margin-bottom: 0.75em;
+  }
+
+  &-contact {
+    display: inline-block;
+    background-color: #0EA6DB;
+    color: #fff;
+    font-style: italic;
+    margin-top: 1.5em;
+    padding: 0.5em 1em;
+    border-radius: 6px;
+  }
+}
+
+.toggle-description {
+  display: block;
+  color: #0EA6DB;
+  margin-top: 1em;
+}