_childs[1] = $p_first; if(is_subclass_of($p_second,"Icon") || is_a($p_second,"Icon") || is_subclass_of($p_second,"Input") || is_a($p_second,"Input")) $this->_childs[0]=$p_second; } else if(is_subclass_of($p_first,"Icon") || is_a($p_first,"Icon") || is_subclass_of($p_first,"Input") || is_a($p_first,"Input")) { $this->_childs[0] = $p_first; if(is_string($p_second)) $this->_childs[1] = $p_second; } } public function setIcon($p_icon) { if(is_subclass_of($p_icon,"Icon") || is_a($p_icon,"Icon")) { $this->_childs[0] = $p_icon; } } public function setText($p_text) { if(is_string($p_text)) { $this->_childs[1] = $p_text; } } public function active($p_on=false) { $this->active = $p_on; } public function __toString() { $ret = ''; if(array_key_exists(0,$this->_childs)) { $ret.= ''; } if(array_key_exists(1,$this->_childs)) { $ret.= ''; } $ret.= '
'.$this->_childs[0]->__toString().'_eventListeners as $eventListener) { $ret.= $eventListener->__toString(); } $ret.= '>'.$this->_childs[1].'
'; return str_replace("\n", "", $ret); } public function addEventListener($p_listener) { if(is_subclass_of($p_listener,"EventListener") || is_a($p_listener,"EventListener")) { $this->_eventListeners[$p_listener->event()] = $p_listener; } } } /* * CLASS Icon */ class Icon { private $_src = null; private $_eventListeners = array(); public function __construct($p_src) { if(is_string($p_src)) { $this->_src = $p_src; } } public function __toString() { $ret = '_eventListeners as $eventListener) { $ret .= $eventListener->__toString(); } $ret .= ' src="'.$this->_src.'">'; return $ret; } public function addEventListener($p_listener) { if(is_subclass_of($p_listener,"EventListener") || is_a($p_listener,"EventListener")) { array_push($this->_eventListeners,$p_listener); } } } /* * CLASS Input */ class Input { private $_ID = null; private $_name = null; private $_class= null; private $_type; private $_value; private $_eventListeners = array(); public function __construct($p_id,$p_name,$p_class,$p_type,$p_value = null,$p_selected = false) { $this->_ID = $p_id; $this->_name = $p_name; $this->_class = $p_class; $this->_type = $p_type; $this->_value = $p_value; $this->_selected = $p_selected; } public function addEventListener($p_listener) { if(is_subclass_of($p_listener,"EventListener") || is_a($p_listener,"EventListener")) { $this->_eventListeners[$p_listener->event()] = $p_listener; } } public function getEventListeners() { return $this->_eventListeners; } public function __toString() { $ret = "_ID))$ret.= " id='".$this->_ID."'"; if(!empty($this->_name))$ret.= " name='".$this->_name."'"; if(!empty($this->_class))$ret.= " class='".$this->_class."'"; if(!empty($this->_type))$ret.= " type='".$this->_type."'"; if(!empty($this->_value))$ret.= " value='".$this->_value."'"; if($this->_selected && $this->_type == "radio") $ret.= " checked='checked'"; foreach($this->_eventListeners as $event => $eventListener) { $ret.= ' '.$eventListener->__toString(); } $ret.= ">"; return $ret; } } /* * CLASS Tree */ class Tree { private $_ID = null; private $_renderer = null; private $_childs = null; private $_eventListeners = null; public function __construct($p_id) { $this->_ID = $p_id; $this->_childs = array(); $this->_renderer = new TreeRenderer(); } public function getID() { return $this->_ID; } public function appendChild($p_node) { if(is_subclass_of($p_node,"TreeNode") || is_a($p_node,"TreeNode")) { array_push($this->_childs, $p_node); } } public function __toString() { return $this->_renderer->_toString($this); } public function hasChildNodes() { if(count($this->_childs) > 0) return true; else return false; } public function getChildNodes() { return $this->_childs; } public function addEventListener($p_listener) { if(is_subclass_of($p_listener,"EventListener") || is_a($p_listener,"EventListener")) { array_push($this->_eventListeners,$p_listener); } } public function getEventListeners() { return $this->_eventListeners; } } class TreeRenderer { public function __construct() {} public function _toString($p_tree) { $ret = '
'; $ret.= '
 
'; if($p_tree->hasChildNodes()) { $childNodes = $p_tree->getChildNodes(); foreach($childNodes as $childNode) { $ret.= $childNode->__toString(); $ret.= '
 
'; } } $ret.= '
'; return $ret; } } class TreeNode { private $_renderer = null; private $_ID = null; private $_value = null; private $_childs = null; private $_eventListeners = null; private $_contextMenu=null; public function __construct() { $this->_renderer = new TreeNodeRenderer(); $this->_childs = array(); $this->_eventListeners = array(); $argsArr = func_get_args(); if(count($argsArr)>0) { foreach($argsArr as $arg) { if(is_string($arg)) $this->_ID = $arg; else $this->_value[] = $arg; } } else { $this->_value[] = new Label("no value"); } } public function appendChild($p_node) { if(is_subclass_of($p_node,"TreeNode") || is_a($p_node,"TreeNode")) { array_push($this->_childs, $p_node); } } public function __toString() { $ret = $this->_renderer->_toString($this); return $ret; } public function setRenderer($p_renderer) { if(is_subclass_of($p_listener,"TreeNodeRenderer") || is_a($p_listener,"TreeNodeRenderer")) { $this->_renderer = $p_renderer; } } public function hasChildNodes() { if(count($this->_childs) > 0) return true; else return false; } public function getID() { return $this->_ID; } public function getValue() { return $this->_value; } public function getChildNodes() { return $this->_childs; } public function addEventListener($p_listener) { if(is_subclass_of($p_listener,"EventListener") || is_a($p_listener,"EventListener")) { $this->_eventListeners[$p_listener->event()] = $p_listener; } } public function getEventListeners() { return $this->_eventListeners; } public function addContextMenu($p_menu) { if(is_subclass_of($p_menu,"ContextMenu") || is_a($p_menu,"ContextMenu")) { $this->_contextMenu = $p_menu; } } public function getContextMenu() { return $this->_contextMenu; } } class TreeNodeRenderer { public function __constructor() {} public function _toString($p_node) { $value = $p_node->getValue(); $eventListeners = $p_node->getEventListeners(); $contextMenu = $p_node->getContextMenu(); if($p_node->hasChildNodes()) $ret = '
'; $ret.= '
'; $ret.='
$eventListener) { if($event == "onmousedown") { $onmousedown = $eventListener->action(); } elseif($event == "ronmousedown") { $ronmousedown = $eventListener->action(); } else { $ret.= ' '.$eventListener->__toString(); } } if($contextMenu != null) { $ret.=" onmousedown='Tree.select(event,this);if(Mouse.checkRClick(event)) { ContextMenu.show(this,event);".$ronmousedown." } else { ".$onmousedown.";};'"; } else { $ret.=" onmousedown='Tree.select(event,this);return ".$onmousedown."'"; } $ret.='> 
'; if($p_node->hasChildNodes()) { $ret.= ""; } else { $ret.= ""; } $ret.= ' $eventListener) { if($event == "onclick") { $ret.= " href='javascript:' ".$eventListener->__toString(); }elseif($event != "onmousedown" && $event != "ronmousedown"){ $ret.= ' '.$eventListener->__toString(); } } if($contextMenu != null) { $ret.=" onmousedown='Tree.select(event,this);(Mouse.checkRClick(event)) ? ".$ronmousedown." : false; return (Mouse.checkRClick(event)) ? ContextMenu.show(this,event) : ".$onmousedown.";'"; } else { $ret.=" onmousedown='Tree.select(event,this);return ".$onmousedown.";'"; } $ret.= '>'; foreach($value as $valueItem) { $ret.= $valueItem->__toString(); } $ret.=''; $ret.='
'; $ret.='
'; if($p_node->hasChildNodes()) { $ret.= '
 
'; $childs = $p_node->getChildNodes(); foreach($childs as $child) { $ret.= $child->__toString(); $ret.= '
 
'; } } $ret.='
'; $ret.='
'; if($contextMenu != null) { $ret.= $contextMenu->__toString(); } $ret.= '
'; $ret.= '
'; return $ret; } } class EventListener { private $_event; private $_action; public function __construct($p_event,$p_action) { $this->_event = $p_event; $this->_action = $p_action; } public function __toString() { return $this->_event."='".$this->_action."'"; } public function event($p_eventType=null) { return $this->_event; } public function action($p_action=null) { return $this->_action; } } class ContextMenu { private $_renderer = null; private $_childs = null; private $_eventListeners = null; public function __construct() { $this->_childs = array(); $this->_renderer = new ContextMenuRenderer(); } public function appendChild($p_node) { if(is_subclass_of($p_node,"ContextMenuNode") || is_a($p_node,"ContextMenuNode")) { array_push($this->_childs, $p_node); } } public function __toString() { return $this->_renderer->_toString($this); } public function hasChildNodes() { if(count($this->_childs) > 0) return true; else return false; } public function getChildNodes() { return $this->_childs; } public function addEventListener($p_listener) { if(is_subclass_of($p_listener,"EventListener") || is_a($p_listener,"EventListener")) { array_push($this->_eventListeners,$p_listener); } } public function getEventListeners() { return $this->_eventListeners; } } class ContextMenuRenderer { public function __construct() {} public function _toString($p_menu) { $ret = '
'; $ret.= '
 
'; if($p_menu->hasChildNodes()) { $childNodes = $p_menu->getChildNodes(); foreach($childNodes as $childNode) { $ret.= $childNode->__toString(); $ret.= '
 
'; } } $ret.= '
'; return $ret; } } class ContextMenuNode { private $_renderer = null; private $_value = null; private $_childs = null; private $_eventListeners = null; public function __construct($p_value = null) { $this->_renderer = new ContextMenuNodeRenderer(); $this->_childs = array(); $this->_eventListeners = array(); if(!empty($p_value)) { $this->_value = $p_value; } else { $this->_value = new Label("undefined value"); } } public function appendChild($p_node) { if(is_subclass_of($p_node,"ContextMenuNode") || is_a($p_node,"ContextMenuNode")) { array_push($this->_childs, $p_node); } } public function __toString() { $ret = $this->_renderer->_toString($this); return $ret; } public function setRenderer($p_renderer) { if(is_subclass_of($p_listener,"ContextMenuNodeRenderer") || is_a($p_listener,"ContextMenuNodeRenderer")) { $this->_renderer = $p_renderer; } } public function hasChildNodes() { if(count($this->_childs) > 0) return true; else return false; } public function getValue() { return $this->_value; } public function getChildNodes() { return $this->_childs; } public function addEventListener($p_listener) { if(is_subclass_of($p_listener,"EventListener") || is_a($p_listener,"EventListener")) { array_push($this->_eventListeners,$p_listener); } } public function getEventListeners() { return $this->_eventListeners; } } class ContextMenuNodeRenderer { public function __constructor() {} public function _toString($p_node) { $value = $p_node->getValue(); $eventListeners = $p_node->getEventListeners(); $ret = '
'; $ret.= '
'; $ret.= '
__toString(); } $ret.= '> 
'; $ret.= 'event() == "onclick") { $ret.= " href='javascript:' onclick='".$eventListener->action()."'"; }else{ $ret.= ' '.$eventListener->__toString(); } } $ret.= '>'; $ret.= $value->__toString(); $ret.=''; $ret.='
'; $ret.='
'; if($p_node->hasChildNodes()) { $childs = $p_node->getChildNodes(); foreach($childs as $child) { $ret.= $child->__toString(); } } $ret.='
'; $ret.= '
'; return $ret; } } ?>