Qual: Code to output tree is now generic
This commit is contained in:
parent
c38f91101d
commit
320b4bde1f
@ -318,7 +318,23 @@ if ($conf->use_javascript_ajax)
|
|||||||
{
|
{
|
||||||
if (! empty($menu['langs'])) $langs->load($menu['langs']);
|
if (! empty($menu['langs'])) $langs->load($menu['langs']);
|
||||||
$titre = $langs->trans($menu['titre']);
|
$titre = $langs->trans($menu['titre']);
|
||||||
$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']);
|
$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'],
|
||||||
|
'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>'
|
||||||
|
);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,56 +145,30 @@ function tree_showpad(&$fulltree,$key,$silent=0)
|
|||||||
// ------------------------------- Used by menu editor -----------------
|
// ------------------------------- Used by menu editor -----------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an element with correct offset
|
* Recursive function to output menu tree. <ul><li>...</li></ul>
|
||||||
*
|
|
||||||
* @param array $tab Array of element
|
|
||||||
* @param int $rang Level of offset
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function tree_showline($tab,$rang)
|
|
||||||
{
|
|
||||||
global $conf, $rangLast, $idLast, $menu_handler;
|
|
||||||
|
|
||||||
// Content of line
|
|
||||||
print '<table class="nobordernopadding centpercent"><tr><td>';
|
|
||||||
print '<strong> <a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab['rowid'].'">'.$tab['title'].'</a></strong>';
|
|
||||||
print '</td><td align="right">';
|
|
||||||
print '<a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab['rowid'].'">'.img_edit('default',0,'class="menuEdit" id="edit'.$tab['rowid'].'"').'</a> ';
|
|
||||||
print '<a href="edit.php?menu_handler='.$menu_handler.'&action=create&menuId='.$tab['rowid'].'">'.img_edit_add('default',0,'class="menuNew" id="new'.$tab['rowid'].'"').'</a> ';
|
|
||||||
print '<a href="index.php?menu_handler='.$menu_handler.'&action=delete&menuId='.$tab['rowid'].'">'.img_delete('default',0,'class="menuDel" id="del'.$tab['rowid'].'"').'</a> ';
|
|
||||||
print '<a href="index.php?menu_handler='.$menu_handler.'&action=up&menuId='.$tab['rowid'].'">'.img_picto("Monter","1uparrow").'</a><a href="index.php?menu_handler='.$menu_handler.'&action=down&menuId='.$tab['rowid'].'">'.img_picto("Descendre","1downarrow").'</a>';
|
|
||||||
print '</td></tr></table>';
|
|
||||||
|
|
||||||
$rangLast = $rang;
|
|
||||||
$idLast = $tab['rowid'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursive function to output menu tree
|
|
||||||
*
|
*
|
||||||
* @param array $tab Array of all elements
|
* @param array $tab Array of all elements
|
||||||
* @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
|
* @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
|
||||||
* @param int $rang Level of element
|
* @param int $rang Level of element
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function tree_recur($tab,$pere,$rang)
|
function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree')
|
||||||
{
|
{
|
||||||
if (empty($pere['rowid']))
|
if (empty($pere['rowid']))
|
||||||
{
|
{
|
||||||
// Test also done with jstree and dynatree (not able to have <a> inside label)
|
// Test also done with jstree and dynatree (not able to have <a> inside label)
|
||||||
print '<script type="text/javascript" language="javascript">
|
print '<script type="text/javascript" language="javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#iddivjstree").treeview({
|
$("#'.$iddivjstree.'").treeview({
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
animated: "fast",
|
animated: "fast",
|
||||||
persist: "location",
|
persist: "location",
|
||||||
control: "#iddivjstreecontrol"
|
control: "#'.$iddivjstree.'control"
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
</script>';
|
</script>';
|
||||||
|
|
||||||
print '<ul id="iddivjstree" style="min-height:300px;">';
|
print '<ul id="'.$iddivjstree.'" style="min-height:300px;">';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rang > 10) return; // Protection contre boucle infinie
|
if ($rang > 10) return; // Protection contre boucle infinie
|
||||||
@ -210,9 +184,7 @@ function tree_recur($tab,$pere,$rang)
|
|||||||
{
|
{
|
||||||
if (empty($ulprinted) && ! empty($pere['rowid'])) { print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; }
|
if (empty($ulprinted) && ! empty($pere['rowid'])) { print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; }
|
||||||
print "\n".'<li>';
|
print "\n".'<li>';
|
||||||
// We shot it with an offset
|
print $tab[$x]['entry'];
|
||||||
tree_showline($tab[$x],$rang);
|
|
||||||
|
|
||||||
// And now we search all its sons of lower level
|
// And now we search all its sons of lower level
|
||||||
tree_recur($tab,$tab[$x],$rang+1);
|
tree_recur($tab,$tab[$x],$rang+1);
|
||||||
print '</li>';
|
print '</li>';
|
||||||
@ -221,9 +193,7 @@ function tree_recur($tab,$pere,$rang)
|
|||||||
{
|
{
|
||||||
if (empty($ulprinted) && ! empty($pere['rowid'])) { print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; }
|
if (empty($ulprinted) && ! empty($pere['rowid'])) { print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; }
|
||||||
print "\n".'<li>';
|
print "\n".'<li>';
|
||||||
// We shot it with an offset
|
print $tab[$x]['entry'];
|
||||||
tree_showline($tab[$x],$rang);
|
|
||||||
|
|
||||||
// And now we search all its sons of lower level
|
// And now we search all its sons of lower level
|
||||||
tree_recur($tab,$tab[$x],$rang+1);
|
tree_recur($tab,$tab[$x],$rang+1);
|
||||||
print '</li>';
|
print '</li>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user