array("label"=>"Youtube"), self::TYPE_IMAGE=>array("label"=>"Image"), self::TYPE_HTML5=>array("label"=>"Html5"), self::TYPE_PDF=>array("label"=>"Pdf"), self::TYPE_LOCALVIDEO=>array("label"=>"Local Video") ); private $mediaRenderer; public function __construct($saveableObject = null){ parent::__construct($saveableObject); if($this->hasProperty("mediaType")){ if ($this->mediaType == self::TYPE_HTML5){ $this->mediaRenderer = new MediaHtml5($this); } if ($this->mediaType == self::TYPE_LOCALVIDEO){ $this->mediaRenderer = new MediaLocalVideo($this); } if ($this->mediaType == self::TYPE_IMAGE){ $this->mediaRenderer = new MediaImage($this); } if ($this->mediaType == self::TYPE_PDF){ $this->mediaRenderer = new MediaPdf($this); } if ($this->mediaType == self::TYPE_YOUTUBE){ $this->mediaRenderer = new MediaYoutube($this); } } else{ throw new MediaException("Missing mediatype for Media in MediaModel construct"); } } public function asText(){ return $this->mediaRenderer->asText(); } public function renderMedia(){ $this->mediaRenderer->render(); } public function getType(){ return $this->mediaType; } public function getTitle(){ return $this->details; } public static function getCollectionName(){ return "media"; } public function setOwnerReference(HasMediaInterface $model){ $this->owner = $model->getReference(); } public function getOwnerReference(){ return $this->owner; } public function getReference(){ return $this->id; } } ?>