phpDocumentor tree-node
[ class tree: tree-node ] [ index: tree-node ] [ all elements ]

Source for file Node.php

Documentation is available at Node.php

  1. <?
  2. /**
  3. * @package tree-node
  4. * @filesource
  5. * @see HTML_TREE_NODE_UTIL_PATH.'/Node.php'
  6. * @copyright (c) http://Finn-Rasmussen.com
  7. * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
  8. * @author http://Finn-Rasmussen.com
  9. * @version 1.9
  10. * @since 21-oct-2005
  11. */
  12.  
  13. /**
  14. * The required files
  15. */
  16. require_once(HTML_PATH.'/Html.php');
  17.  
  18. /**
  19. * The Node class
  20. * <code>
  21. * Usage:
  22. * $node = new Node($children);
  23. * print $node->getHtml();
  24. * Or
  25. * Node::display($children);
  26. * </code>
  27. * @package tree-node
  28. */
  29.  
  30. class Node extends Html {
  31. /**
  32. * Constructor
  33. * @param object $children The children objects
  34. * @param String $key The key
  35. */
  36. function Node($children='',$key='') {
  37. $this->Html();
  38. if ($children!='') {
  39. if (is_object($children)) {
  40. $this->add($children);
  41. } else {
  42. if (is_array($children)) {
  43. foreach($children as $key=>$value) {
  44. $this->add(new Node($value,$key));
  45. }
  46. } else {
  47. $this->add(new Text("$key=$children"));
  48. }
  49. }
  50. }
  51. }
  52.  
  53. /**
  54. * Get the html for the node and its children
  55. * @return String The html
  56. */
  57. function getHtml() {
  58. $html = '';
  59. $html .= $this->getElements(); // As html
  60. return $html;
  61. }
  62.  
  63. /**
  64. * Display html
  65. * <code>
  66. * Usage:
  67. * Node::display($children);
  68. * </code>
  69. * @static
  70. * @param object $children The children objects
  71. * @param String $key The key
  72. */
  73. function display($children='',$key='') {
  74. $html = new Node($children,$key);
  75. $html->addHtml();
  76. }
  77. }
  78. ?>

Documentation generated on Thu, 22 Dec 2005 17:14:41 +0100 by phpDocumentor 1.3.0RC3