![]() |
- Developper API
2.0.5
|
00001 <?php 00010 require_once("DataObjectFactory.php"); 00011 require_once("AbstractDataObject.php"); 00012 require_once("Recipe.php"); 00013 require_once("Media.php"); 00014 require_once("Shop.php"); 00015 require_once("WEObject.php"); 00016 require_once("Review.php"); 00017 require_once("Property.php"); 00018 require_once("Variety.php"); 00019 require_once("VintageProperty.php"); 00020 require_once("Utils.php"); 00021 00022 class Wine extends AbstractDataObject 00023 { 00024 private $objects; 00025 00026 private static $properties = array( 00027 "id", 00028 "dateupdate", 00029 "vincod", 00030 "vincodperso", 00031 "abstract", 00032 "name", 00033 "vintageyear", 00034 "picture", 00035 "tag", 00036 "more", 00037 "winetype", 00038 "appellation", 00039 "advice", 00040 "presentation", 00041 "specifications" 00042 ); 00043 00052 public function __construct($id,$type,$xmlObject,$language) 00053 { 00054 parent::__construct($id,$type,$xmlObject,$language); 00055 $this->objects = array(); 00056 } 00057 00058 //Abstract Methods 00059 protected function isCustomProperties($propertyName) 00060 { 00061 return !(in_array($propertyName,Wine::$properties)); 00062 } 00063 00064 //Private Methods 00065 private function getTheValue ($value) 00066 { 00067 if ($val = $this->getTheValues ($value)) 00068 return $val[0]; 00069 return false; 00070 } 00071 00072 private function getTheValues ($value) 00073 { 00074 if(!array_key_exists($value,$this->objects)) 00075 { 00076 $this->objects[$value] = parent::getProperty($value); 00077 } 00078 00079 if(count($this->objects[$value]) > 0) 00080 { 00081 return $this->objects[$value]; 00082 } 00083 else 00084 return array(); 00085 } 00086 00087 //Class Methods 00092 public final function getDateUpdate(){return $this->getTheValue("dateupdate");} 00093 00098 public final function getVincod(){return $this->getTheValue("vincod");} 00099 00104 public final function getVincodPerso(){return $this->getTheValue("vincodperso");} 00105 00110 public final function getAbsoluteVincod() 00111 { 00112 $value = $this->getVincodPerso(); 00113 if($value) 00114 { 00115 $val = $value->getValue(); 00116 if(empty($val)) 00117 return $this->getVincod(); 00118 else 00119 return $value; 00120 } 00121 else 00122 return false; 00123 } 00124 00129 public final function getAbstract(){return $this->getTheValue("abstract");} 00130 00135 public final function getName(){return $this->getTheValue("name");} 00136 00141 public final function getVintageYear(){return $this->getTheValue("vintageyear");} 00142 00147 public final function getPicture(){return $this->getTheValue("picture");} 00148 00153 public final function getTag(){return $this->getTheValue("tag");} 00154 00159 public final function getMore(){return $this->getTheValue("more");} 00160 00165 public final function getWineType(){return $this->getTheValue("winetype");} 00166 00171 public final function getAppellation(){return $this->getTheValue("appellation");} 00172 00177 public final function getAdvice(){return $this->getTheValues("advice");} 00178 00183 public final function getPresentation(){return $this->getTheValues("presentation");} 00184 00189 public final function getSpecifications(){return $this->getTheValues("specifications");} 00190 00195 public final function isVintage(){return count($this->getVintageProperty) > 0;} 00196 00201 public final function getVintageProperty() 00202 { 00203 if(!array_key_exists("vintageProperty",$this->objects)) 00204 { 00205 $vintageArrayElements = getSXMLElementWithNameSpace($this->xmlObject,"vintage",true); 00206 $vintagePropertyArray = array(); 00207 foreach($vintageArrayElements as $vintageElement) 00208 { 00209 $vintageProperty = VintageProperty::getVintagePropertyFromSXMLElement($this->getAbsoluteVincod()->getValue(),$vintageElement); 00210 if($vintageProperty) 00211 { 00212 array_push 00213 ( 00214 $vintagePropertyArray, 00215 $vintageProperty 00216 ); 00217 } 00218 } 00219 00220 $this->objects["vintageProperty"] = $vintagePropertyArray; 00221 } 00222 00223 if(count($this->objects["vintageProperty"]) > 0) 00224 { 00225 $value = $this->objects["vintageProperty"]; 00226 return $value[0]; 00227 } 00228 else 00229 return false; 00230 } 00231 00236 public final function getReviews() 00237 { 00238 if(!array_key_exists("reviews",$this->objects)) 00239 { 00240 $reviewArrayElements = getSXMLElementWithNameSpace($this->xmlObject,"review",true); 00241 00242 $reviewPropertyArray = array(); 00243 foreach($reviewArrayElements as $reviewElement) 00244 { 00245 $review = Review::getReviewFromSXMLElement($reviewElement); 00246 if($review) 00247 { 00248 array_push 00249 ( 00250 $reviewPropertyArray, 00251 $review 00252 ); 00253 } 00254 } 00255 00256 $this->objects["reviews"] = $reviewPropertyArray; 00257 } 00258 00259 00260 if(count($this->objects["reviews"] ) > 0) 00261 { 00262 return $this->objects["reviews"]; 00263 } 00264 else 00265 return array(); 00266 } 00267 00272 public final function getGrapesVarieties() 00273 { 00274 if(!array_key_exists("grapesvarieties",$this->objects)) 00275 { 00276 $varietiesArrayElements = getSXMLElementWithNameSpace($this->xmlObject,"variety",true); 00277 00278 $varietiesPropertyArray = array(); 00279 foreach($varietiesArrayElements as $varietyElement) 00280 { 00281 $variety = Variety::getVarietyFromSXMLElement($varietyElement); 00282 if($variety) 00283 { 00284 array_push 00285 ( 00286 $varietiesPropertyArray, 00287 $variety 00288 ); 00289 } 00290 } 00291 00292 $this->objects["grapesvarieties"] = $varietiesPropertyArray; 00293 } 00294 00295 00296 if(count($this->objects["grapesvarieties"] ) > 0) 00297 { 00298 return $this->objects["grapesvarieties"]; 00299 } 00300 else 00301 return array(); 00302 } 00303 00308 public final function getMedias() 00309 { 00310 if(!array_key_exists("medias",$this->objects)) 00311 { 00312 $mediaArrayElements = getSXMLElementWithNameSpace($this->xmlObject,"media",true); 00313 00314 $mediaPropertyArray = array(); 00315 foreach($mediaArrayElements as $mediaElement) 00316 { 00317 $media = Media::getMediaFromSXMLElement($mediaElement); 00318 if($media) 00319 { 00320 array_push 00321 ( 00322 $mediaPropertyArray, 00323 $media 00324 ); 00325 } 00326 } 00327 00328 $this->objects["medias"] = $mediaPropertyArray; 00329 } 00330 00331 00332 if(count($this->objects["medias"] ) > 0) 00333 { 00334 return $this->objects["medias"]; 00335 } 00336 else 00337 return array(); 00338 } 00339 00344 public final function getRecipes() 00345 { 00346 if(!array_key_exists("recipes",$this->objects)) 00347 { 00348 $recipeArrayElements = getSXMLElementWithNameSpace($this->xmlObject,"recipe",true); 00349 00350 $recipePropertyArray = array(); 00351 foreach($recipeArrayElements as $recipeElement) 00352 { 00353 $recipe = Recipe::getRecipeFromSXMLElement($recipeElement); 00354 if($recipe) 00355 { 00356 array_push 00357 ( 00358 $recipePropertyArray, 00359 $recipe 00360 ); 00361 } 00362 } 00363 00364 $this->objects["recipes"] = $recipePropertyArray; 00365 } 00366 00367 00368 if(count($this->objects["recipes"] ) > 0) 00369 { 00370 return $this->objects["recipes"]; 00371 } 00372 else 00373 return array(); 00374 } 00375 00380 public final function getShops() 00381 { 00382 if(!array_key_exists("shops",$this->objects)) 00383 { 00384 $shopArrayElements = getSXMLElementWithNameSpace($this->xmlObject,"shop",true); 00385 00386 $shopPropertyArray = array(); 00387 foreach($shopArrayElements as $shopElement) 00388 { 00389 $shop = Shop::getShopFromSXMLElement($shopElement); 00390 if($shop) 00391 { 00392 array_push 00393 ( 00394 $shopPropertyArray, 00395 $shop 00396 ); 00397 } 00398 } 00399 00400 $this->objects["shops"] = $shopPropertyArray; 00401 } 00402 00403 00404 if(count($this->objects["shops"] ) > 0) 00405 { 00406 return $this->objects["shops"]; 00407 } 00408 else 00409 return array(); 00410 } 00411 00416 public final function getWES() 00417 { 00418 if(!array_key_exists("weobjects",$this->objects)) 00419 { 00420 $weArrayElements = getSXMLElementWithNameSpace($this->xmlObject,"we",true); 00421 00422 $wePropertyArray = array(); 00423 foreach($weArrayElements as $weElement) 00424 { 00425 $we = WEObject::getWEObjectFromSXMLElement($weElement); 00426 if($we) 00427 { 00428 array_push 00429 ( 00430 $wePropertyArray, 00431 $we 00432 ); 00433 } 00434 } 00435 00436 $this->objects["weobjects"] = $wePropertyArray; 00437 } 00438 00439 00440 if(count($this->objects["weobjects"] ) > 0) 00441 { 00442 return $this->objects["weobjects"]; 00443 } 00444 else 00445 return array(); 00446 } 00447 00452 public final function getOwner() 00453 { 00454 $vincod = $this->getAbsoluteVincod(); 00455 if($vincod) 00456 return DataObjectFactory::getOwnerByVincod($vincod->getValue(),$this->getLanguage()); 00457 00458 return false; 00459 } 00460 00465 public final function getWinery() 00466 { 00467 $vincod = $this->getAbsoluteVincod(); 00468 if($vincod) 00469 return DataObjectFactory::getWineryByVincod($vincod->getValue(),$this->getLanguage()); 00470 00471 return false; 00472 } 00473 00478 public final function getRange() 00479 { 00480 $vincod = $this->getAbsoluteVincod(); 00481 if($vincod) 00482 return DataObjectFactory::getRangeByVincod($vincod->getValue(),$this->getLanguage()); 00483 00484 return false; 00485 } 00486 00491 public final function getOtherVintages() 00492 { 00493 $vincod = $this->getAbsoluteVincod(); 00494 if($vincod) 00495 return DataObjectFactory::getOtherVintagesByVincod($vincod->getValue(),$this->getLanguage()); 00496 00497 return array(); 00498 } 00499 00504 public final function getOtherLanguage($lang) 00505 { 00506 00507 $vincod = $this->getAbsoluteVincod(); 00508 if($vincod) 00509 return DataObjectFactory::getOtherLanguagesByVincod($vincod->getValue(),$lang); 00510 00511 return false; 00512 } 00513 00518 public final function getAvailableLanguages() 00519 { 00520 $vincod = $this->getAbsoluteVincod(); 00521 if($vincod) 00522 return DataObjectFactory::getAvailableLanguagesByVincod($vincod->getValue()); 00523 00524 return array(); 00525 } 00526 00527 } 00528 ?>