28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
33$langs->loadLangs(array(
"other",
"admin"));
35$dirstandard = array();
36$dirsmartphone = array();
37$dirmenus = array_merge(array(
"/core/menus/"), (array) $conf->modules_parts[
'menus']);
38foreach ($dirmenus as $dirmenu) {
39 $dirstandard[] = $dirmenu.
'standard';
40 $dirsmartphone[] = $dirmenu.
'smartphone';
43$action =
GETPOST(
'action',
'aZ09');
44$confirm =
GETPOST(
'confirm',
'alpha');
47$menu_handler_top =
'all';
48$menu_handler_top = preg_replace(
'/(_backoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
49$menu_handler_top = preg_replace(
'/(_frontoffice\.php|_menu\.php)/i',
'', $menu_handler_top);
51$menu_handler = $menu_handler_top;
53if (
GETPOST(
"handler_origine")) {
54 $menu_handler =
GETPOST(
"handler_origine");
57 $menu_handler =
GETPOST(
"menu_handler");
60$menu_handler_to_search = preg_replace(
'/(_backoffice|_frontoffice|_menu)?(\.php)?/i',
'', $menu_handler);
62if (empty($user->admin)) {
76 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
77 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
78 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
"menuId");
80 $result = $db->query($sql);
81 $num = $db->num_rows($result);
84 $obj = $db->fetch_object($result);
85 $current[
'rowid'] = $obj->rowid;
86 $current[
'order'] = $obj->position;
87 $current[
'type'] = $obj->type;
88 $current[
'fk_menu'] = $obj->fk_menu;
93 $sql =
"SELECT m.rowid, m.position";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
95 $sql .=
" WHERE (m.position < ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid < ".
GETPOSTINT(
"menuId").
"))";
96 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
97 $sql .=
" AND m.entity = ".$conf->entity;
98 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
99 $sql .=
" AND m.fk_menu = '".$db->escape($current[
'fk_menu']).
"'";
100 $sql .=
" ORDER BY m.position, m.rowid";
102 $result = $db->query($sql);
103 $num = $db->num_rows($result);
106 $obj = $db->fetch_object($result);
107 $previous[
'rowid'] = $obj->rowid;
108 $previous[
'order'] = $obj->position;
112 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
113 $sql .=
" SET m.position = ".((int) $previous[
'order']);
114 $sql .=
" WHERE m.rowid = ".((int) $current[
'rowid']);
117 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
118 $sql .=
" SET m.position = ".((int) ($current[
'order'] != $previous[
'order'] ? $current[
'order'] : $current[
'order'] + 1));
119 $sql .=
" WHERE m.rowid = ".((int) $previous[
'rowid']);
122} elseif ($action ==
'down') {
127 $sql =
"SELECT m.rowid, m.position, m.type, m.fk_menu";
128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
129 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
"menuId");
131 $result = $db->query($sql);
132 $num = $db->num_rows($result);
135 $obj = $db->fetch_object($result);
136 $current[
'rowid'] = $obj->rowid;
137 $current[
'order'] = $obj->position;
138 $current[
'type'] = $obj->type;
139 $current[
'fk_menu'] = $obj->fk_menu;
144 $sql =
"SELECT m.rowid, m.position";
145 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
146 $sql .=
" WHERE (m.position > ".($current[
'order']).
" OR (m.position = ".($current[
'order']).
" AND rowid > ".
GETPOSTINT(
"menuId").
"))";
147 $sql .=
" AND m.menu_handler='".$db->escape($menu_handler_to_search).
"'";
148 $sql .=
" AND m.entity = ".$conf->entity;
149 $sql .=
" AND m.type = '".$db->escape($current[
'type']).
"'";
150 $sql .=
" AND m.fk_menu = '".$db->escape($current[
'fk_menu']).
"'";
151 $sql .=
" ORDER BY m.position, m.rowid";
153 $result = $db->query($sql);
154 $num = $db->num_rows($result);
157 $obj = $db->fetch_object($result);
158 $next[
'rowid'] = $obj->rowid;
159 $next[
'order'] = $obj->position;
163 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
164 $sql .=
" SET m.position = ".((int) ($current[
'order'] != $next[
'order'] ? $next[
'order'] : $current[
'order'] + 1));
165 $sql .=
" WHERE m.rowid = ".((int) $current[
'rowid']);
168 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"menu as m";
169 $sql .=
" SET m.position = ".((int) $current[
'order']);
170 $sql .=
" WHERE m.rowid = ".((int) $next[
'rowid']);
173} elseif ($action ==
'confirm_delete' && $confirm ==
'yes') {
176 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
177 $sql .=
" WHERE rowid = ".GETPOSTINT(
'menuId');
178 $resql = $db->query($sql);
184 header(
"Location: ".DOL_URL_ROOT.
'/admin/menus/index.php?menu_handler='.$menu_handler);
199$form =
new Form($db);
202$arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
203$arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
205llxHeader(
'', $langs->trans(
"Menus"),
'',
'', 0, 0, $arrayofjs, $arrayofcss,
'',
'mod-admin page-menus_index');
214$head[$h][0] = DOL_URL_ROOT.
"/admin/menus.php";
215$head[$h][1] = $langs->trans(
"MenuHandlers");
216$head[$h][2] =
'handler';
219$head[$h][0] = DOL_URL_ROOT.
"/admin/menus/index.php";
220$head[$h][1] = $langs->trans(
"MenuAdmin");
221$head[$h][2] =
'editor';
226print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"MenusEditorDesc").
"</span><br>\n";
231if ($action ==
'delete') {
232 $sql =
"SELECT m.titre as title";
233 $sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
234 $sql .=
" WHERE m.rowid = ".GETPOSTINT(
'menuId');
235 $result = $db->query($sql);
236 $obj = $db->fetch_object($result);
238 print $form->formconfirm(
"index.php?menu_handler=".$menu_handler.
"&menuId=".
GETPOSTINT(
'menuId'), $langs->trans(
"DeleteMenu"), $langs->trans(
"ConfirmDeleteMenu", $obj->title),
"confirm_delete");
243 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).
'&backtopage='.urlencode($_SERVER[
'PHP_SELF']));
246print
'<form name="newmenu" class="nocellnopadd" action="'.$_SERVER[
"PHP_SELF"].
'">';
247print
'<input type="hidden" action="change_menu_handler">';
248print $langs->trans(
"MenuHandler").
': ';
249$formadmin->select_menu_families($menu_handler.(preg_match(
'/_menu/', $menu_handler) ?
'' :
'_menu'),
'menu_handler', array_merge($dirstandard, $dirsmartphone));
250print
' <input type="submit" class="button small" value="'.$langs->trans(
"Refresh").
'">';
252print
'<div class="floatright">';
278$data[] = array(
'rowid' => 0,
'fk_menu' => -1,
'title' =>
"racine",
'mainmenu' =>
'',
'leftmenu' =>
'',
'fk_mainmenu' =>
'',
'fk_leftmenu' =>
'');
282$sql =
"SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module";
283$sql .=
" FROM ".MAIN_DB_PREFIX.
"menu as m";
284$sql .=
" WHERE menu_handler = '".$db->escape($menu_handler_to_search).
"'";
285$sql .=
" AND entity = ".$conf->entity;
287$sql .=
" ORDER BY m.position, m.rowid";
289$res = $db->query($sql);
291 $num = $db->num_rows($res);
294 while ($menu = $db->fetch_array($res)) {
295 if (!empty($menu[
'langs'])) {
296 $langs->load($menu[
'langs']);
298 $titre = $langs->trans($menu[
'titre']);
300 $entry =
'<table class="nobordernopadding centpercent"><tr><td class="tdoverflowmax200">';
301 $entry .=
'<strong class="paddingleft"><a href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.$titre.
'</a></strong>';
303 $entry .=
'<td class="right nowraponall">';
304 $entry .=
'<a class="editfielda marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_edit(
'default', 0,
'class="menuEdit" id="edit'.$menu[
'rowid'].
'"').
'</a> ';
305 $entry .=
'<a class="marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=create&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_edit_add(
'default').
'</a> ';
306 $entry .=
'<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.
'&action=delete&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_delete(
'default').
'</a> ';
308 $entry .=
'<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.
'&action=up&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_picto(
"Up",
"1uparrow").
'</a><a href="index.php?menu_handler='.$menu_handler_to_search.
'&action=down&menuId='.$menu[
'rowid'].
'">'.
img_picto(
"Down",
"1downarrow").
'</a>';
309 $entry .=
'</td></tr></table>';
311 $buttons =
'<a class="editfielda marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=edit&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_edit(
'default', 0,
'class="menuEdit" id="edit'.$menu[
'rowid'].
'"').
'</a> ';
312 $buttons .=
'<a class="marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.
'&action=create&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_edit_add(
'default').
'</a> ';
313 $buttons .=
'<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.
'&action=delete&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_delete(
'default').
'</a> ';
314 $buttons .=
' ';
315 $buttons .=
'<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.
'&action=up&token='.
newToken().
'&menuId='.$menu[
'rowid'].
'">'.
img_picto(
"Up",
"1uparrow").
'</a><a href="index.php?menu_handler='.$menu_handler_to_search.
'&action=down&menuId='.$menu[
'rowid'].
'">'.
img_picto(
"Down",
"1downarrow").
'</a>';
318 'rowid' => $menu[
'rowid'],
319 'module' => $menu[
'module'],
320 'fk_menu' => $menu[
'fk_menu'],
322 'mainmenu' => $menu[
'mainmenu'],
323 'leftmenu' => $menu[
'leftmenu'],
324 'fk_mainmenu' => $menu[
'fk_mainmenu'],
325 'fk_leftmenu' => $menu[
'fk_leftmenu'],
326 'position' => $menu[
'position'],
328 'buttons' => $buttons
334global $tree_recur_alreadyadded;
338print
'<div class="div-table-responsive">';
339print
'<table class="noborder centpercent">';
341print
'<tr class="liste_titre">';
342print
'<td>'.$langs->trans(
"TreeMenuPersonalized").
'</td>';
343print
'<td class="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto($langs->trans(
"UndoExpandAll"),
'folder',
'class="paddingright"').
'</a>';
344print
' | <a href="#">'.img_picto($langs->trans(
"ExpandAll"),
'folder-open',
'class="paddingright"').
'</a></div></td>';
348print
'<td colspan="2">';
352tree_recur($data, $data[0], 0,
'iddivjstree', 0, 0);
362$remainingdata = array();
363foreach ($data as $datar) {
364 if (empty($datar[
'rowid']) || !empty($tree_recur_alreadyadded[$datar[
'rowid']])) {
367 $remainingdata[] = $datar;
370if (count($remainingdata)) {
371 print
'<div class="div-table-responsive">';
372 print
'<table class="noborder centpercent">';
374 print
'<tr class="liste_titre">';
375 print
'<td>'.$langs->trans(
"NotTopTreeMenuPersonalized").
'</td>';
376 print
'<td class="right"></td>';
380 print
'<td colspan="2">';
381 foreach ($remainingdata as $datar) {
382 $father = array(
'rowid' => $datar[
'rowid'],
'title' =>
"???",
'mainmenu' => $datar[
'fk_mainmenu'],
'leftmenu' => $datar[
'fk_leftmenu'],
'fk_mainmenu' =>
'',
'fk_leftmenu' =>
'');
384 tree_recur($data, $father, 0,
'iddivjstree'.$datar[
'rowid'], 1, 1);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
img_edit_add($titlealt='default', $other='')
Show logo +.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0, $moreparam='')
Recursive function to output a tree.