103 lines
3.9 KiB
PHP
103 lines
3.9 KiB
PHP
<?php
|
|
|
|
require_once(dirname(__FILE__)."/load.php");
|
|
|
|
try{
|
|
|
|
AnalyticsHelper::logPageImpression();
|
|
|
|
$config = GlobalVariables::get("config");
|
|
$directLink = $config->pages->remoteLocationPath."categorySummary_".$_GET["category"];
|
|
$mobileLink = GUIHandlerMobile::getBaseUrl()."categorySummary_".$_GET["category"];
|
|
|
|
$additionalHeaders = array();
|
|
$additionalHeaders[] = '<link rel="canonical" href="'.$directLink.'"/>';
|
|
$additionalHeaders[] = '<link rel="alternate" media="only screen and (max-width: 640px)" href="'.$mobileLink.'"/>';
|
|
|
|
GUIHandler::generateHtmlHeaders(array(
|
|
"title"=>NotiziaModel::$NOTIZIE_CATEGORY[$_GET["category"]]["label"],
|
|
"additionalMetadata"=>$additionalHeaders
|
|
));
|
|
|
|
$category = "";
|
|
if(array_key_exists("category", $_GET) && strcmp($_GET["category"], "")!=0){
|
|
|
|
// var_dump(NotiziaModel::$NOTIZIE_CATEGORY[intval($_GET["category"])]["hidden"]);
|
|
if(NotiziaModel::$NOTIZIE_CATEGORY[$_GET["category"]]["hidden"]){
|
|
GUIHandler::redirect("index.php");
|
|
}
|
|
$category = $_GET["category"];
|
|
|
|
// $category = NotiziaModel::CATEGORY_CRONACA;
|
|
|
|
$category = intval($category);
|
|
|
|
$notizie = GlobalVariables::get("dao")->query("NotiziaModel",
|
|
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>$category,"about.data"=>array('$lte'=>new MongoDate())),
|
|
array("sort"=>array("about.data"=>-1),"limit"=>10)
|
|
);
|
|
|
|
if (sizeof($notizie)>0){
|
|
$notizie = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $notizie);
|
|
}
|
|
}
|
|
else{
|
|
GUIHandler::redirect("index.php");
|
|
}
|
|
|
|
|
|
}catch(GUIException $ex){
|
|
$error = $ex->getMessage();
|
|
}catch (Exception $exec){
|
|
$msg = LogModel::fromException($exec);
|
|
GlobalVariables::get("dao")->save($msg);
|
|
|
|
GUIHandler::redirect("index.php");
|
|
}
|
|
?>
|
|
<div style="width:1000px;margin-left:auto;margin-right:auto;">
|
|
<?php
|
|
GUIHandler::generateHeadPublic($category);
|
|
GUIHandler::generateMenu();?>
|
|
<div class="categorySummaryContainer">
|
|
<?php $i=0;
|
|
if(sizeof($notizie)>0){
|
|
foreach ($notizie as $notizia){
|
|
$i++;
|
|
// $stringTitolo = (strlen($notizia->titolo) > 103) ? substr($notizia->titolo,0,100).'...' : $notizia->titolo;
|
|
// $stringSottotitolo = (strlen($notizia->sottotitolo) > 73) ? substr($notizia->sottotitolo,0,70).'...' : $notizia->sottotitolo;
|
|
// $stringTesto = (strlen($notizia->testo) > 33) ? substr($notizia->testo,0,30).'...' : $notizia->testo;
|
|
$stringTitolo = (strlen($notizia->titolo) > 103) ? htmlentities( substr( html_entity_decode( $notizia->titolo, ENT_QUOTES|ENT_HTML5 ),0,100) ).'...' : $notizia->titolo;
|
|
$stringSottotitolo = (strlen($notizia->sottotitolo) > 73) ? htmlentities( substr( html_entity_decode( $notizia->sottotitolo, ENT_QUOTES|ENT_HTML5 ) ,0,70) ).'...' : $notizia->sottotitolo;
|
|
$stringTesto = (strlen($notizia->testo) > 33) ? htmlentities( substr( html_entity_decode( $notizia->testo, ENT_QUOTES|ENT_HTML5 ),0,30) ).'...' : $notizia->testo;
|
|
$media = DaoMediaHandler::getMainMediaFromModel($notizia);
|
|
?>
|
|
<div class="notiziaContainer">
|
|
<div class="notiziaImage mediaContent"><?php (!is_null($media))?$media->renderMedia(array("size"=>MediaRenderer::SIZE_SMALL)):"" ;?></div>
|
|
<a href="<?php echo $notizia->getAbsoluteUrl();?>" id="notizia_<?php echo $i;?>" class="notiziaInfo">
|
|
<div class="notiziaTitolo"><?php echo $stringTitolo;?></div>
|
|
<div class="notiziaSottotitolo"><?php echo$stringSottotitolo;?></div>
|
|
<div class="notiziaTesto"><?php echo $stringTesto;?></div>
|
|
</a>
|
|
</div>
|
|
<script type="text/javascript">
|
|
|
|
</script>
|
|
<?php
|
|
}
|
|
}
|
|
else{
|
|
?>
|
|
<div style="padding:20px 10px;">Al momento non è presente nessuna notizia in questa categoria</div>
|
|
<?php }?>
|
|
</div>
|
|
<div class="summaryRightBar">
|
|
<?php GUIHandler::generateRightBannerBlock($category);?>
|
|
</div>
|
|
|
|
<?php
|
|
GUIHandler::generateFooter();
|
|
GUIHandler::generateGoogleAnalyticsScripts();
|
|
?>
|
|
</div>
|