API16:JHtmlBehavior/tree
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Contents |
Syntax
static tree($id, $params=array(), $root=array())
| Parameter Name | Default Value | Description |
|---|---|---|
| $id | ||
| $params | array() | |
| $root | array() |
Defined in
libraries/joomla/html/html/behavior.php
Importing
jimport( 'joomla.html.html.behavior' );
Source Body
public static function tree($id, $params = array(), $root = array()) { static $trees; if (!isset($trees)) { $trees = array(); } // Include mootools framework JHtml::_('behavior.framework'); JHTML::_('script','system/mootree.js', false, true); JHTML::_('stylesheet','system/mootree.css', array(), true); 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'] : JHTML::_('image','system/mootree.gif', '', array(), true, true); // 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
<CodeExamplesForm />
