New: Uniformize code to manage menus handler provided by external
modules
This commit is contained in:
parent
d78192040b
commit
acef131833
@ -28,6 +28,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
||||||
|
|
||||||
|
$action=GETPOST('action');
|
||||||
|
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
@ -38,9 +39,13 @@ $langs->load("other");
|
|||||||
// Security check
|
// Security check
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) accessforbidden();
|
||||||
|
|
||||||
$dirtop = "/core/menus/standard";
|
$dirstandard = array("/core/menus/standard");
|
||||||
$dirleft = "/core/menus/standard";
|
$dirsmartphone = array("/core/menus/smartphone");
|
||||||
$dirsmartphone = "/core/menus/smartphone";
|
foreach($conf->menus_modules as $dir)
|
||||||
|
{
|
||||||
|
$dirstandard[]=$dir.'/standard';
|
||||||
|
$dirsmartphone[]=$dir.'/standard';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Cette page peut etre longue. On augmente le delai autorise.
|
// Cette page peut etre longue. On augmente le delai autorise.
|
||||||
@ -56,7 +61,7 @@ error_reporting($err);
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["cancel"]))
|
if ($action == 'update' && empty($_POST["cancel"]))
|
||||||
{
|
{
|
||||||
$_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
|
$_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
|
||||||
|
|
||||||
@ -116,15 +121,13 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
$htmladmin=new FormAdmin($db);
|
$formadmin=new FormAdmin($db);
|
||||||
|
|
||||||
$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
|
$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
|
||||||
llxHeader('',$langs->trans("Setup"),$wikihelp);
|
llxHeader('',$langs->trans("Setup"),$wikihelp);
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("Menus"),'','setup');
|
print_fiche_titre($langs->trans("Menus"),'','setup');
|
||||||
|
|
||||||
print $langs->trans("MenusDesc")."<br>\n";
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
|
|
||||||
@ -146,6 +149,9 @@ $h++;
|
|||||||
|
|
||||||
dol_fiche_head($head, 'handler', $langs->trans("Menus"));
|
dol_fiche_head($head, 'handler', $langs->trans("Menus"));
|
||||||
|
|
||||||
|
print $langs->trans("MenusDesc")."<br>\n";
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
|
||||||
if (isset($_GET["action"]) && $_GET["action"] == 'edit')
|
if (isset($_GET["action"]) && $_GET["action"] == 'edit')
|
||||||
{
|
{
|
||||||
@ -172,10 +178,10 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit')
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $htmladmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirtop, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled="disabled"');
|
print $formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled="disabled"');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $htmladmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED, 'MAIN_MENUFRONT_STANDARD', $dirtop, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?'':' disabled="disabled"');
|
print $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED, 'MAIN_MENUFRONT_STANDARD', $dirstandard, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?'':' disabled="disabled"');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -183,10 +189,10 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit')
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $htmladmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array($dirtop,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"');
|
print $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $htmladmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array($dirtop,$dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"');
|
print $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|||||||
@ -30,14 +30,12 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");
|
|||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if (! $user->admin)
|
if (! $user->admin) accessforbidden();
|
||||||
accessforbidden();
|
|
||||||
|
|
||||||
$dirtop = "/core/menus/standard";
|
$dirstandard = "/core/menus/standard";
|
||||||
$dirleft = "/core/menus/standard";
|
|
||||||
$dirsmartphone = "/core/menus/smartphone";
|
$dirsmartphone = "/core/menus/smartphone";
|
||||||
|
|
||||||
$dirmenu = array($dirleft,$dirsmartphone);
|
$dirmenu = array($dirstandard,$dirsmartphone);
|
||||||
|
|
||||||
$action=GETPOST('action');
|
$action=GETPOST('action');
|
||||||
$mesg=GETPOST('mesg');
|
$mesg=GETPOST('mesg');
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
||||||
* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2009-2011 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2009-2011 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -30,14 +30,15 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/treeview.lib.php");
|
|||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if (! $user->admin)
|
if (! $user->admin) accessforbidden();
|
||||||
accessforbidden();
|
|
||||||
|
|
||||||
$dirtop = "/core/menus/standard";
|
$dirstandard = array("/core/menus/standard");
|
||||||
$dirleft = "/core/menus/standard";
|
$dirsmartphone = array("/core/menus/smartphone");
|
||||||
$dirsmartphone = "/core/menus/smartphone";
|
foreach($conf->menus_modules as $dir)
|
||||||
|
{
|
||||||
$dirmenu = array($dirleft,$dirsmartphone);
|
$dirstandard[]=$dir.'/standard';
|
||||||
|
$dirsmartphone[]=$dir.'/standard';
|
||||||
|
}
|
||||||
|
|
||||||
$mesg=$_GET["mesg"];
|
$mesg=$_GET["mesg"];
|
||||||
|
|
||||||
@ -207,9 +208,6 @@ llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs);
|
|||||||
|
|
||||||
print_fiche_titre($langs->trans("Menus"),'','setup');
|
print_fiche_titre($langs->trans("Menus"),'','setup');
|
||||||
|
|
||||||
print $langs->trans("MenusEditorDesc")."<br>\n";
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
|
|
||||||
dol_htmloutput_mesg($mesg);
|
dol_htmloutput_mesg($mesg);
|
||||||
|
|
||||||
@ -233,6 +231,10 @@ $h++;
|
|||||||
|
|
||||||
dol_fiche_head($head, 'editor', $langs->trans("Menus"));
|
dol_fiche_head($head, 'editor', $langs->trans("Menus"));
|
||||||
|
|
||||||
|
print $langs->trans("MenusEditorDesc")."<br>\n";
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
|
||||||
// Confirmation for remove menu entry
|
// Confirmation for remove menu entry
|
||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
@ -250,7 +252,7 @@ if ($_GET["action"] == 'delete')
|
|||||||
print '<form name="newmenu" class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form name="newmenu" class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
print '<input type="hidden" action="change_menu_handler">';
|
print '<input type="hidden" action="change_menu_handler">';
|
||||||
print $langs->trans("MenuHandler").': ';
|
print $langs->trans("MenuHandler").': ';
|
||||||
print $formadmin->select_menu_families($menu_handler,'menu_handler',$dirmenu);
|
print $formadmin->select_menu_families($menu_handler,'menu_handler',array_merge($dirstandard,$dirsmartphone));
|
||||||
print ' <input type="submit" class="button" value="'.$langs->trans("Refresh").'">';
|
print ' <input type="submit" class="button" value="'.$langs->trans("Refresh").'">';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,6 @@ llxHeader('',$langs->trans("Setup"));
|
|||||||
|
|
||||||
print_fiche_titre($langs->trans("Menus"),'','setup');
|
print_fiche_titre($langs->trans("Menus"),'','setup');
|
||||||
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,8 @@ class Conf
|
|||||||
public $modules = array(); // List of modules
|
public $modules = array(); // List of modules
|
||||||
public $css_modules = array();
|
public $css_modules = array();
|
||||||
public $tabs_modules = array();
|
public $tabs_modules = array();
|
||||||
public $triggers_modules = array('/core/triggers');
|
public $triggers_modules = array('/core/triggers'); // TODO default triggers should not be into the module list
|
||||||
|
public $menus_modules = array();
|
||||||
public $hooks_modules = array();
|
public $hooks_modules = array();
|
||||||
public $login_method_modules = array();
|
public $login_method_modules = array();
|
||||||
|
|
||||||
@ -149,6 +150,12 @@ class Conf
|
|||||||
$params=explode(':',$value,2);
|
$params=explode(':',$value,2);
|
||||||
$this->tabs_modules[$params[0]][]=$value;
|
$this->tabs_modules[$params[0]][]=$value;
|
||||||
}
|
}
|
||||||
|
// If this is constant for a new tab page activated by a module
|
||||||
|
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_MENUS/i',$key,$reg))
|
||||||
|
{
|
||||||
|
$modulename = strtolower($reg[1]);
|
||||||
|
$this->menus_modules[] = '/'.$modulename.'/core/menus';
|
||||||
|
}
|
||||||
// If this is constant for triggers activated by a module
|
// If this is constant for triggers activated by a module
|
||||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_TRIGGERS$/i',$key,$reg))
|
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_TRIGGERS$/i',$key,$reg))
|
||||||
{
|
{
|
||||||
@ -175,18 +182,15 @@ class Conf
|
|||||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_SMS$/i',$key,$reg))
|
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_SMS$/i',$key,$reg))
|
||||||
{
|
{
|
||||||
$module=strtolower($reg[1]);
|
$module=strtolower($reg[1]);
|
||||||
// Add this module in list of modules that provide SMS
|
$this->sms_engine[$module]=$module; // Add this module in list of modules that provide SMS
|
||||||
$this->sms_engine[$module]=$module;
|
|
||||||
}
|
}
|
||||||
// If this is a module constant
|
// If this is a module constant
|
||||||
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)$/i',$key,$reg))
|
elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)$/i',$key,$reg))
|
||||||
{
|
{
|
||||||
$module=strtolower($reg[1]);
|
$module=strtolower($reg[1]);
|
||||||
//print "Module ".$module." is enabled<br>\n";
|
|
||||||
$this->$module=(object) array();
|
$this->$module=(object) array();
|
||||||
$this->$module->enabled=true;
|
$this->$module->enabled=true;
|
||||||
// Add this module in list of enabled modules
|
$this->modules[]=$module; // Add this module in list of enabled modules
|
||||||
$this->modules[]=$module;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -128,24 +128,27 @@ class FormAdmin
|
|||||||
*
|
*
|
||||||
* @param string $selected Preselected menu value
|
* @param string $selected Preselected menu value
|
||||||
* @param string $htmlname Name of html select
|
* @param string $htmlname Name of html select
|
||||||
* @param string $dirmenu Directory to scan or array of directories to scan
|
* @param array $dirmenuarray Array of directories to scan
|
||||||
* @param string $moreattrib More attributes on html select tag
|
* @param string $moreattrib More attributes on html select tag
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function select_menu($selected, $htmlname, $dirmenu, $moreattrib='')
|
function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib='')
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
if ($selected == 'eldy.php') $selected='eldy_backoffice.php'; // For compatibility
|
if ($selected == 'eldy.php') $selected='eldy_backoffice.php'; // For compatibility
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (! is_array($dirmenuarray)) return -1;
|
||||||
|
|
||||||
$menuarray=array();
|
$menuarray=array();
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
foreach ($conf->file->dol_document_root as $dirroot)
|
||||||
{
|
{
|
||||||
if (is_array($dirmenu)) $dirmenus=$dirmenu;
|
foreach($dirmenuarray as $dirtoscan)
|
||||||
else $dirmenus=array($dirmenu);
|
|
||||||
foreach($dirmenus as $dirtoscan)
|
|
||||||
{
|
{
|
||||||
$dir=$dirroot.$dirtoscan;
|
$dir=$dirroot.$dirtoscan;
|
||||||
|
//print $dir.'<br>';
|
||||||
if (is_dir($dir))
|
if (is_dir($dir))
|
||||||
{
|
{
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
|
|||||||
@ -1130,17 +1130,26 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
|||||||
/*
|
/*
|
||||||
* Top menu
|
* Top menu
|
||||||
*/
|
*/
|
||||||
$top_menu=isset($conf->browser->phone)?$conf->smart_menu:$conf->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
|
if (GETPOST('menu')) $top_menu=GETPOST('menu'); // menu=eldy_backoffice.php
|
||||||
|
|
||||||
// Load the top menu manager
|
// Load the top menu manager
|
||||||
$result=dol_include_once("/core/menus/standard/".$top_menu);
|
// Load the top menu manager (only if not already done)
|
||||||
if (! $result) // If failed to include, we try with standard
|
if (! class_exists('MenuTop'))
|
||||||
{
|
{
|
||||||
$top_menu='eldy_backoffice.php';
|
$menufound=0;
|
||||||
include_once(DOL_DOCUMENT_ROOT."/core/menus/standard/".$top_menu);
|
$dirmenus=array_merge(array("/core/menus"),$conf->menus_modules);
|
||||||
}
|
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 menu '.$top_menu.' -->'."\n";
|
||||||
|
|
||||||
@ -1321,16 +1330,25 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
|||||||
$bookmarks=printBookmarksList($db, $langs);
|
$bookmarks=printBookmarksList($db, $langs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$left_menu=isset($conf->browser->phone)?$conf->smart_menu:$conf->top_menu;
|
$left_menu=empty($conf->browser->phone)?$conf->top_menu:$conf->smart_menu;
|
||||||
if (GETPOST('menu')) $left_menu=GETPOST('menu'); // menu=eldy_backoffice.php
|
if (GETPOST('menu')) $left_menu=GETPOST('menu'); // menu=eldy_backoffice.php
|
||||||
|
|
||||||
// Load the left menu manager
|
// Load the top menu manager (only if not already done)
|
||||||
$result=dol_include_once("/core/menus/standard/".$left_menu);
|
if (! class_exists('MenuLeft'))
|
||||||
if (! $result) // If menu manager removed or not found
|
{
|
||||||
{
|
$menufound=0;
|
||||||
$left_menu='eldy_backoffice.php';
|
$dirmenus=array_merge(array("/core/menus"),$conf->menus_modules);
|
||||||
include_once(DOL_DOCUMENT_ROOT ."/core/menus/standard/".$left_menu);
|
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
|
// Left column
|
||||||
print '<!-- Begin left area - menu '.$left_menu.' -->'."\n";
|
print '<!-- Begin left area - menu '.$left_menu.' -->'."\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user