lock in categorySummary per le categorie hidden; aggiunta del sondaggio in articolo; inizio funzione di commento
130 lines
3.8 KiB
PHP
130 lines
3.8 KiB
PHP
<?php
|
|
|
|
require_once(dirname(__FILE__)."/load.php");
|
|
|
|
try {
|
|
|
|
// AnalyticsHelper::logNotiziaImpression($articolo->id);
|
|
AnalyticsHelper::logPageImpression();
|
|
|
|
GUIHandler::generateHtmlHeaders();
|
|
$searchParameters = "";
|
|
if(array_key_exists("search", $_POST) && strcmp($_POST["search"], "")!=0){
|
|
|
|
var_dump($_POST["search"]);
|
|
$searchParameters = strip_tags(PostHandler::get("search"));
|
|
|
|
// $notizie = GlobalVariables::get("dao")->query("NotiziaModel",
|
|
// array("status"=>NotiziaModel::STATUS_ACCEPTED),
|
|
// array("sort"=>array("about.data"=>-1),"limit"=>$limit,"skip"=>$page*$limit)
|
|
// );
|
|
$found = false;
|
|
$limit=12;
|
|
$page = 1;
|
|
$numPages = 1;
|
|
|
|
if(array_key_exists("page", $_POST)){
|
|
$page = intval($_POST["page"]);
|
|
}
|
|
|
|
$skip =($page - 1) * $limit;
|
|
$notizieAll = GlobalVariables::get("dao")->query("NotiziaModel",
|
|
array("status"=>NotiziaModel::STATUS_ACCEPTED)
|
|
);
|
|
|
|
if(sizeof($notizieAll)>0){
|
|
$dim = count($notizieAll);
|
|
$numPages = ceil($dim/$limit);
|
|
}
|
|
else{
|
|
$found = false;
|
|
}
|
|
|
|
$notizie = GlobalVariables::get("dao")->query("NotiziaModel",
|
|
array("status"=>NotiziaModel::STATUS_ACCEPTED),
|
|
array("sort"=>array("about.data"=>-1),"skip"=>$skip,"limit"=>$limit)
|
|
);
|
|
|
|
if (sizeof($notizie)>0){
|
|
$found=true;
|
|
$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");
|
|
echo "Errore";
|
|
}
|
|
|
|
|
|
}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();
|
|
GUIHandler::generateMenu();?>
|
|
<div class="searchResultsContainer">
|
|
<?php
|
|
if ($found){
|
|
$i=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;
|
|
$media = DaoMediaHandler::getMainMediaFromModel($notizia);
|
|
?>
|
|
<div class="notiziaContainer">
|
|
<div class="notiziaImage mediaContent"><?php (!is_null($media))?$media->renderMedia(array("size"=>MediaRenderer::SIZE_SMALL)):"" ;?></div>
|
|
<div 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>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(event){
|
|
$("#notizia_<?php echo $i;?>").click(function(event){
|
|
window.location.href="articolo.php?id=<?php echo $notizia->id;?>";
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
}
|
|
else{
|
|
?>
|
|
<div style="color:red;">Nessun articolo trovato con questi parametri di ricerca.</div>
|
|
<?php
|
|
}
|
|
?>
|
|
</div>
|
|
<div class="summaryRightBar">
|
|
<?php GUIHandler::generateRightBannerBlock();?>
|
|
</div>
|
|
<div class="paging">
|
|
<form method="POST">
|
|
<input type="hidden" value="<?php echo $searchParameters;?>">
|
|
<?php
|
|
// for($i = 1;$i<=$numPages;$i++){
|
|
?>
|
|
<!-- <div id ="page_<?php // echo $i;?>" class="page" style="padding:10px;cursor:pointer;"><?php //echo $i;?></div> -->
|
|
<?php
|
|
// }
|
|
?>
|
|
<!-- <input type="hidden" name="page" value="javascript:$('#page<?php //echo $i;?>').click(function(){$('.page').val('$(#page_<?php // echo $i;?>)')})"> -->
|
|
</form>
|
|
</div>
|
|
|
|
<?php
|
|
GUIHandler::generateFooter();
|
|
?>
|
|
</div>
|