forked from Wavyzz/dolibarr
New: First changes to simplify/optimize menu management.
This commit is contained in:
@@ -89,7 +89,7 @@ print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentTheme").'</td><
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentMenuHandler").'</td><td colspan="2">';
|
||||
if (preg_match('/^smartphone/',$conf->smart_menu) && ! empty($conf->browser->phone)) print $conf->smart_menu;
|
||||
else print $conf->top_menu;
|
||||
else print $conf->standard_menu;
|
||||
print '</td></tr>'."\n";
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
@@ -48,7 +48,7 @@ class Conf
|
||||
public $theme; // Contains current theme ("eldy", "auguria", ...)
|
||||
public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...)
|
||||
//! Used to store current menu handlers
|
||||
public $top_menu;
|
||||
public $standard_menu;
|
||||
public $smart_menu;
|
||||
|
||||
public $modules = array(); // List of activated modules
|
||||
|
||||
@@ -169,7 +169,7 @@ class Translate
|
||||
}
|
||||
if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys
|
||||
|
||||
dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
|
||||
//dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
|
||||
|
||||
$newdomain = $domain;
|
||||
$modulename = '';
|
||||
|
||||
@@ -2105,7 +2105,7 @@ function dol_print_error($db='',$error='')
|
||||
$out.="<br>\n";
|
||||
$out.="<b>".$langs->trans("RequestedUrl").":</b> ".$_SERVER["REQUEST_URI"]."<br>\n";;
|
||||
$out.="<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:'')."<br>\n";;
|
||||
$out.="<b>".$langs->trans("MenuManager").":</b> ".$conf->top_menu."<br>\n";
|
||||
$out.="<b>".$langs->trans("MenuManager").":</b> ".$conf->standard_menu."<br>\n";
|
||||
$out.="<br>\n";
|
||||
$syslog.="url=".$_SERVER["REQUEST_URI"];
|
||||
$syslog.=", query_string=".$_SERVER["QUERY_STRING"];
|
||||
|
||||
@@ -46,14 +46,10 @@ class MenuManager
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array &$menu_array Table of menu entries to show before entries of menu handler
|
||||
* @param array &$menu_array_after Table of menu entries to show after entries of menu handler
|
||||
*/
|
||||
function __construct($db, &$menu_array, &$menu_array_after)
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db=$db;
|
||||
$this->menu_array=$menu_array;
|
||||
$this->menu_array_after=$menu_array_after;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ class MenuManager
|
||||
var $type_user=1; // Put 0 for internal users, 1 for external users
|
||||
var $atarget=""; // Valeur du target a utiliser dans les liens
|
||||
|
||||
|
||||
var $menu_array;
|
||||
var $menu_array_after;
|
||||
|
||||
@@ -47,14 +46,10 @@ class MenuManager
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array &$menu_array Table of menu entries to show before entries of menu handler
|
||||
* @param array &$menu_array_after Table of menu entries to show after entries of menu handler
|
||||
*/
|
||||
function __construct($db, &$menu_array, &$menu_array_after)
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db=$db;
|
||||
$this->menu_array=$menu_array;
|
||||
$this->menu_array_after=$menu_array_after;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1474,7 +1474,6 @@ function dol_eldy_showmenu($type_user, &$menuentry, &$listofmodulesforexternal)
|
||||
{
|
||||
//print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
|
||||
//print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
|
||||
|
||||
if (empty($menuentry['enabled'])) return 0; // Entry disabled by condition
|
||||
if ($type_user && $menuentry['module'])
|
||||
{
|
||||
|
||||
@@ -45,14 +45,10 @@ class MenuManager
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array &$menu_array Table of menu entries to show before entries of menu handler
|
||||
* @param array &$menu_array_after Table of menu entries to show after entries of menu handler
|
||||
*/
|
||||
function __construct($db, &$menu_array, &$menu_array_after)
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db=$db;
|
||||
$this->menu_array=$menu_array;
|
||||
$this->menu_array_after=$menu_array_after;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,14 +45,10 @@ class MenuManager
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array &$menu_array Table of menu entries to show before entries of menu handler
|
||||
* @param array &$menu_array_after Table of menu entries to show after entries of menu handler
|
||||
*/
|
||||
function __construct($db,&$menu_array,&$menu_array_after)
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db=$db;
|
||||
$this->menu_array=$menu_array;
|
||||
$this->menu_array_after=$menu_array_after;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,14 +38,10 @@ class MenuManager
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array &$menu_array Table of menu entries to show before entries of menu handler
|
||||
* @param array &$menu_array_after Table of menu entries to show after entries of menu handler
|
||||
*/
|
||||
function __construct($db, &$menu_array, &$menu_array_after)
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db=$db;
|
||||
$this->menu_array=$menu_array;
|
||||
$this->menu_array_after=$menu_array_after;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -773,6 +773,45 @@ if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity'
|
||||
}
|
||||
}
|
||||
|
||||
//print 'eee'.$conf->standard_menu;
|
||||
|
||||
// Init menu manager
|
||||
if (empty($user->societe_id)) // If internal user or not defined
|
||||
{
|
||||
$conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED);
|
||||
$conf->smart_menu=(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED);
|
||||
}
|
||||
else // If external user
|
||||
{
|
||||
$conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
|
||||
$conf->smart_menu=(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED);
|
||||
}
|
||||
// For backward compatibility
|
||||
if (empty($conf->standard_menu)) $conf->standard_menu ='eldy_backoffice.php';
|
||||
elseif ($conf->standard_menu == 'eldy.php') $conf->standard_menu='eldy_backoffice.php';
|
||||
|
||||
// Load the menu manager (only if not already done)
|
||||
$file_menu=empty($conf->browser->phone)?$conf->standard_menu:$conf->smart_menu;
|
||||
if (GETPOST('menu')) $file_menu=GETPOST('menu'); // menu=eldy_backoffice.php
|
||||
if (! class_exists('MenuManager'))
|
||||
{
|
||||
$menufound=0;
|
||||
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$menufound=dol_include_once($dirmenu."standard/".$file_menu);
|
||||
if ($menufound) break;
|
||||
}
|
||||
if (! $menufound) // If failed to include, we try with standard
|
||||
{
|
||||
$file_menu='eldy_backoffice.php';
|
||||
include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
|
||||
}
|
||||
}
|
||||
$menumanager = new MenuManager($db);
|
||||
|
||||
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
@@ -798,7 +837,10 @@ if (! function_exists("llxHeader"))
|
||||
{
|
||||
global $conf;
|
||||
|
||||
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
|
||||
// html header
|
||||
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
|
||||
|
||||
// top menu and left menu area
|
||||
if (empty($conf->global->MAIN_HIDE_TOP_MENU))
|
||||
{
|
||||
top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring);
|
||||
@@ -807,6 +849,8 @@ if (! function_exists("llxHeader"))
|
||||
{
|
||||
left_menu('', $help_url, '', '', 1, $title);
|
||||
}
|
||||
|
||||
// main area
|
||||
main_area($title);
|
||||
}
|
||||
}
|
||||
@@ -1150,7 +1194,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
{
|
||||
global $user, $conf, $langs, $db;
|
||||
global $dolibarr_main_authentication;
|
||||
global $hookmanager;
|
||||
global $hookmanager,$menumanager;
|
||||
|
||||
// Instantiate hooks of thirdparty module only if not already define
|
||||
if (! is_object($hookmanager))
|
||||
@@ -1162,22 +1206,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
|
||||
$toprightmenu='';
|
||||
|
||||
// Define menu manager in setup
|
||||
if (empty($user->societe_id)) // If internal user or not defined
|
||||
{
|
||||
$conf->top_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED);
|
||||
$conf->smart_menu=(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED);
|
||||
}
|
||||
else // If external user
|
||||
{
|
||||
$conf->top_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
|
||||
$conf->smart_menu=(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED);
|
||||
}
|
||||
// For backward compatibility
|
||||
if ($conf->top_menu == 'eldy.php') $conf->top_menu='eldy_backoffice.php';
|
||||
elseif ($conf->top_menu == 'rodolphe.php') $conf->top_menu='eldy_backoffice.php';
|
||||
if (! $conf->top_menu) $conf->top_menu ='eldy_backoffice.php';
|
||||
|
||||
// For backward compatibility with old modules
|
||||
if (empty($conf->headerdone)) top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
|
||||
|
||||
@@ -1267,27 +1295,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
/*
|
||||
* Top menu
|
||||
*/
|
||||
$top_menu=empty($conf->browser->phone)?$conf->top_menu:$conf->smart_menu;
|
||||
if (GETPOST('menu')) $top_menu=GETPOST('menu'); // menu=eldy_backoffice.php
|
||||
|
||||
// Load the top menu manager (only if not already done)
|
||||
if (! class_exists('MenuManager'))
|
||||
{
|
||||
$menufound=0;
|
||||
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$menufound=dol_include_once($dirmenu."standard/".$top_menu);
|
||||
if ($menufound) break;
|
||||
}
|
||||
if (! $menufound) // If failed to include, we try with standard
|
||||
{
|
||||
$top_menu='eldy_backoffice.php';
|
||||
include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$top_menu;
|
||||
}
|
||||
}
|
||||
|
||||
print "\n".'<!-- Start top horizontal menu '.$top_menu.' -->'."\n";
|
||||
print "\n".'<!-- Start top horizontal -->'."\n";
|
||||
|
||||
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '<div class="ui-layout-north"> <!-- Begin top layout -->'."\n";
|
||||
|
||||
@@ -1296,10 +1304,8 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
print '<div id="tmenu_tooltip" class="tmenu">'."\n";
|
||||
|
||||
// Show menu
|
||||
$dummy1=array();$dummy2=array();
|
||||
$menutop = new MenuManager($db,$dummy1,$dummy2);
|
||||
$menutop->atarget=$target;
|
||||
$menutop->showmenu('top'); // This contains a \n
|
||||
$menumanager->atarget=$target;
|
||||
$menumanager->showmenu('top'); // This contains a \n
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
@@ -1313,7 +1319,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
$company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')';
|
||||
}
|
||||
$logintext='<div class="login"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$user->id.'"';
|
||||
$logintext.=$menutop->atarget?(' target="'.$menutop->atarget.'"'):'';
|
||||
$logintext.=$target?(' target="'.$target.'"'):'';
|
||||
$logintext.='>'.$user->login.'</a>';
|
||||
if ($user->societe_id) $logintext.=$companylink;
|
||||
$logintext.='</div>';
|
||||
@@ -1349,7 +1355,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
&& $_SESSION["dol_authmode"] != 'http')
|
||||
{
|
||||
$logouttext .='<a href="'.DOL_URL_ROOT.'/user/logout.php"';
|
||||
$logouttext .=$menutop->atarget?(' target="'.$menutop->atarget.'"'):'';
|
||||
$logouttext .=$atarget?(' target="'.$atarget.'"'):'';
|
||||
$logouttext .='>';
|
||||
$logouttext .= img_picto($langs->trans('Logout'), 'logout.png', 'class="login"');
|
||||
$logouttext .='</a>';
|
||||
@@ -1415,7 +1421,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
||||
function left_menu($menu_array_before, $helppagename='', $moresearchform='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='')
|
||||
{
|
||||
global $user, $conf, $langs, $db;
|
||||
global $hookmanager;
|
||||
global $hookmanager, $menumanager;
|
||||
|
||||
$searchform='';
|
||||
$bookmarks='';
|
||||
@@ -1481,33 +1487,14 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
||||
$bookmarks=printBookmarksList($db, $langs);
|
||||
}
|
||||
|
||||
$left_menu=empty($conf->browser->phone)?$conf->top_menu:$conf->smart_menu;
|
||||
if (GETPOST('menu')) $left_menu=GETPOST('menu'); // menu=eldy_backoffice.php
|
||||
|
||||
// Load the menu manager (only if not already done)
|
||||
if (! class_exists('MenuManager'))
|
||||
{
|
||||
$menufound=0;
|
||||
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$menufound=dol_include_once($dirmenu."standard/".$left_menu);
|
||||
if ($menufound) break;
|
||||
}
|
||||
if (! $menufound) // If failed to include, we try with standard
|
||||
{
|
||||
$top_menu='eldy_backoffice.php';
|
||||
include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$top_menu;
|
||||
}
|
||||
}
|
||||
|
||||
// Left column
|
||||
print '<!-- Begin left menu - menu '.$left_menu.' -->'."\n";
|
||||
print '<!-- Begin left menu -->'."\n";
|
||||
|
||||
print '<div class="vmenu">'."\n";
|
||||
|
||||
$menuleft=new MenuManager($db,$menu_array_before,$menu_array_after);
|
||||
$menuleft->showmenu('left'); // output menu_array and menu found in database
|
||||
$menumanager->menu_array = $menu_array_before;
|
||||
$menumanager->menu_array_after = $menu_array_after;
|
||||
$menumanager->showmenu('left'); // output menu_array and menu found in database
|
||||
|
||||
|
||||
// Show other forms
|
||||
|
||||
Reference in New Issue
Block a user