aggiunta funzione per caricare e mostrare LocalVideo

This commit is contained in:
Lorenzo Giacomelli
2017-02-21 13:26:28 +01:00
parent a62e0102ad
commit 69c4238e1e
5 changed files with 48 additions and 25 deletions
@@ -10,12 +10,11 @@ class MediaLocalVideo extends MediaRenderer{
public function asText(array $opt = array()){
$size = MediaRendererInterface::SIZE_ORIGINAL;
if(array_key_exists("size", $opt) && array_key_exists($opt["size"], self::$SIZES)){
$size = $opt["size"];
$size = self::$SIZES[$opt["size"]];
}
$video = $this->getLocalVideoLinkAndType();
return '<video width="300" height="300" controls >'.
'<source src="'.$video["path"].'" type="video/'.$video["extension"].'" >'.
return '<video width="'.$size["width"].'" height="'.$size["height"].'" controls >'.
'<source src="'.$this->getVideoLink($size).'" type="video/'.$this->getExtension().'" >'.
'</video>';
}
@@ -28,18 +27,16 @@ class MediaLocalVideo extends MediaRenderer{
return $basepath."/".$this->id.".".$this->extension;
}
public function getLocalVideoLinkAndType(){
$video = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$this->id));
if (!is_null($video)){
$basepath = GlobalVariables::get("config")->paths->media;
$videoPath= $basepath."/".$video->id.".".$video->extension;
$arr = array();
$arr["path"] = $videoPath;
$arr["extension"] = $video->extension;
return $arr;
public function getExtension(){
$video = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$this->id));
return $video->extension;
}
public function getVideoLink($size){
if(!array_key_exists($size, self::$SIZES)){
$size = MediaRendererInterface::SIZE_ORIGINAL;
}
return GUIHandler::getBaseUrl().'getLocalVideo.php?id='.$this->id.'&size='.$size;
}
}
+17 -2
View File
@@ -74,11 +74,11 @@ try{
throw new Exception("Invalid mediaType '".$mediaType."' while trying to add the media in addMultimedia");
}
// GUIHandler::redirectPost("admin/homeMultimedia.php",array("id"=>$notiziaId));
GUIHandler::redirectPost("admin/homeMultimedia.php",array("id"=>$notiziaId));
}
}
$formFile = '<span class="label">Selezionare un file</span><input type="hidden" name="MAX_FILE_SIZE" value="0" />
$formFile = '<span class="label">Selezionare un file</span><input type="hidden" name="MAX_FILE_SIZE" value="62914560" />
<input type="file" name="data"/>';
$formYoutube = '<span class="label">Link</span> <input type="text" name ="data"/>';
@@ -97,6 +97,8 @@ HTMLHelper::generateAdminHead();
?>
<div>
<?php echo $error;?>
<div class="errorShow" style="color:red;">
</div>
<div>
<form enctype="multipart/form-data" id="loadFile" method="POST">
<div style="margin:15px 5px;">
@@ -154,5 +156,18 @@ HTMLHelper::generateAdminHead();
$("form#loadFile").attr("action","homeMultimedia.php");
$("form#loadFile").submit();
});
$("input[name=data]").on("change",function(){
var fileSize = this.files[0].size/1024/1024;
if(fileSize > 60){
$("#submit").hide();
$(".errorShow").append("Dimesioni file non consentite. Max 60MB.")
}
else{
$("#submit").show();
$(".errorShow").html("");
}
});
});
</script>
+6
View File
@@ -77,6 +77,12 @@ HTMLHelper::generateAdminHead();
</ul>
Tale restizione &egrave; consigliata anche per i banner di tipo <i>HTML5</i>.
</p>
<h3>Contenuti Multimediali</h3>
<p style="text-align:justify;">
Caricare contenuti multimediali in proporzione 16:9.
La dimensione minima deve essere 500x375.
Non possono essere caricati file più grandi di <b>60MB</b>.
</p>
<?php } ?>
<?php if (AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_BANNER_SUPERVISOR)){ ?>
<p style="text-align:justify;">
+9 -4
View File
@@ -142,11 +142,16 @@ GUIHandler::generateHtmlHeaders(array("additionalMetadata"=>$additionalHeaders,"
if(sizeof($medias)>0){
$pos = array_search($media, $medias);
}
if($media->mediaType == MediaModel::TYPE_IMAGE){
?>
<div onclick="javascript:loadImage('<?php echo $pos;?>')">
<?php $media->renderMedia(array("size"=>MediaRenderer::SIZE_BIG,"clickable"=>true));?>
</div>
<?php
<div onclick="javascript:loadImage('<?php echo $pos;?>')">
<?php $media->renderMedia(array("size"=>MediaRenderer::SIZE_BIG,"clickable"=>true));?>
</div>
<?php }
else {
$media->renderMedia(array("size"=>MediaRenderer::SIZE_MEDIUM,"clickable"=>false));
}
}
?>
</div>
+4 -4
View File
@@ -13,11 +13,11 @@ if (array_key_exists("id",$_GET)) {
if (!is_null($video)){
$basepath = GlobalVariables::get("config")->paths->media;
$videoPath= $basepath."/".$video->id.".".$video->extension;
$lenght = filesize($videoPath);
$arr = array();
$arr["path"] = $videoPath;
$arr["extension"] = $video->extension;
return $arr;
header('Content-type: '.mime_content_type($videoPath));
header('Content-Lenght: '.$lenght);
readfile($videoPath);
}
}
?>