From 459855a636cf0760b99bc0c8c2cc287eff9a07c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sat, 20 Feb 2010 15:07:46 +0000 Subject: [PATCH] Mutualize code in menu --- htdocs/admin/menus.php | 178 +++++++++--------- htdocs/html.formadmin.class.php | 13 +- .../includes/menus/barre_top/auguria.lib.php | 112 +++++++++++ .../menus/barre_top/auguria_backoffice.php | 74 +------- .../menus/barre_top/auguria_frontoffice.php | 73 +------ htdocs/includes/menus/barre_top/eldy.lib.php | 8 +- htdocs/product.class.php | 37 +++- 7 files changed, 251 insertions(+), 244 deletions(-) create mode 100644 htdocs/includes/menus/barre_top/auguria.lib.php diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index c5ace7f0b35..efb36c74239 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * * This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ /** * \file htdocs/admin/menus.php * \ingroup core - * \brief Page de configuration des gestionnaires de menu + * \brief Page to setup menu manager to use * \version $Id$ */ @@ -35,16 +35,16 @@ $langs->load("companies"); $langs->load("products"); $langs->load("admin"); -if (!$user->admin) - accessforbidden(); +// Security check +if (!$user->admin) accessforbidden(); $dirtop = "../includes/menus/barre_top"; $dirleft = "../includes/menus/barre_left"; /* -* Actions -*/ + * Actions + */ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["cancel"])) { @@ -57,7 +57,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can dolibarr_set_const($db, "MAIN_MENUFRONT_BARRELEFT",$_POST["main_menufront_barreleft"],'chaine',0,'',$conf->entity); // Define list of menu handlers to initialize - $listofmenuhandler=array(); + $listofmenuhandler=array(); $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["main_menu_barretop"])]=1; $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["main_menufront_barretop"])]=1; $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["main_menu_barreleft"])]=1; @@ -82,8 +82,8 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can /* -* Affichage -*/ + * View + */ $html=new Form($db); $htmladmin=new FormAdmin($db); @@ -114,98 +114,98 @@ dol_fiche_head($head, 'handler', $langs->trans("Menus")); if (isset($_GET["action"]) && $_GET["action"] == 'edit') { - print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="update">'; + print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="update">'; - clearstatcache(); + clearstatcache(); - // Gestionnaires de menu - $var=true; + // Gestionnaires de menu + $var=true; - print '<table class="noborder" width="100%">'; - print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>'; - print '<td>'; + print '<table class="noborder" width="100%">'; + print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>'; + print '<td>'; print $html->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc")); - print '</td>'; - print '<td>'; + print '</td>'; + print '<td>'; print $html->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc")); - print '</td>'; - print '</tr>'; - - // Menu top - $var=!$var; - print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuTopManager").'</td>'; - print '<td>'; - print $htmladmin->select_menu($conf->global->MAIN_MENU_BARRETOP,'main_menu_barretop',$dirtop); - print '</td>'; - print '<td>'; - print $htmladmin->select_menu($conf->global->MAIN_MENUFRONT_BARRETOP,'main_menufront_barretop',$dirtop); - print '</td>'; - print '</tr>'; - - // Menu left - $var=!$var; - print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuLeftManager").'</td>'; - print '<td>'; - print $htmladmin->select_menu($conf->global->MAIN_MENU_BARRELEFT,'main_menu_barreleft',$dirleft); - print '</td>'; - print '<td>'; - print $htmladmin->select_menu($conf->global->MAIN_MENUFRONT_BARRELEFT,'main_menufront_barreleft',$dirleft); - print '</td>'; - print '</tr>'; - - print '</table>'; + print '</td>'; + print '</tr>'; + + // Menu top + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuTopManager").'</td>'; + print '<td>'; + print $htmladmin->select_menu($conf->global->MAIN_MENU_BARRETOP,'main_menu_barretop',$dirtop); + print '</td>'; + print '<td>'; + print $htmladmin->select_menu($conf->global->MAIN_MENUFRONT_BARRETOP,'main_menufront_barretop',$dirtop); + print '</td>'; + print '</tr>'; + + // Menu left + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuLeftManager").'</td>'; + print '<td>'; + print $htmladmin->select_menu($conf->global->MAIN_MENU_BARRELEFT,'main_menu_barreleft',$dirleft); + print '</td>'; + print '<td>'; + print $htmladmin->select_menu($conf->global->MAIN_MENUFRONT_BARRELEFT,'main_menufront_barreleft',$dirleft); + print '</td>'; + print '</tr>'; + + print '</table>'; print '<br><center>'; - print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">'; - print ' '; + print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">'; + print ' '; print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">'; - print '</center>'; + print '</center>'; - print '</form>'; + print '</form>'; } else { - // Gestionnaires de menu - $var=true; + // Gestionnaires de menu + $var=true; - print '<table class="noborder" width="100%">'; - print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>'; - print '<td>'; + print '<table class="noborder" width="100%">'; + print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>'; + print '<td>'; print $html->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc")); - print '</td>'; - print '<td>'; + print '</td>'; + print '<td>'; print $html->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc")); - print '</td>'; - print '</tr>'; - - $var=!$var; - print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuTopManager").'</td>'; - print '<td>'; - $filelib=preg_replace('/.php$/i','',$conf->global->MAIN_MENU_BARRETOP); - print $filelib; - print '</td>'; - print '<td>'; - $filelib=preg_replace('/.php$/i','',$conf->global->MAIN_MENUFRONT_BARRETOP); - print $filelib; - print '</td>'; - print '</tr>'; - - $var=!$var; - print '<tr '.$bc[$var].'>'; - print '<td>'.$langs->trans("DefaultMenuLeftManager").'</td>'; - print '<td>'; - $filelib=preg_replace('/.php$/i','',$conf->global->MAIN_MENU_BARRELEFT); - print $filelib; - print '</td>'; - print '<td>'; - $filelib=preg_replace('/.php$/i','',$conf->global->MAIN_MENUFRONT_BARRELEFT); - print $filelib; - print '</td>'; - print '</tr>'; - - print '</table>'; + print '</td>'; + print '</tr>'; + + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuTopManager").'</td>'; + print '<td>'; + $filelib=preg_replace('/.php$/i','',$conf->global->MAIN_MENU_BARRETOP); + print $filelib; + print '</td>'; + print '<td>'; + $filelib=preg_replace('/.php$/i','',$conf->global->MAIN_MENUFRONT_BARRETOP); + print $filelib; + print '</td>'; + print '</tr>'; + + $var=!$var; + print '<tr '.$bc[$var].'>'; + print '<td>'.$langs->trans("DefaultMenuLeftManager").'</td>'; + print '<td>'; + $filelib=preg_replace('/.php$/i','',$conf->global->MAIN_MENU_BARRELEFT); + print $filelib; + print '</td>'; + print '<td>'; + $filelib=preg_replace('/.php$/i','',$conf->global->MAIN_MENUFRONT_BARRELEFT); + print $filelib; + print '</td>'; + print '</tr>'; + + print '</table>'; } print '</div>'; @@ -213,9 +213,9 @@ print '</div>'; if (! isset($_GET["action"]) || $_GET["action"] != 'edit') { - print '<div class="tabsAction">'; - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; - print '</div>'; + print '<div class="tabsAction">'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; + print '</div>'; } $db->close(); diff --git a/htdocs/html.formadmin.class.php b/htdocs/html.formadmin.class.php index fa930f3d542..b96d556465f 100644 --- a/htdocs/html.formadmin.class.php +++ b/htdocs/html.formadmin.class.php @@ -67,7 +67,7 @@ class FormAdmin } asort($langs_available); - + foreach ($langs_available as $key => $value) { if ($filter && is_array($filter)) @@ -108,14 +108,11 @@ class FormAdmin { if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { - $filelib=preg_replace('/\.php$/i','',$file); + if (preg_match('/lib\.php$/i',$file)) continue; // We exclude library files + $filelib=preg_replace('/\.php$/i','',$file); $prefix=''; - if (preg_match('/^eldy/i',$file)) $prefix='0'; // Recommanded - else if (preg_match('/^auguria/i',$file)) $prefix='2'; // Other - else if (preg_match('/^default/i',$file)) $prefix='2'; // Other - else if (preg_match('/^rodolphe/i',$file)) $prefix='2'; // Other - else if (preg_match('/^empty/i',$file)) $prefix='2'; // Other - else $prefix='1'; // Experimental + if (preg_match('/^eldy/i',$file)) $prefix='0'; // 0=Recommanded, 1=Experimental, 2=Other + else $prefix='2'; if ($file == $selected) { diff --git a/htdocs/includes/menus/barre_top/auguria.lib.php b/htdocs/includes/menus/barre_top/auguria.lib.php new file mode 100644 index 00000000000..6278c755736 --- /dev/null +++ b/htdocs/includes/menus/barre_top/auguria.lib.php @@ -0,0 +1,112 @@ +<?php +/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net> + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/includes/menus/barre_top/auguria.lib.php + * \brief Library for file auguria menus + * \version $Id$ + */ + + + +/** + * Core function to output top menu auguria + * + * @param unknown_type $db + * @param unknown_type $atarget + * @param unknown_type $hideifnotallowed + */ +function print_auguria_menu($db,$atarget,$hideifnotallowed) +{ + require_once(DOL_DOCUMENT_ROOT."/core/menubase.class.php"); + + global $user,$conf,$langs,$dolibarr_main_db_name; + + // On sauve en session le menu principal choisi + if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; + if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; + $_SESSION["leftmenuopened"]=""; + + $menuArbo = new Menubase($db,'auguria','top'); + $tabMenu = $menuArbo->menuTopCharger($hideifnotallowed,$_SESSION['mainmenu'], 'auguria'); + + + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<ul class="tmenu">'."\n"; + else print '<table class="tmenu" summary="topmenu"><tr class="tmenu">'."\n"; + + for($i=0; $i<count($tabMenu); $i++) + { + if ($tabMenu[$i]['enabled'] == true) + { + $idsel=(empty($tabMenu[$i]['mainmenu'])?'none':$tabMenu[$i]['mainmenu']); + if ($tabMenu[$i]['right'] == true) // Is allowed + { + // Define url + if (preg_match("/^(http:\/\/|https:\/\/)/i",$tabMenu[$i]['url'])) + { + $url = $tabMenu[$i]['url']; + } + else + { + $url=DOL_URL_ROOT.$tabMenu[$i]['url']; + if (! preg_match('/\?/',$url)) $url.='?'; + else $url.='&'; + if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) + { + $url.='mainmenu='.$tabMenu[$i]['mainmenu'].'&leftmenu=&'; + } + $url.="idmenu=".$tabMenu[$i]['rowid']; + } + + // Define the class (top menu selected or not) + if (! empty($_SESSION['idmenu']) && $tabMenu[$i]['rowid'] == $_SESSION['idmenu']) $class='class="tmenusel"'; + else if (! empty($_SESSION['mainmenu']) && $tabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) $class='class="tmenusel"'; + else $class='class="tmenu"'; + + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<li class="tmenu" id="li_'.$idsel.'">'; + else print '<td class="tmenu" id="td_'.$idsel.'">'; + + print '<a '.$class.' id="mainmenu_'.$idsel.'" href="'.$url.'"'.($tabMenu[$i]['atarget']?" target='".$tabMenu[$i]['atarget']."'":($atarget?" target=$atarget":"")).'>'; + print $tabMenu[$i]['titre']; + print '</a>'; + + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</li>'."\n"; + else print '</td>'."\n"; + } + else + { + if (! $hideifnotallowed) + { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<li class="tmenu" id="li_'.$idsel.'">'; + else print '<td class="tmenu" id="td_'.$idsel.'">'; + + print '<a class="tmenudisabled" id="mainmenu_'.$idsel.'" href="#">'.$tabMenu[$i]['titre'].'</a>'; + + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</li>'."\n"; + else print '</td>'."\n"; + } + } + } + } + + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</ul>'."\n"; + else print '</tr></table>'."\n"; +} + +?> diff --git a/htdocs/includes/menus/barre_top/auguria_backoffice.php b/htdocs/includes/menus/barre_top/auguria_backoffice.php index ba03879b27e..c99694f3d19 100644 --- a/htdocs/includes/menus/barre_top/auguria_backoffice.php +++ b/htdocs/includes/menus/barre_top/auguria_backoffice.php @@ -57,79 +57,9 @@ class MenuTop { */ function showmenu() { - require_once(DOL_DOCUMENT_ROOT."/core/menubase.class.php"); + require_once(DOL_DOCUMENT_ROOT.'/includes/menus/barre_top/auguria.lib.php'); - global $user,$conf,$langs,$dolibarr_main_db_name; - - // On sauve en session le menu principal choisi - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; - $_SESSION["leftmenuopened"]=""; - - $menuArbo = new Menubase($this->db,'auguria','top'); - $tabMenu = $menuArbo->menuTopCharger($this->hideifnotallowed,$_SESSION['mainmenu'], 'auguria'); - - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<ul class="tmenu">'."\n"; - else print '<table class="tmenu" summary="topmenu"><tr class="tmenu">'."\n"; - - for($i=0; $i<count($tabMenu); $i++) - { - if ($tabMenu[$i]['enabled'] == true) - { - $idsel=(empty($tabMenu[$i]['mainmenu'])?'none':$tabMenu[$i]['mainmenu']); - if ($tabMenu[$i]['right'] == true) // Is allowed - { - // Define url - if (preg_match("/^(http:\/\/|https:\/\/)/i",$tabMenu[$i]['url'])) - { - $url = $tabMenu[$i]['url']; - } - else - { - $url=DOL_URL_ROOT.$tabMenu[$i]['url']; - if (! preg_match('/\?/',$url)) $url.='?'; - else $url.='&'; - if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) - { - $url.='mainmenu='.$tabMenu[$i]['mainmenu'].'&leftmenu=&'; - } - $url.="idmenu=".$tabMenu[$i]['rowid']; - } - - // Define the class (top menu selected or not) - if (! empty($_SESSION['idmenu']) && $tabMenu[$i]['rowid'] == $_SESSION['idmenu']) $class='class="tmenusel"'; - else if (! empty($_SESSION['mainmenu']) && $tabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) $class='class="tmenusel"'; - else $class='class="tmenu"'; - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<li class="tmenu" id="li_'.$idsel.'">'; - else print '<td class="tmenu" id="td_'.$idsel.'">'; - - print '<a '.$class.' id="mainmenu_'.$idsel.'" href="'.$url.'"'.($tabMenu[$i]['atarget']?" target='".$tabMenu[$i]['atarget']."'":($this->atarget?" target=$this->atarget":"")).'>'; - print $tabMenu[$i]['titre']; - print '</a>'; - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</li>'."\n"; - else print '</td>'."\n"; - } - else - { - if (! $this->hideifnotallowed) - { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<li class="tmenu" id="li_'.$idsel.'">'; - else print '<td class="tmenu" id="td_'.$idsel.'">'; - - print '<a class="tmenudisabled" id="mainmenu_'.$idsel.'" href="#">'.$tabMenu[$i]['titre'].'</a>'; - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</li>'."\n"; - else print '</td>'."\n"; - } - } - } - } - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</ul>'."\n"; - else print '</tr></table>'."\n"; + print_auguria_menu($this->db,$this->atarget,$this->hideifnotallowed); } } diff --git a/htdocs/includes/menus/barre_top/auguria_frontoffice.php b/htdocs/includes/menus/barre_top/auguria_frontoffice.php index 91847e3db46..4e4fc77be81 100644 --- a/htdocs/includes/menus/barre_top/auguria_frontoffice.php +++ b/htdocs/includes/menus/barre_top/auguria_frontoffice.php @@ -58,78 +58,9 @@ class MenuTop { */ function showmenu() { - require_once(DOL_DOCUMENT_ROOT."/core/menubase.class.php"); + require_once(DOL_DOCUMENT_ROOT.'/includes/menus/barre_top/auguria.lib.php'); - global $user,$conf,$langs,$dolibarr_main_db_name; - - // On sauve en session le menu principal choisi - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; - $_SESSION["leftmenuopened"]=""; - - $menuArbo = new Menubase($this->db,'auguria','top'); - $tabMenu = $menuArbo->menuTopCharger($this->hideifnotallowed,$_SESSION['mainmenu'], 'auguria'); - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<ul class="tmenu">'."\n"; - else print '<table class="tmenu" summary="topmenu"><tr class="tmenu">'."\n"; - - for($i=0; $i<count($tabMenu); $i++) - { - if ($tabMenu[$i]['enabled'] == true) - { - $idsel=(empty($tabMenu[$i]['mainmenu'])?'none':$tabMenu[$i]['mainmenu']); - if ($tabMenu[$i]['right'] == true) // Is allowed - { - // Define url - if (preg_match("/^(http:\/\/|https:\/\/)/i",$tabMenu[$i]['url'])) - { - $url = $tabMenu[$i]['url']; - } - else - { - $url=DOL_URL_ROOT.$tabMenu[$i]['url']; - if (! preg_match('/\?/',$url)) $url.='?'; - else $url.='&'; - if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) - { - $url.='mainmenu='.$tabMenu[$i]['mainmenu'].'&leftmenu=&'; - } - $url.="idmenu=".$tabMenu[$i]['rowid']; - } - - // Define the class (top menu selected or not) - if (! empty($_SESSION['idmenu']) && $tabMenu[$i]['rowid'] == $_SESSION['idmenu']) $class='class="tmenusel"'; - else if (! empty($_SESSION['mainmenu']) && $tabMenu[$i]['mainmenu'] == $_SESSION['mainmenu']) $class='class="tmenusel"'; - else $class='class="tmenu"'; - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<li class="tmenu" id="li_'.$idsel.'">'; - else print '<td class="tmenu" id="td_'.$idsel.'">'; - - print '<a '.$class.' id="mainmenu_'.$idsel.'" href="'.$url.'"'.($tabMenu[$i]['atarget']?" target='".$tabMenu[$i]['atarget']."'":($this->atarget?" target=$this->atarget":"")).'>'; - print $tabMenu[$i]['titre']; - print '</a>'; - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</li>'."\n"; - else print '</td>'."\n"; - } - else - { - if (! $this->hideifnotallowed) - { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<li class="tmenu" id="li_'.$idsel.'">'; - else print '<td class="tmenu" id="td_'.$idsel.'">'; - - print '<a class="tmenudisabled" id="mainmenu_'.$idsel.'" href="#">'.$tabMenu[$i]['titre'].'</a>'; - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</li>'."\n"; - else print '</td>'."\n"; - } - } - } - } - - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '</ul>'."\n"; - else print '</tr></table>'."\n"; + print_auguria_menu($this->db,$this->atarget,$this->hideifnotallowed); } } diff --git a/htdocs/includes/menus/barre_top/eldy.lib.php b/htdocs/includes/menus/barre_top/eldy.lib.php index c79ea07185e..d795a4cafe7 100644 --- a/htdocs/includes/menus/barre_top/eldy.lib.php +++ b/htdocs/includes/menus/barre_top/eldy.lib.php @@ -24,7 +24,13 @@ */ - +/** + * Core function to output top menu eldy + * + * @param unknown_type $db + * @param unknown_type $atarget + * @param unknown_type $hideifnotallowed + */ function print_eldy_menu($db,$atarget,$hideifnotallowed) { global $user,$conf,$langs,$dolibarr_main_db_name; diff --git a/htdocs/product.class.php b/htdocs/product.class.php index d83b206199e..8ba221f4635 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -2402,8 +2402,10 @@ class Product extends CommonObject * \param nbbyrow Nombre vignettes par ligne (si mode vignette) * \return int Nombre de photos affichees */ - function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5) + function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0) { + global $user; + include_once(DOL_DOCUMENT_ROOT ."/lib/files.lib.php"); $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; @@ -2427,12 +2429,14 @@ class Product extends CommonObject { $nbphoto++; $photo = $file; + $viewfilename = $file; if ($size == 1) { // Format vignette // On determine nom du fichier vignette $photo_vignette=''; if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$photo,$regs)) { $photo_vignette=preg_replace('/'.$regs[0].'/i','',$photo)."_small".$regs[0]; + if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; } @@ -2444,7 +2448,7 @@ class Product extends CommonObject print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'" alt="Taille origine" target="_blank">'; // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine - if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) { + if ($photo_vignette) { print '<img class="photo" border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdirthumb.$photo_vignette).'">'; } else { @@ -2453,6 +2457,22 @@ class Product extends CommonObject print '</a>'; + if ($showfilename) print '<br>'.$viewfilename; + if ($showaction) + { + print '<br>'; + // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites + if ($photo_vignette && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) + { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_refresh($langs->trans('GenerateThumb')).' </a>'; + } + if ($user->rights->produit->creer || $user->rights->service->creer) + { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; + print img_delete().'</a>'; + } + } + if ($nbbyrow) print '</td>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>'; @@ -2460,6 +2480,16 @@ class Product extends CommonObject if ($size == 0) { // Format origine print '<img class="photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'">'; + + if ($showfilename) print '<br>'.$viewfilename; + if ($showaction) + { + if ($user->rights->produit->creer || $user->rights->service->creer) + { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; + print img_delete().'</a>'; + } + } } // On continue ou on arrete de boucler ? @@ -2470,7 +2500,8 @@ class Product extends CommonObject if ($nbbyrow && $size==1) { // Ferme tableau - while ($nbphoto % $nbbyrow) { + while ($nbphoto % $nbbyrow) + { print '<td width="'.ceil(100/$nbbyrow).'%"> </td>'; $nbphoto++; } -- GitLab