Creati nuovi banner lunghi Aumentate numero notizie ansa Aumentate numero notizie cronaca in homepage fix mobile articolo per show player video modifica amministrazione per show player mobile
174 lines
5.4 KiB
PHP
174 lines
5.4 KiB
PHP
<?php
|
|
|
|
require_once(dirname(__FILE__)."/../load.php");
|
|
|
|
GUIHandler::generateHtmlHeaders(array(),true);
|
|
|
|
if (!AdminLoginManager::isLogged()){
|
|
GUIHandler::redirect("admin/login.php");
|
|
}
|
|
else if (!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE_SUPERVISOR) &&
|
|
!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE)){
|
|
GUIHandler::redirect("admin/index.php");
|
|
}
|
|
|
|
try{
|
|
$error = "";
|
|
$notiziaId = PostHandler::get("id");
|
|
|
|
$notizia = new NotiziaModel();
|
|
$medias = array();
|
|
// var_dump($notizia);
|
|
if(!is_null($notiziaId) && strcmp($notiziaId, "")!=0){
|
|
$notizia = GlobalVariables::get("dao")->getFirst("NotiziaModel",array('id'=>$notiziaId));
|
|
$medias = GlobalVariables::get("dao")->query("MediaModel",array('owner.id'=>$notiziaId));
|
|
|
|
if(array_key_exists("remove", $_POST)){
|
|
$idsString = PostHandler::get("remove");
|
|
$idsArr = explode("\n", $idsString);
|
|
|
|
$ids = array();
|
|
if(sizeof($idsArr)>0){
|
|
foreach ($idsArr as $id){
|
|
$id = trim($id);
|
|
if(strcmp($id, "")!=0){
|
|
$ids[] = $id;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(sizeof($ids)>0){
|
|
|
|
// $notiziaModel = GlobalVariables::get("dao")->getFirst("NotiziaModel", array("id"=>$notiziaId));
|
|
foreach ($ids as $id){
|
|
$media = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$id));
|
|
DaoMediaHandler::deleteMedia($notizia, $media);
|
|
}
|
|
}
|
|
GUIHandler::redirectPost("admin/homeMultimedia.php",array("id"=>$notiziaId));
|
|
}
|
|
|
|
if(array_key_exists("setMain", $_POST)){
|
|
$id = PostHandler::get("setMain");
|
|
$id = trim($id);
|
|
$mediaMain = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$id));
|
|
|
|
DaoMediaHandler::setMainMediaToModel($notizia, $mediaMain);
|
|
GUIHandler::redirectPost("admin/homeMultimedia.php",array("id"=>$notiziaId));
|
|
}
|
|
|
|
if(array_key_exists("rmMain", $_POST) && strcmp(PostHandler::get("rmMain"), "true")==0){
|
|
|
|
DaoMediaHandler::setMainMediaToModel($notizia,null);
|
|
GUIHandler::redirectPost("admin/homeMultimedia.php",array("id"=>$notiziaId));
|
|
}
|
|
}
|
|
else{
|
|
GUIHandler::redirect("admin/listNotizie.php");
|
|
}
|
|
|
|
|
|
|
|
}catch(GUIException $ex){
|
|
$error = $ex->getMessage();
|
|
}catch (Exception $exec){
|
|
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage());
|
|
$error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico.";
|
|
}
|
|
|
|
MenuGenerator::generateMenu();
|
|
HTMLHelper::generateAdminHead();
|
|
|
|
?>
|
|
<div>
|
|
<?php echo $error;?>
|
|
<div class="notiziaContainer">
|
|
<?php if(sizeof($medias)>0){
|
|
foreach ($medias as $media){
|
|
if($media->id == $notizia->getMainMediaReference()){?>
|
|
<div style="" class="mediaElement mainElement mediaContent" idref="<?php echo $media->id;?>">
|
|
<?php }
|
|
else{?>
|
|
<div class="mediaElement mediaContent" idref="<?php echo $media->id;?>">
|
|
<?php }
|
|
$media->renderMedia(array("size"=>MediaRenderer::SIZE_SMALL));?>
|
|
</div>
|
|
<?php }
|
|
}?>
|
|
</div>
|
|
<div class="notiziaMenu">
|
|
<ul>
|
|
<li><a href="#" id="mediaMenu_addMedia">Aggiungi Multimedia</a></li>
|
|
<li><a href="#" id="mediaMenu_rmMedia">Rimuovi Multimedia</a></li>
|
|
<li><a href="#" id="mediaMenu_setMain">Imposta Media Principale</a></li>
|
|
<?php if(!DaoMediaHandler::hasMainMedia($notizia)){?>
|
|
|
|
<?php }else{ ?>
|
|
<!-- <li><a href="#" id="mediaMenu_unsetMain">Rimuovi Media Principale</a></li> -->
|
|
<?php }?>
|
|
<li><a href="#" id="mediaMenu_back">Indietro</a></li>
|
|
</ul>
|
|
</div>
|
|
<form id="mediaForm" method="POST" action="">
|
|
<input type="hidden" name="id" value="<?php echo $notiziaId;?>" />
|
|
<input type="hidden" name="addMedia" value="" />
|
|
</form>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function(event){
|
|
|
|
|
|
$("#mediaMenu_addMedia").click(function(event){
|
|
$("form#mediaForm").attr("action","addMultimedia.php");
|
|
$("form#mediaForm input[type=hidden][name=id]").val("<?php echo $notiziaId;?>");
|
|
$("form#mediaForm input[type=hidden][name=addMedia]").val("true");
|
|
$("form#mediaForm").submit();
|
|
});
|
|
|
|
$("#mediaMenu_back").click(function(event){
|
|
$("form#mediaForm").attr("action","homeNotizie.php");
|
|
$("form#mediaForm input[type=hidden][name=id]").val("<?php echo $notiziaId;?>");
|
|
$("form#mediaForm").submit();
|
|
});
|
|
|
|
$(".mediaElement").click(function (){
|
|
$(this).toggleClass("selected");
|
|
});
|
|
|
|
$("#mediaMenu_rmMedia").click(function (){
|
|
var paramStr = "";
|
|
$(".mediaElement.selected").each(function(){
|
|
paramStr+="\n"+$(this).attr("idref");
|
|
});
|
|
openPagePost("homeMultimedia.php", [{name:"id",value:"<?php echo $notiziaId;?>"},{name:"remove",value:paramStr}]);
|
|
});
|
|
|
|
$("#mediaMenu_setMain").click(function (){
|
|
var paramStr = "";
|
|
paramStr = $(".mediaElement.selected").attr("idref");
|
|
openPagePost("homeMultimedia.php", [{name:"id",value:"<?php echo $notiziaId;?>"},{name:"setMain",value:paramStr}]);
|
|
});
|
|
|
|
$("video").on('canplay',function (event){
|
|
$(".videoContainerForImageAppend img.poster").hide();
|
|
|
|
$(".videoContainerForImageAppend video.localVideo").attr("style","");
|
|
}
|
|
// $("video").on('loadstart',function (event){
|
|
// $(this).addClass("loading");
|
|
// });
|
|
|
|
// $("video").on('canplay',function (event){
|
|
// $(this).removeClass("loading");
|
|
// $(this).attr('poster','');
|
|
// });
|
|
|
|
|
|
|
|
// $("#mediaMenu_unsetMain").click(function (){
|
|
// openPagePost("homeMultimedia.php", [{name:"id",value:"<?php echo $notiziaId;?>"},{name:"rmMain",value:"true"}]);
|
|
// });
|
|
});
|
|
</script>
|