Commit 4b5b5fd1 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#74708_dysfonctionnement_d_un_menu' into 'hotline'

hotline #74708 fix CompareUrl

See merge request afi/opacce!2652
parents c46c6159 ef417298
- ticket #74708 : Boite menu vertical : correction de la prise en charge du paramètre de pliage du menu.
\ No newline at end of file
......@@ -24,13 +24,24 @@ class Class_CompareUrl {
protected static $_request;
public static function isInRequestUrl($url) {
if(!$url)
return false;
if(!is_string($url))
return false;
if (!$request_path = static::getRequestPath())
return false;
if ('/' == $request_path)
return false;
return strpos($url, $request_path) !== false;
$pos = strpos($url, $request_path);
if(null === $pos)
return false;
return false !== $pos;
}
......
......@@ -28,9 +28,6 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue
/** @var Class_Systeme_ModulesMenu */
private $_cls_menu;
/** @var string */
private $_li_style;
private $path_ico;
......@@ -45,7 +42,6 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue
public function getHtml() {
extract($this->preferences);
$menu = $this->preferences['menu'];
$menu_deplie = $this->preferences['menu_deplie'];
$afficher_titre = $this->preferences['afficher_titre'];
list($id_profil, $menu) = (false !== strpos($menu, Class_Systeme_ModulesMenu::MENU_CONFIG_PROFIL_SEPARATOR))
......@@ -60,9 +56,6 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue
$this->_loadToggleMenuJsAndCss($toggle_menu);
$this->_cls_menu = new Class_Systeme_ModulesMenu();
$this->_li_style = sprintf('margin-left:20px;%s',
$menu_deplie ? '' : 'display:none;');
$id_profil = $profil->getId();
$menus = Class_Systeme_Widget_Menu::findAllAsArray($id_profil);
......@@ -82,7 +75,7 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue
$contenu = $this->preferences['new_html']
? $this->_getContentHtml($config['menus'])
: $this->_getContentAsOldHtml($config);
: $this->_getContentAsOldHtml($config['menus']);
$this->titre = $titre;
$this->contenu = $contenu;
......@@ -419,22 +412,33 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue
}
protected function _getContentAsOldHtml($config) {
$contenu = '<div class="menuGauche"><ul class="menuGauche">';
foreach ($config['menus'] as $key => $entree) {
$entree['id_module'] = $key;
$contenu .= $this->_getLigne($entree);
if (array_isset('sous_menus', $entree)) {
$sub_content = '';
foreach ($entree["sous_menus"] as $sub_key => $sous_menu) {
$sous_menu['id_module'] = $sub_key;
$sub_content .= $this->_getLigne($sous_menu);
}
$contenu .= $this->_subMenuLi($sub_content);
}
}
return $contenu .= '</ul></div>';
protected function _getContentAsOldHtml($entries) {
$content = [];
foreach($entries as $id => $entry)
$content [] = $this->_getEntryContent($id, $entry);
return $this->_tag('div',
$this->_tag('ul',
implode($content),
['class' => 'menuGauche']),
['class' => 'menuGauche']);
}
protected function _getEntryContent($id, $entry) {
$entry['id_module'] = $id;
$content = [$this->_getLigne($entry)];
if(!array_isset('sous_menus', $entry))
return implode($content);
$sub_content = [];
foreach($entry['sous_menus'] as $sub_id => $sub_entry)
$sub_content [] = $this->_getEntryContent($sub_id, $sub_entry);
$content [] = $this->_subMenuLi(implode($sub_content));
return implode(array_filter($content));
}
......@@ -466,8 +470,26 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue
protected function _subMenuLi($sub_content) {
return $this->_tag('li',
$this->_tag('ul', $sub_content),
['class' => 'menuGauche', 'style' => $this->_li_style]);
if(!$sub_content)
return '';
$css = ['margin-left: 20px;'];
$css [] = $this->_isCollapsedMenu() ? 'display: none' : '';
return $sub_content
? $this->_tag('li',
$this->_tag('ul', $sub_content),
['class' => 'menuGauche',
'style' => implode($css)])
: '';
}
protected function _isCollapsedMenu() {
if(!isset($this->preferences['menu_deplie']))
return true;
return false == (boolean) $this->preferences['menu_deplie'];
}
}
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class CompareUrlIsInRequestUrlTest extends ModelTestCase {
/** @test */
public function withWrongParamShouldReturnFalse() {
$this->assertFalse(Class_CompareUrl::isInRequestUrl([]));
}
}
\ No newline at end of file
......@@ -159,7 +159,7 @@ abstract class MenuVerticalWithManyItemsTestCase extends MenuVerticalTestCase {
/** @test */
function parentItemShouldHaveDisplayNone() {
$this->assertXPath($this->_html, '//ul/li[contains(@style, "display:none")]');
$this->assertXPath($this->_html, '//ul/li[contains(@style, "display: none")]');
}
......@@ -228,7 +228,7 @@ class MenuVerticalRssWithManyItemsTest extends MenuVerticalWithManyItemsTestCase
function withMenuDeplieOnShouldNotHaveDisplayNone() {
$this->helper->setPreference('menu_deplie', 1);
$this->_html = $this->helper->getBoite();
$this->assertNotXPath($this->_html, '//ul/li[contains(@style, "display:none")]');
$this->assertNotXPath($this->_html, '//ul/li[contains(@style, "display: none")]');
}
/** @test */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment