- <?
- /**
- * @package tree-node
- * @filesource
- * @see HTML_TREE_NODE_UTIL_PATH.'/Node.php'
- * @copyright (c) http://Finn-Rasmussen.com
- * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
- * @author http://Finn-Rasmussen.com
- * @version 1.9
- * @since 21-oct-2005
- */
-
- /**
- * The required files
- */
- require_once(HTML_PATH.'/Html.php');
-
- /**
- * The Node class
- * <code>
- * Usage:
- * $node = new Node($children);
- * print $node->getHtml();
- * Or
- * Node::display($children);
- * </code>
- * @package tree-node
- */
-
- class Node extends Html {
- /**
- * Constructor
- * @param object $children The children objects
- * @param String $key The key
- */
- function Node($children='',$key='') {
- $this->Html();
- if ($children!='') {
- if (is_object($children)) {
- $this->add($children);
- } else {
- if (is_array($children)) {
- foreach($children as $key=>$value) {
- $this->add(new Node($value,$key));
- }
- } else {
- $this->add(new Text("$key=$children"));
- }
- }
- }
- }
-
- /**
- * Get the html for the node and its children
- * @return String The html
- */
- function getHtml() {
- $html = '';
- $html .= $this->getElements(); // As html
- return $html;
- }
-
- /**
- * Display html
- * <code>
- * Usage:
- * Node::display($children);
- * </code>
- * @static
- * @param object $children The children objects
- * @param String $key The key
- */
- function display($children='',$key='') {
- $html = new Node($children,$key);
- $html->addHtml();
- }
- }
- ?>