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

Source for file NodeView.php

Documentation is available at NodeView.php

  1. <?
  2. /**
  3. * @package tree-node
  4. * @filesource
  5. * @see HTML_TREE_NODE_VIEW_PATH.'/NodeView.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. require_once(HTML_BASE_UTIL_PATH.'/Link.php');
  18. require_once(HTML_BASE_UTIL_PATH.'/Images.php');
  19. if (defined('HTML_LANGUAGE_UTIL_PATH')) {
  20. require_once(HTML_LANGUAGE_UTIL_PATH.'/Translate.php');
  21. }
  22.  
  23. /**
  24. * The NodeView class reflects a node with a link and an image
  25. * <code>
  26. * Usage:
  27. * $nodeview = new NodeView($text,$href,$image,$level);
  28. * print $nodeview->getHtml();
  29. * Or
  30. * NodeView::display($text,$href,$image,$level);
  31. * </code>
  32. * @package tree-node
  33. */
  34.  
  35. class NodeView extends Html {
  36. /**
  37. * @var String $text The text for the node link
  38. */
  39. var $text = '';
  40.  
  41. /**
  42. * @var String $href The href for the node link
  43. */
  44. var $href = '';
  45.  
  46. /**
  47. * @var String $image The name for the node image
  48. */
  49. var $image = '';
  50.  
  51. /**
  52. * @var int $level The level for the node
  53. */
  54. var $level = '';
  55.  
  56. /**
  57. * Constructor
  58. * @param String $text The text for the node link
  59. * @param String $href The href for the node link
  60. * @param String $image The name for the node image
  61. * @param int $level The level for the node
  62. */
  63. function NodeView($text='',$href='',$image='',$level=0) {
  64. $this->Html();
  65. if (defined('HTML_LANGUAGE_UTIL_PATH')) {
  66. $this->text = '&nbsp;'.ucfirst(Translate::get($text));
  67. } else {
  68. $this->text = '&nbsp;'.ucfirst($text);
  69. }
  70. $this->href = $href;
  71. $this->image = $image;
  72. $this->level = $level;
  73. }
  74.  
  75. /**
  76. * Get the html for the node
  77. * @return String The html
  78. */
  79. function getHtml() {
  80. $html = '';
  81. for ($i=1;$i<$this->level;$i++) {
  82. $html .= "&nbsp;".($i>1?'.':'');
  83. $html .= "&nbsp;&nbsp;";
  84. }
  85. $link = new Link($this->text,$this->href);
  86. $link->add(new Images($this->image));
  87. $html .= $link->getHtml()."<br />\r\n";
  88. return $html;
  89. }
  90.  
  91. /**
  92. * Display html
  93. <code>
  94. * Usage:
  95. * NodeView::display($text,$href,$image,$level);
  96. * </code>
  97. * @static
  98. * @param String $text The text for the node link
  99. * @param String $href The href for the node link
  100. * @param String $image The name for the node image
  101. * @param int $level The level for the node
  102. */
  103. function display($text='',$href='',$image='',$level=0) {
  104. $html = new NodeView($text,$href,$image,$level);
  105. $html->addHtml();
  106. }
  107. }
  108. ?>

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