From b060e5961b7bed9083acbe2aded297416e875388 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2013 19:47:03 +0100 Subject: [PATCH] Qual: Another step in men manager rewrite. --- htdocs/compta/bank/pre.inc.php | 1 + htdocs/compta/paiement/cheque/pre.inc.php | 1 + htdocs/core/menus/smartphone/index.php | 1 - .../core/menus/smartphone/smartphone.lib.php | 215 ------------------ .../core/menus/smartphone/smartphone_menu.php | 132 ----------- htdocs/core/menus/standard/auguria_menu.php | 1 + htdocs/core/menus/standard/eldy_menu.php | 1 + htdocs/core/menus/standard/empty.php | 1 + htdocs/ftp/pre.inc.php | 1 + htdocs/main.inc.php | 1 - 10 files changed, 6 insertions(+), 349 deletions(-) delete mode 100644 htdocs/core/menus/smartphone/index.php delete mode 100755 htdocs/core/menus/smartphone/smartphone.lib.php delete mode 100755 htdocs/core/menus/smartphone/smartphone_menu.php diff --git a/htdocs/compta/bank/pre.inc.php b/htdocs/compta/bank/pre.inc.php index f995c226c4d..a507c4c0a71 100644 --- a/htdocs/compta/bank/pre.inc.php +++ b/htdocs/compta/bank/pre.inc.php @@ -51,6 +51,7 @@ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers + require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; $menu = new Menu(); // Entry for each bank account diff --git a/htdocs/compta/paiement/cheque/pre.inc.php b/htdocs/compta/paiement/cheque/pre.inc.php index ad915f21299..bc730c9740d 100644 --- a/htdocs/compta/paiement/cheque/pre.inc.php +++ b/htdocs/compta/paiement/cheque/pre.inc.php @@ -50,6 +50,7 @@ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers + require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; $menu = new Menu(); // Entry for each bank account diff --git a/htdocs/core/menus/smartphone/index.php b/htdocs/core/menus/smartphone/index.php deleted file mode 100644 index 7db0dd9ebf9..00000000000 --- a/htdocs/core/menus/smartphone/index.php +++ /dev/null @@ -1 +0,0 @@ -Url not available \ No newline at end of file diff --git a/htdocs/core/menus/smartphone/smartphone.lib.php b/htdocs/core/menus/smartphone/smartphone.lib.php deleted file mode 100755 index ad71482fe10..00000000000 --- a/htdocs/core/menus/smartphone/smartphone.lib.php +++ /dev/null @@ -1,215 +0,0 @@ - - * Copyright (C) 2010 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ - -/** - * \file htdocs/core/menus/smartphone/smartphone.lib.php - * \brief Library for file smartphone menus - */ - - -/** - * Core function to output top menu smartphone - * - * @param DoliDB $db Database handler - * @param string $atarget Target - * @param int $type_user 0=Internal,1=External,2=All - * @param string $limitmenuto To limit menu to a top or left menu value - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @return void - */ -function print_smartphone_menu($db,$atarget,$type_user,$limitmenuto,&$tabMenu,&$menu) -{ - require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; - - global $user,$conf,$langs,$dolibarr_main_db_name; - - $mainmenu=$_SESSION["mainmenu"]; - $leftmenu=$_SESSION["leftmenu"]; - - $submenus=''; - - //$tabMenu=array(); - - $menutop = new Menubase($db,'smartphone'); - $menuleft = new Menubase($db,'smartphone'); - $newTabMenu = $menutop->menuTopCharger('', '', $type_user, 'smartphone',$tabMenu); - $numTabMenu = count($newTabMenu); - - print_start_menu_array(); - for($i=0; $i<$numTabMenu; $i++) - { - if ($newTabMenu[$i]['enabled'] == true) - { - if ($newTabMenu[$i]['perms'] == true) // Is allowed - { - // Define url - if (preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) - { - $url = dol_buildpath($newTabMenu[$i]['url'],1); - $url=preg_replace('/&.*/i','',$url); - } - else - { - $menus=''; - - if ($limitmenuto > 0) - { - $newmenu = new Menu(); - $leftmenu = $menuleft->menuLeftCharger($newmenu,$newTabMenu[$i]['mainmenu'],'',($user->societe_id?1:0),'smartphone',$tabMenu); - $menus = $leftmenu->liste; - //var_dump($menus); - } - - print_start_menu_entry(); - - if (is_array($menus) && !empty($menus) && $limitmenuto > 0) - { - $title=$newTabMenu[$i]['titre']; - // To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($newTabMenu[$i]['titre'],ENT_QUOTES,'UTF-8'),'',array('&'))); - print_text_menu_entry($title); - - $num = count($menus); - //var_dump($menus); - - if ($num > 0) print_start_submenu_array(); - - for($j=0; $j<$num; $j++) - { - $url=dol_buildpath($menus[$j]['url'],1); - $url=preg_replace('/&.*/i','',$url); - - if ($menus[$j]['level'] == 0) - { - print_start_menu_entry(); - if (empty($menus[$j+1]['level'])) print ''; - $title=$menus[$j]['titre']; - // To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($menus[$j]['titre'],ENT_QUOTES,'UTF-8'),'',array('&'))); - print_text_menu_entry($title); - if (empty($menus[$j+1]['level'])) print ''; - } - - if ($menus[$j]['level'] > 0) - { - if ($menus[$j-1]['level'] == 0) print_start_submenu_array(); - - print_start_menu_entry(); - print ''; - $title=$menus[$j]['titre']; - // To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($menus[$j]['titre'],ENT_QUOTES,'UTF-8'),'',array('&'))); - print_text_menu_entry($title); - print ''; - print_end_menu_entry(); - - if (empty($menus[$j+1]['level'])) print_end_menu(); - } - - if (empty($menus[$j+1]['level'])) print_end_menu_entry(); - } - - if ($num > 0) print_end_menu(); - } - else - { - $url=dol_buildpath($newTabMenu[$i]['url'],1); - $url=preg_replace('/&.*/i','',$url); - - print ''; - $title=$newTabMenu[$i]['titre']; - // To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($newTabMenu[$i]['titre'],ENT_QUOTES,'UTF-8'),'',array('&'))); - print_text_menu_entry($title); - print ''; - } - - print_end_menu_entry(); - } - } - } - } - - print_end_menu(); - print "\n"; -} - -/** - * Output menu entry - * - * @param string $theme Theme - * @return void - */ -function print_start_menu_array($theme='c') -{ - print '
    '; - print "\n"; -} - -/** - * Output start submenu entry - * - * @return void - */ -function print_start_submenu_array() -{ - print '
      '; - print "\n"; -} - -/** - * Output start menu entry - * - * @return void - */ -function print_start_menu_entry() -{ - print '
    • '; -} - -/** - * Output menu entry - * - * @param string $text Text - * @return void - */ -function print_text_menu_entry($text) -{ - print $text; -} - -/** - * Output end menu entry - * - * @return void - */ -function print_end_menu_entry() -{ - print '
    • '; - print "\n"; -} - -/** - * Output end menu - * - * @return void - */ -function print_end_menu() -{ - print '
    '; - print "\n"; -} - -?> diff --git a/htdocs/core/menus/smartphone/smartphone_menu.php b/htdocs/core/menus/smartphone/smartphone_menu.php deleted file mode 100755 index 1b8b87de0dd..00000000000 --- a/htdocs/core/menus/smartphone/smartphone_menu.php +++ /dev/null @@ -1,132 +0,0 @@ - - * Copyright (C) 2007-2010 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/menus/smartphone/smartphone_menu.php - * \brief Menu smartphone manager - */ - - -/** - * Class to manage smartphone menu smartphone - */ -class MenuSmart -{ - - var $hideifnotallowed=1; // Put 0 for back office menu, 1 for front office menu - var $atarget=""; // Valeur du target a utiliser dans les liens - var $name="smartphone"; - - var $tabMenu; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param int $type_user Type of user - */ - function __construct($db, $type_user) - { - $this->type_user=$type_user; - $this->db=$db; - } - - /** - * Load this->tabMenu - * - * @return void - */ - function loadMenu() - { - // On sauve en session le menu principal choisi - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; - - // Read mainmenu and leftmenu that define which menu to show - if (isset($_GET["mainmenu"])) - { - // On sauve en session le menu principal choisi - $mainmenu=$_GET["mainmenu"]; - $_SESSION["mainmenu"]=$mainmenu; - $_SESSION["leftmenuopened"]=""; - } - else - { - // On va le chercher en session si non defini par le lien - $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; - } - - if (isset($_GET["leftmenu"])) - { - // On sauve en session le menu principal choisi - $leftmenu=$_GET["leftmenu"]; - $_SESSION["leftmenu"]=$leftmenu; - - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse - { - //$leftmenu=""; - $_SESSION["leftmenuopened"]=""; - } - else - { - $_SESSION["leftmenuopened"]=$leftmenu; - } - } else { - // On va le chercher en session si non defini par le lien - $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; - } - - require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; - $tabMenu=array(); - $menuArbo = new Menubase($this->db,'smartphone'); - $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'smartphone', $tabMenu); - $this->tabMenu=$tabMenu; - } - - - /** - * Show menu - * - * @param string $mode 'top' or 'left' - * @return int Number of menu entries shown - */ - function showmenu($mode) - { - global $conf; - - require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php'; - - if ($this->type_user == 1) - { - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; - $conf->global->MAIN_SEARCHFORM_CONTACT=0; - } - - $this->menu=new Menu(); - - print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$mode,$this->tabMenu,$this->menu); - - unset($this->menu); - - return 1; - } - -} - -?> \ No newline at end of file diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index b7c76af0d32..1aeb8d8ac98 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -168,6 +168,7 @@ class MenuManager $res='ErrorBadParameterForMode'; + require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; $this->menu=new Menu(); if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu); diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index ffe5470728e..2b4ad8c97a7 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -124,6 +124,7 @@ class MenuManager $res='ErrorBadParameterForMode'; + require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; $this->menu=new Menu(); if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu); diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 83b49382da3..c0198ead137 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -69,6 +69,7 @@ class MenuManager $id='mainmenu'; + require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; $this->menu=new Menu(); if ($mode == 'top') diff --git a/htdocs/ftp/pre.inc.php b/htdocs/ftp/pre.inc.php index 261188b8e91..19a9d2547fb 100644 --- a/htdocs/ftp/pre.inc.php +++ b/htdocs/ftp/pre.inc.php @@ -47,6 +47,7 @@ function llxHeader($head = '', $title='', $help_url='', $morehtml='', $target='' top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers + require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; $menu = new Menu(); $MAXFTP=20; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a3262e69ec1..2a7b8ca2ea8 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -242,7 +242,6 @@ if (! empty($conf->file->main_force_https)) // Chargement des includes complementaires de presentation -if (! defined('NOREQUIREMENU')) require_once DOL_DOCUMENT_ROOT .'/core/class/menu.class.php'; // Need 10ko memory (11ko in 2.2) if (! defined('NOREQUIREHTML')) require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; // Need 660ko memory (800ko in 2.2) if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; // Need 22ko memory