Merge branch 'master' of ssh://gitolite@asdynamics.com:50005/projects/fdn2.git
This commit is contained in:
@@ -8,8 +8,20 @@ interface HasMediaInterface{
|
||||
*/
|
||||
public function getReference();
|
||||
|
||||
/**
|
||||
* Setta la referenza ai media
|
||||
* @param array $references
|
||||
*/
|
||||
public function setMediaReferences(array $references);
|
||||
|
||||
|
||||
/**
|
||||
* Ritorna un array contentente le referenze ai media
|
||||
* @return array
|
||||
*/
|
||||
public function getMediaReferences();
|
||||
|
||||
public function setMainMedia();
|
||||
|
||||
public function getMainMedia();
|
||||
}
|
||||
?>
|
||||
@@ -14,6 +14,10 @@ abstract class HasMediaModel extends Model implements HasMediaInterface{
|
||||
return $rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see HasMediaInterface::setMediaReferences()
|
||||
*/
|
||||
public function setMediaReferences(array $medias){
|
||||
$this->mediaReferences = array();
|
||||
if(sizeof($medias)>0){
|
||||
@@ -25,6 +29,10 @@ abstract class HasMediaModel extends Model implements HasMediaInterface{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see HasMediaInterface::getMediaReferences()
|
||||
*/
|
||||
public function getMediaReferences(){
|
||||
if(!property_exists($this, "mediaReferences")){
|
||||
$this->mediaReferences = array();
|
||||
|
||||
@@ -10,10 +10,10 @@ class MediaHandler{
|
||||
* Ritorna un array coi i media della news
|
||||
*/
|
||||
public static function getMedias(HasMediaModel $model,MediaModel $media){
|
||||
$newsReference = $model->getReference();
|
||||
$newsReference = $model->getMediaReferences();
|
||||
$rval = array();
|
||||
|
||||
$rval = $dao->query(MediaModel::COLLECTION_NAME,array($newsReference->id),array(),"MediaModel");
|
||||
$rval = $dao->query("MediaModel",array($newsReference["id"]),array());
|
||||
|
||||
return $rval;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,18 @@ class MediaModel extends Model implements MediaInterface{
|
||||
if ($this->type == self::TYPE_HTML5){
|
||||
$this->mediaRenderer = new MediaHtml5($this);
|
||||
}
|
||||
if ($this->type == self::TYPE_LOCALVIDEO){
|
||||
$this->mediaRenderer = new MediaLocalVideo($this);
|
||||
}
|
||||
if ($this->type == self::TYPE_IMAGE){
|
||||
$this->mediaRenderer = new MediaImage($this);
|
||||
}
|
||||
if ($this->type == self::TYPE_PDF){
|
||||
$this->mediaRenderer = new MediaPdf($this);
|
||||
}
|
||||
if ($this->type == self::TYPE_YOUTUBE){
|
||||
$this->mediaRenderer = new MediaYoutube($this);
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw new MediaException("Invalid media type for Media; mediatype '".$mediaType."'");
|
||||
|
||||
@@ -13,6 +13,10 @@ require_once(dirname(__FILE__)."/HasMediaInterface.php");
|
||||
require_once(dirname(__FILE__)."/HasMediaModel.php");
|
||||
require_once(dirname(__FILE__)."/MediaRendererInterface.php");
|
||||
require_once(dirname(__FILE__)."/mediaRenderers/MediaHtml5.php");
|
||||
require_once(dirname(__FILE__)."/mediaRenderers/MediaImage.php");
|
||||
require_once(dirname(__FILE__)."/mediaRenderers/MediaPdf.php");
|
||||
require_once(dirname(__FILE__)."/mediaRenderers/MediaLocalVideo.php");
|
||||
require_once(dirname(__FILE__)."/mediaRenderers/MediaYoutube.php");
|
||||
require_once(dirname(__FILE__)."/MediaHandler.php");
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
class MediaImage extends Media{
|
||||
private $path;
|
||||
|
||||
public function __construct($path){
|
||||
parent::__construct(self::TYPE_IMAGE);
|
||||
$this->path = $path;
|
||||
class MediaImage implements MediaRendererInterface{
|
||||
private $modelRef;
|
||||
|
||||
public function __construct(MediaModel $model){
|
||||
$this->modelRef = $model;
|
||||
}
|
||||
|
||||
public function asText(){
|
||||
echo $this->path;
|
||||
return $this->modelRef->path;
|
||||
}
|
||||
|
||||
public function render(){
|
||||
echo $this->asText();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1 +1,18 @@
|
||||
<?php
|
||||
|
||||
class MediaPdf implements MediaRendererInterface{
|
||||
private $modelRef;
|
||||
|
||||
public function __construct(MediaModel $model){
|
||||
$this->modelRef = $model;
|
||||
}
|
||||
|
||||
public function asText(){
|
||||
return $this->modelRef->path;
|
||||
}
|
||||
|
||||
public function render(){
|
||||
echo $this->asText();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,15 +1,18 @@
|
||||
<?php
|
||||
|
||||
class MediaYoutube extends Media{
|
||||
private $link;
|
||||
class MediaYoutube implements MediaRendererInterface{
|
||||
private $modelRef;
|
||||
|
||||
public function __construct($link){
|
||||
parent::__construct(self::TYPE_YOUTUBE);
|
||||
$this->link = $link;
|
||||
public function __construct(MediaModel $model){
|
||||
$this->modelRef = $model;
|
||||
}
|
||||
|
||||
public function asText(){
|
||||
return $this->modelRef->link;
|
||||
}
|
||||
|
||||
public function asText(){
|
||||
echo "iframe ".$this->link;
|
||||
public function render(){
|
||||
echo $this->asText();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user