diff --git a/.gitattributes b/.gitattributes index 79c70aab59210bb38090382e5af5923adf257a81..dbfd8f04acccdf4923f988df4b41d6a598c6c9dd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2621,7 +2621,10 @@ library/ZendAfi/View/Helper/MapEvents.php -text library/ZendAfi/View/Helper/MapForLieu.php -text library/ZendAfi/View/Helper/MemoryFormat.php -text library/ZendAfi/View/Helper/Menu/Base.php -text +library/ZendAfi/View/Helper/Menu/Boite.php -text library/ZendAfi/View/Helper/Menu/Entry.php -text +library/ZendAfi/View/Helper/Menu/Menus.php -text +library/ZendAfi/View/Helper/Menu/SousMenus.php -text library/ZendAfi/View/Helper/MenuHorizontal.php -text library/ZendAfi/View/Helper/ModuleAbstract.php -text library/ZendAfi/View/Helper/NewsBibHelper.php -text diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php index cfa60ed7ddb23ce2f32885dae2dc6cd687df20b6..5cf42893977a72bc3f964043fb27f1d3b3706cb3 100644 --- a/library/ZendAfi/View/Helper/Accueil/Base.php +++ b/library/ZendAfi/View/Helper/Accueil/Base.php @@ -38,7 +38,7 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac */ public function __construct($id_module, $params) { parent::__construct($id_module, $params); - $this->id_module = $id_module; + $this->type_module = $params["type_module"]; $this->division = null; if (array_isset('division', $params)) diff --git a/library/ZendAfi/View/Helper/Menu/Base.php b/library/ZendAfi/View/Helper/Menu/Base.php index a9f43ac627bfc7b5b7fb83eb733077fa541fbf6f..20be31bce778850688e32922879d656360ceb674 100644 --- a/library/ZendAfi/View/Helper/Menu/Base.php +++ b/library/ZendAfi/View/Helper/Menu/Base.php @@ -11,33 +11,24 @@ * * AFI-OPAC 2.0 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -abstract class ZendAfi_View_Helper_Menu_Base extends ZendAfi_View_Helper_ModuleAbstract { - public function __construct($id_module,$params) { - $params['type_module'] = $params['type_menu']; - parent::__construct($id_module, $params); - } - - +abstract class ZendAfi_View_Helper_Menu_Base extends ZendAfi_View_Helper_BaseHelper { public static function getModuleHelperFromParams($id_menu, $menu) { if (!array_isset('preferences', $menu)) $menu['preferences'] = array(); $menu['preferences']['picto'] = $menu['picto']; $menu['preferences']['libelle'] = $menu['libelle']; - if (Class_Systeme_ModulesMenu::isModuleAccueil($menu)) { - $menu['type_module'] = Class_Systeme_ModulesMenu::moduleAccueilType($menu); - return ZendAfi_View_Helper_Accueil_Base::getModuleHelperFromParams($id_menu, $menu); - } - - return new ZendAfi_View_Helper_Menu_Entry($id_menu, $menu); + return Class_Systeme_ModulesMenu::isModuleAccueil($menu) + ? new ZendAfi_View_Helper_Menu_Boite($id_menu, $menu) + : new ZendAfi_View_Helper_Menu_Entry($id_menu, $menu); } } diff --git a/library/ZendAfi/View/Helper/Menu/Boite.php b/library/ZendAfi/View/Helper/Menu/Boite.php new file mode 100644 index 0000000000000000000000000000000000000000..15166bfba2c024a1a58de9968ec1a3830d25eba3 --- /dev/null +++ b/library/ZendAfi/View/Helper/Menu/Boite.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_View_Helper_Menu_Boite extends ZendAfi_View_Helper_BaseHelper { + protected $_id_module; + protected $_params; + + public function __construct($id_module, $params) { + parent::__construct(); + $this->_id_module = $id_module; + $this->_params = $params; + $this->_params['type_module'] = Class_Systeme_ModulesMenu::moduleAccueilType($params); + } + + public function getBoite() { + $helper = ZendAfi_View_Helper_Accueil_Base::getModuleHelperFromParams($this->_id_module, + $this->_params); + $helper->setView($this->view); + return $helper->getBoite(); + } +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Menu/Entry.php b/library/ZendAfi/View/Helper/Menu/Entry.php index 02c7803d499847ced2b2e0c06d356988b74c76f9..851192ce56d143e28f5d939c1cc3c22927f24bfa 100644 --- a/library/ZendAfi/View/Helper/Menu/Entry.php +++ b/library/ZendAfi/View/Helper/Menu/Entry.php @@ -20,22 +20,48 @@ */ class ZendAfi_View_Helper_Menu_Entry extends ZendAfi_View_Helper_Menu_Base { + protected $_type_module; + protected $_preferences; + protected $_sous_menus; + + public function __construct($id_module,$params) { + parent::__construct(); + $this->_type_module = $params['type_menu']; + $this->_preferences = isset($params['preferences']) ? $params['preferences'] : []; + $this->_picto = $params['picto']; + $this->_libelle = $params['libelle']; + $this->_sous_menus = isset($params['sous_menus']) ? $params['sous_menus'] : null; + } + + public function getBoite() { + $html = $this->getTagAnchor(); + + if ($this->_sous_menus) { + $helper = new ZendAfi_View_Helper_Menu_SousMenus($this->_sous_menus); + $helper->setView($this->view); + $html .= $helper->getBoite(); + } + + return $html; + } + + + public function getTagAnchor() { $modMenus = new Class_Systeme_ModulesMenu(); - $params = $modMenus->getUrl($this->type_module, $this->preferences); + $params = $modMenus->getUrl($this->_type_module, $this->_preferences); $url = $params['url']; - if ($params['target']) - $target = "target='".$params['target']."'"; - else - $target = ''; + $target = $params['target'] + ? "target='".$params['target']."'"; + : ''; $anchor='<a href="'.htmlspecialchars($url).'" '.$target.'>'; - if($this->preferences["picto"] > '' and $this->preferences["picto"] != "vide.gif") { - $anchor.=sprintf('<img alt="%s" src="'.URL_IMG.'menus/'.$this->preferences["picto"].'" />', - $this->translate()->_('pictogramme pour %s', $this->preferences["libelle"])); + if($this->_picto > '' and $this->_picto != "vide.gif") { + $anchor.=sprintf('<img alt="%s" src="'.URL_IMG.'menus/'.$this->_picto.'" />', + $this->translate()->_('pictogramme pour %s', $this->_libelle)); } + $anchor.=$this->_preferences["libelle"].'</a>'; - $anchor.=$this->preferences["libelle"].'</a>'; return $anchor; } } diff --git a/library/ZendAfi/View/Helper/Menu/Menus.php b/library/ZendAfi/View/Helper/Menu/Menus.php new file mode 100644 index 0000000000000000000000000000000000000000..663e1226620e6626a1b948d1427d2410dbf92512 --- /dev/null +++ b/library/ZendAfi/View/Helper/Menu/Menus.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_View_Helper_Menu_Menus extends ZendAfi_View_Helper_BaseHelper { + protected $_ul_class = ''; + protected $_li_class = 'menu'; + protected $_menus = []; + + public function __construct($menus) { + parent::__construct(); + $this->_menus = $menus; + } + + public function getBoite() { + $html = '<ul class="'.$this->_ul_class.'">'; + + foreach($this->_menus as $id_menu => $entree) { + $li_class = Class_Systeme_ModulesMenu::isModuleAccueil($entree) + ? $this->_li_class.' boite' + : $this->_li_class; + + $html.= '<li class="'.$li_class.'">'; + $html.= $this->renderModule($id_menu, $entree); + $html.='</li>'; + } + + $html.='</ul>'; + return $html; + } + + + function renderModule($id_menu, $menu){ + $helper = ZendAfi_View_Helper_Menu_Base::getModuleHelperFromParams($id_menu, $menu); + $helper->setView($this->view); + return $helper->getBoite(); + } +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Menu/SousMenus.php b/library/ZendAfi/View/Helper/Menu/SousMenus.php new file mode 100644 index 0000000000000000000000000000000000000000..02480cf4bc3c976bd7295394deb481ad90ac26c7 --- /dev/null +++ b/library/ZendAfi/View/Helper/Menu/SousMenus.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_View_Helper_Menu_SousMenus extends ZendAfi_View_Helper_Menu_Menus { + protected $_ul_class = 'sous-menus'; + protected $_li_class = ''; +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/MenuHorizontal.php b/library/ZendAfi/View/Helper/MenuHorizontal.php index 0793c954730940a037a1b9b81a7248b8cd9d72bf..ccfc035c6167328be8d9003f9106c4d3eb7b958c 100644 --- a/library/ZendAfi/View/Helper/MenuHorizontal.php +++ b/library/ZendAfi/View/Helper/MenuHorizontal.php @@ -35,41 +35,15 @@ class ZendAfi_View_Helper_MenuHorizontal extends ZendAfi_View_Helper_BaseHelper if(!count($menus)) return $this->retourErreur($this->translate()->_("Ce menu ne contient aucune entrée.")); + $helper = new ZendAfi_View_Helper_Menu_Menus($menus); + $helper->setView($this->view); + return '<div id="menu_horizontal">' .$this->tagEditMenu() - .$this->renderMenus($menus, '', 'menu') + .$helper->getBoite() // .$this->renderMenus($menus, '', 'menu') .'</div>'; } - - public function renderMenus($menus, $ul_class, $li_class='') { - $html = '<ul class="'.$ul_class.'">'; - - foreach($menus as $id_menu => $entree) { - if (Class_Systeme_ModulesMenu::isModuleAccueil($entree)) - $li_class .= ' boite'; - - $html.='<li class="'.trim($li_class).'">'; - $html.=$this->renderModule($id_menu, $entree); - - if(array_isset('sous_menus', $entree)) - $html .= $this->renderMenus($entree['sous_menus'], 'sous_menu'); - - $html.='</li>'; - } - - $html.='</ul>'; - return $html; - } - - - function renderModule($id_menu, $menu){ - $helper = ZendAfi_View_Helper_Menu_Base::getModuleHelperFromParams($id_menu, $menu); - $helper->setView($this->view); - return $helper->getBoite(); - } - - public function tagEditMenu() { return $this->view->tagAnchor($this->view->url(['module' => 'admin', 'controller' => 'profil', diff --git a/library/ZendAfi/View/Helper/ModuleAbstract.php b/library/ZendAfi/View/Helper/ModuleAbstract.php index 68e6b6715ef2e57b5fac6141ad6af8ab9b3772e1..e592da6556b13151f4aaa9a14672604e9ce130b1 100644 --- a/library/ZendAfi/View/Helper/ModuleAbstract.php +++ b/library/ZendAfi/View/Helper/ModuleAbstract.php @@ -31,7 +31,6 @@ abstract class ZendAfi_View_Helper_ModuleAbstract extends ZendAfi_View_Helper_Ba public function __construct($id_module,$params) { parent::__construct(); $this->id_module = $id_module; - $this->type_module = $params["type_module"]; $this->preferences = $params["preferences"]; }