From 2bd0f04d8f64c40f8e911059959fc694d0aecac5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Thu, 12 Nov 2015 00:45:30 +0100 Subject: [PATCH] Add feature to get nb of top menu entrie Fix translation of units --- htdocs/core/class/menu.class.php | 14 ++++++++++++ htdocs/core/menus/standard/auguria_menu.php | 15 +++++++++---- htdocs/core/menus/standard/eldy_menu.php | 13 ++++++++--- htdocs/core/menus/standard/empty.php | 7 +++++- htdocs/langs/en_US/other.lang | 24 ++++++++++----------- htdocs/theme/eldy/style.css.php | 7 +++++- 6 files changed, 59 insertions(+), 21 deletions(-) diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 737e682bba3..0715c2fafdc 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -98,4 +98,18 @@ class Menu if (count($this->liste) > 1) array_pop($this->liste); } + /** + * Return number of visible entries (gray or not) + * + * @return int Number of visible (gray or not) menu entries + */ + function getNbOfVisibleMenuEntries() + { + $nb=0; + foreach($this->liste as $val) + { + if (! empty($val['enabled'])) $nb++; + } + return $nb; + } } diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index a7c701aaeff..ae173504ed6 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -157,9 +157,9 @@ class MenuManager /** * Show menu * - * @param string $mode 'top', 'left', 'jmobile' + * @param string $mode 'top', 'left', 'jmobile' * @param array $moredata An array with more data to output - * @return string + * @return int 0 or nb of top menu entries if $mode = 'topnb' */ function showmenu($mode, $moredata=null) { @@ -169,8 +169,8 @@ class MenuManager if ($this->type_user == 1) { - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; - $conf->global->MAIN_SEARCHFORM_CONTACT=0; + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; + $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; } require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; @@ -178,6 +178,13 @@ class MenuManager if ($mode == 'top') print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0); if ($mode == 'left') print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); + + if ($mode == 'topnb') + { + print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1); + return $this->menu->getNbOfVisibleMenuEntries(); + } + if ($mode == 'jmobile') { print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1); diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 4326de6d98f..354f7de1453 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -113,7 +113,7 @@ class MenuManager * * @param string $mode 'top', 'left', 'jmobile' * @param array $moredata An array with more data to output - * @return string + * @return int 0 or nb of top menu entries if $mode = 'topnb' */ function showmenu($mode, $moredata=null) { @@ -123,8 +123,8 @@ class MenuManager if ($this->type_user == 1) { - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; - $conf->global->MAIN_SEARCHFORM_CONTACT=0; + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=0; + $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; } require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; @@ -142,6 +142,12 @@ class MenuManager if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0); } + if ($mode == 'topnb') + { + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1); + return $this->menu->getNbOfVisibleMenuEntries(); + } + if ($mode == 'jmobile') { print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1); @@ -238,6 +244,7 @@ class MenuManager unset($this->menu); //print 'xx'.$mode; + return 0; } } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index e1b240a8e5e..60f9f3cec7f 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -62,7 +62,7 @@ class MenuManager * * @param string $mode 'top', 'left', 'jmobile' * @param array $moredata An array with more data to output - * @return string + * @return int 0 or nb of top menu entries if $mode = 'topnb' */ function showmenu($mode, $moredata=null) { @@ -78,6 +78,11 @@ class MenuManager $noout=0; if ($mode == 'jmobile') $noout=1; + if ($mode == 'topnb') + { + return 1; + } + if ($mode == 'top' || $mode == 'jmobile') { if (empty($noout)) print_start_menu_array_empty(); diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 83cb5c7e428..7485aada8dc 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -121,20 +121,20 @@ LengthUnitdm=dm LengthUnitcm=cm LengthUnitmm=mm Surface=Area -SurfaceUnitm2=m2 -SurfaceUnitdm2=dm2 -SurfaceUnitcm2=cm2 -SurfaceUnitmm2=mm2 -SurfaceUnitfoot2=ft2 -SurfaceUnitinch2=in2 +SurfaceUnitm2=m² +SurfaceUnitdm2=dm² +SurfaceUnitcm2=cm² +SurfaceUnitmm2=mm² +SurfaceUnitfoot2=ft² +SurfaceUnitinch2=in² Volume=Volume TotalVolume=Total volume -VolumeUnitm3=m3 -VolumeUnitdm3=dm3 -VolumeUnitcm3=cm3 -VolumeUnitmm3=mm3 -VolumeUnitfoot3=ft3 -VolumeUnitinch3=in3 +VolumeUnitm3=m³ +VolumeUnitdm3=dm³ (L) +VolumeUnitcm3=cm³ (ml) +VolumeUnitmm3=mm³ (µl) +VolumeUnitfoot3=ft³ +VolumeUnitinch3=in³ VolumeUnitounce=ounce VolumeUnitlitre=litre VolumeUnitgallon=gallon diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c245fce73c8..b57fa159b17 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -31,7 +31,7 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); if (! defined('NOLOGIN')) define('NOLOGIN',1); // File must be accessed by logon page so without login -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); @@ -214,6 +214,11 @@ print 'dol_screenheight='.$_SESSION['dol_screenheight']."\n"; print '*/'."\n"; if (! empty($conf->dol_optimize_smallscreen)) $fontsize=11; + + +//$nb=$menumanager->showmenu('topnb'); +//print $nb; + ?> /* ============================================================================== */ -- GitLab