diff --git a/VERSIONS_HOTLINE/80724 b/VERSIONS_HOTLINE/80724 new file mode 100644 index 0000000000000000000000000000000000000000..170a2f0da8ff3d226abc4a0ad03e272ed385c508 --- /dev/null +++ b/VERSIONS_HOTLINE/80724 @@ -0,0 +1 @@ + - ticket #80724 : Menu horizontal: correction du paramétrage des éléments dans des sous - sous menus \ No newline at end of file diff --git a/library/Class/Systeme/Widget/Menu.php b/library/Class/Systeme/Widget/Menu.php index 45f0f7d38ff4e7998d9a621209161fa5fd8e307e..a4e1aa23bd52f91528d62fd9ae2aa603bfdea40d 100644 --- a/library/Class/Systeme/Widget/Menu.php +++ b/library/Class/Systeme/Widget/Menu.php @@ -117,7 +117,7 @@ class Class_Systeme_Widget_Menu extends Class_Systeme_Widget_Abstract { if(isset($datas['children'])) $sub_menus = $this->_convertChildren($datas['children']); - if(!$this->hasParent() && $sub_menus) { + if(!$this->hasParent()) { $datas['menus'] = (new Class_Systeme_MenuHorizontal($sub_menus))->asCfgProfil(); return $this->_save($datas); } @@ -150,12 +150,34 @@ class Class_Systeme_Widget_Menu extends Class_Systeme_Widget_Abstract { return $profil->setCfgMenus($cfg_menus)->save(); } - $cfg_menus[$this->getParent()]['menus'][$this->getPosition()]['sous_menus'][$this->getId()] = $datas; + $this->_saveDeepIn($cfg_menus[$this->getParent()]['menus'], + $datas); return $profil->setCfgMenus($cfg_menus)->save(); } + + protected function _saveDeepIn(&$entries, $datas) { + foreach($entries as &$entry) { + if(isset($entry['id_module']) && ($this->getId() == (string)$entry['id_module'])) { + $entry = $datas; + return true; + } + + if (isset($entry['sous_menus']) && $this->_saveDeepIn($entry['sous_menus'], $datas)) + return true; + + if (isset($entry['menus']) && $this->_saveDeepIn($entry['menus'], $datas)) + return true; + } + + return false; + } + + + + public function getResourcesProvider() { if(!parent::getResourcesProvider()) $this->setResourcesProvider(new Class_Systeme_ModulesMenu()); diff --git a/library/ZendAfi/Form/Configuration/Menu/Entry.php b/library/ZendAfi/Form/Configuration/Menu/Entry.php index 9cf01a7d782f571e44ddc3fb5cdd1b272bc6765b..9c4ab0ad79f017030c920b7c36b78a62f6126d0f 100644 --- a/library/ZendAfi/Form/Configuration/Menu/Entry.php +++ b/library/ZendAfi/Form/Configuration/Menu/Entry.php @@ -27,7 +27,7 @@ class ZendAfi_Form_Configuration_Menu_Entry extends ZendAfi_Form { $this ->addElement('text', 'libelle', - ['label' => $this->_('Text du lien')]) + ['label' => $this->_('Texte du lien')]) ->addElement('IcoPicker', 'picto', ['label' => $this->_('Icône du lien')]) diff --git a/tests/application/modules/admin/controllers/WidgetControllerTest.php b/tests/application/modules/admin/controllers/WidgetControllerTest.php index 8d1ac248df23800d81ebaff64f1d6dd1dd1a3abc..7cb15573ca063d8a643578df5cd950d01bf1d645 100644 --- a/tests/application/modules/admin/controllers/WidgetControllerTest.php +++ b/tests/application/modules/admin/controllers/WidgetControllerTest.php @@ -2437,3 +2437,137 @@ class WidgetControllerLibraryPostDispatchTest extends WidgetControllerWidgetConf $this->assertEquals(['town' => [1]], $widget->getdefault_filters()); } } + + + + +class WidgetControllerHorizontalMenuChangeLinkTextTest extends Admin_AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $cfg_menus = ['H' => + [ + 'type_module' => 'MENU', + 'type_menu' => 'MENU', + 'id_module' => '', + 'libelle' => 'Menu horizontal', + 'picto' => 'vide.gif', + 'action' => '', + 'clef_profil' => '0', + 'children' => '29;', + 'preferences' => [ + 'type_module' => 'MENU', + 'type_menu' => 'MENU', + 'id_module' => '', + 'libelle' => 'Menu horizontal', + 'picto' => 'vide.gif', + 'action' => '', + 'clef_profil' => '0', + 'children' => '29;' ], + 'menus' => [ + 0 => + [ + 'type_module' => 'MENU', + 'type_menu' => 'MENU', + 'id_module' => '0', + 'libelle' => 'AIDE', + 'picto' => 'vide.gif', + 'action' => '', + 'clef_profil' => '', + 'children' => '1;', + 'preferences' => [ + 'type_module' => 'MENU', + 'type_menu' => 'MENU', + 'id_module' => '0', + 'libelle' => 'AIDE', + 'picto' => 'vide.gif', + 'action' => '', + 'clef_profil' => '', + 'children' => '1;' ], + 'sous_menus' => [ + 0 => [ + 'type_module' => 'MENU', + 'type_menu' => 'MENU', + 'id_module' => '0', + 'libelle' => 'Menu', + 'picto' => '', + 'action' => '', + 'clef_profil' => '0', + 'children' => 'PROFIL;', + 'preferences' => [ + 'type_module' => 'MENU', + 'type_menu' => 'MENU', + 'id_module' => '2', + 'libelle' => 'Menu', + 'picto' => '', + 'action' => '', + 'clef_profil' => '0', + 'children' => 'PROFIL;', + ], + 'sous_menus' => [ + 1 => [ + 'type_module' => 'PROFIL', + 'type_menu' => 'PROFIL', + 'id_module' => '1', + 'libelle' => 'Lien vers un profil ou une page', + 'picto' => '', + 'action' => '', + 'clef_profil' => '1', + ], + ], + ], + ], + ], + ] + ] + ]; + + $this->fixture('Class_Profil', + ['id' => 34, + 'libelle' => 'Numérique', + 'parent_id' => null, + 'cfg_menus' => $cfg_menus]) + ->beCurrentProfil(); + } + + + /** @test */ + public function renameMenuLinkToProfilLabelToPlayMoviesShouldUpdateCfgMenus() { + $this->postDispatch('/admin/widget/edit-menu/id/2/id_profil/34/parent/H', + ['libelle' => 'play movies', + 'clef_profil' => 1, + 'picto' => '']); + + $menus = Class_Profil::find(34)->getCfgMenusAsArray()['H']; + $this->assertEquals('play movies', + $menus['menus'][0]['sous_menus'][1]['sous_menus'][2]['libelle']); + } + + + /** @test */ + public function removeHorizontalMenuChildenShouldDeleteSubmenus() { + $this->postDispatch('/admin/widget/edit-menu/id/H/id_profil/34', + ['libelle' => 'Menu horizontal', + 'children' => '', + 'picto' => '']); + + $menus = Class_Profil::find(34)->getCfgMenusAsArray()['H']; + $this->assertEmpty($menus['menus']); + } + + + + /** @test */ + public function addEntryUnderMenuAidesShouldNotRemoveItsSubmenus() { + $this->postDispatch('/admin/widget/edit-menu/id/0/id_profil/34/parent/H', + ['libelle' => 'Menu', + 'children' => '1;ACCUEIL', + 'picto' => '']); + + $menus = Class_Profil::find(34)->getCfgMenusAsArray()['H']; + $this->assertCount(2, $menus['menus'][0]['sous_menus']); + } +}