JHTMLBehavior/tree
From Joomla! Documentation
< API15:JHTMLBehavior
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
tree($id, $params=array(), $root=array())
Parameter Name | Default Value | Description |
---|---|---|
$id | ||
$params | array() | |
$root | array() |
Defined in[edit]
libraries/joomla/html/html/behavior.php
Importing[edit]
jimport( 'joomla.html.html.behavior' );
Source Body[edit]
function tree($id, $params = array(), $root = array())
{
static $trees;
if (!isset($trees)) {
$trees = array();
}
// Include mootools framework
JHTMLBehavior::mootools();
JHTML::script('mootree.js');
JHTML::stylesheet('mootree.css');
if (isset($trees[$id]) && ($trees[$id])) {
return;
}
// Setup options object
$opt['div'] = (array_key_exists('div', $params)) ? $params['div'] : $id.'_tree';
$opt['mode'] = (array_key_exists('mode', $params)) ? $params['mode'] : 'folders';
$opt['grid'] = (array_key_exists('grid', $params)) ? '\\'.$params['grid'] : '\\true';
$opt['theme'] = (array_key_exists('theme', $params)) ? $params['theme'] : JURI::root(true).'/media/system/images/mootree.gif';
// Event handlers
$opt['onExpand'] = (array_key_exists('onExpand', $params)) ? '\\'.$params['onExpand'] : null;
$opt['onSelect'] = (array_key_exists('onSelect', $params)) ? '\\'.$params['onSelect'] : null;
$opt['onClick'] = (array_key_exists('onClick', $params)) ? '\\'.$params['onClick'] : '\\function(node){ window.open(node.data.url, $chk(node.data.target) ? node.data.target : \'_self\'); }';
$options = JHTMLBehavior::_getJSObject($opt);
// Setup root node
$rt['text'] = (array_key_exists('text', $root)) ? $root['text'] : 'Root';
$rt['id'] = (array_key_exists('id', $root)) ? $root['id'] : null;
$rt['color'] = (array_key_exists('color', $root)) ? $root['color'] : null;
$rt['open'] = (array_key_exists('open', $root)) ? '\\'.$root['open'] : '\\true';
$rt['icon'] = (array_key_exists('icon', $root)) ? $root['icon'] : null;
$rt['openicon'] = (array_key_exists('openicon', $root)) ? $root['openicon'] : null;
$rt['data'] = (array_key_exists('data', $root)) ? $root['data'] : null;
$rootNode = JHTMLBehavior::_getJSObject($rt);
$treeName = (array_key_exists('treeName', $params)) ? $params['treeName'] : '';
$js = ' window.addEvent(\'domready\', function(){
tree'.$treeName.' = new MooTreeControl('.$options.','.$rootNode.');
tree'.$treeName.'.adopt(\''.$id.'\');})';
// Attach tooltips to document
$document =& JFactory::getDocument();
$document->addScriptDeclaration($js);
// Set static array
$trees[$id] = true;
return;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]