55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 14/gen/2016
|
|
*/
|
|
|
|
require_once(dirname(__FILE__)."/../../load.php");
|
|
|
|
$useModel = "NotiziaModel";
|
|
$permissionFlagRequired = AdminModel::ADMIN_TYPE_EDITORE_SUPERVISOR;
|
|
$exposedFields = array(
|
|
"category"=>function ($data){
|
|
if (array_key_exists($data, NotiziaModel::$NOTIZIE_CATEGORY) ){
|
|
return NotiziaModel::$NOTIZIE_CATEGORY[$data]["label"];
|
|
}
|
|
else {
|
|
return "Sconosciuta";
|
|
}
|
|
},
|
|
"titolo"=>function($data){
|
|
$rval = $data;
|
|
if (strlen($rval)>80){
|
|
$rval = substr($rval, 0, 80)."...";
|
|
}
|
|
return $rval;
|
|
},
|
|
"sottotitolo"=>function($data){
|
|
$rval = $data;
|
|
if (strlen($rval)>80){
|
|
$rval = substr($rval, 0, 80)."...";
|
|
}
|
|
return $rval;
|
|
},
|
|
"about"=>array("data"=>null,"author"=>null),
|
|
"id"=>null
|
|
);
|
|
|
|
$filter = array("status"=>NotiziaModel::STATUS_ACCEPTED);
|
|
$categoryPost = PostHandler::get("category");
|
|
if (!is_null($categoryPost) && array_key_exists($categoryPost, NotiziaModel::$NOTIZIE_CATEGORY)){
|
|
$filter["category"] = intval($categoryPost);
|
|
}
|
|
|
|
$ret = DatatablesHelper::getResult($useModel, $permissionFlagRequired, $exposedFields, $filter);
|
|
if (property_exists($ret, "data") && sizeof($ret->data)>0){
|
|
foreach ($ret->data as $key=>$ele ){
|
|
$ret->data[$key]->sottotitolo = iconv('UTF-8', 'UTF-8//IGNORE', html_entity_decode($ret->data[$key]->sottotitolo));
|
|
$ret->data[$key]->titolo = iconv('UTF-8', 'UTF-8//IGNORE', html_entity_decode($ret->data[$key]->titolo));
|
|
}
|
|
}
|
|
echo json_encode($ret);
|
|
|
|
|
|
|
|
?>
|