From 5bfffcce9744691490c822910a2b19df402aed9d Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 17 Nov 2025 10:33:23 +0100 Subject: [PATCH] Code improvement and ergonomy for menu display --- html/css/style-classic7.css | 13 +++++++- html/do.php | 3 +- include/anc_od.inc.php | 4 +-- include/lib/ac_common.php | 64 +++++++++++++++++++++++++++++++++---- include/lib/user_menu.php | 2 +- include/template/menu.php | 3 +- include/upgrade.inc.php | 2 +- 7 files changed, 77 insertions(+), 14 deletions(-) diff --git a/html/css/style-classic7.css b/html/css/style-classic7.css index aeb0271b2..c0429d58b 100644 --- a/html/css/style-classic7.css +++ b/html/css/style-classic7.css @@ -3519,7 +3519,18 @@ margin:1px; .nav-level2 .active { border-radius:0px !important; } - +/******************************************/ +/* MENU LEVEL > 3 */ +/******************************************/ +.nav-level4{ + --border-size:2px; +} +.nav-level4 .nav-item:hover{ + background-color: aliceblue; +} +.nav-level4 .active { + background-color: aliceblue; +} /****************************************/ /* Module for smartphone menu */ /***************************************/ diff --git a/html/do.php b/html/do.php index e09e51cbc..7db6f5f2a 100644 --- a/html/do.php +++ b/html/do.php @@ -281,7 +281,8 @@ if (isset($_REQUEST['ac'])) // Show module and highligt selected one show_module($module_id); - + global $level; + $level = 0; show_menu( $amenu_id[0]['pm_id_v3']); show_menu( $amenu_id[0]['pm_id_v2']); diff --git a/include/anc_od.inc.php b/include/anc_od.inc.php index c7bad6b60..416e948c3 100644 --- a/include/anc_od.inc.php +++ b/include/anc_od.inc.php @@ -50,7 +50,7 @@ echo ' //---------------------------------------------------------------------- // show the menu //---------------------------------------------------------------------- -echo ShowItem(array( +echo show_menu_extension(array( array( "?".http_build_query(["ac"=>$http->request("ac"),"new"=>1,"gDossier"=>$dossier_id]), _("Nouveau"), @@ -61,7 +61,7 @@ echo ShowItem(array( _("Liste"), _("Liste opérations") ) -), "H", "nav-item", "nav-link", "", "nav nav-pills nav-level3"); +)); //---------------------------------------------------------------------- diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index c761b969c..82152711c 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -519,7 +519,57 @@ function sql_string($p_string) $p_string = noalyss_str_replace('\\', '\\\\', $p_string); return $p_string; } +/** + * @brief Same menu for all extensions, with the right level, it calls + * ShowItem with the right parameters + * @global $level (int) global variable of the menu level + * @param $p_array (array) + * @param $default (string) selected item + * @param $p_extra (string) extra code for the table tag (CSS or javascript) + * @see ShowItem + */ +function show_menu_extension($p_array,$default="",$p_extra="") +{ + global $level; + + + $level++; + switch ($level) { + case 3: + $p_dir='H'; + $class="nav-item nav-item-underline"; + $class_ref="nav-link"; + $p_extra="noprint nav nav-pills nav-level3"; + $class_div="menu3"; + break; + case 2: + $p_dir='H'; + $class="nav-item nav-item-underline"; + $class_ref="nav-link"; + $p_extra="noprint nav nav-pills nav-level2"; + $class_div="menu2"; + break; + case 1: + $p_dir='H'; + $class="nav-item nav-item-underline"; + $class_ref="nav-link"; + $p_extra='noprint nav nav-pills nav-fill flex-row '; + $class_div="top_menu"; + break; + default: + $p_dir='H'; + $class="nav-item nav-item-underline"; + $class_ref="nav-link"; + $p_extra="noprint nav nav-level4"; + $class_div="menu3"; + break; + } + return "
" + . ShowItem($p_array,$p_dir,$class,$class_ref,$default,$p_extra) + ."
"; + +} /** * \brief store the string which print * the content of p_array in a table @@ -536,6 +586,7 @@ function sql_string($p_string) function ShowItem($p_array, $p_dir='V', $class="nav-item", $class_ref="nav-link", $default="", $p_extra="nav nav-pills nav-fill") { + $ret = ''; // for comptability with old application mtitle for anchor is replace by nav-link @@ -543,9 +594,9 @@ function ShowItem($p_array, $p_dir='V', $class="nav-item", $class_ref="nav-link" // direction Vertical if ($p_dir == 'V') { - $ret .= "