From: stephen@cubedesigners.com Date: Thu, 31 Jan 2019 17:52:35 +0000 (+0000) Subject: WIP #2340 @6.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b01d5d29e4366946a148402e53c4632d96808a0c;p=ccgm.git WIP #2340 @6.25 --- diff --git a/framework/application/Bootstrap.php b/framework/application/Bootstrap.php index 2f9008c..c98a854 100644 --- a/framework/application/Bootstrap.php +++ b/framework/application/Bootstrap.php @@ -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') diff --git a/framework/application/controllers/ResearchCategoriesController.php b/framework/application/controllers/ResearchCategoriesController.php index 7bac7c2..3f10fb8 100644 --- a/framework/application/controllers/ResearchCategoriesController.php +++ b/framework/application/controllers/ResearchCategoriesController.php @@ -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; } } diff --git a/framework/application/forms/CMS/Research.php b/framework/application/forms/CMS/Research.php index 540ce15..de8103d 100644 --- a/framework/application/forms/CMS/Research.php +++ b/framework/application/forms/CMS/Research.php @@ -4,6 +4,11 @@ class CCGM_Form_CMS_Research extends CCGM_Form_CMS_Text { public function init() { parent::init(); + $intro = new CCGM_Form_Element_Markitup('studies_intro'); + $intro->setLabel("Texte d'introduction pour les études"); + $intro->setAttrib('rows', 10); + $this->addElement($intro); + $studies = new CCGM_Form_CMS_Element_ResearchStudies('studies'); $studies->setLabel('Gestion des études cliniques'); $this->addElement($studies); diff --git a/framework/application/views/helpers/ResearchCategories.php b/framework/application/views/helpers/ResearchCategories.php new file mode 100644 index 0000000..851f72c --- /dev/null +++ b/framework/application/views/helpers/ResearchCategories.php @@ -0,0 +1,45 @@ +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 = '
'; + + while ($row = $query->fetch()) { + + $URL = CubeIT_Navigation_Page::generateAutoUri($row, Bootstrap::getResearchCategoriesURLTemplate()); + + $res .= ''; + $res .= '
'; + $res .= ''; + $res .= '
'; // .research-categories-icon + $res .= ''. $row->name .''; + $res .= '
'; + + } + + $res .= '
'; + + echo $res; + } + + +} diff --git a/framework/application/views/scripts/research-categories/index.phtml b/framework/application/views/scripts/research-categories/index.phtml index d9686f4..28728ed 100644 --- a/framework/application/views/scripts/research-categories/index.phtml +++ b/framework/application/views/scripts/research-categories/index.phtml @@ -10,9 +10,30 @@ $this->showsidebar = false;

parent_title ?>

currentPage->label ?>

-
-        studies); ?>
-        
+ studies) == 0) echo __('Aucun résultat trouvé.'); ?> + + studies as $study): ?> + +
+
+
title ?>
+
description) ?>
+ + title}") ?>" class="study-contact">Nous contacter +
+
+

Pathologie : pathology ?>

+

Investigateur : investigator ?>

+

+ Spécialité(s) : + specialities) as $specialityID): ?> + + +

+
+
+ + rightbar() ?> diff --git a/framework/application/views/scripts/templates/research.phtml b/framework/application/views/scripts/templates/research.phtml index bdd0ec1..0e03fd6 100644 --- a/framework/application/views/scripts/templates/research.phtml +++ b/framework/application/views/scripts/templates/research.phtml @@ -6,6 +6,8 @@ $this->contentWidth = 662;
markupDotclear($this->studies_intro); + echo $this->ResearchCategories(); echo $this->markupDotclear($this->text); ?>
diff --git a/js/research.js b/js/research.js new file mode 100644 index 0000000..6a55159 --- /dev/null +++ b/js/research.js @@ -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(''+ more +'') + } + }); + + $(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 index 0000000..44c152b --- /dev/null +++ b/less/research.less @@ -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; +}