2007-04-30 10:35:47 +02:00
|
|
|
<?php
|
2008-01-08 19:35:13 +01:00
|
|
|
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
2012-02-12 15:17:54 +01:00
|
|
|
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-12-30 15:13:49 +01:00
|
|
|
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
2007-04-30 10:35:47 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2007-04-30 10:35:47 +02:00
|
|
|
* (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
|
2011-08-01 00:21:57 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2007-04-30 10:35:47 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2008-09-01 23:51:38 +02:00
|
|
|
* \file htdocs/admin/menus/index.php
|
|
|
|
|
* \ingroup core
|
|
|
|
|
* \brief Index page for menu editor
|
|
|
|
|
*/
|
2008-01-09 00:23:14 +01:00
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
|
2007-12-14 10:54:24 +01:00
|
|
|
|
|
|
|
|
$langs->load("other");
|
2008-01-08 19:35:13 +01:00
|
|
|
$langs->load("admin");
|
2007-12-14 10:54:24 +01:00
|
|
|
|
2012-02-12 15:17:54 +01:00
|
|
|
if (! $user->admin) accessforbidden();
|
2007-06-08 00:52:47 +02:00
|
|
|
|
2012-06-12 18:35:29 +02:00
|
|
|
$dirstandard = array();
|
|
|
|
|
$dirsmartphone = array();
|
2012-07-02 19:30:37 +02:00
|
|
|
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
|
|
|
|
|
foreach($dirmenus as $dirmenu)
|
2012-02-12 15:17:54 +01:00
|
|
|
{
|
2012-06-14 16:48:02 +02:00
|
|
|
$dirstandard[]=$dirmenu.'standard';
|
|
|
|
|
$dirsmartphone[]=$dirmenu.'smartphone';
|
2012-02-12 15:17:54 +01:00
|
|
|
}
|
2007-04-30 10:35:47 +02:00
|
|
|
|
2012-07-09 18:09:44 +02:00
|
|
|
$action=GETPOST('action','alpha');
|
|
|
|
|
$confirm=GETPOST('confirm','alpha');
|
|
|
|
|
$mesg=GETPOST('mesg');
|
2008-01-08 19:35:13 +01:00
|
|
|
|
2011-02-13 14:22:54 +01:00
|
|
|
$menu_handler_top=$conf->global->MAIN_MENU_STANDARD;
|
2010-09-23 12:02:27 +02:00
|
|
|
$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE;
|
2013-02-19 15:23:25 +01:00
|
|
|
$menu_handler_top=preg_replace('/(_backoffice\.php|_menu\.php)/i','',$menu_handler_top);
|
|
|
|
|
$menu_handler_top=preg_replace('/(_frontoffice\.php|_menu\.php)/i','',$menu_handler_top);
|
|
|
|
|
$menu_handler_smartphone=preg_replace('/(_backoffice\.php|_menu\.php)/i','',$menu_handler_smartphone);
|
|
|
|
|
$menu_handler_smartphone=preg_replace('/(_frontoffice\.php|_menu\.php)/i','',$menu_handler_smartphone);
|
2007-05-07 19:35:51 +02:00
|
|
|
|
2010-09-29 12:10:33 +02:00
|
|
|
$menu_handler=$menu_handler_top;
|
2007-05-07 19:35:51 +02:00
|
|
|
|
2012-09-08 02:03:47 +02:00
|
|
|
if (GETPOST("handler_origine")) $menu_handler=GETPOST("handler_origine");
|
|
|
|
|
if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler");
|
2007-06-08 00:52:47 +02:00
|
|
|
|
2013-03-30 14:27:13 +01:00
|
|
|
$menu_handler_to_search=preg_replace('/(_backoffice|_frontoffice|_menu)?(\.php)?/i','',$menu_handler);
|
2013-02-19 15:23:25 +01:00
|
|
|
|
2007-06-08 00:52:47 +02:00
|
|
|
|
2007-05-07 19:35:51 +02:00
|
|
|
/*
|
2013-02-19 15:23:25 +01:00
|
|
|
* Actions
|
|
|
|
|
*/
|
2007-05-07 19:35:51 +02:00
|
|
|
|
2012-07-09 18:09:44 +02:00
|
|
|
if ($action == 'up')
|
2007-04-30 10:35:47 +02:00
|
|
|
{
|
2009-10-25 16:36:45 +01:00
|
|
|
$current=array();
|
|
|
|
|
$previous=array();
|
|
|
|
|
|
|
|
|
|
// Get current position
|
|
|
|
|
$sql = "SELECT m.rowid, m.position, m.type, m.fk_menu";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
2007-05-07 18:44:27 +02:00
|
|
|
$sql.= " WHERE m.rowid = ".$_GET["menuId"];
|
2009-10-25 16:36:45 +01:00
|
|
|
dol_syslog("admin/menus/index.php ".$sql);
|
2009-02-11 21:19:47 +01:00
|
|
|
$result = $db->query($sql);
|
2008-01-12 17:14:14 +01:00
|
|
|
$num = $db->num_rows($result);
|
2007-04-30 10:35:47 +02:00
|
|
|
$i = 0;
|
|
|
|
|
while($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($result);
|
2009-10-25 16:36:45 +01:00
|
|
|
$current['rowid'] = $obj->rowid;
|
|
|
|
|
$current['order'] = $obj->position;
|
|
|
|
|
$current['type'] = $obj->type;
|
|
|
|
|
$current['fk_menu'] = $obj->fk_menu;
|
2007-04-30 10:35:47 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
2009-02-11 21:19:47 +01:00
|
|
|
|
2009-10-25 16:36:45 +01:00
|
|
|
// Menu before
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql = "SELECT m.rowid, m.position";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql.= " WHERE (m.position < ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid < ".$_GET["menuId"]."))";
|
2013-02-19 15:23:25 +01:00
|
|
|
$sql.= " AND m.menu_handler='".$menu_handler_to_search."'";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " AND m.entity = ".$conf->entity;
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql.= " AND m.type = '".$current['type']."'";
|
|
|
|
|
$sql.= " AND m.fk_menu = '".$current['fk_menu']."'";
|
|
|
|
|
$sql.= " ORDER BY m.position, m.rowid";
|
|
|
|
|
dol_syslog("admin/menus/index.php ".$sql);
|
2009-02-11 21:19:47 +01:00
|
|
|
$result = $db->query($sql);
|
2008-01-12 17:14:14 +01:00
|
|
|
$num = $db->num_rows($result);
|
2007-04-30 10:35:47 +02:00
|
|
|
$i = 0;
|
|
|
|
|
while($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($result);
|
2009-10-25 16:36:45 +01:00
|
|
|
$previous['rowid'] = $obj->rowid;
|
|
|
|
|
$previous['order'] = $obj->position;
|
2007-04-30 10:35:47 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
2009-02-11 21:19:47 +01:00
|
|
|
|
2007-05-07 18:44:27 +02:00
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql.= " SET m.position = ".$previous['order'];
|
|
|
|
|
$sql.= " WHERE m.rowid = ".$current['rowid']; // Up the selected entry
|
|
|
|
|
dol_syslog("admin/menus/index.php ".$sql);
|
2009-02-11 21:19:47 +01:00
|
|
|
$db->query($sql);
|
2007-05-07 18:44:27 +02:00
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql.= " SET m.position = ".($current['order']!=$previous['order']?$current['order']:$current['order']+1);
|
|
|
|
|
$sql.= " WHERE m.rowid = ".$previous['rowid']; // Descend celui du dessus
|
|
|
|
|
dol_syslog("admin/menus/index.php ".$sql);
|
2009-02-11 21:19:47 +01:00
|
|
|
$db->query($sql);
|
2007-04-30 10:35:47 +02:00
|
|
|
}
|
|
|
|
|
|
2012-07-09 18:09:44 +02:00
|
|
|
elseif ($action == 'down')
|
2007-04-30 10:35:47 +02:00
|
|
|
{
|
2009-10-25 16:36:45 +01:00
|
|
|
$current=array();
|
|
|
|
|
$next=array();
|
2007-04-30 10:35:47 +02:00
|
|
|
|
2009-10-25 16:36:45 +01:00
|
|
|
// Get current position
|
|
|
|
|
$sql = "SELECT m.rowid, m.position, m.type, m.fk_menu";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
|
|
|
|
$sql.= " WHERE m.rowid = ".$_GET["menuId"];
|
2009-10-25 16:36:45 +01:00
|
|
|
dol_syslog("admin/menus/index.php ".$sql);
|
2009-02-11 21:19:47 +01:00
|
|
|
$result = $db->query($sql);
|
2008-01-12 17:14:14 +01:00
|
|
|
$num = $db->num_rows($result);
|
2007-04-30 10:35:47 +02:00
|
|
|
$i = 0;
|
|
|
|
|
while($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($result);
|
2009-10-25 16:36:45 +01:00
|
|
|
$current['rowid'] = $obj->rowid;
|
|
|
|
|
$current['order'] = $obj->position;
|
|
|
|
|
$current['type'] = $obj->type;
|
|
|
|
|
$current['fk_menu'] = $obj->fk_menu;
|
2007-04-30 10:35:47 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
2009-02-11 21:19:47 +01:00
|
|
|
|
2009-10-25 16:36:45 +01:00
|
|
|
// Menu after
|
2008-01-12 17:14:14 +01:00
|
|
|
$sql = "SELECT m.rowid, m.position";
|
2007-05-07 18:44:27 +02:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql.= " WHERE (m.position > ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid > ".$_GET["menuId"]."))";
|
2013-02-19 15:23:25 +01:00
|
|
|
$sql.= " AND m.menu_handler='".$menu_handler_to_search."'";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " AND m.entity = ".$conf->entity;
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql.= " AND m.type = '".$current['type']."'";
|
|
|
|
|
$sql.= " AND m.fk_menu = '".$current['fk_menu']."'";
|
|
|
|
|
$sql.= " ORDER BY m.position, m.rowid";
|
|
|
|
|
dol_syslog("admin/menus/index.php ".$sql);
|
2009-02-11 21:19:47 +01:00
|
|
|
$result = $db->query($sql);
|
2008-01-12 17:14:14 +01:00
|
|
|
$num = $db->num_rows($result);
|
2007-04-30 10:35:47 +02:00
|
|
|
$i = 0;
|
|
|
|
|
while($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($result);
|
2009-10-25 16:36:45 +01:00
|
|
|
$next['rowid'] = $obj->rowid;
|
|
|
|
|
$next['order'] = $obj->position;
|
2007-04-30 10:35:47 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
2009-02-11 21:19:47 +01:00
|
|
|
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql.= " SET m.position = ".($current['order']!=$next['order']?$next['order']:$current['order']+1); // Down the selected entry
|
|
|
|
|
$sql.= " WHERE m.rowid = ".$current['rowid'];
|
|
|
|
|
dol_syslog("admin/menus/index.php ".$sql);
|
2009-02-11 21:19:47 +01:00
|
|
|
$db->query($sql);
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; // Up the next entry
|
|
|
|
|
$sql.= " SET m.position = ".$current['order'];
|
|
|
|
|
$sql.= " WHERE m.rowid = ".$next['rowid'];
|
|
|
|
|
dol_syslog("admin/menus/index.php ".$sql);
|
2009-02-11 21:19:47 +01:00
|
|
|
$db->query($sql);
|
|
|
|
|
}
|
2007-05-07 18:44:27 +02:00
|
|
|
|
2012-07-09 18:09:44 +02:00
|
|
|
elseif ($action == 'confirm_delete' && $confirm == 'yes')
|
2007-05-07 18:44:27 +02:00
|
|
|
{
|
2008-01-08 19:35:13 +01:00
|
|
|
$db->begin();
|
2009-02-11 21:19:47 +01:00
|
|
|
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
|
|
|
|
|
$sql.= " WHERE rowid = ".$_GET['menuId'];
|
2008-01-12 15:52:53 +01:00
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2007-04-30 10:35:47 +02:00
|
|
|
{
|
2008-01-08 19:35:13 +01:00
|
|
|
$db->commit();
|
|
|
|
|
|
2012-08-31 05:58:38 +02:00
|
|
|
header("Location: ".DOL_URL_ROOT.'/admin/menus/index.php?menu_handler='.$menu_handler.'&mesg='.urlencode($langs->trans("MenuDeleted")));
|
2007-04-30 10:35:47 +02:00
|
|
|
exit ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-01-08 19:35:13 +01:00
|
|
|
$db->rollback();
|
|
|
|
|
|
2007-04-30 10:35:47 +02:00
|
|
|
$reload = 0;
|
2012-07-09 18:09:44 +02:00
|
|
|
$action='';
|
2007-04-30 10:35:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-06 00:30:46 +02:00
|
|
|
|
|
|
|
|
/*
|
2009-05-27 16:32:19 +02:00
|
|
|
* View
|
2007-06-06 00:30:46 +02:00
|
|
|
*/
|
2009-05-27 16:32:19 +02:00
|
|
|
|
2011-11-08 10:18:45 +01:00
|
|
|
$form=new Form($db);
|
|
|
|
|
$formadmin=new FormAdmin($db);
|
2007-06-06 00:30:46 +02:00
|
|
|
|
2013-03-30 14:27:13 +01:00
|
|
|
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
|
|
|
|
|
$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
|
2013-02-19 20:15:30 +01:00
|
|
|
|
|
|
|
|
llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs,$arrayofcss);
|
2007-06-06 00:30:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
print_fiche_titre($langs->trans("Menus"),'','setup');
|
|
|
|
|
|
2011-12-08 22:48:28 +01:00
|
|
|
|
|
|
|
|
dol_htmloutput_mesg($mesg);
|
2008-01-08 19:35:13 +01:00
|
|
|
|
|
|
|
|
|
2007-06-06 00:30:46 +02:00
|
|
|
$h = 0;
|
|
|
|
|
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
|
|
|
|
|
$head[$h][1] = $langs->trans("MenuHandlers");
|
|
|
|
|
$head[$h][2] = 'handler';
|
|
|
|
|
$h++;
|
|
|
|
|
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php";
|
|
|
|
|
$head[$h][1] = $langs->trans("MenuAdmin");
|
|
|
|
|
$head[$h][2] = 'editor';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2010-10-28 12:22:06 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT."/admin/menus/other.php";
|
2013-03-24 07:11:44 +01:00
|
|
|
$head[$h][1] = $langs->trans("Miscellaneous");
|
2010-10-28 12:22:06 +02:00
|
|
|
$head[$h][2] = 'misc';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_fiche_head($head, 'editor', $langs->trans("Menus"));
|
2007-06-06 00:30:46 +02:00
|
|
|
|
2012-02-12 15:17:54 +01:00
|
|
|
print $langs->trans("MenusEditorDesc")."<br>\n";
|
|
|
|
|
print "<br>\n";
|
|
|
|
|
|
|
|
|
|
|
2009-09-27 14:27:42 +02:00
|
|
|
// Confirmation for remove menu entry
|
2012-07-09 18:09:44 +02:00
|
|
|
if ($action == 'delete')
|
2007-04-30 10:35:47 +02:00
|
|
|
{
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql = "SELECT m.titre";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
|
|
|
|
$sql.= " WHERE m.rowid = ".$_GET['menuId'];
|
2007-04-30 10:35:47 +02:00
|
|
|
$result = $db->query($sql);
|
|
|
|
|
$obj = $db->fetch_object($result);
|
2009-02-11 21:19:47 +01:00
|
|
|
|
2013-09-06 11:51:24 +02:00
|
|
|
print $form->formconfirm("index.php?menu_handler=".$menu_handler."&menuId=".$_GET['menuId'],$langs->trans("DeleteMenu"),$langs->trans("ConfirmDeleteMenu",$obj->titre),"confirm_delete");
|
2007-04-30 10:35:47 +02:00
|
|
|
}
|
|
|
|
|
|
2007-07-08 18:24:06 +02:00
|
|
|
|
2008-05-23 17:28:03 +02:00
|
|
|
print '<form name="newmenu" class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'">';
|
2007-06-08 00:52:47 +02:00
|
|
|
print '<input type="hidden" action="change_menu_handler">';
|
|
|
|
|
print $langs->trans("MenuHandler").': ';
|
2013-02-19 15:23:25 +01:00
|
|
|
print $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/',$menu_handler)?'':'_menu'),'menu_handler',array_merge($dirstandard,$dirsmartphone));
|
2007-06-08 00:52:47 +02:00
|
|
|
print ' <input type="submit" class="button" value="'.$langs->trans("Refresh").'">';
|
|
|
|
|
print '</form>';
|
2007-04-30 10:35:47 +02:00
|
|
|
|
2007-06-08 00:52:47 +02:00
|
|
|
print '<br>';
|
2007-04-30 10:35:47 +02:00
|
|
|
|
|
|
|
|
print '<table class="border" width="100%">';
|
2007-05-07 19:35:51 +02:00
|
|
|
|
2007-04-30 10:35:47 +02:00
|
|
|
print '<tr class="liste_titre">';
|
2007-06-06 00:30:46 +02:00
|
|
|
print '<td>'.$langs->trans("TreeMenuPersonalized").'</td>';
|
2013-02-20 18:34:54 +01:00
|
|
|
print '<td align="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto('','object_category').' '.$langs->trans("UndoExpandAll").'</a>';
|
|
|
|
|
print ' | <a href="#">'.img_picto('','object_category-expanded').' '.$langs->trans("ExpandAll").'</a></div></td>';
|
2007-04-30 10:35:47 +02:00
|
|
|
print '</tr>';
|
2007-05-07 19:35:51 +02:00
|
|
|
|
2007-04-30 10:35:47 +02:00
|
|
|
print '<tr>';
|
2013-02-20 18:34:54 +01:00
|
|
|
print '<td colspan="2">';
|
2007-06-06 00:30:46 +02:00
|
|
|
|
2009-02-11 21:19:47 +01:00
|
|
|
// ARBORESCENCE
|
2007-04-30 10:35:47 +02:00
|
|
|
|
|
|
|
|
$rangLast = 0;
|
|
|
|
|
$idLast = -1;
|
2008-01-06 16:24:23 +01:00
|
|
|
if ($conf->use_javascript_ajax)
|
2007-04-30 10:35:47 +02:00
|
|
|
{
|
2008-01-08 19:35:13 +01:00
|
|
|
/*-------------------- MAIN -----------------------
|
2009-10-25 16:36:45 +01:00
|
|
|
tableau des elements de l'arbre:
|
|
|
|
|
c'est un tableau a 2 dimensions.
|
|
|
|
|
Une ligne represente un element : data[$x]
|
|
|
|
|
chaque ligne est decomposee en 3 donnees:
|
2010-09-23 12:02:27 +02:00
|
|
|
- l'index de l'élément
|
|
|
|
|
- l'index de l'élément parent
|
2009-10-25 16:36:45 +01:00
|
|
|
- la chaine a afficher
|
2009-02-11 21:19:47 +01:00
|
|
|
ie: data[]= array (index, index parent, chaine )
|
2008-01-08 19:35:13 +01:00
|
|
|
*/
|
2009-10-25 16:36:45 +01:00
|
|
|
//il faut d'abord declarer un element racine de l'arbre
|
2008-01-08 19:35:13 +01:00
|
|
|
|
2012-09-27 00:05:13 +02:00
|
|
|
$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>'');
|
2008-01-08 19:35:13 +01:00
|
|
|
|
2009-10-25 16:36:45 +01:00
|
|
|
//puis tous les elements enfants
|
2008-01-08 19:35:13 +01:00
|
|
|
|
2012-09-27 00:05:13 +02:00
|
|
|
$sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu";
|
2008-01-08 19:35:13 +01:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
2013-02-19 15:23:25 +01:00
|
|
|
$sql.= " WHERE menu_handler = '".$menu_handler_to_search."'";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " AND entity = ".$conf->entity;
|
2011-04-06 13:11:32 +02:00
|
|
|
$sql.= " AND fk_menu >= 0";
|
2009-10-25 16:36:45 +01:00
|
|
|
$sql.= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same)
|
2008-01-08 19:35:13 +01:00
|
|
|
|
2012-09-08 02:03:47 +02:00
|
|
|
dol_syslog("sql=".$sql);
|
|
|
|
|
$res = $db->query($sql);
|
2008-01-08 19:35:13 +01:00
|
|
|
if ($res)
|
|
|
|
|
{
|
|
|
|
|
$num = $db->num_rows($res);
|
|
|
|
|
|
|
|
|
|
$i = 1;
|
2011-09-03 01:57:26 +02:00
|
|
|
while ($menu = $db->fetch_array($res))
|
2008-01-08 19:35:13 +01:00
|
|
|
{
|
2009-02-11 21:19:47 +01:00
|
|
|
if (! empty($menu['langs'])) $langs->load($menu['langs']);
|
2008-01-08 19:35:13 +01:00
|
|
|
$titre = $langs->trans($menu['titre']);
|
2013-02-20 19:01:29 +01:00
|
|
|
$data[] = array(
|
|
|
|
|
'rowid'=>$menu['rowid'],
|
|
|
|
|
'fk_menu'=>$menu['fk_menu'],
|
|
|
|
|
'title'=>$titre,
|
|
|
|
|
'mainmenu'=>$menu['mainmenu'],
|
|
|
|
|
'leftmenu'=>$menu['leftmenu'],
|
|
|
|
|
'fk_mainmenu'=>$menu['fk_mainmenu'],
|
|
|
|
|
'fk_leftmenu'=>$menu['fk_leftmenu'],
|
2013-03-30 14:27:13 +01:00
|
|
|
'entry'=>'<table class="nobordernopadding centpercent"><tr><td>'.
|
|
|
|
|
'<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'.$titre.'</a></strong>'.
|
|
|
|
|
'</td><td align="right">'.
|
|
|
|
|
'<a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'.img_edit('default',0,'class="menuEdit" id="edit'.$menu['rowid'].'"').'</a> '.
|
|
|
|
|
'<a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=create&menuId='.$menu['rowid'].'">'.img_edit_add('default',0,'class="menuNew" id="new'.$menu['rowid'].'"').'</a> '.
|
|
|
|
|
'<a href="index.php?menu_handler='.$menu_handler_to_search.'&action=delete&menuId='.$menu['rowid'].'">'.img_delete('default',0,'class="menuDel" id="del'.$menu['rowid'].'"').'</a> '.
|
|
|
|
|
'<a href="index.php?menu_handler='.$menu_handler_to_search.'&action=up&menuId='.$menu['rowid'].'">'.img_picto("Monter","1uparrow").'</a><a href="index.php?menu_handler='.$menu_handler_to_search.'&action=down&menuId='.$menu['rowid'].'">'.img_picto("Descendre","1downarrow").'</a>'.
|
|
|
|
|
'</td></tr></table>'
|
2013-02-20 19:01:29 +01:00
|
|
|
);
|
2009-02-11 21:19:47 +01:00
|
|
|
$i++;
|
2008-01-08 19:35:13 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-25 16:36:45 +01:00
|
|
|
// Appelle de la fonction recursive (ammorce)
|
2008-09-01 23:51:38 +02:00
|
|
|
// avec recherche depuis la racine.
|
2012-09-27 00:05:13 +02:00
|
|
|
//var_dump($data);
|
|
|
|
|
tree_recur($data,$data[0],0);
|
2008-01-08 19:35:13 +01:00
|
|
|
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Boutons actions
|
|
|
|
|
*/
|
|
|
|
|
print '<div class="tabsAction">';
|
2008-01-09 00:23:14 +01:00
|
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'">'.$langs->trans("NewMenu").'</a>';
|
2008-01-08 19:35:13 +01:00
|
|
|
print '</div>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$langs->load("errors");
|
|
|
|
|
print '<div class="error">'.$langs->trans("ErrorFeatureNeedJavascript").'</div>';
|
2007-04-30 10:35:47 +02:00
|
|
|
}
|
|
|
|
|
|
2008-01-08 19:48:12 +01:00
|
|
|
print '<br>';
|
|
|
|
|
|
2012-07-09 18:09:44 +02:00
|
|
|
llxFooter();
|
2012-09-08 02:03:47 +02:00
|
|
|
|
2012-07-09 18:09:44 +02:00
|
|
|
$db->close();
|
|
|
|
|
?>
|