204 lines
5.3 KiB
PHP
204 lines
5.3 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"));
|
|
|
|
|
|
$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")->search("NotiziaModel",$searchParameters,
|
|
array("status"=>NotiziaModel::STATUS_ACCEPTED)
|
|
);
|
|
|
|
// $notizieAll = GlobalVariables::get("dao")->query("NotiziaModel",
|
|
// array("status"=>NotiziaModel::STATUS_ACCEPTED)
|
|
// );
|
|
|
|
if(sizeof($notizieAll)>0){
|
|
$dim = count($notizieAll);
|
|
$numPages = ceil($dim/$limit);
|
|
$found = true;
|
|
}
|
|
else{
|
|
$found = false;
|
|
}
|
|
|
|
$notizie = GlobalVariables::get("dao")->search("NotiziaModel",$searchParameters,
|
|
array("status"=>NotiziaModel::STATUS_ACCEPTED),
|
|
array("sort"=>array("about.data"=>-1),"limit"=>$limit,"skip"=>$skip)
|
|
);
|
|
|
|
// $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");
|
|
}
|
|
|
|
|
|
}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
|
|
}
|
|
?>
|
|
<div class="paging">
|
|
<form id="changePage" method="POST">
|
|
<input type="hidden" name ="search" value="<?php echo $searchParameters;?>">
|
|
<?php
|
|
if($page-2>1){
|
|
?>
|
|
<div id ="page_first" class="page">
|
|
Inizio
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
$("#page_first").click(function(){
|
|
$("input#pageSend").val('1');
|
|
$("form#changePage").submit();
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
|
|
$j = 1;
|
|
$last = $page +2;
|
|
if($page-2<1){
|
|
$j = $page;
|
|
}
|
|
else if($page+2 >$numPages){
|
|
$j = $numPages-3;
|
|
$last = $numPages;
|
|
}
|
|
else{
|
|
$j = $page - 2;
|
|
}
|
|
for($j;$j<=$last;$j++){
|
|
if($j == $page){
|
|
?>
|
|
<div id ="page_<?php echo $j;?>" class="page current" >
|
|
<?php echo $j;?>
|
|
</div>
|
|
<?php
|
|
}
|
|
else{
|
|
?>
|
|
<div id ="page_<?php echo $j;?>" class="page">
|
|
<?php echo $j;?>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
$("#page_<?php echo $j;?>").click(function(){
|
|
$("input#pageSend").val(<?php echo $j;?>);
|
|
$("form#changePage").submit();
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
if($page+2<$numPages){
|
|
?>
|
|
<div id ="page_last" class="page">
|
|
Ultima
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
$("#page_last").click(function(){
|
|
$("input#pageSend").val('<?php echo $numPages;?>');
|
|
$("form#changePage").submit();
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
<input id="pageSend" type="hidden" name="page" />
|
|
</form>
|
|
</div>
|
|
<?php
|
|
}
|
|
else{
|
|
?>
|
|
<div style="color:red;">Nessun articolo trovato con questi parametri di ricerca.</div>
|
|
<?php
|
|
}
|
|
?>
|
|
</div>
|
|
<div class="summaryRightBar">
|
|
<?php GUIHandler::generateRightBannerBlock();?>
|
|
</div>
|
|
<?php
|
|
GUIHandler::generateFooter();
|
|
GUIHandler::generateGoogleAnalyticsScripts();
|
|
?>
|
|
</div>
|