- Developper API  2.0.5
developerApi_2.0.5/VintageProperty.php
Go to the documentation of this file.
00001 <?php
00011 class VintageProperty
00012 {
00013         private $vincod;
00014         private $vintageyear;
00015         private $qrcode; 
00016         private $picture;
00017         private $vinogusto;
00018 
00019         private static $xmlNodesName = array(
00020                 "vintageyear",
00021                 "qrcode",
00022                 "dateupdate",
00023                 "picture",
00024                 "vinogusto"
00025         );
00035         public function __construct($vincod,$vintageyear,$qrcode,$picture,$vinogusto)
00036         {
00037                 $this->vincod = $vincod;
00038                 $this->vintageyear = $vintageyear;
00039                 $this->qrcode = $qrcode;
00040                 $this->picture = $picture;
00041                 $this->vinogusto = $vinogusto; 
00042         }
00043 
00048         public final function getVincod()
00049         {
00050                 return (!empty($this->vincod)) ? $this->vincod : false;
00051         }
00052 
00057         public final function getVintageYear()
00058         {
00059         return (!empty($this->vintageyear)) ? $this->vintageyear : false;
00060         }
00061 
00066         public final function getQRCode()
00067         {
00068         return (!empty($this->qrcode)) ? $this->qrcode : false;
00069         }
00070 
00075         public final function getPicture()
00076         {
00077         return (!empty($this->picture)) ? $this->picture : false;
00078         }
00079 
00084         public final function getVinogusto()
00085         {
00086         return (!empty($this->vinogusto)) ? $this->vinogusto : false;
00087         }
00088 
00094         public final static function getVintagePropertyFromSXMLElement($vincod,$node)
00095         {
00096                 if(!VintageProperty::isSXMLNodeProperty($node))
00097                 {
00098                         error("Vintage Property creation failed for element: ".$node->getName());
00099                         return false;
00100                 }                       
00101 
00102                 $vintageyear = $node->xpath("vintageyear");
00103                 if(count($vintageyear) > 0)
00104                         $vintageyear = (string) $vintageyear[0];
00105                 else
00106                         $vintageyear = "";
00107 
00108                 $qrcode = $node->xpath("qrcode");
00109                 if(count($qrcode) > 0)
00110                         $qrcode = (string) $qrcode[0];
00111                 else
00112                         $qrcode = "";
00113 
00114                 $picture = $node->xpath("picture");
00115                 if(count($picture) > 0)
00116                         $picture = (string) $picture[0];
00117                 else
00118                         $picture = "";
00119 
00120                 $vinogusto = $node->xpath("vinogusto");
00121                 if(count($vinogusto) > 0)
00122                         $vinogusto = (string) $vinogusto[0];
00123                 else
00124                         $vinogusto = "";
00125 
00126                 $property = new VintageProperty($vincod,$vintageyear,$qrcode,$picture,$vinogusto);
00127                 return $property;                       
00128         }
00129 
00135         public final static function isSXMLNodeProperty($node)
00136         {
00137                 if(!hasChildren($node))
00138                         return false;
00139                 else
00140                 {
00141                         foreach($node->children() as $child)
00142                         {
00143                                 $name = $child->getName();
00144 
00145                                 if( ! in_array($name,VintageProperty::$xmlNodesName) )
00146                                         return false;                           
00147                         }
00148 
00149                         return true;
00150                 }
00151         }
00152 }
00153 ?>