From 215ce3869243b6a1798f731d26bab92111399536 Mon Sep 17 00:00:00 2001 From: llaffont <laurent.laffont@gmail.com> Date: Tue, 21 Jan 2014 21:56:17 +0100 Subject: [PATCH] =?UTF-8?q?Lorsque=20la=20boite=20critiques=20est=20dans?= =?UTF-8?q?=20un=20menu,=20l'url=20du=20titre=20contient=20l'id=20du=20men?= =?UTF-8?q?u=20pour=20pouvoir=20=C3=AAtre=20retrouv=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/ZendAfi/View/Helper/Accueil/Base.php | 23 ++++++++++++++----- .../ZendAfi/View/Helper/Accueil/Critiques.php | 11 +++++---- library/ZendAfi/View/Helper/Menu/Base.php | 20 +++++++++++----- library/ZendAfi/View/Helper/Menu/Boite.php | 13 +++++++++-- library/ZendAfi/View/Helper/Menu/Entry.php | 1 + library/ZendAfi/View/Helper/Menu/Menus.php | 20 ++++++++++++---- library/ZendAfi/View/Helper/Menu/Null.php | 8 +++++++ .../ZendAfi/View/Helper/MenuHorizontal.php | 1 + library/ZendAfi/View/Helper/TagAnchor.php | 2 +- .../ProfilOptionsControllerTest.php | 12 +++++++++- 10 files changed, 87 insertions(+), 24 deletions(-) diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php index ce31a05af71..bd2c13520f9 100644 --- a/library/ZendAfi/View/Helper/Accueil/Base.php +++ b/library/ZendAfi/View/Helper/Accueil/Base.php @@ -25,12 +25,15 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstract { protected static $modules_config; - protected $division; // Division dans laquelle se trouve le module - protected $titre; // Titre du module - protected $contenu; // Contenu du module - protected $message; // Message au dessus de la boite du module - protected $rss_interne; // Lien sur fil rss interne - protected $_fonction_admin_helper = 'FonctionsAdmin_Boite'; + + protected + $division, // Division dans laquelle se trouve le module + $titre, // Titre du module + $contenu, // Contenu du module + $message, // Message au dessus de la boite du module + $rss_interne, // Lien sur fil rss interne + $_fonction_admin_helper = 'FonctionsAdmin_Boite', + $_id_menu; //identifiant du menu si rendu dans un menu @@ -61,6 +64,14 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac return $this; } + + + public function setIdMenu($id_menu) { + $this->_id_menu = $id_menu; + return $this; + } + + // Par défaut le contenu de la boîte n'est pas en cache public function shouldCacheContent() { if (Class_Users::isCurrentUserCanAccesBackend()) diff --git a/library/ZendAfi/View/Helper/Accueil/Critiques.php b/library/ZendAfi/View/Helper/Accueil/Critiques.php index 8e5871656fc..c59013ffdb5 100644 --- a/library/ZendAfi/View/Helper/Accueil/Critiques.php +++ b/library/ZendAfi/View/Helper/Accueil/Critiques.php @@ -85,10 +85,13 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_ protected function _getTitle() { - return $this->view->getHelper('tagAnchor')->baseURL($this->preferences['titre'], - 'blog', - 'viewcritiques', - array('id_module' => $this->id_module)); + return $this->view + ->getHelper('tagAnchor') + ->baseURL($this->preferences['titre'], + 'blog', + 'viewcritiques', + ['id_module' => $this->id_module, + 'id_menu' => $this->_id_menu]); } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Menu/Base.php b/library/ZendAfi/View/Helper/Menu/Base.php index 4824dce2720..3ac5eaa384d 100644 --- a/library/ZendAfi/View/Helper/Menu/Base.php +++ b/library/ZendAfi/View/Helper/Menu/Base.php @@ -20,7 +20,9 @@ */ abstract class ZendAfi_View_Helper_Menu_Base extends ZendAfi_View_Helper_BaseHelper { - public static function getModuleHelperFromParams($id_menu, $menu, $view) { + protected $_id_menu; + + public static function getModuleHelperFromParams($id_module, $menu, $view) { if (!isset($menu['type_menu'])) return new ZendAfi_View_Helper_Menu_Null(); @@ -30,20 +32,26 @@ abstract class ZendAfi_View_Helper_Menu_Base extends ZendAfi_View_Helper_BaseHel $menu['preferences']['picto'] = $menu['picto'] ; $menu['preferences']['libelle'] = $menu['libelle']; - $helper = self::getMenuHelper($menu, $id_menu); + $helper = self::getMenuHelper($menu, $id_module); $helper->setView($view); return $helper; } - private static function getMenuHelper($menu, $id_menu) { + public function setIdMenu($id_menu) { + $this->_id_menu = $id_menu; + return $this; + } + + + private static function getMenuHelper($menu, $id_module) { if (Class_Systeme_ModulesMenu::isModuleAccueil($menu)) - return new ZendAfi_View_Helper_Menu_Boite($id_menu, $menu); + return new ZendAfi_View_Helper_Menu_Boite($id_module, $menu); if ($menu['type_menu'] == 'PROFIL') - return new ZendAfi_View_Helper_Menu_Profil($id_menu, $menu); + return new ZendAfi_View_Helper_Menu_Profil($id_module, $menu); - return new ZendAfi_View_Helper_Menu_Entry($id_menu, $menu); + return new ZendAfi_View_Helper_Menu_Entry($id_module, $menu); } } diff --git a/library/ZendAfi/View/Helper/Menu/Boite.php b/library/ZendAfi/View/Helper/Menu/Boite.php index 0bcbc4efed5..dd714ad72ac 100644 --- a/library/ZendAfi/View/Helper/Menu/Boite.php +++ b/library/ZendAfi/View/Helper/Menu/Boite.php @@ -20,8 +20,10 @@ */ class ZendAfi_View_Helper_Menu_Boite extends ZendAfi_View_Helper_BaseHelper { - protected $_id_module; - protected $_params; + protected + $_id_module, + $_id_menu, + $_params; public function __construct($id_module, $params) { parent::__construct(); @@ -31,12 +33,19 @@ class ZendAfi_View_Helper_Menu_Boite extends ZendAfi_View_Helper_BaseHelper { } + public function setIdMenu($id_menu) { + $this->_id_menu = $id_menu; + return $this; + } + + public function getBoite($li_class='') { $helper = ZendAfi_View_Helper_Accueil_Base::getModuleHelperFromParams($this->_id_module, $this->_params, $this->view); $helper->setView($this->view); $helper->setFonctionAdminHelper('FonctionsAdmin_Menu'); + $helper->setIdMenu($this->_id_menu); $class = $li_class ? $li_class.' boite' : 'boite'; return '<li class="'.$class.'">'.$helper->getBoite().'</li>'; diff --git a/library/ZendAfi/View/Helper/Menu/Entry.php b/library/ZendAfi/View/Helper/Menu/Entry.php index 600df580ac5..b541b3ace33 100644 --- a/library/ZendAfi/View/Helper/Menu/Entry.php +++ b/library/ZendAfi/View/Helper/Menu/Entry.php @@ -40,6 +40,7 @@ class ZendAfi_View_Helper_Menu_Entry extends ZendAfi_View_Helper_Menu_Base { if ($this->_sous_menus) { $helper = new ZendAfi_View_Helper_Menu_SousMenus($this->_sous_menus); $helper->setView($this->view); + $helper->setIdMenu($this->_id_menu); $html .= $helper->getBoite(); } diff --git a/library/ZendAfi/View/Helper/Menu/Menus.php b/library/ZendAfi/View/Helper/Menu/Menus.php index 174a9e896dd..b28bb8a10ee 100644 --- a/library/ZendAfi/View/Helper/Menu/Menus.php +++ b/library/ZendAfi/View/Helper/Menu/Menus.php @@ -20,8 +20,10 @@ */ class ZendAfi_View_Helper_Menu_Menus extends ZendAfi_View_Helper_BaseHelper { - protected $_menus = []; - protected $_menu_class = 'menu'; + protected + $_menus = [], + $_menu_class = 'menu', + $_id_menu; public function __construct($menus) { parent::__construct(); @@ -29,6 +31,12 @@ class ZendAfi_View_Helper_Menu_Menus extends ZendAfi_View_Helper_BaseHelper { } + public function setIdMenu($id_menu) { + $this->_id_menu = $id_menu; + return $this; + } + + public function getBoite() { return '<ul>'.$this->renderMenus().'</ul>'; } @@ -45,8 +53,12 @@ class ZendAfi_View_Helper_Menu_Menus extends ZendAfi_View_Helper_BaseHelper { function renderModule($menu){ - $helper = ZendAfi_View_Helper_Menu_Base::getModuleHelperFromParams($menu['id_module'], $menu, $this->view); - return $helper->getBoite($this->_menu_class); + $helper = ZendAfi_View_Helper_Menu_Base::getModuleHelperFromParams($menu['id_module'], + $menu, + $this->view); + return $helper + ->setIdMenu($this->_id_menu) + ->getBoite($this->_menu_class); } } diff --git a/library/ZendAfi/View/Helper/Menu/Null.php b/library/ZendAfi/View/Helper/Menu/Null.php index edfd2b1998e..334d3838835 100644 --- a/library/ZendAfi/View/Helper/Menu/Null.php +++ b/library/ZendAfi/View/Helper/Menu/Null.php @@ -20,9 +20,17 @@ */ class ZendAfi_View_Helper_Menu_Null extends ZendAfi_View_Helper_BaseHelper { + protected $_id_menu; + public function getBoite($li_class='') { return ''; } + + public function setIdMenu($id_menu) { + $this->_id_menu = $id_menu; + return $this; + } + } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/MenuHorizontal.php b/library/ZendAfi/View/Helper/MenuHorizontal.php index f7e74272b83..ce574a55fac 100644 --- a/library/ZendAfi/View/Helper/MenuHorizontal.php +++ b/library/ZendAfi/View/Helper/MenuHorizontal.php @@ -41,6 +41,7 @@ class ZendAfi_View_Helper_MenuHorizontal extends ZendAfi_View_Helper_BaseHelper return $this->retourErreur($this->translate()->_("Ce menu ne contient aucune entrée.")); $helper = new ZendAfi_View_Helper_Menu_Menus($menus); + $helper->setIdMenu('H'); $helper->setView($this->view); return '<div id="'.$tag_id.'" class="menu_horizontal">' diff --git a/library/ZendAfi/View/Helper/TagAnchor.php b/library/ZendAfi/View/Helper/TagAnchor.php index de155d34f4f..d26fb994d6e 100644 --- a/library/ZendAfi/View/Helper/TagAnchor.php +++ b/library/ZendAfi/View/Helper/TagAnchor.php @@ -37,7 +37,7 @@ class ZendAfi_View_Helper_TagAnchor extends Zend_View_Helper_HtmlElement { } public function baseURL($text, $controller, $action, $params) { - $url = 'http://' . $_SERVER['SERVER_NAME'] . BASE_URL . '/' . $controller . '/' . $action . '?' . http_build_query($params); + $url = 'http://' . $_SERVER['SERVER_NAME'] . BASE_URL . '/' . $controller . '/' . $action . '?' . http_build_query($params, '', '&'); return $this->tagAnchor($url, $text); } diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index 4bd6e62fbf1..78a30019228 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -49,7 +49,9 @@ abstract class ProfilOptionsControllerWithProfilAdulteTestCase extends AbstractC ['type_menu' => Class_Systeme_ModulesMenu::MODULE_ACCUEIL_PREFIX.'CRITIQUES', 'libelle' => 'Critiques', 'picto' => 'vide.gif', - 'preferences' => ['rss_avis' => '1', 'id_panier' => 3]], + 'preferences' => ['rss_avis' => '1', + 'id_panier' => 3, + 'titre' => 'Coup de coeur']], ['type_menu' => 'PROFIL', 'libelle' => 'Profil adulte', @@ -377,6 +379,14 @@ class ProfilOptionsControllerViewProfilAdulteTest extends ProfilOptionsControlle } + /** @test */ + public function menuHorizontalBoiteCritiquesShouldContainsIdMenuInTitleLink() { + $this->assertXPathContentContains('//div[@id="menu_horizontal"]//div[@class="boite critiques"]//a[contains(@href, "blog/viewcritiques?id_module=2&id_menu=H")]', + 'Coup de coeur', + $this->_response->getBody()); + } + + /** @test */ public function menuHorizontalShouldDisplaySitothequeWithUrl() { $this->assertXPath('//div[@id="menu_horizontal"]//li[@class="menu"]//a[contains(@href, "/sito/sitoview?id_categorie=&id_items=10-1-2&nb=10&titre=&picto=vide.gif&libelle=Sitoth%C3%A8que")]'); -- GitLab