- Developper API  2.0.5
developerApi_2.0.5/Shop.php
Go to the documentation of this file.
00001 <?php
00011 require_once("DataStructure.php");
00012 
00013 class Shop extends DataStructure
00014 {
00015         private static $xmlNodesName = array(
00016                 "name",
00017                 "url",
00018                 "description"
00019         );
00020 
00021         private $description;
00022 
00030         public function __construct($name,$description,$url)
00031         {
00032                 parent::__construct($name,"shop",$url);
00033                 $this->description = $description;
00034         }
00035     
00040         public final function getDescription()
00041         {
00042                 return (!empty($this->description)) ? $this->description : false;
00043         }
00044 
00050         public final static function getShopFromSXMLElement($node)
00051         {
00052                 if(!Shop::isSXMLNodeProperty($node))
00053                 {
00054                         error("Shop creation failed for element: ".$node->getName());
00055                         return false;
00056                 }                       
00057                 
00058                 $name = $node->xpath("name");           
00059                 if(count($name) > 0)
00060                         $name = (string) $name[0];
00061                 else
00062                         $name = "";
00063 
00064                 $url = $node->xpath("url");
00065                 if(count($url) > 0)
00066                         $url = (string) $url[0];
00067                 else
00068                         $url = "";
00069 
00070                 $description = $node->xpath("description");
00071                 if(count($description) > 0)
00072                         $description = (string) $description[0];
00073                 else
00074                         $description = "";
00075 
00076         
00077                 $shop = new Shop($name,$description,$url);
00078                 return $shop;                   
00079         }
00080 
00086         public final static function isSXMLNodeProperty($node)
00087         {
00088                 if(!hasChildren($node))
00089                         return false;
00090                 else
00091                 {
00092                         foreach($node->children() as $child)
00093                         {
00094                                 $name = $child->getName();
00095 
00096                                 if( ! in_array($name,Shop::$xmlNodesName) )
00097                                         return false;                           
00098                         }
00099 
00100                         return true;
00101                 }
00102         }
00103 }
00104 ?>