- <?
- /**
- * @package tree-node
- * @filesource
- * @see HTML_TREE_NODE_VIEW_PATH.'/NodeView.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');
- require_once(HTML_BASE_UTIL_PATH.'/Link.php');
- require_once(HTML_BASE_UTIL_PATH.'/Images.php');
- if (defined('HTML_LANGUAGE_UTIL_PATH')) {
- require_once(HTML_LANGUAGE_UTIL_PATH.'/Translate.php');
- }
-
- /**
- * The NodeView class reflects a node with a link and an image
- * <code>
- * Usage:
- * $nodeview = new NodeView($text,$href,$image,$level);
- * print $nodeview->getHtml();
- * Or
- * NodeView::display($text,$href,$image,$level);
- * </code>
- * @package tree-node
- */
-
- class NodeView extends Html {
- /**
- * @var String $text The text for the node link
- */
- var $text = '';
-
- /**
- * @var String $href The href for the node link
- */
- var $href = '';
-
- /**
- * @var String $image The name for the node image
- */
- var $image = '';
-
- /**
- * @var int $level The level for the node
- */
- var $level = '';
-
- /**
- * Constructor
- * @param String $text The text for the node link
- * @param String $href The href for the node link
- * @param String $image The name for the node image
- * @param int $level The level for the node
- */
- function NodeView($text='',$href='',$image='',$level=0) {
- $this->Html();
- if (defined('HTML_LANGUAGE_UTIL_PATH')) {
- $this->text = ' '.ucfirst(Translate::get($text));
- } else {
- $this->text = ' '.ucfirst($text);
- }
- $this->href = $href;
- $this->image = $image;
- $this->level = $level;
- }
-
- /**
- * Get the html for the node
- * @return String The html
- */
- function getHtml() {
- $html = '';
- for ($i=1;$i<$this->level;$i++) {
- $html .= " ".($i>1?'.':'');
- $html .= " ";
- }
- $link = new Link($this->text,$this->href);
- $link->add(new Images($this->image));
- $html .= $link->getHtml()."<br />\r\n";
- return $html;
- }
-
- /**
- * Display html
- <code>
- * Usage:
- * NodeView::display($text,$href,$image,$level);
- * </code>
- * @static
- * @param String $text The text for the node link
- * @param String $href The href for the node link
- * @param String $image The name for the node image
- * @param int $level The level for the node
- */
- function display($text='',$href='',$image='',$level=0) {
- $html = new NodeView($text,$href,$image,$level);
- $html->addHtml();
- }
- }
- ?>