$array = array(
array('first element', null),
array('second element', array(
array('sub1', null),
array('sub2', null)
)),
array('third element', null)
) ;
* SLFramework_Treelist::render($array) ;
* if the array have 1 elements i.e. array('title element') the first element is the title (no children)
* if the array have 2 elements i.e. array('title element', "E45AF"), the second element will be considered as the id of the array
* if the array have 3 elements i.e. array('title element', "E45AF", null) the third element is the children (array or null)
* if the array have 4 elements i.e. array('title element', "E45AF", null, false), the fourth element will be considered as an indication whether the node is to be expanded or not (by default it is true)
*
* @param array $array list to display, each item of the list is an array : array('title', null) if the node is the last one in the tree or array(title, array(...)) if there is other son nodes.
* @param boolean $reduce_develop to enable the reduction and the expansion of the tree with javascript
* @param string $reorder_callback if you want to make the tree (nested list) sortable, please indicate what is the ajax callback function to be called upon sort. This function will receive the array in the $_POST['result'] variable. This function should return "OK". Otherwise, the return message will be 'alerted'
* @param string $classPerso a CSS custom class to customize the apparence of the tree
* @return void
*/
static function render($array, $reduce_develop=false, $reorder_callback=null, $classPerso=""){
$rand = rand(1, 10000000) ;
?>
" ;
SLFramework_Treelist::render_sub($array,$reduce_develop, false, $rand) ;
echo "" ;
if ($reorder_callback!=null) {
?>
" ;
foreach ($array as $item) {
$id = "" ;
$next_hide = false ;
$children = null ;
$plus_minus = "class='minus_folder'" ;
if (isset($item[1])) {
$id = " id='".$item[1]."' " ;
}
if (isset($item[2])) {
$children = $item[2] ;
}
if (isset($item[3])) {
if (!$item[3]) {
$next_hide=true ;
$plus_minus = "class='plus_folder'" ;
}
}
$toggle="" ;
if ($reduce_develop && ($children!=null)) {
$toggle = " onclick='folderToggle".$rand."(event, jQuery(this).find(\"ul:first\"));' ".$plus_minus." " ;
} else if ($reduce_develop) {
$toggle = " onclick='stopPropag".$rand."(event);' " ;
}
// We replace the link in the text by a stopPropag to avoid closing the hierarchy when clicking on links
if ($children!=null) {
$item[0] = str_replace(""."".$item[0]."
" ;
if ($children!=null) {
SLFramework_Treelist::render_sub($children, $reduce_develop, $next_hide, $rand) ;
} else {
echo "" ;
}
echo "" ;
}
echo "" ;
}
}
}
?>