477 lines
18 KiB
PHP
477 lines
18 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 05/feb/2016
|
|
*/
|
|
|
|
require_once(dirname(__FILE__)."/load.php");
|
|
|
|
try {
|
|
// UserLoginManager::logout();
|
|
$sendComment = false;
|
|
$articolo = null;
|
|
|
|
if (array_key_exists("id", $_GET)){
|
|
$articolo = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("id"=>strval($_GET["id"]),"status"=>NotiziaModel::STATUS_ACCEPTED));
|
|
}
|
|
else if (array_key_exists("short", $_GET) ) {
|
|
$short = strval($_GET["short"]);
|
|
$articolo = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("shortenedUrl"=> $short ,"status"=>NotiziaModel::STATUS_ACCEPTED));
|
|
}
|
|
if (is_null($articolo)){
|
|
GUIHandler::redirect("index.php");
|
|
}
|
|
AnalyticsHelper::logNotiziaImpression($articolo->id);
|
|
AnalyticsHelper::logPageImpression();
|
|
|
|
$user = UserLoginManager::getLogged();
|
|
|
|
$media = DaoMediaHandler::getMainMediaFromModel($articolo);
|
|
$medias = DaoMediaHandler::getMedias($articolo);
|
|
|
|
$commenti = GlobalVariables::get("dao")->query("CommentoModel",
|
|
array("notizia"=>$articolo->id,"status"=>CommentoModel::STATUS_ACCEPTED),
|
|
array("sort"=>array("about.data"=>-1))
|
|
);
|
|
// echo $articolo->titolo;
|
|
// var_dump($medias);
|
|
$mesi = array(1=>'Gennaio', 'Febbraio', 'Marzo', 'Aprile',
|
|
'Maggio', 'Giugno', 'Luglio', 'Agosto',
|
|
'Settembre', 'Ottobre', 'Novembre','Dicembre');
|
|
|
|
$data = date("d",$articolo->about->data->sec)." ".$mesi[date("n",$articolo->about->data->sec)]." ".date("Y",$articolo->about->data->sec)." ".date("H:i",$articolo->about->data->sec);
|
|
|
|
$config = GlobalVariables::get("config");
|
|
$directLink = $config->pages->remoteLocationPath."articolo_".$articolo->id;
|
|
$mobileLink = GUIHandlerMobile::getBaseUrl()."articolo_".$articolo->id;
|
|
// $directLink = $articolo->getAbsoluteUrl();
|
|
// $mobileLink = $articolo->getAbsoluteMobileUrl();
|
|
|
|
$additionalHeaders = array();
|
|
$additionalHeaders[] = '<link rel="canonical" href="'.$directLink.'"/>';
|
|
$additionalHeaders[] = '<link rel="alternate" media="only screen and (max-width: 640px)" href="'.$mobileLink.'"/>';
|
|
$additionalHeaders[] = '<meta property="og:url" content="'.$directLink.'"/>';
|
|
$additionalHeaders[] = '<meta property="og:site_name" content="I Fatti di Napoli"/>';
|
|
$additionalHeaders[] = '<meta property="og:type" content="article"/>';
|
|
$additionalHeaders[] = '<meta property="og:title" content="'.htmlentities(strip_tags($articolo->titolo),ENT_QUOTES).'"/>';
|
|
$additionalHeaders[] = '<meta property="og:description" content="'.htmlentities(strip_tags($articolo->sottotitolo),ENT_QUOTES).'"/>';
|
|
// $additionalHeaders[] = '<meta property="og:author" content="https://www.facebook.com/antonio.pianelli"/>';
|
|
$additionalHeaders[] = '<meta property="fb:app_id" content="1707001356211512"/>';
|
|
|
|
$mediaMetaInfo = '';
|
|
if ($media->mediaType == MediaModel::TYPE_LOCALVIDEO || $media->mediaType == MediaModel::TYPE_YOUTUBE){
|
|
$mediaMetaInfo = 'itemprop="video"';
|
|
if ($media->mediaType == MediaModel::TYPE_YOUTUBE){
|
|
$additionalHeaders[] = '<meta property="og:image" content="'.$media->getRenderer()->getThumbnailLink().'"/>';
|
|
|
|
$additionalHeaders[] = '<meta property="og:video" content="'.$media->getRenderer()->getVideoLink().'"/>';
|
|
$additionalHeaders[] = '<meta property="og:video:type" content="application/x-shockwave-flash"/>';
|
|
$additionalHeaders[] = '<meta property="og:video:width" content="240"/>';
|
|
$additionalHeaders[] = '<meta property="og:video:height" content="205"/>';
|
|
}
|
|
}
|
|
else if ($media->mediaType == MediaModel::TYPE_IMAGE){
|
|
$mediaMetaInfo = 'itemprop="image"';
|
|
$additionalHeaders[] = '<meta property="og:image" content="'.$media->getRenderer()->getImageLink(MediaRenderer::SIZE_BIG).'"/>';
|
|
$additionalHeaders[] = '<meta property="og:image:url" content="'.$media->getRenderer()->getImageLink(MediaRenderer::SIZE_BIG).'"/>';
|
|
}
|
|
|
|
if(array_key_exists("submit", $_POST) && strcmp($_POST["submit"] ,"Submit")==0){
|
|
// var_dump($articolo->sondaggio->voci);
|
|
if($articolo->hasProperty("sondaggio") && !is_null($articolo->sondaggio)){
|
|
if(!in_array($user->username, $articolo->sondaggio->votanti)){
|
|
$selectedVoice = $_POST["voce"];
|
|
foreach ($articolo->sondaggio->voci as $voce){
|
|
// var_dump($voce);
|
|
if(strcmp($voce->nome, $selectedVoice)==0){
|
|
$voce->voti +=1;
|
|
}
|
|
// var_dump($voce);
|
|
}
|
|
|
|
$articolo->sondaggio->votanti[] = $user->username;
|
|
GlobalVariables::get("dao")->save($articolo);
|
|
}
|
|
}
|
|
// var_dump($articolo->sondaggio);
|
|
}
|
|
|
|
if(array_key_exists("sendCommento", $_POST) && strcmp($_POST["sendCommento"] ,"Invia")==0){
|
|
if(UserLoginManager::isLogged()){
|
|
$saveable = new stdClass();
|
|
|
|
$saveable->user = $user->id;
|
|
$saveable->notizia = $articolo->id;
|
|
$saveable->titolo = strip_tags($_POST["titolo"]);
|
|
$saveable->testo = strip_tags($_POST["commento"]);
|
|
$saveable->status = CommentoModel::STATUS_PENDING;
|
|
|
|
// var_dump($saveable);
|
|
$commento = new CommentoModel($saveable);
|
|
GlobalVariables::get("dao")->save($commento);
|
|
$sendComment = true;
|
|
}
|
|
}
|
|
|
|
}catch(GUIException $ex){
|
|
$error = $ex->getMessage();
|
|
}catch (Exception $exec){
|
|
$msg = LogModel::fromException($exec);
|
|
GlobalVariables::get("dao")->save($msg);
|
|
|
|
GUIHandler::redirect("index.php");
|
|
}
|
|
GUIHandler::generateHtmlHeaders(array("additionalMetadata"=>$additionalHeaders,"author"=>false,"description"=>htmlentities(strip_tags($articolo->sottotitolo),ENT_QUOTES),"title"=>htmlentities(strip_tags($articolo->titolo),ENT_QUOTES)));
|
|
?>
|
|
<!--<div class="imageOverlay" onclick="javascript:hidePreview()">
|
|
<div class="imagePreviewBefore"><img src="images/leftImage.png" /></div>
|
|
<div class="imagePreviewAfter"><img src="images/rightImage.png" /></div>
|
|
</div>
|
|
<div class="clickableImageContainer" onclick="javascript:hidePreview()"></div> -->
|
|
<div style="width:1000px;margin-left:auto;margin-right:auto;" itemscope itemtype="http://schema.org/Article">
|
|
<?php
|
|
|
|
GUIHandler::generateHeadPublic($articolo->category);
|
|
GUIHandler::generateMenu();
|
|
?>
|
|
<div class="articoloCategory">
|
|
<div class="categoryStyle">
|
|
<div class="icon"><img alt="" src="images/categoryIcon.png"></div>
|
|
<div class="articoloCategoryName" style="background-color:<?php echo NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["color"] ?>"><span itemprop="articleSection"><?php echo strtoupper(NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["label"]);?></span></div>
|
|
</div>
|
|
</div>
|
|
<div class="articoloContainer" >
|
|
<div class="headArticolo">
|
|
<div class="articoloMainMedia mediaContent" >
|
|
<?php if(!is_null($media)) {
|
|
$pos = 0;
|
|
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 }
|
|
else {
|
|
$media->renderMedia(array("size"=>MediaRenderer::SIZE_ORIGINAL,"clickable"=>false));
|
|
}
|
|
}
|
|
?>
|
|
</div>
|
|
<div class="articoloTitle">
|
|
<div class="title" itemprop="name"><?php echo htmlentities($articolo->titolo);?></div>
|
|
<div class="subTitle">
|
|
<span><?php echo $data;?> —</span>
|
|
<span itemprop="headline"><?php echo $articolo->sottotitolo;?></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="articoloLeftBar">
|
|
<div class="utilityBar">
|
|
<div class="stamp">
|
|
<a href="javascript:void(0);" onclick="javascript:printNews('<?php echo $articolo->id;?>');"><div style="background-image:url(images/stampa.png);"></div></a>
|
|
</div>
|
|
<div class="socialBarArticolo">
|
|
<?php
|
|
$twitterCutTitle = trim(strip_tags($articolo->titolo));
|
|
if (strlen($twitterCutTitle)>95){
|
|
$twitterCutTitle = substr($twitterCutTitle, 0, 92) . "...";
|
|
}
|
|
?>
|
|
<a class="socialLink" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $articolo->getAbsoluteUrl();?>"><div style="background-image:url(images/fb_round.png);"></div></a>
|
|
<a class="socialLink" target="_blank" href="https://twitter.com/intent/tweet?via=fattidinapoli&url=<?php echo $articolo->getAbsoluteUrl();?>&text=<?php echo urlencode($twitterCutTitle." -");?>"><div style="background-image:url(images/twitter_round.png);"></div></a>
|
|
<a class="socialLink" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo $articolo->getAbsoluteUrl();?>"><div style="background-image:url(images/linkedin_round.png);"></div></a>
|
|
<a class="socialLink" target="_blank" href="https://plus.google.com/share?url=<?php echo $articolo->getAbsoluteUrl();?>"><div style="background-image:url(images/google_round.png);"></div></a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if($articolo->hasProperty("sondaggio") && !is_null($articolo->sondaggio)){?>
|
|
<div class="sondaggioContainer">
|
|
<div id="sondaggioGraph" style=""></div>
|
|
<?php if(UserLoginManager::isLogged()){
|
|
if(!in_array($user->username, $articolo->sondaggio->votanti)){?>
|
|
<div class="sondaggioOptions">
|
|
<div style="text-align:center;"><?php echo trim(html_entity_decode($articolo->sondaggio->titolo));?></div>
|
|
<form method="POST">
|
|
|
|
<?php foreach ($articolo->sondaggio->voci as $voce){?>
|
|
<div style="padding:5px;"><span style="vertical-align:middle;"><?php echo $voce->nome;?></span> <input style="vertical-align:middle;" type="radio" name="voce" value="<?php echo $voce->nome;?>"></div>
|
|
<?php } ?>
|
|
<input class="subInput" type="submit" name="submit" value="Submit" />
|
|
</form>
|
|
</div>
|
|
<?php }
|
|
else{
|
|
?>
|
|
<div class="sondaggio noLogin">Hai già votato per questo sondaggio</div>
|
|
<?php }
|
|
}
|
|
else{
|
|
?>
|
|
<div class="sondaggio noLogin">Effettua il <a href="#loginLink">login</a> per votare o se non hai ancora un account <a href="#regButton">registrati</a></div>
|
|
<?php }
|
|
?>
|
|
</div>
|
|
<?php }?>
|
|
<div class="articoloTesto" itemprop="articleBody"><?php echo $articolo->testo;?></div>
|
|
<?php if(sizeof($medias)>0){?>
|
|
<div class="mediasConatiner" <?php if(sizeof($medias)==1){?> style="display:none;"<?php }?>>
|
|
<div class="headMedias">
|
|
<div class="moreMedia"><span>Altri contenuti</span></div>
|
|
</div>
|
|
<div class="caroselContainer">
|
|
<script type="text/javascript">
|
|
var items = [];
|
|
</script>
|
|
<?php
|
|
$i=0;
|
|
foreach($medias as $mediaImage){
|
|
if($mediaImage->mediaType == MediaModel::TYPE_IMAGE){
|
|
$imageArray = getimagesize($mediaImage->getRenderer()->getImageLink(MediaRenderer::SIZE_BIG));
|
|
?>
|
|
<div class="carosImage mediaContent">
|
|
<span class="helper"></span>
|
|
<div style="display:inline-block;" onclick="javascript:loadImage('<?php echo $i;?>')"><?php $mediaImage->renderMedia(array("size"=>MediaRenderer::SIZE_MINI,"clickable"=>true));?></div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var ele ={
|
|
src: '<?php echo GUIHandler::getBaseUrl()."getImage.php?id=".$mediaImage->id."&size=".MediaRenderer::SIZE_BIG;?>',
|
|
w:<?php echo $imageArray[0];?>,
|
|
h:<?php echo $imageArray[1];?>
|
|
}
|
|
items.push(ele);
|
|
</script>
|
|
<?php
|
|
$i++;
|
|
}
|
|
else {
|
|
?>
|
|
<div class="carosImage mediaContent">
|
|
<span class="helper"></span>
|
|
<div style="display:inline-block;" ><?php $mediaImage->renderMedia(array("size"=>MediaRenderer::SIZE_MINI,"clickable"=>true));?></div>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<?php }?>
|
|
<div class="fb-comments" data-href="<?php echo $directLink;?>" data-width="100%" data-numposts="5"></div>
|
|
<div class="commentiContainer">
|
|
<div class="commentiLabelContainer">
|
|
<div class="commentiLabel">Commenti (<?php echo count($commenti);?>)</div>
|
|
<hr style="color:#ddd;">
|
|
</div>
|
|
<?php if(sizeof($commenti)>0){
|
|
?>
|
|
<div class="oldCommentiContainer">
|
|
<?php foreach ($commenti as $oldCommento){
|
|
$utonto = GlobalVariables::get("dao")->getFirst("UserModel",array("_id"=>$oldCommento->user));
|
|
?>
|
|
<div class="commento">
|
|
<div class="commentoTitle"><?php echo $oldCommento->titolo;?></div>
|
|
<div class="commentoTesto"><?php echo $oldCommento->testo;?></div>
|
|
<div class="userInfo">
|
|
<div class="userCommento">Inviato da <span class="user" ><?php echo $utonto->nome." ".$utonto->cognome;?></span> il <span class="data"><?php echo date("d/m/Y",$oldCommento->date->sec)?></span></div>
|
|
</div>
|
|
</div>
|
|
<?php }
|
|
?>
|
|
</div>
|
|
<?php
|
|
}
|
|
echo '<hr style="color:#ddd;">';
|
|
if($sendComment){
|
|
?>
|
|
<div class="commento commentoInviato">Il tuo commento è stato inviato alla redazione ed è in attesa di essere accettato.</div>
|
|
<?php }
|
|
|
|
if(UserLoginManager::isLogged()){
|
|
?>
|
|
<div id="commentoArea" class="commento">
|
|
<div class="commentoTitle">
|
|
Aggiungi il tuo commento per questa notizia
|
|
</div>
|
|
<div>
|
|
<form method="POST" id="commentoForm">
|
|
<input name="titolo" type="text" placeholder="Titolo del commento"/>
|
|
<textarea name="commento" placeholder="Il tuo commento" rows="5" cols="80"></textarea>
|
|
<input type="hidden" name="id" value="<?php echo $articolo->id;?>" />
|
|
<div class="sendBtnDiv">
|
|
<input type="submit" name="sendCommento" value="Invia" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<?php }
|
|
else{
|
|
?>
|
|
<div class="commento noLogin">Per commentare questa notizia <a href="#loginLink">accedi</a> all'applicazione o <a href="#regButton">registrati</a> se non hai ancora un account </div>
|
|
<?php }
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="articoloRightBar" style="width:280px;display:inline-block;">
|
|
<?php GUIHandler::generateRightBannerBlock($articolo->category);?>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
GUIHandler::generateFooter();
|
|
?>
|
|
</div>
|
|
<!-- Root element of PhotoSwipe. Must have class pswp. -->
|
|
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
|
|
|
|
<!-- Background of PhotoSwipe.
|
|
It's a separate element as animating opacity is faster than rgba(). -->
|
|
<div class="pswp__bg"></div>
|
|
|
|
<!-- Slides wrapper with overflow:hidden. -->
|
|
<div class="pswp__scroll-wrap">
|
|
|
|
<!-- Container that holds slides.
|
|
PhotoSwipe keeps only 3 of them in the DOM to save memory.
|
|
Don't modify these 3 pswp__item elements, data is added later on. -->
|
|
<div class="pswp__container">
|
|
<div class="pswp__item"></div>
|
|
<div class="pswp__item"></div>
|
|
<div class="pswp__item"></div>
|
|
</div>
|
|
|
|
<!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
|
|
<div class="pswp__ui pswp__ui--hidden">
|
|
|
|
<div class="pswp__top-bar">
|
|
|
|
<!-- Controls are self-explanatory. Order can be changed. -->
|
|
|
|
<div class="pswp__counter"></div>
|
|
|
|
<button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
|
|
|
|
<!-- Eliminato share <button class="pswp__button pswp__button--share" title="Share"></button> -->
|
|
|
|
<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
|
|
|
|
<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
|
|
|
|
<!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
|
|
<!-- element will get class pswp__preloader--active when preloader is running -->
|
|
<div class="pswp__preloader">
|
|
<div class="pswp__preloader__icn">
|
|
<div class="pswp__preloader__cut">
|
|
<div class="pswp__preloader__donut"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
|
|
<div class="pswp__share-tooltip"></div>
|
|
</div>
|
|
|
|
<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
|
|
</button>
|
|
|
|
<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
|
|
</button>
|
|
|
|
<div class="pswp__caption">
|
|
<div class="pswp__caption__center"></div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<script type="text/javascript">
|
|
function loadImage(pos){
|
|
|
|
var pswpElement = document.querySelectorAll('.pswp')[0];
|
|
|
|
//build items array
|
|
pos = parseInt(pos);
|
|
|
|
//define options (if needed)
|
|
var options = {
|
|
index: pos // start at slide
|
|
};
|
|
|
|
//Initializes and opens PhotoSwipe
|
|
var gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
|
|
gallery.init();
|
|
}
|
|
$(document).ready(function(event){
|
|
// $("video").on('loadstart',function (event){
|
|
// var wid = $(this).innerWidth();
|
|
// $(".videoContainerForImageAppend").append('<img src="images/loading.gif" class="poster" style="width:'+ wid +'px;background-color:black;"/>')
|
|
// $(this).hide();
|
|
// });
|
|
|
|
// $("video").on('canplay',function (event){
|
|
// $(".poster").hide();
|
|
// $(this).show();
|
|
// $(this).get(0).play();
|
|
// });
|
|
|
|
$("#submit").click(function (){
|
|
// $("form#commentoForm").submit(function (){
|
|
$.ajax({
|
|
method:'POST',
|
|
url:'sendCommentoBackend.php',
|
|
dataType:'html',
|
|
data:$("#commentoForm").serialize(),
|
|
success: function(data){
|
|
$("#commentoArea").remove();
|
|
$("#sentMessage").html(data);
|
|
}
|
|
});
|
|
// });
|
|
});
|
|
|
|
<?php if($articolo->hasProperty("sondaggio") && !is_null($articolo->sondaggio)){
|
|
$colori=array('#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1','#7cb5ec');?>
|
|
$("#sondaggioGraph").highcharts({
|
|
chart:{type:'bar'},
|
|
title:{text:'<?php echo trim(html_entity_decode($articolo->sondaggio->titolo)); ?>'},
|
|
xAxis:{
|
|
categories:[<?php $i =0; foreach($articolo->sondaggio->voci as $voce){
|
|
echo ($i++==0?"":", ")."\"".trim($voce->nome)."\"";
|
|
}
|
|
?>],
|
|
},
|
|
yAxis:{
|
|
title:{text:"Numero Voti"},
|
|
tickInterval:1
|
|
},
|
|
|
|
legend: {
|
|
enabled: false,
|
|
},
|
|
series:[{
|
|
name:"Voti",
|
|
data:[<?php $i =0; foreach($articolo->sondaggio->voci as $voce){
|
|
// echo ($i++==0?"":", ").$voce->voti;
|
|
echo ($i++==0?"{":", {")."y:".$voce->voti.",color:'".$colori[$i%10]."'}";
|
|
}
|
|
?>]
|
|
}]
|
|
});
|
|
<?php }
|
|
?>
|
|
<?php
|
|
// if(sizeof($medias)>0){?>
|
|
|
|
<?php
|
|
// }
|
|
?>
|
|
});
|
|
</script>
|
|
<?php GUIHandler::generateGoogleAnalyticsScripts();?>
|