From 42195e244a9e32694ffc7eb4801160e5acd20524 Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Wed, 30 Jan 2019 17:01:38 +0000 Subject: [PATCH] WIP #2340 @6.75 --- framework/application/Bootstrap.php | 57 ++++++++++++++++++- .../ResearchCategoriesController.php | 31 ++++++++++ .../forms/CMS/Element/ResearchStudies.php | 12 ++++ framework/application/forms/CMS/Research.php | 6 +- .../Study.php => ResearchStudies.php} | 11 +++- .../forms/CMS/Sub/Research/Studies.php | 14 ----- .../scripts/research-categories/index.phtml | 19 +++++++ .../views/scripts/templates/research.phtml | 3 +- 8 files changed, 133 insertions(+), 20 deletions(-) create mode 100644 framework/application/controllers/ResearchCategoriesController.php create mode 100644 framework/application/forms/CMS/Element/ResearchStudies.php rename framework/application/forms/CMS/{Sub/Research/Study.php => ResearchStudies.php} (70%) delete mode 100644 framework/application/forms/CMS/Sub/Research/Studies.php create mode 100644 framework/application/views/scripts/research-categories/index.phtml diff --git a/framework/application/Bootstrap.php b/framework/application/Bootstrap.php index 591388b..2f9008c 100644 --- a/framework/application/Bootstrap.php +++ b/framework/application/Bootstrap.php @@ -68,7 +68,6 @@ class Bootstrap extends CubeIT_Bootstrap { $templates['Recherche clinique'] = array( //'listing' => 'Listing', 'research' => 'Recherche clinique', - 'researchStudies' => 'Études cliniques', ); $templates['Parcours patient'] = array('parcours' => 'Parcours', 'soins' => 'Soins support'); $templates['Traitements'] = array('traitement' => 'Traitement (Texte avec accordéon)'); @@ -87,6 +86,62 @@ class Bootstrap extends CubeIT_Bootstrap { return $templates; } + + protected function _makeNavigationOnePage(&$navigation, $r, $t, $isAdmin, $locale = false) { + $page = parent::_makeNavigationOnePage($navigation, $r, $t, $isAdmin, $locale); + + if (!$page) { + return; + } + + if ($page->getTemplate() == 'research') { + $this->addResearchCategoriesPages($page, $locale, $isAdmin); + } + } + + + /** + * + * @param CubeIT_Navigation_Page_Locale $page + */ + protected function addResearchCategoriesPages($page, $locale, $isAdmin) { + //$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! + + $db = Zend_Db_Table::getDefaultAdapter(); + $s = $db->select()->from('research_categories') + ->order('id ASC'); + $q = $s->query(); + + while ($r = $q->fetch()) { + + //$r = CubeIT_Util_Cms::unserialize($r, $locale); + if ($r->name == '') { + continue; + } + + $online = true; + + $pageTitle = sprintf(__('Essais sur les cancers en %s'), strtolower($r->name)); + + $p = new CubeIT_Navigation_Page_Locale(); + $p->setController('ResearchCategories'); + $p->setId($page->getId() . '/' . $r->id); + //$p->setAutoUri($r, $datas['seourl_stu'], $page->getLocale()); + $p->setAutoUri($r, $URL_template); + $p->setSitemap($online); + $p->setTitle($pageTitle); + $p->setEditable(false); + $p->setParams(array('research_category_id' => $r->id)); + $p->setOnline($online); + $p->setDomain($page->getDomain()); + $p->setLabel($pageTitle); // Used in breadcrumbs + sidebar menu + $page->addPage($p); + } + } + protected function _makeURL($r, $seoUrl, $locale, $title, $parent, $isAdmin) { if ($locale) { $navLocales = $this->getNavigationLocales($isAdmin); diff --git a/framework/application/controllers/ResearchCategoriesController.php b/framework/application/controllers/ResearchCategoriesController.php new file mode 100644 index 0000000..7bac7c2 --- /dev/null +++ b/framework/application/controllers/ResearchCategoriesController.php @@ -0,0 +1,31 @@ +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(); + +// if (!$q->rowCount()) { +// $this->_404(); +// return; +// } + +// $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(); + } + +} diff --git a/framework/application/forms/CMS/Element/ResearchStudies.php b/framework/application/forms/CMS/Element/ResearchStudies.php new file mode 100644 index 0000000..c7a3508 --- /dev/null +++ b/framework/application/forms/CMS/Element/ResearchStudies.php @@ -0,0 +1,12 @@ +setBaseForm(new CCGM_Form_CMS_ResearchStudies()); + $this->clearDecorators(); + } + +} diff --git a/framework/application/forms/CMS/Research.php b/framework/application/forms/CMS/Research.php index 1e9e315..540ce15 100644 --- a/framework/application/forms/CMS/Research.php +++ b/framework/application/forms/CMS/Research.php @@ -4,8 +4,8 @@ class CCGM_Form_CMS_Research extends CCGM_Form_CMS_Text { public function init() { parent::init(); - $studies = new CCGM_Form_CMS_Sub_Research_Studies(); - $studies->setLegend('Études Cliniques'); - $this->addSubForm($studies, 'studies'); + $studies = new CCGM_Form_CMS_Element_ResearchStudies('studies'); + $studies->setLabel('Gestion des études cliniques'); + $this->addElement($studies); } } diff --git a/framework/application/forms/CMS/Sub/Research/Study.php b/framework/application/forms/CMS/ResearchStudies.php similarity index 70% rename from framework/application/forms/CMS/Sub/Research/Study.php rename to framework/application/forms/CMS/ResearchStudies.php index 91c9a45..622a53c 100644 --- a/framework/application/forms/CMS/Sub/Research/Study.php +++ b/framework/application/forms/CMS/ResearchStudies.php @@ -1,10 +1,13 @@ addElement($id); + $title = new Zend_Form_Element_Text('title'); $title->setLabel('Titre'); $this->addElement($title); @@ -28,6 +31,12 @@ class CCGM_Form_CMS_Sub_Research_Study extends CubeIT_Form_SubForm { $specialities = new CCGM_Form_CMS_Element_ResearchSpecialities('specialities'); $specialities->setLabel('Spécialités'); $this->addElement($specialities); + + $this->setListTitle(__('Études Cliniques')) + ->setNewTitle(__('Créer une étude')) + ->setEditTitle(sprintf(__("Edition de l'étude « %s »"), '$name')) + ->setTitleColumn('title') + ->setModel('CCGM_Model_ResearchStudy'); } } diff --git a/framework/application/forms/CMS/Sub/Research/Studies.php b/framework/application/forms/CMS/Sub/Research/Studies.php deleted file mode 100644 index 8b17600..0000000 --- a/framework/application/forms/CMS/Sub/Research/Studies.php +++ /dev/null @@ -1,14 +0,0 @@ -setBaseSubForm($study); - $this->setBaseLegend('Edition de l\'étude « $title »'); - $this->setNewLegend('Nouvelle étude'); - } - -} diff --git a/framework/application/views/scripts/research-categories/index.phtml b/framework/application/views/scripts/research-categories/index.phtml new file mode 100644 index 0000000..d9686f4 --- /dev/null +++ b/framework/application/views/scripts/research-categories/index.phtml @@ -0,0 +1,19 @@ +headTitle($this->currentPage->title . ' / ' . $this->currentPage->getParent()->getTitle(), 'SET'); +$this->showsidebar = false; + +?> + +
+
+

parent_title ?>

+

currentPage->label ?>

+ +
+        studies); ?>
+        
+ +
+ rightbar() ?> +
diff --git a/framework/application/views/scripts/templates/research.phtml b/framework/application/views/scripts/templates/research.phtml index c161a14..bdd0ec1 100644 --- a/framework/application/views/scripts/templates/research.phtml +++ b/framework/application/views/scripts/templates/research.phtml @@ -1,4 +1,5 @@ showsidebar = false; $this->contentWidth = 662; ?> @@ -9,4 +10,4 @@ $this->contentWidth = 662; ?> rightbar() ?> - \ No newline at end of file + -- 2.39.5