Class HTML_TreeMenu

Description

HTML_TreeMenu Class

A simple couple of PHP classes and some not so simple Jabbascript which produces a tree menu. In IE this menu is dynamic, with branches being collapsable. In IE5+ the status of the collapsed/open branches persists across page refreshes.In any other browser the tree is static. Code is based on work of Harald Radi.

Usage.

After installing the package, copy the example php script to your servers document root. Also place the TreeMenu.js and the images folder in the same place. Running the script should then produce the tree.

Thanks go to Chip Chapin (http://www.chipchapin.com) for many excellent ideas and improvements.

Located in /include/TreeMenu.php (line 64)


	
			
Direct descendents
Class Description
HTML_IgepArbol HTML_IgepTreeMenu Class
Variable Summary
array $items
Method Summary
HTML_TreeMenu HTML_TreeMenu ()
object Returns &addItem ( &$node, object $node)
object The createFromStructure (array $params)
object The createFromXML (mixed $xml)
Variables
array $items (line 70)

Indexed array of subnodes

Methods
Constructor HTML_TreeMenu (line 77)

Constructor

  • access: public
HTML_TreeMenu HTML_TreeMenu ()
addItem (line 91)

This function adds an item to the the tree.

  • return: a reference to the new node inside the tree.
  • access: public
object Returns &addItem ( &$node, object $node)
  • object $node: The node to add. This object should be a HTML_TreeNode object.
  • &$node
createFromStructure (line 114)

Import method for creating HTML_TreeMenu objects/structures

out of existing tree objects/structures. Currently supported are Wolfram Kriesings' PEAR Tree class, and Richard Heyes' (me!) Tree class (available here: http://www.phpguru.org/). This method is intended to be used statically, eg: $treeMenu = &HTML_TreeMenu::createFromStructure($myTreeStructureObj);

  • return: resulting HTML_TreeMenu object
object The createFromStructure (array $params)
  • array $params: An array of parameters that determine how the import happens. This can consist of: structure => The tree structure type => The type of the structure, currently can be either 'heyes' or 'kriesing' nodeOptions => Default options for each node
createFromXML (line 261)

Creates a treeMenu from XML. The structure of your XML should be like so:

<treemenu> <node text="First node" icon="folder.gif" expandedIcon="folder-expanded.gif" /> <node text="Second node" icon="folder.gif" expandedIcon="folder-expanded.gif"> <node text="Sub node" icon="folder.gif" expandedIcon="folder-expanded.gif" /> </node> <node text="Third node" icon="folder.gif" expandedIcon="folder-expanded.gif"> </treemenu>

Any of the options you can supply to the HTML_TreeNode constructor can be supplied as attributes to the <node> tag. If there are no subnodes for a particular node, you can use the XML shortcut <node ... /> instead of <node ... ></node>. The $xml argument can be either the XML as a string, or an pre-created XML_Tree object. Also, this method REQUIRES my own Tree class to work (http://phpguru.org/tree.html). If this has not been include()ed or require()ed this method will die().

  • return: HTML_TreeMenu object
object The createFromXML (mixed $xml)
  • mixed $xml: This can be either a string containing the XML, or an XML_Tree object (the PEAR::XML_Tree package).

Documentation generated on Wed, 05 Oct 2011 10:36:47 +0200 by phpDocumentor 1.4.1