Merge branch 'master' of ssh://gitolite@asdynamics.com:50005/projects/fdn2.git

This commit is contained in:
Lorenzo Giacomelli
2016-03-04 12:27:30 +01:00
21 changed files with 150 additions and 53 deletions
@@ -81,8 +81,20 @@ class DaoMediaHandler implements MediaHandlerInterface{
$model->setMediaReferences($mediaArr);
if($model->getMainMediaReference() == $mediaId){
$medias = self::getMedias($model);
if (sizeof($medias)>0){
if ($media->getReference() == $medias[0]->getReference()){
$model->setMainMedia($medias[1]);
}
else {
$model->setMainMedia($medias[0]);
}
}
else {
$model->setMainMedia(null);
}
// echo "UGUALE!";
$model->setMainMedia(null);
}
GlobalVariables::get("dao")->save($model);
@@ -146,7 +158,7 @@ class DaoMediaHandler implements MediaHandlerInterface{
* @param MediaInterface $media
* @throws MediaException
*/
public static function setMainMediaToModel(HasMediaInterface $model, MediaInterface $media=null){
public static function setMainMediaToModel(HasMediaInterface $model, MediaInterface $media){
try{
self::addMedia($model, $media);
$model->setMainMedia($media);
@@ -53,7 +53,7 @@ abstract class HasMediaModel extends Model implements HasMediaInterface{
* (non-PHPdoc)
* @see HasMediaInterface::setMainMedia()
*/
public function setMainMedia(MediaInterface $media=null){
public function setMainMedia(MediaInterface $media = null){
if(!is_null($media)){
$this->mainMedia = $media->getReference();
}
+4 -4
View File
@@ -59,13 +59,13 @@ class MediaModel extends Model implements MediaInterface{
}
}
public function asText(){
return $this->mediaRenderer->asText();
public function asText(array $opts = array()){
return $this->mediaRenderer->asText($opts);
}
public function renderMedia(){
public function renderMedia(array $opts = array()){
// var_dump($this->mediaRenderer);
$this->mediaRenderer->render();
$this->mediaRenderer->render($opts);
}
public function getType(){
+1 -1
View File
@@ -15,7 +15,7 @@ class NotiziaBlock {
$mainMedia = DaoMediaHandler::getMainMediaFromModel($this->notizia);
$mediaText = "";
if (!is_null($mainMedia)){
$mediaText = $mainMedia->asText();
$mediaText = $mainMedia->asText(array("clickable"=>true));
}
$rval = '<div class="notiziaBlock">';
$rval.= '<div class="notiziaMainMedia">'.$mediaText.'</div>';
+1 -1
View File
@@ -30,7 +30,7 @@ interface HasMediaInterface{
* Setta la reference del media principale
* @param MediaInterface $media
*/
public function setMainMedia(MediaInterface $media=null);
public function setMainMedia(MediaInterface $media = null);
/**
* Restituisce la reference (id) del main media, se non esiste ritorna null
+1 -1
View File
@@ -56,7 +56,7 @@ interface MediaHandlerInterface{
* @param MediaInterface $media
* @throws MediaException
*/
public static function setMainMediaToModel(HasMediaInterface $model, MediaInterface $media=null);
public static function setMainMediaToModel(HasMediaInterface $model, MediaInterface $media);
/**
* Prende in ingresso un HasMediaInterface ritorna un array di un elemento array("mainMedia"=>"&value");
@@ -1,6 +1,25 @@
<?php
interface MediaRendererInterface{
const SIZE_SMALL = 1;
const SIZE_SMALL_W = 160;
const SIZE_SMALL_H = 120;
const SIZE_MEDIUM = 2;
const SIZE_MEDIUM_W = 240;
const SIZE_MEDIUM_H = 205;
const SIZE_BIG = 3;
const SIZE_BIG_H = 800;
const SIZE_BIG_W = 600;
const SIZE_ORIGINAL = 4;
const SIZE_ORIGINAL_H = null;
const SIZE_ORIGINAL_W = null;
public function asText(array $opt = array()) ;
public function render(array $opt = array());
+2
View File
@@ -13,6 +13,8 @@ require_once(dirname(__FILE__)."/MediaHandlerInterface.php");
require_once(dirname(__FILE__)."/MediaRendererInterface.php");
require_once(dirname(__FILE__)."/mediaRenderers/MediaRenderer.php");
require_once(dirname(__FILE__)."/mediaRenderers/MediaHtml5.php");
require_once(dirname(__FILE__)."/mediaRenderers/MediaImage.php");
require_once(dirname(__FILE__)."/mediaRenderers/MediaPdf.php");
@@ -1,6 +1,6 @@
<?php
class MediaHtml5 implements MediaRendererInterface{
class MediaHtml5 extends MediaRenderer{
private $code;
public function __construct($code){
@@ -8,7 +8,16 @@ class MediaHtml5 implements MediaRendererInterface{
}
public function asText(array $opt = array()){
return $this->code;
$size = MediaRendererInterface::SIZE_ORIGINAL;
$width = '';
$height = '';
if(array_key_exists("size", $opt) && array_key_exists($opt["size"], self::$SIZES)){
$size = $opt["size"];
$width = 'height:'.self::$SIZES[$size]["width"].'px;';
$height = 'width:'.self::$SIZES[$size]["height"].'px;';
}
return '<div style="'.$height.$width.'overflow:hidden;">'.$this->code.'</div>';
}
public function render(array $opt = array()){
@@ -1,14 +1,16 @@
<?php
class MediaImage implements MediaRendererInterface{
class MediaImage extends MediaRenderer{
private $id;
public function __construct($id){
$this->id = $id;
}
public function asText(array $opt = array()){
$size = "small";
if(sizeof($opt)>0 && array_key_exists("size", $opt)){
$size = MediaRendererInterface::SIZE_ORIGINAL;
if(array_key_exists("size", $opt) && array_key_exists($opt["size"], self::$SIZES)){
$size = $opt["size"];
}
return '<img src="'.GUIHandler::getBaseUrl().'getImage.php?id='.$this->id.'&size='.$size.'"/>';
@@ -1,6 +1,6 @@
<?php
class MediaLocalVideo implements MediaRendererInterface{
class MediaLocalVideo extends MediaRenderer{
private $id;
public function __construct($model){
+13 -2
View File
@@ -1,6 +1,6 @@
<?php
class MediaPdf implements MediaRendererInterface{
class MediaPdf extends MediaRenderer{
private $id;
public function __construct($model){
@@ -8,7 +8,18 @@ class MediaPdf implements MediaRendererInterface{
}
public function asText(array $opt = array()){
return GlobalVariables::get("config")->paths->media."/".$this->id.".pdf";
$clickable = false;
if (array_key_exists("clickable", $opt)){
$clickable = $opt["clickable"];
}
if ($clickable){
return '<a href="'.GUIHandler::getBaseUrl().'getPDF.php?id='.$this->id.'"><img src="'.GUIHandler::getBaseUrl().'images/pdf.png"/></a>';
}
else {
return '<img src="'.GUIHandler::getBaseUrl().'images/pdf.png"/>';
}
// return GlobalVariables::get("config")->paths->media."/".$this->id.".pdf";
}
public function render(array $opt = array()){
@@ -0,0 +1,16 @@
<?php
/*
Author: Riccardo Di Dato
Creation Date: 04/mar/2016
*/
abstract class MediaRenderer implements MediaRendererInterface{
public static $SIZES = array(
MediaRendererInterface::SIZE_SMALL => array("width"=>MediaRendererInterface::SIZE_SMALL_W,"height"=>MediaRendererInterface::SIZE_SMALL_H),
MediaRendererInterface::SIZE_MEDIUM => array("width"=>MediaRendererInterface::SIZE_MEDIUM_W,"height"=>MediaRendererInterface::SIZE_MEDIUM_H),
MediaRendererInterface::SIZE_BIG => array("width"=>MediaRendererInterface::SIZE_BIG_W,"height"=>MediaRendererInterface::SIZE_BIG_H),
MediaRendererInterface::SIZE_ORIGINAL => array("width"=>MediaRendererInterface::SIZE_ORIGINAL_W,"height"=>MediaRendererInterface::SIZE_ORIGINAL_H)
);
}
?>
@@ -1,6 +1,6 @@
<?php
class MediaYoutube implements MediaRendererInterface{
class MediaYoutube extends MediaRenderer{
private $link;
public function __construct($model){
@@ -8,9 +8,10 @@ class MediaYoutube implements MediaRendererInterface{
}
public function asText(array $opt = array()){
return $this->link;
// return '<iframe width="420" height="315"
// src="'.$this->link.'?autoplay=0" frameborder="0" />';
// return $this->link;
return '<iframe width="420" height="315"
src="'.$this->link.'?autoplay=0" frameborder="0"></iframe>';
// return '<iframe width="560" height="315" src="https://www.youtube.com/embed/4qkv-iy_MaQ" frameborder="0" allowfullscreen></iframe>';
}
public function render(array $opt = array()){
+1 -1
View File
@@ -97,7 +97,7 @@ try{
<div><span class="label">Tipo</span><?php echo $bannerTypeString;?></div>
</div>
<div>
<?php $media->renderMedia(); ?>
<?php $media->renderMedia(array("size"=>MediaRenderer::SIZE_MEDIUM)); ?>
</div>
</div>
<div class="bannerMenuContainer">
+8 -7
View File
@@ -86,7 +86,7 @@ HTMLHelper::generateAdminHead();
<?php if(sizeof($medias)>0){
foreach ($medias as $media){
if($media->id == $notizia->getMainMediaReference()){?>
<div style="display:background-color:yellow;" class="mediaElement" idref="<?php echo $media->id;?>">
<div style="" class="mediaElement mainElement" idref="<?php echo $media->id;?>">
<?php }
else{?>
<div class="mediaElement" idref="<?php echo $media->id;?>">
@@ -100,10 +100,11 @@ HTMLHelper::generateAdminHead();
<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)){?>
<li><a href="#" id="mediaMenu_setMain">Imposta Media Principale</a></li>
<?php }else{ ?>
<li><a href="#" id="mediaMenu_unsetMain">Rimuovi Media Principale</a></li>
<!-- <li><a href="#" id="mediaMenu_unsetMain">Rimuovi Media Principale</a></li> -->
<?php }?>
<li><a href="#" id="mediaMenu_back">Back</a></li>
</ul>
@@ -147,8 +148,8 @@ HTMLHelper::generateAdminHead();
openPagePost("homeMultimedia.php", [{name:"id",value:"<?php echo $notiziaId;?>"},{name:"setMain",value:paramStr}]);
});
$("#mediaMenu_unsetMain").click(function (){
openPagePost("homeMultimedia.php", [{name:"id",value:"<?php echo $notiziaId;?>"},{name:"rmMain",value:"true"}]);
});
// $("#mediaMenu_unsetMain").click(function (){
// openPagePost("homeMultimedia.php", [{name:"id",value:"<?php echo $notiziaId;?>"},{name:"rmMain",value:"true"}]);
// });
});
</script>
</script>
+13 -18
View File
@@ -6,20 +6,15 @@ Creation Date: 14/gen/2016
require_once(dirname(__FILE__)."/load.php");
$sizes = array(
"large"=>array("width"=>800,"height"=>600),
"small"=>array("width"=>160,"height"=>120)
);
// $sizes = array(
// "large"=>array("width"=>800,"height"=>600),
// "small"=>array("width"=>160,"height"=>120)
// );
if (array_key_exists("id",$_GET)) {
if (array_key_exists('size',$_GET)){
$size=$_GET['size'];
}
else {
$size = "original";
}
if (!array_key_exists($size, $sizes) || strcmp("original", $size)==0){
$size = null;
$size = MediaImage::SIZE_ORIGINAL;
if (array_key_exists('size',$_GET) && array_key_exists(intval($_GET["size"]), MediaImage::$SIZES)){
$size=intval($_GET['size']);
}
$img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
@@ -32,12 +27,12 @@ if (array_key_exists("id",$_GET)) {
$geom = $thumb->getimagegeometry();
if($img->extension != "gif"){
if (!is_null($size)){
if ($size!=MediaImage::SIZE_ORIGINAL){
if ($geom["width"]>=$geom["height"]){
$thumb->scaleimage($sizes[$size]["width"], 0,false);
$thumb->scaleimage(MediaImage::$SIZES[$size]["width"], 0,false);
}
else {
$thumb->scaleimage(0, $sizes[$size]["height"],false);
$thumb->scaleimage(0, MediaImage::$SIZES[$size]["height"],false);
}
}
@@ -47,13 +42,13 @@ if (array_key_exists("id",$_GET)) {
else{
$thumb = $thumb->coalesceimages();
if (!is_null($size)){
if ($size!=MediaImage::SIZE_ORIGINAL){
foreach ($thumb as $frame){
if ($geom["width"]>=$geom["height"]){
$thumb->scaleimage($sizes[$size]["width"], 0,false);
$thumb->scaleimage(MediaImage::$SIZES[$size]["width"], 0,false);
}
else {
$thumb->scaleimage(0, $sizes[$size]["height"],false);
$thumb->scaleimage(0, MediaImage::$SIZES[$size]["height"],false);
}
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
/*
Author: Riccardo Di Dato
Creation Date: 04/mar/2016
*/
require_once(dirname(__FILE__). "/load.php");
if (array_key_exists("id",$_GET)) {
$pdfModel = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
$id = $_GET["id"];
if (!is_null($pdfModel)){
$localFilePath = GlobalVariables::get("config")->paths->media."/".$id.".pdf";
$exposedFilePath = GlobalVariables::get("config")->paths->xsendfile."/".$id.".pdf";
if (!SFSManager::fileExists($exposedFilePath)){
SystemController::shellExec("ln",'-s "'.$localFilePath.'" "'.$exposedFilePath.'"');
}
header('X-Sendfile: '.$exposedFilePath.'');
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . basename($exposedFilePath) . '"');
}
}
?>
+1 -1
View File
@@ -119,7 +119,7 @@ catch (Exception $ex){
<div class="newsContainer">
<?php if(sizeof($politicaNews)>0){
foreach ($politicaNews as $politica){
$stringTitolo = (strlen($politia->titolo) > 103) ? substr($politica->titolo,0,100).'...' : $politica->titolo;
$stringTitolo = (strlen($politica->titolo) > 103) ? substr($politica->titolo,0,100).'...' : $politica->titolo;
$string = (strlen($politica->sottotitolo) > 53) ? substr($politica->sottotitolo,0,50).'...' : $politica->sottotitolo;?>
<div class="news">
<div class="newsSummary"><?php
+3 -2
View File
@@ -84,8 +84,9 @@ div.notiziaStat >div > div {text-align:center;}
| | | | __/ (_| | | (_| |
|_| |_|\___|\__,_|_|\__,_|
*/
.mediaElement{display:inline-block; background-color:yellow;padding:15px;}
*/
.mediaElement.mainElement{background-color:yellow;}
.mediaElement{display:inline-block; padding:15px;}
.mediaElement.selected {opacity:0.4;background-color:orange;}
/*
+3 -2
View File
@@ -89,7 +89,8 @@ body{font-family:lato, arial;}
.ansa{border:solid #d6d6d6 1px;border-left:0px;border-right:0px;border-top:0px;height:180px;}
.ansa> div {display:inline-block;vertical-align:top;}
.ansaImage{display:inline-block;margin:15px 7px;width:150px;overflow:hidden;text-align:center;}
.ansaImage{display:inline-block;margin:15px 7px;width:150px; height:113px; overflow:hidden;text-align:center;}
.ansaImage > * {max-height:100%;max-width:100%;}
.ansaNews{margin-top:2px;width:330px;cursor:pointer;}
.ansaTitolo{font-weight:bold;font-size:20px;text-align:justify;}
.ansaSottotitolo{font-size:17px;color:#767676;text-align:justify;}
@@ -220,4 +221,4 @@ body{font-family:lato, arial;}
padding: 12px 50px;
}
.articoloContainer{}
.articoloContainer{}