Fix menu editor (data not aligned)
This commit is contained in:
parent
b7218c1bcd
commit
658fe93d8c
@ -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)
|
||||
'<a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=create&menuId='.$menu['rowid'].'">'.img_edit_add('default').'</a> '.
|
||||
'<a href="index.php?menu_handler='.$menu_handler_to_search.'&action=delete&menuId='.$menu['rowid'].'">'.img_delete('default').'</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>'
|
||||
'<a href="index.php?menu_handler='.$menu_handler_to_search.'&action=up&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>'.
|
||||
'</td></tr></table>',
|
||||
'buttons'=>'<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').'</a> '.
|
||||
'<a href="index.php?menu_handler='.$menu_handler_to_search.'&action=delete&menuId='.$menu['rowid'].'">'.img_delete('default').'</a> '.
|
||||
' '.
|
||||
'<a href="index.php?menu_handler='.$menu_handler_to_search.'&action=up&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>'
|
||||
);
|
||||
$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 '</td>';
|
||||
|
||||
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 '<table class="noborder centpercent">';
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("NotTopTreeMenuPersonalized").'</td>';
|
||||
print '<td align="right"></td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print '<tr>';
|
||||
print '<td colspan="2">';
|
||||
|
||||
print '<td colspan="2">';
|
||||
|
||||
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'].'<br>'."\n";
|
||||
tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
print '</td>';
|
||||
|
||||
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
|
||||
@ -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 <a> inside label)
|
||||
@ -138,8 +138,8 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
|
||||
|
||||
print '<ul id="'.$iddivjstree.'">';
|
||||
}
|
||||
|
||||
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']."<br>\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 '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
|
||||
}
|
||||
print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
|
||||
print $tab[$x]['entry'];
|
||||
if ($showfk) print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
|
||||
if ($showfk)
|
||||
{
|
||||
print '<table class="nobordernopadding centpercent"><tr><td>';
|
||||
print '<strong> ';
|
||||
print $tab[$x]['title'];
|
||||
print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
|
||||
print '</td><td align="right">';
|
||||
print $tab[$x]['buttons'];
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
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'].'<br>'."\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']."<br>\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 '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
|
||||
}
|
||||
print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
|
||||
print $tab[$x]['entry'];
|
||||
if ($showfk) print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
|
||||
if ($showfk)
|
||||
{
|
||||
print '<table class="nobordernopadding centpercent"><tr><td>';
|
||||
print '<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">';
|
||||
print $tab[$x]['title'];
|
||||
print '</a></strong>';
|
||||
print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
|
||||
print '</td><td align="right">';
|
||||
print $tab[$x]['buttons'];
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
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'].'<br>'."\n";
|
||||
$tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
|
||||
// And now we search all its sons of lower level
|
||||
|
||||
Loading…
Reference in New Issue
Block a user