00001 <?php 00008 #include <type.php> 00009 include_once('/media/SRV/zigmoyd/usr/lib/module/common/type.php'); 00010 00015 class zItem extends zCore{ 00022 var $type; 00029 var $data; 00036 var $link=null; 00043 var $parent=null; 00044 00051 function zItem($type){ 00052 $this->type = $type; 00053 } 00059 function hasParent(){ 00060 return is_null($this->parent); 00061 } 00067 function setParent(&$parentNode){ 00068 if(!ofPolymorphicType($parentNode, 'zItem')){ 00069 perror("<code>zigmoyd.common.zItem.setParent()</code><br />parentItem is not of zItem Class Type instead its a ".typeId($parentNode)." Type So It Cannot be linked with a zItem Object"); 00070 return false; 00071 } 00072 if(!(strtolower($this->getType()) == strtolower($nextElem->getType()))){ 00073 perror("<code>zigmoyd.common.zItem.setParent()</code><br />parentItem Node is not of same Type of this Item Node<br />Expecting ".$this->getType()." But getting ".$parentNode->getType()); 00074 return false; 00075 } 00076 $this->parent = $parentNode; 00077 return true; 00078 } 00084 function &getParent(){ 00085 return $this->parent; 00086 } 00093 function setData($val){ 00094 if(ofType($val, $this->type)){ 00095 $this->data = $val; 00096 return true; 00097 } 00098 perror("<code>zigmoyd.common.zItem.setData($val)</code><br />DataType Mismatch. Expecting value of Type $this->type But ".typeId($val)." Type value Given.<br />Not setting the Data in teh Data Block"); 00099 return false; 00100 } 00106 function getData(){ 00107 return $this->data; 00108 } 00114 function hasNext(){ 00115 return !is_null($this->link); 00116 } 00123 function setNext($nextElem){ 00124 if(!ofType($nextElem, 'zItem')){ 00125 perror("<code>zigmoyd.common.zItem.setNext()</code><br />nextItem is not of zItem Class Type instead its a ".typeId($nextElem)." Type So It Cannot be linked with a zItem Object"); 00126 return false; 00127 } 00128 if(strtolower($this->getType()) == strtolower($nextElem->getType())){ 00129 $nextElem->setParent($this); 00130 $this->link = $nextElem; 00131 return true; 00132 } 00133 perror("<code>zigmoyd.common.zItem.setNext()</code><br />nextItem Node is not of same Type of this Item Node<br />Expecting ".$this->getType()." But getting ".$nextElem->getType()); 00134 return false; 00135 } 00141 function &getNext(){ 00142 return $this->link; 00143 } 00148 function removeNext(){ 00149 unset($this->link); 00150 $this->link = null; 00151 } 00157 function getType(){ 00158 return $this->type; 00159 } 00166 function isDataValid($type){ 00167 return (typeId($this->data)==$type); 00168 } 00175 function isValid($type){ 00176 if($this->isDataValid($type)){ 00177 if($this->hasNext()){ 00178 return $this->isValid($this->type); 00179 } 00180 return true; 00181 } 00182 return false; 00183 } 00184 } 00186 ?>