diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 28ac344f626..29d8f9307f5 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -112,9 +112,22 @@ $cate_arbo = $c->get_full_arbo(); if ($conf->use_javascript) { print '
| '.$langs->trans("CategoriesTree").' | |||
| '.$langs->trans("CategoriesTree").' | '; + print ''; + if ($_GET["expand"] != 'all') + { + print ''.$langs->trans("ExpandAll").''; + print ' | ';
+ }
+ if ($_GET["expand"] != 'none')
+ {
+ print ''.$langs->trans("UndoExpandAll").'';
+ print ' | ';
+ }
+ print ' | ';
+ print '
| '; + print ' | |||
| ';
if (sizeof($cate_arbo))
{
@@ -128,8 +141,12 @@ if ($conf->use_javascript)
// Création noeud racine
$node=array();
$rootnode='-1';
- $node[$rootnode] = new HTML_TreeNode(
- array('text' => $langs->trans("AllCats"), 'link' => '', 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true)
+ $node[$rootnode] = new HTML_TreeNode(array(
+ 'text' => $langs->trans("AllCats"),
+ 'link' => '',
+ 'icon' => $icon,
+ 'expandedIcon' => $expandedIcon,
+ 'expanded' => true)
//,array('onclick' => "alert('foo'); return false", 'onexpand' => "alert('Expanded')")
);
@@ -140,12 +157,31 @@ if ($conf->use_javascript)
$i++;
$nodeparent=ereg_replace('_[0-9]+$','',$cate_arbo[$key]['fullpath']);
if (! $nodeparent) $nodeparent=$rootnode;
- //print "Ajout noeud sur noeud ".$nodeparent.' pour categorie '.$cate_arbo[$key]['fulllabel']." \n"; - $node[$cate_arbo[$key]['fullpath']]=$node[$nodeparent]->addItem(new HTML_TreeNode(array( + + // Definition du nouvel element a ajouter dans l'arbre + $newelement=array( 'text' => $cate_arbo[$key]['label'], //'link' => $_SERVER["PHP_SELF"].'?id='.$cate_arbo[$key]['id'], 'link' => DOL_URL_ROOT.'/categories/viewcat.php?id='.$cate_arbo[$key]['id'], - 'icon' => $icon, 'expandedIcon' => $expandedIcon))); + 'icon' => $icon, + 'expandedIcon' => $expandedIcon + ); + + if ($_GET["expand"]) + { + $patharray=split('_',$cate_arbo[$key]['fullpath']); + $level=(sizeof($patharray)-1); + if ($_GET["expand"] == 'all' || $level <= $_GET["expand"]) { + $newelement['expanded']=true; + } + if ($_GET["expand"] == 'none') + { + $newelement['expanded']=false; + } +//print 'x'.$cate_arbo[$key]['fullpath'].' level='.$level.' expand='.$newelement['expanded'].' '; + } + + $node[$cate_arbo[$key]['fullpath']]=$node[$nodeparent]->addItem(new HTML_TreeNode($newelement)); //print 'Resultat: noeud '.$cate_arbo[$key]['fullpath']." créé \n"; } | |||