diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php
index ed5f56954c0..5fb19b0b5ec 100644
--- a/htdocs/admin/menus/index.php
+++ b/htdocs/admin/menus/index.php
@@ -289,11 +289,11 @@ if ($conf->use_javascript_ajax)
- la chaine a afficher
ie: data[]= array (index, index parent, chaine )
*/
-
+
//il faut d'abord declarer un element racine de l'arbre
$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>'');
-
+
//puis tous les elements enfants
$sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.module";
@@ -313,6 +313,7 @@ if ($conf->use_javascript_ajax)
{
if (! empty($menu['langs'])) $langs->load($menu['langs']);
$titre = $langs->trans($menu['titre']);
+
$data[] = array(
'rowid'=>$menu['rowid'],
'module'=>$menu['module'],
@@ -329,28 +330,33 @@ if ($conf->use_javascript_ajax)
''.img_edit_add('default').' '.
''.img_delete('default').' '.
' '.
- ''.img_picto("Monter","1uparrow").''.img_picto("Descendre","1downarrow").''.
- ''
+ ''.img_picto("Up","1uparrow").''.img_picto("Down","1downarrow").''.
+ '',
+ 'buttons'=>''.img_edit('default',0,'class="menuEdit" id="edit'.$menu['rowid'].'"').' '.
+ ''.img_edit_add('default').' '.
+ ''.img_delete('default').' '.
+ ' '.
+ ''.img_picto("Up","1uparrow").''.img_picto("Down","1downarrow").''
);
$i++;
}
}
global $tree_recur_alreadyadded; // This var was def into tree_recur
-
+
// Appelle de la fonction recursive (ammorce)
// avec recherche depuis la racine.
//var_dump($data);
tree_recur($data, $data[0], 0, 'iddivjstree'); // $data[0] is virtual record 'racine'
-
+
print '';
-
+
print '';
-
+
print '';
-
-
+
+
// Process remaining records (records that are not linked to root by any path)
$remainingdata = array();
foreach($data as $datar)
@@ -358,30 +364,30 @@ if ($conf->use_javascript_ajax)
if (empty($datar['rowid']) || $tree_recur_alreadyadded[$datar['rowid']]) continue;
$remainingdata[] = $datar;
}
-
+
if (count($remainingdata))
{
print '
';
-
+
print '';
print '| '.$langs->trans("NotTopTreeMenuPersonalized").' | ';
print ' | ';
print '
';
-
+
print '';
- print '| ';
-
+ print ' | ';
+
foreach($remainingdata as $datar)
{
$father = array('rowid'=>$datar['rowid'],'title'=>"???",'mainmenu'=>$datar['fk_mainmenu'],'leftmenu'=>$datar['fk_leftmenu'],'fk_mainmenu'=>'','fk_leftmenu'=>'');
//print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].' '."\n";
tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1);
}
-
+
print ' | ';
-
+
print '
';
-
+
print '
';
}
diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php
index db0fcd07fae..944520d04d5 100644
--- a/htdocs/core/lib/treeview.lib.php
+++ b/htdocs/core/lib/treeview.lib.php
@@ -110,15 +110,15 @@ function tree_showpad(&$fulltree,$key,$silent=0)
* @param int $rang Level of element
* @param string $iddivjstree Id to use for parent ul element
* @param int $donoresetalreadyloaded Do not reset global array $donoresetalreadyloaded used to avoid to go down on an aleady processed record
- * @param int $showfk Show fk links to parent into label
+ * @param int $showfk 1=show fk_links to parent into label (used by menu editor only)
* @return void
*/
function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0)
{
global $tree_recur_alreadyadded;
-
+
if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array();
-
+
if ($rang == 0)
{
// Test also done with jstree and dynatree (not able to have inside label)
@@ -138,8 +138,8 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
print '';
}
-
- if ($rang > 50)
+
+ if ($rang > 50)
{
return; // Protect against infinite loop. Max 50 depth
}
@@ -154,19 +154,31 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid'])
{
//print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."
\n";
- if (empty($ulprinted) && ! empty($pere['rowid']))
- {
+ if (empty($ulprinted) && ! empty($pere['rowid']))
+ {
if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
{
dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
continue;
}
-
+
print ''; $ulprinted++;
}
print "\n".'- ';
- print $tab[$x]['entry'];
- if ($showfk) print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
+ if ($showfk)
+ {
+ print '
| ';
+ print ' ';
+ print $tab[$x]['title'];
+ print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
+ print ' | ';
+ print $tab[$x]['buttons'];
+ print ' |
';
+ }
+ else
+ {
+ print $tab[$x]['entry'];
+ }
//print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'
'."\n";
$tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
// And now we search all its sons of lower level
@@ -176,7 +188,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
{
//print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."
\n";
- if (empty($ulprinted) && ! empty($pere['rowid']))
+ if (empty($ulprinted) && ! empty($pere['rowid']))
{
if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
{
@@ -184,12 +196,25 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
//print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.';
continue;
}
-
+
print ''; $ulprinted++;
}
print "\n".'- ';
- print $tab[$x]['entry'];
- if ($showfk) print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
+ if ($showfk)
+ {
+ print '
| ';
+ print ' ';
+ print $tab[$x]['title'];
+ print '';
+ print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
+ print ' | ';
+ print $tab[$x]['buttons'];
+ print ' |
';
+ }
+ else
+ {
+ print $tab[$x]['entry'];
+ }
//print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'
'."\n";
$tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
// And now we search all its sons of lower level