Rework nuove librerie mongo

Signed-off-by: Riccardo Di Dato <r.didato@asdynamics.it>
This commit is contained in:
Riccardo Di Dato
2017-08-17 14:58:02 +02:00
parent 542e94fd4d
commit ec7ebe7974
44 changed files with 403 additions and 238 deletions
+2 -1
View File
@@ -46,7 +46,8 @@ while (is_array($dati) && sizeof($dati)>0){
$notizia->about->author = $admin->nome." ".$admin->cognome;
$notizia->isAnsa = $ele->primaPagina==1;
$notizia->about->data = new MongoDate(strtotime($ele->data));
// $notizia->about->data = new MongoDate(strtotime($ele->data));
$notizia->about->data = new MongoDB\BSON\UTCDateTime(strtotime($ele->data)*1000) ; //New version
$notizia->titolo = $ele->mainTitle;
$notizia->sottotitolo = $ele->secTitle;
+3 -1
View File
@@ -12,9 +12,11 @@ Creation Date: 19/nov/2013
// $dbconn->location = "localhost";
// $dbconn->username = "root";
// $dbconn->password = "root";
// Password mongo produzione: p14n3ll1FDN2
$database = new stdClass();
$database->dbName = "fdn2";
$database->connectionString = null;
$database->connectionString = "mongodb://fdn2:p14n3ll1FDN2@db.ifattidinapoli.it/fdn2";
$currentSystem = new stdClass();
$currentSystem->storageBaseDir = "/home/asdynamics/storage"; // Il path con storage ecc in cui mettere immagini, file temporanei ecc
+16 -8
View File
@@ -127,10 +127,13 @@ class AnalyticsHelper {
public static function countNotiziaImpressions($id, $start = null, $end = null){
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_NOTIZIA,"content.notizia"=>$id);
if (!is_null($start)){
$searchArray["date"]['$gte'] = new MongoDate($start);
// $searchArray["date"]['$gte'] = new MongoDate($start);
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime( $start * 1000 );
}
if (!is_null($end)){
$searchArray["date"]['$lte'] = new MongoDate($end);
// $searchArray["date"]['$lte'] = new MongoDate($end);
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime( $end * 1000 );
}
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
}
@@ -204,10 +207,12 @@ class AnalyticsHelper {
public static function countBannerImpressions($id, $start = null, $end = null){
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_BANNER_IMPRESSION,"content.banner"=>$id);
if (!is_null($start)){
$searchArray["date"]['$gte'] = new MongoDate($start);
// $searchArray["date"]['$gte'] = new MongoDate($start);
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime($start * 1000);
}
if (!is_null($end)){
$searchArray["date"]['$lte'] = new MongoDate($end);
// $searchArray["date"]['$lte'] = new MongoDate($end);
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime($end * 1000);
}
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
}
@@ -267,10 +272,12 @@ class AnalyticsHelper {
public static function countBannerClicks($id, $start = null, $end = null){
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_BANNER_CLICK,"content.banner"=>$id);
if (!is_null($start)){
$searchArray["date"]['$gte'] = new MongoDate($start);
// $searchArray["date"]['$gte'] = new MongoDate($start);
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime($start * 1000);
}
if (!is_null($end)){
$searchArray["date"]['$lte'] = new MongoDate($end);
// $searchArray["date"]['$lte'] = new MongoDate($end);
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime($end * 1000);
}
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
}
@@ -306,11 +313,12 @@ class AnalyticsHelper {
}
}
$baseSearchArray = array("position"=>$position,"end"=>array('$gte'=>new MongoDate(strtotime("tomorrow"))),"categories"=>$category);
// $baseSearchArray = array("position"=>$position,"end"=>array('$gte'=>new MongoDate(strtotime("tomorrow"))),"categories"=>$category);
$baseSearchArray = array("position"=>$position,"end"=>array('$gte'=>new MongoDB\BSON\UTCDateTime( strtotime("tomorrow") * 1000 ) ),"categories"=>$category);
// Prendi il primo dei "mai mostrati oggi" tra quelli non presenti nella pagina
$todayPlusShown = array_merge($idList,$shown);
if (sizeof($todayPlusShown)>0){
$tmp = array_map(function ($id) {return new MongoId($id);}, $todayPlusShown);
$tmp = array_map(function ($id) {return new MongoDB\BSON\ObjectID($id);}, $todayPlusShown);
$tmp = array('_id'=>array('$nin'=>$tmp));
$rval = GlobalVariables::get("dao")->getFirst("BannerModel", array_merge($baseSearchArray, $tmp) );
}
+12 -6
View File
@@ -12,7 +12,8 @@ class PipelineHelper {
'$match'=>array(
'statType'=>StatisticModel::STAT_TYPE_PAGE,
'date'=>array(
'$gte'=>new MongoDate($startDate)
// '$gte'=>new MongoDate($startDate)
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000)
)
)
),
@@ -84,8 +85,10 @@ class PipelineHelper {
'$match'=>array(
'statType'=>StatisticModel::STAT_TYPE_PAGE,
'tdate'=>array(
'$gte'=>new MongoDate($startDate),
'$lte'=>new MongoDate($endDate)
// '$gte'=>new MongoDate($startDate),
// '$lte'=>new MongoDate($endDate)
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000),
'$lte'=>new MongoDB\BSON\UTCDateTime($endDate * 1000)
)
)
),
@@ -146,7 +149,8 @@ class PipelineHelper {
'$match'=>array(
'statType'=>StatisticModel::STAT_TYPE_PAGE,
'date'=>array(
'$gte'=>new MongoDate($startDate)
// '$gte'=>new MongoDate($startDate)
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000)
)
)
),
@@ -212,7 +216,8 @@ class PipelineHelper {
'$match'=>array(
'statType'=>StatisticModel::STAT_TYPE_BANNER_IMPRESSION,
'content.position'=>$position,
'date'=>array( '$gte'=>new MongoDate(strtotime("today")) )
// 'date'=>array( '$gte'=>new MongoDate(strtotime("today")) )
'date'=>array( '$gte'=>new MongoDB\BSON\UTCDateTime(strtotime("today") * 1000) )
)
),
array(
@@ -246,7 +251,8 @@ class PipelineHelper {
'$match'=>array(
'statType'=>StatisticModel::STAT_TYPE_NOTIZIA,
'date'=>array(
'$gte'=>new MongoDate($startDate)
// '$gte'=>new MongoDate($startDate)
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000)
)
)
),
+1 -1
View File
@@ -60,7 +60,7 @@ class RSSHelper {
}
}
echo '<pubDate>'.date(DATE_RFC2822,$notizia->about->data->sec).'</pubDate>',PHP_EOL;
echo '<pubDate>'.date(DATE_RFC2822,$notizia->about->data->toDateTime()->getTimestamp()).'</pubDate>',PHP_EOL;
echo '<guid>'.GUIHandler::getBaseUrl().'articolo_'.$notizia->id.'</guid>',PHP_EOL;
echo '</item>',PHP_EOL;
@@ -4,8 +4,8 @@ Author: Riccardo Di Dato
Creation Date: 23/dic/2015
*/
abstract class DaoSaveableDefaultImplementation implements DaoSaveable {
private $saveableObject;
abstract class DaoSaveableDefaultImplementation implements DaoSaveable, Serializable {
protected $saveableObject;
public function __construct($saveableObject = null){
@@ -20,8 +20,8 @@ abstract class DaoSaveableDefaultImplementation implements DaoSaveable {
if (strcmp($attr,"id")==0){
$attr = "_id";
}
if (!($value instanceof MongoId)){
$value = new MongoId($value);
if (!($value instanceof MongoDB\BSON\ObjectID)){
$value = new MongoDB\BSON\ObjectID($value);
}
}
$this->saveableObject->$attr = $value;
@@ -29,21 +29,15 @@ abstract class DaoSaveableDefaultImplementation implements DaoSaveable {
public function &__get($attr){
$rval = null;
if (strcmp($attr,"id")==0 || strcmp($attr,"_id")==0){
if (strcmp($attr,"id")==0){
$attr = "_id";
}
if ($this->hasProperty($attr)){
$idf = '$id';
$rval = &$this->saveableObject->$attr->$idf;
}
else {
$rval = null;
}
if (strcmp($attr,"id")==0){
$attr = '_id';
}
else {
if ($this->hasProperty($attr)){
$rval = &$this->saveableObject->$attr;
}
if (strcmp($attr,"_id")==0){
$rval = strval($rval);
}
return $rval;
}
@@ -71,7 +65,8 @@ abstract class DaoSaveableDefaultImplementation implements DaoSaveable {
private function toArray($input){
$rval = $input;
if (is_object($rval) ){
if (!($rval instanceof MongoId) && !($rval instanceof MongoDate) ){
// if (!($rval instanceof MongoId) && !($rval instanceof MongoDate) ){
if (!($rval instanceof MongoDB\BSON\ObjectID) && !($rval instanceof MongoDB\BSON\UTCDateTime) ){
$rval = (array)$input;
}
// $rval = (array)$input;
@@ -118,7 +113,8 @@ abstract class DaoSaveableDefaultImplementation implements DaoSaveable {
}
}
else if (is_object($rval)) {
if (!($rval instanceof MongoId) && !($rval instanceof MongoDate)){
// if (!($rval instanceof MongoId) && !($rval instanceof MongoDate)){
if (!($rval instanceof MongoDB\BSON\ObjectID) && !($rval instanceof MongoDB\BSON\UTCDateTime) ){
foreach ( $rval as $key=>$val){
$rval->$key = $this->toObject($val);
}
@@ -127,6 +123,58 @@ abstract class DaoSaveableDefaultImplementation implements DaoSaveable {
return $rval;
}
private function toArrayAndScalars($obj){
$rval = $obj;
if ( ( $rval instanceof MongoDB\BSON\ObjectID ) || ( $rval instanceof MongoDB\BSON\UTCDateTime ) ){
$rval = [
'__fetch' => get_class($rval),
'value' => strval($rval)
];
}
else if ( is_object( $rval ) ){
$rval = (array)($rval);
}
if ( is_array($rval) ) {
foreach ( $rval as $key=>$val ) {
if (!is_scalar($val)){
$rval[$key] = $this->toArrayAndScalars($val);
}
}
}
return $rval;
}
private function fromArrayAndScalars($obj){
$rval = $obj;
if (is_array($obj)){
if (array_key_exists("__fetch", $rval) && array_key_exists("value", $rval) ){
$class = $rval["__fetch"];
$val = $rval["value"];
$rval = new $class($val);
}
else {
foreach ($rval as $key=>$value){
$rval[$key] = $this->fromArrayAndScalars($value);
}
}
}
return $rval;
}
public function serialize(){
return json_encode( $this->toArrayAndScalars( $this->saveableObject ) );
}
public function unserialize($serialized){
$this->updateFromSaveableObj( $this->fromArrayAndScalars( json_decode( $serialized, true ) ) );
}
}
?>
+91 -58
View File
@@ -5,10 +5,20 @@ Creation Date: 22/dic/2015
*/
class GenericDao{
private $mongoObj;
private $database;
/**
* Nome del database
* @var string
*/
private $dbName;
/**
* Contiene il controller del driver mongo
* @var MongoDB\Driver\Manager
*/
private $client;
/**
* La connection string viene passata interamente a MongoClient, richiede formato 'mongo://server:port'.
* host1 e database sono obbligatori
@@ -17,17 +27,13 @@ class GenericDao{
*/
public function __construct($dbName, $connectionString = null){
if (is_null($connectionString)){
$this->mongoObj = new MongoClient();
$this->client = new MongoDB\Driver\Manager();
}
else {
// if (!preg_match("~^mongo[:][/][/]\w+[:].+$~",$connectionString)){
// throw new CoreException("Invalid connectionString parameter passed to 'GenericDao::__construct()' ('".print_r($connectionString,true)."')");
// }
$this->mongoObj = new MongoClient($connectionString);
$this->client = new MongoDB\Driver\Manager($connectionString);
}
$this->dbName = $dbName;
$this->database = $this->mongoObj->$dbName;
}
/**
@@ -48,6 +54,7 @@ class GenericDao{
* @return DaoSaveable[]
*/
public function query($modelClass, array $filter = array(), array $options = array()){
$modelClass = trim($modelClass);
if (!is_null($modelClass)){
if (!is_subclass_of($modelClass, "DaoSaveable", true)){
throw new CoreException("Invalid return class passed to GenericDao::query ($modelClass)");
@@ -55,7 +62,6 @@ class GenericDao{
}
$collectionName = $modelClass::getCollectionName();
$collection = $this->database->$collectionName;
$useFilter = $filter;
@@ -69,20 +75,23 @@ class GenericDao{
}
if (array_key_exists("_id",$useFilter) && is_string($useFilter["_id"])){
$useFilter["_id"] = new MongoId($useFilter["_id"]);
$useFilter["_id"] = new MongoDB\BSON\ObjectID($useFilter["_id"]);
}
$cursor = $collection->find($useFilter);
if (array_key_exists("sort",$options)){
$cursor->sort($options["sort"]);
}
if (array_key_exists("skip",$options)){
$cursor->skip($options["skip"]);
if (array_key_exists("creationDate",$options["sort"]) && !array_key_exists("_id",$options["sort"])){
$options["sort"]["_id"] = $options["sort"]["creationDate"];
}
}
if (array_key_exists("limit",$options)){
$cursor->limit($options["limit"]);
$options["limit"] = intval($options["limit"]);
}
if (array_key_exists("skip",$options)){
$options["skip"] = intval($options["skip"]);
}
$query = new MongoDB\Driver\Query($useFilter, $options);
$cursor = $this->client->executeQuery($this->dbName.".$collectionName",$query);
$rval = array();
foreach ($cursor as $element){
@@ -90,6 +99,7 @@ class GenericDao{
}
return $rval;
}
@@ -101,7 +111,6 @@ class GenericDao{
}
$collectionName = $modelClass::getCollectionName();
$collection = $this->database->$collectionName;
$useFilter = $filter;
@@ -115,13 +124,15 @@ class GenericDao{
}
if (array_key_exists("_id",$useFilter) && is_string($useFilter["_id"])){
$useFilter["_id"] = new MongoId($useFilter["_id"]);
$useFilter["_id"] = new MongoDB\BSON\ObjectID($useFilter["_id"]);
}
$command = new \MongoDB\Driver\Command( [ 'count' => $collectionName, 'query' => $useFilter ] );
$cursor = $this->client->executeCommand( $this->dbName, $command );
$cursor = $collection->find($useFilter);
return $cursor->count(true);
foreach ($cursor as $ele){
return $ele->n;
}
}
/**
@@ -132,13 +143,13 @@ class GenericDao{
* @return DaoSaveable
*/
public function getFirst($modelClass, array $filter = array(), array $options = array()){
$rval = $this->query($modelClass,$filter,$options);
if (sizeof($rval)>0){
$rval = reset($rval);
}
else {
$rval = null;
$options["limit"] = 1;
$rval = null;
$list = $this->query($modelClass, $filter, $options);
if (sizeof($list)>0){
$rval = reset($list);
}
return $rval;
}
@@ -148,18 +159,23 @@ class GenericDao{
*/
public function save(DaoSaveable $model){
$collectionName = $model->getCollectionName();
$collection = $this->database->$collectionName;
$saveObj = $model->getSaveableObj();
$bulk = new MongoDB\Driver\BulkWrite();
if ( array_key_exists("_id", $saveObj) && !is_null($saveObj["_id"]) ){
$collection->update( array("_id"=>$saveObj["_id"] ), $saveObj );
$bulk->update(array("_id"=>$saveObj["_id"] ),$saveObj);
}
else {
$saveObj["_id"] = new MongoId();
$collection->insert($saveObj);
$saveObj["_id"] = new MongoDB\BSON\ObjectID();
$bulk->insert($saveObj);
$model->updateFromSaveableObj($saveObj);
}
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 100);
$result = $this->client->executeBulkWrite($this->dbName.".$collectionName", $bulk, $writeConcern);
//TODO: (Rik) Controllo sul write concern
}
/**
@@ -167,16 +183,8 @@ class GenericDao{
* @param DaoSaveable $model
*/
public function delete(DaoSaveable $model){
$collectionName = $model->getCollectionName();
$collection = $this->database->$collectionName;
$saveObj = $model->getSaveableObj();
if ( array_key_exists("_id", $saveObj) && !is_null($saveObj["_id"]) ){
$saveObj["deleted"] = true;
$collection->update( array("_id"=>$saveObj["_id"] ), $saveObj );
$model->updateFromSaveableObj($saveObj);
}
$model->deleted = true;
$this->save($model);
}
@@ -190,15 +198,15 @@ class GenericDao{
* @return DaoSaveable[]
*/
public function aggregate($modelClass, array $pipeline = array(), array $options = array()){
$modelClass = trim($modelClass);
if (!is_null($modelClass)){
if (!is_subclass_of($modelClass, "DaoSaveable", true)){
throw new CoreException("Invalid return class passed to GenericDao::aggregate ($modelClass)");
}
}
$collectionName = $modelClass::getCollectionName();
$collection = $this->database->$collectionName;
$addDeleteMatch = true;
if (sizeof($pipeline)>0){
foreach ($pipeline as $ele){
@@ -207,7 +215,7 @@ class GenericDao{
if (array_key_exists('$match', $ele) && array_key_exists("deleted", $ele['$match'])){
$addDeleteMatch = false;
}
if (array_key_exists('$groupBy', $ele)){
// Sostituzione di id con _id
foreach ($ele as $key=>$val){
@@ -216,13 +224,13 @@ class GenericDao{
unset($val["id"]);
}
}
// Sostituzione di _id stringa con MongoId
if (array_key_exists("_id",$val) && is_string($val["_id"])){
$val["_id"] = new MongoId($val["_id"]);
$val["_id"] = new MongoDB\BSON\ObjectID( $val["_id"] );
}
}
}
}
}
@@ -230,23 +238,48 @@ class GenericDao{
if ($addDeleteMatch){
if (array_key_exists('$match', $pipeline[0])){
$pipeline[0]['$match']["deleted"] = false;
// array_unshift($pipeline[0]['$match'], array("deleted"=>false));
// array_unshift($pipeline[0]['$match'], array("deleted"=>false));
}
else {
array_unshift($pipeline, array('$match'=>array("deleted"=>false)));
}
}
$rval = array();
$command = new \MongoDB\Driver\Command( [ 'aggregate' => $collectionName, 'pipeline' => $pipeline ] );
$cursor = $this->client->executeCommand( $this->dbName, $command );
$resultArray = $collection->aggregate($pipeline);
if (array_key_exists("result", $resultArray)){
$rval = $resultArray["result"];
$rval = [];
foreach ($cursor as $ele){ // inganniamo il cursore, in realtà il risultato è uno
//TODO CHECK
if (!is_null($ele->result)){
$rval = $ele->result;
$rval = json_decode( json_encode($rval) ,true );
}
}
// var_dump($resultArray);
return $rval;
}
/**
* Ritorna la lista dei notizia model ordinati per pertinenza
* @param string $modelClass
* @param string $searchWord
* @param array $filter
* @param array $options
* @throws CoreException
* @return DaoSaveable[]
*/
public function search($modelClass, $search, array $filter = array(), array $options = array()){
$filter['$text'] = array('$search'=> trim($search) );
return $this->query($modelClass, $filter, $options);
}
public function searchCount($modelClass, $search, array $filter = array(), array $options = array()){
$filter['$text'] = array('$search'=> trim($search) );
return $this->count($modelClass, $filter, $options);
}
/**
* Ritorna la lista dei notizia model ordinati per pertinenza
@@ -257,7 +290,7 @@ class GenericDao{
* @throws CoreException
* @return DaoSaveable[]
*/
public function search($modelClass, $searchWord, array $filter = array(), array $options = array()){
public function searchOld($modelClass, $searchWord, array $filter = array(), array $options = array()){
if (!is_null($modelClass)){
if (!is_subclass_of($modelClass, "DaoSaveable", true)){
throw new CoreException("Invalid return class passed to GenericDao::query ($modelClass)");
@@ -310,8 +343,8 @@ class GenericDao{
}
public function searchCount($modelClass, $searchWord, array $filter = array(), array $options = array()){
if (!is_null($modelClass)){
public function searchCountOld($modelClass, $searchWord, array $filter = array(), array $options = array()){
if (!is_null($modelClass)){
if (!is_subclass_of($modelClass, "DaoSaveable", true)){
throw new CoreException("Invalid return class passed to GenericDao::query ($modelClass)");
}
@@ -13,7 +13,7 @@ class DaoMediaHandler implements MediaHandlerInterface{
$referenceIds = array();
if (sizeof($newsReference)>0){
foreach ($newsReference as $ref){
$referenceIds[] = new MongoId($ref);
$referenceIds[] = new MongoDB\BSON\ObjectID($ref);
}
}
$rval = array();
@@ -178,7 +178,7 @@ class DaoMediaHandler implements MediaHandlerInterface{
$mainMedia = $model->getMainMediaReference();
$tmp = null;
if(!is_null($mainMedia)){
$mainMediaId = new MongoId($mainMedia);
$mainMediaId = new MongoDB\BSON\ObjectID($mainMedia);
$tmp = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$mainMediaId));
}
// var_dump($tmp);
+2 -1
View File
@@ -13,7 +13,8 @@ class AccessModel extends Model {
$requiredProps = array("related");
if (!$this->hasProperty("date")){
$this->date = new MongoDate();
// $this->date = new MongoDate();
$this->date = new MongoDB\BSON\UTCDateTime( time() * 1000 );
}
foreach ($requiredProps as $prop){
+2 -1
View File
@@ -37,7 +37,8 @@ class CommentoModel extends Model{
}
if (!$this->hasProperty("date")){
$this->date = new MongoDate();
// $this->date = new MongoDate();
$this->date = new MongoDB\BSON\UTCDateTime( time() * 1000 );
}
}
+2 -1
View File
@@ -11,7 +11,8 @@ class LogModel extends Model {
parent::__construct($saveableObject);
if (!$this->hasProperty("date")){
$this->date = new MongoDate();
// $this->date = new MongoDate();
$this->date = new MongoDB\BSON\UTCDateTime( time() * 1000 );
}
}
+2 -1
View File
@@ -21,7 +21,8 @@ class MailTemplateModel extends Model{
}
if (!$this->hasProperty("date")){
$this->date = new MongoDate();
// $this->date = new MongoDate();
$this->date = new MongoDB\BSON\UTCDateTime( time() * 1000 );
}
foreach ($requiredProps as $prop){
@@ -22,7 +22,8 @@ class PasswordRecoveryRequestModel extends Model{
}
if (!$this->hasProperty("date")){
$this->date = new MongoDate();
// $this->date = new MongoDate();
$this->date = new MongoDB\BSON\UTCDateTime( time() * 1000 );
}
if (!$this->hasProperty("sent")){
+2 -1
View File
@@ -27,7 +27,8 @@ class StatisticModel extends Model {
$requiredProps = array("user","content","source", "ip", "statType");
if (!$this->hasProperty("date")){
$this->date = new MongoDate();
// $this->date = new MongoDate();
$this->date = new MongoDB\BSON\UTCDateTime( time() * 1000 );
}
foreach ($requiredProps as $prop){
+3 -2
View File
@@ -70,8 +70,9 @@ class DatatablesHelper {
$rval->$key = self::getObjectFromFieldsArray($obj->$key, $val);
}
else {
if ($obj->$key instanceof MongoDate){
$rval->$key = date("d-m-Y H:i",$obj->$key->sec);
if ($obj->$key instanceof MongoDB\BSON\UTCDateTime){
// $rval->$key = date("d-m-Y H:i",$obj->$key->sec);
$rval->$key = date("d-m-Y H:i", $obj->$key->toDateTime()->getTimestamp() );
}
else {
$rval->$key = $obj->$key;
+1 -1
View File
@@ -73,7 +73,7 @@ class CommentoBlock {
$rval.= '<div class="commentoTitolo">'.$this->commento->titolo.'</div>';
$rval.= '<div class="commentoTesto">'.$this->commento->testo.'</div>';
$rval.= '<div class="commentoUser">'.$userString.'</div>';
$rval.= '<div class="commentoDate">'.date("d-m-Y H:i",$this->commento->date->sec).'</div>';
$rval.= '<div class="commentoDate">'.date("d-m-Y H:i",$this->commento->date->toDateTime()->getTimestamp()).'</div>';
$rval.= "</div>";
return $rval;
+12 -4
View File
@@ -391,16 +391,24 @@ class GUIHandler {
// }
$stats = GlobalVariables::get("dao")->aggregate("StatisticModel",PipelineHelper::getMostViewedOfLastDays(strtotime("-7 days"),5));
$idArray = array_map(function ($ele){ return new MongoId($ele["_id"]["notizia"]);}, $stats);
$idArray = array_map(function ($ele){ return new MongoDB\BSON\ObjectID($ele["_id"]["notizia"]);}, $stats);
// $lastsNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$in'=>$idArray),"about.data"=>array('$lte'=>new MongoDate(),'$gte'=>new MongoDate(strtotime('-2 months')))),
// array("sort"=>array("about.data"=>-1))
// );
$lastsNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$in'=>$idArray),"about.data"=>array('$lte'=>new MongoDate(),'$gte'=>new MongoDate(strtotime('-2 months')))),
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$in'=>$idArray),"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ),'$gte'=>new MongoDB\BSON\UTCDateTime( strtotime('-2 months') * 1000 ) )),
array("sort"=>array("about.data"=>-1))
);
if (sizeof($lastsNews)<5){
$missing = 5-sizeof($lastsNews);
// $add = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$nin'=>$idArray),"about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>$missing)
// );
$add = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$nin'=>$idArray),"about.data"=>array('$lte'=>new MongoDate())),
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$nin'=>$idArray),"about.data"=>array( '$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ) ) ),
array("sort"=>array("about.data"=>-1),"limit"=>$missing)
);
$lastsNews = array_merge($lastsNews,$add);
@@ -429,7 +437,7 @@ class GUIHandler {
$i=0;
foreach($lastsNews as $last){
$i++;
$data = $mesi[date("n",$last->about->data->sec)]." ".date("Y",$last->about->data->sec);
$data = $mesi[date("n",$last->about->data->toDateTime()->getTimestamp())]." ".date("Y",$last->about->data->toDateTime()->getTimestamp());
$string = (strlen($last->titolo) > 103) ? substr($last->titolo,0,100).'...' : $last->titolo;?>
<a href="<?php echo $last->getAbsoluteUrl();?>" id="last_<?php echo $i;?>" class="lastContainer">
<div class="lastData"><?php echo $data;?></div>
+2 -2
View File
@@ -402,7 +402,7 @@ class GUIHandlerMobile {
public static function generateRightBannerBlock($category = BannerModel::GENERAL_CATEGORY){
$stats = GlobalVariables::get("dao")->aggregate("StatisticModel",PipelineHelper::getMostViewedOfLastDays(strtotime("-7 days"),5));
$idArray = array_map(function ($ele){ return new MongoId($ele["_id"]["notizia"]);}, $stats);
$idArray = array_map(function ($ele){ return new MongoDB\BSON\ObjectID($ele["_id"]["notizia"]);}, $stats);
$lastsNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$in'=>$idArray)),
@@ -446,7 +446,7 @@ class GUIHandlerMobile {
$i=0;
foreach($lastsNews as $last){
$i++;
$data = $mesi[date("n",$last->about->data->sec)]." ".date("Y",$last->about->data->sec);
$data = $mesi[date("n",$last->about->data->toDateTime()->getTimestamp())]." ".date("Y",$last->about->data->toDateTime()->getTimestamp());
$string = (strlen($last->titolo) > 103) ? substr($last->titolo,0,100).'...' : $last->titolo;?>
<a href="articolo.php?id=<?php echo $last->id;?>" id="last_<?php echo $i;?>" class="lastContainer">
<div class="lastData"><?php echo $data;?></div>
@@ -22,7 +22,8 @@ abstract class LoginManager {
ASDSessionHandler::setSessionValue(static::getSessionVariableName(), $user);
$user->lastConnection = new stdClass();
$user->lastConnection->date = new MongoDate();
// $user->lastConnection->date = new MongoDate();
$user->lastConnection->date = new MongoDB\BSON\UTCDateTime(time()*1000);
$user->lastConnection->ip = $_SERVER['REMOTE_ADDR'];
$dao->save($user);
+16 -36
View File
@@ -17,57 +17,37 @@ require_once(dirname(__FILE__)."/FileLogger.php");
// |_____\___/ \__, |\__, |\___|_| |___/
// |___/ |___/
//
LoggingFacilityManager::addLogger(
"system",
new SyslogLogger("System",$systemCatalogManager,true)
);
$sysLog = new SyslogLogger("System",$systemCatalogManager,true);
LoggingFacilityManager::addLogger( "system", $sysLog );
LoggingFacilityManager::getLogger("system")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
LoggingFacilityManager::addLogger(
"core",
new FileLogger("Core",$systemCatalogManager,$config->files->core_log,true)
);
$coreLog = new FileLogger("Core",$systemCatalogManager,$config->files->core_log,true);
LoggingFacilityManager::addLogger( "core", $coreLog );
LoggingFacilityManager::getLogger("core")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
LoggingFacilityManager::addLogger(
"dao",
new FileLogger("DAO",$systemCatalogManager,$config->files->dao_log,true)
);
$daoLog = new FileLogger("DAO",$systemCatalogManager,$config->files->dao_log,true);
LoggingFacilityManager::addLogger( "dao",$daoLog );
LoggingFacilityManager::getLogger("dao")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
LoggingFacilityManager::addLogger(
"task",
new FileLogger("Task",$systemCatalogManager,$config->files->task_log,true)
);
$taskLog = new FileLogger("Task",$systemCatalogManager,$config->files->task_log,true);
LoggingFacilityManager::addLogger( "task", $taskLog );
LoggingFacilityManager::getLogger("task")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
LoggingFacilityManager::addLogger(
"general",
new FileLogger("General",$systemCatalogManager,$config->files->general_log,true)
);
$generalLog = new FileLogger("General",$systemCatalogManager,$config->files->general_log,true);
LoggingFacilityManager::addLogger( "general", $generalLog );
LoggingFacilityManager::getLogger("general")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
LoggingFacilityManager::addLogger(
"gui",
new FileLogger("GUI",$systemCatalogManager,$config->files->gui_log,true)
);
$guiLog = new FileLogger("GUI",$systemCatalogManager,$config->files->gui_log,true);
LoggingFacilityManager::addLogger( "gui", $guiLog );
LoggingFacilityManager::getLogger("gui")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
LoggingFacilityManager::addLogger(
"mail",
new FileLogger("Mail",$systemCatalogManager,$config->files->mail_log,true)
);
$mailLog = new FileLogger("Mail",$systemCatalogManager,$config->files->mail_log,true);
LoggingFacilityManager::addLogger( "mail", $mailLog );
LoggingFacilityManager::getLogger("mail")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
LoggingFacilityManager::addLogger(
"api",
new FileLogger("API",$systemCatalogManager,$config->files->api_log,true)
);
$apiLog = new FileLogger("API",$systemCatalogManager,$config->files->api_log,true);
LoggingFacilityManager::addLogger( "api", $apiLog );
LoggingFacilityManager::getLogger("api")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
?>
+2 -1
View File
@@ -56,7 +56,8 @@ class FDN_Mailer {
}
else {
$mail->status = MailModel::STATUS_SENT;
$mail->sendDate = new MongoDate();
// $mail->sendDate = new MongoDate();
$mail->sendDate = new MongoDB\BSON\UTCDateTime( time() * 1000 );
}
GlobalVariables::get("dao")->save($mail);
}
@@ -15,7 +15,8 @@ class DeleteOldPasswordResetRequestsTask extends Task {
}
public static function execute(){
$requests = GlobalVariables::get("dao")->query("PasswordRecoveryRequestModel",array("date"=>array( '$lte'=>new MongoDate( strtotime("-10 minutes") ) ) ) ,array("limit"=>10));
// $requests = GlobalVariables::get("dao")->query("PasswordRecoveryRequestModel",array("date"=>array( '$lte'=>new MongoDate( strtotime("-10 minutes") ) ) ) ,array("limit"=>10));
$requests = GlobalVariables::get("dao")->query("PasswordRecoveryRequestModel",array("date"=>array( '$lte'=>new MongoDB\BSON\UTCDateTime( strtotime("-10 minutes") * 1000 ) ) ) ,array("limit"=>10));
if(sizeof($requests)>0){
foreach ($requests as $request){
GlobalVariables::get("dao")->delete($request);
+2 -1
View File
@@ -14,7 +14,8 @@ class NewsletterCheckTask extends Task {
}
public static function execute(){
$mailTemplates = GlobalVariables::get("dao")->query("MailTemplateModel",array("status"=>MailTemplateModel::STATUS_READY,"date"=>array('$lte'=>new MongoDate())));
// $mailTemplates = GlobalVariables::get("dao")->query("MailTemplateModel",array("status"=>MailTemplateModel::STATUS_READY,"date"=>array('$lte'=>new MongoDate())));
$mailTemplates = GlobalVariables::get("dao")->query("MailTemplateModel",array("status"=>MailTemplateModel::STATUS_READY,"date"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))));
if (sizeof($mailTemplates)>0){
foreach ($mailTemplates as $mailTemplate){
FDN_Mailer::generateTemplateQueue($mailTemplate);
+1 -1
View File
@@ -42,7 +42,7 @@ try{
$err = true;
$exc->addMessage("Inserire un nome utente per accedere all'applicazione");
}
if (GlobalVariables::get("dao")->count("AdminModel",array("username"=>$giornalista->username,"id"=>array('$ne'=>new MongoId($giornalista->id) ) ) ) > 0 ){
if (GlobalVariables::get("dao")->count("AdminModel",array("username"=>$giornalista->username,"id"=>array('$ne'=>new MongoDB\BSON\ObjectID($giornalista->id) ) ) ) > 0 ){
$err = true;
$exc->addMessage("Il nome utente '".$giornalista->username."' è già in uso");
}
+2 -2
View File
@@ -63,8 +63,8 @@ try {
<a href="#" id="mailForm_elimina">Elimina</a>
</div>
<div><span class="label"><b>Oggetto</b></span><?php echo $mail->subject; ?> </div>
<div><span class="label"><b>Giorno</b></span><?php echo date("d-m-Y",$mail->date->sec); ?> </div>
<div><span class="label"><b>Ora</b></span><?php echo date("H:i",$mail->date->sec); ?> </div>
<div><span class="label"><b>Giorno</b></span><?php echo date("d-m-Y",$mail->date->toDateTime()->getTimestamp()); ?> </div>
<div><span class="label"><b>Ora</b></span><?php echo date("H:i",$mail->date->toDateTime()->getTimestamp()); ?> </div>
<hr/>
<div><?php echo $mail->body; ?></div>
</div>
+7 -4
View File
@@ -35,8 +35,11 @@ try{
if(array_key_exists("action", $_POST) && strcmp(PostHandler::get("action"), "save")==0){
$banner->customer = PostHandler::get("customer");
$banner->link = PostHandler::get("link");
$banner->start = new Mongodate(strtotime(PostHandler::get("dateStart")));
$banner->end = new Mongodate(strtotime(PostHandler::get("dateEnd")));
// $banner->start = new Mongodate(strtotime(PostHandler::get("dateStart")));
// $banner->end = new Mongodate(strtotime(PostHandler::get("dateEnd")));
$banner->start = new MongoDB\BSON\UTCDateTime( strtotime(PostHandler::get("dateStart")) * 1000 );
$banner->end = new MongoDB\BSON\UTCDateTime( strtotime(PostHandler::get("dateEnd")) * 1000);
if (strcmp("",PostHandler::get("position"))==0){
throw new GUIException("Selezionare una posizione per il banner");
@@ -102,11 +105,11 @@ try{
</div>
<div>
<span class="label">Data inizio:</span>
<input type="text" id="datepickerStart" name="dateStart" value="<?php echo date("d-m-Y",$banner->start->sec);?>">
<input type="text" id="datepickerStart" name="dateStart" value="<?php echo date("d-m-Y",$banner->start->toDateTime()->getTimestamp());?>">
</div>
<div>
<span class="label">Data fine:</span>
<input type="text" id="datepickerEnd" name="dateEnd" value="<?php echo date("d-m-Y",$banner->end->sec);?>">
<input type="text" id="datepickerEnd" name="dateEnd" value="<?php echo date("d-m-Y",$banner->end->toDateTime()->getTimestamp());?>">
</div>
<div><span class="label">&nbsp;</span><b>Categorie</b></div>
<?php
+6 -4
View File
@@ -30,7 +30,8 @@ try {
$tmp->fromName = "I Fatti di Napoli - Newsletter";
$tmp->subject = "";
$tmp->body = "";
$tmp->date = new MongoDate();
// $tmp->date = new MongoDate();
$tmp->date = new MongoDB\BSON\UTCDateTime( time() * 1000 );
$mail = new MailTemplateModel($tmp);
@@ -54,7 +55,8 @@ try {
if(!preg_match("/^[0-9]{2}[-][0-9]{2}[-][0-9]{4} [0-9]{2}[:][0-9]{2}$/", $dateString)){
throw new GUIException("Il formato della data inserita non è corretto. Per favore segui il seguente formato Date: dd-mm-yyyy hh:ii");
}
$tmp->date = new MongoDate(strtotime($dateString));
// $tmp->date = new MongoDate(strtotime($dateString));
$tmp->date = new MongoDB\BSON\UTCDateTime(strtotime($dateString) * 1000);
GlobalVariables::get("dao")->save($mail);
@@ -98,11 +100,11 @@ if (strcmp($mailBody, "")==0){
</div>
<div>
<span class="label">Giorno</span>
<input type="text" id="datepicker" name="data" value="<?php echo ($edit)? date("d-m-Y",$mail->date->sec):date("d-m-Y");?>">
<input type="text" id="datepicker" name="data" value="<?php echo ($edit)? date("d-m-Y",$mail->date->toDateTime()->getTimestamp()):date("d-m-Y");?>">
</div>
<div>
<span class="label">Ora</span>
<input type="text" id="timepicker" name="time" value="<?php echo ($edit)? date("H:i",$mail->date->sec):date("H:i");?>">
<input type="text" id="timepicker" name="time" value="<?php echo ($edit)? date("H:i",$mail->date->toDateTime()->getTimestamp()):date("H:i");?>">
</div>
<div>
<!-- <div style="margin:auto;width:1024px;" contenteditable="true"><?php echo $mailBody;?></div>-->
+6 -4
View File
@@ -19,7 +19,8 @@ try{
$notiziaId = PostHandler::get("id");
$notizia = new NotiziaModel();
$notizia->about->data = new MongoDate();
// $notizia->about->data = new MongoDate();
$notizia->about->data = new MongoDB\BSON\UTCDateTime( time() * 1000 );
// var_dump($notizia);
if(!is_null($notiziaId) && strcmp($notiziaId, "")!=0){
@@ -63,7 +64,8 @@ try{
throw new GUIException("Il formato della data inserita non è corretto. Per favore segui il seguente formato Date: dd-mm-yyyy hh:ii");
}
$mongoDate = new MongoDate(strtotime($dateString));
// $mongoDate = new MongoDate(strtotime($dateString));
$mongoDate = new MongoDB\BSON\UTCDateTime( strtotime($dateString) * 1000);
$notizia->about->data = $mongoDate;
if(!$edit){
@@ -138,8 +140,8 @@ try{
</div>
<div style="text-align:center;">Corpo della notizia</div>
<textarea name="testo" id="editore_testo" rows="10" cols="80"><?php echo $notizia->testo;?></textarea>
<div style="display:inline-block;"><span class="label">Data:</span><input type="text" id="datepicker" name="data" value="<?php echo date("d-m-Y",$notizia->about->data->sec);?>"></div>
<div style="display:inline-block;"><span class="label">Ora:</span><input type="text" id="timepicker" name="time" value="<?php echo date("H:i",$notizia->about->data->sec);?>"></div>
<div style="display:inline-block;"><span class="label">Data:</span><input type="text" id="datepicker" name="data" value="<?php echo date("d-m-Y",$notizia->about->data->toDateTime()->getTimestamp());?>"></div>
<div style="display:inline-block;"><span class="label">Ora:</span><input type="text" id="timepicker" name="time" value="<?php echo date("H:i",$notizia->about->data->toDateTime()->getTimestamp());?>"></div>
<input type="hidden" name="action" value=""/>
</form>
+2 -2
View File
@@ -91,8 +91,8 @@ try{
<div>
<div><span class="label">Cliente</span><?php echo $banner->customer;?></div>
<div><span class="label">Link</span><?php echo $banner->link;?></div>
<div><span class="label">Data Inizio</span><?php echo date("d-m-Y H:i",$banner->start->sec);?></div>
<div><span class="label">Data Fine</span><?php echo date("d-m-Y H:i",$banner->end->sec);?></div>
<div><span class="label">Data Inizio</span><?php echo date("d-m-Y H:i",$banner->start->toDateTime()->getTimestamp());?></div>
<div><span class="label">Data Fine</span><?php echo date("d-m-Y H:i",$banner->end->toDateTime()->getTimestamp());?></div>
<div><span class="label">Posizione</span><?php echo $bannerPositionString;?></div>
<div><span class="label">Tipo</span><?php echo $bannerTypeString;?></div>
</div>
+1 -1
View File
@@ -56,7 +56,7 @@ try {
<a href="#" id="mailForm_annulla">Indietro</a>
</div>
<div><span class="label"><b>Code</b></span><?php echo $logMsg->getCode(); ?> </div>
<div><span class="label"><b>Data</b></span><?php echo date("d-m-Y H:i",$logMsg->date->sec); ?> </div>
<div><span class="label"><b>Data</b></span><?php echo date("d-m-Y H:i",$logMsg->date->toDateTime()->getTimestamp()); ?> </div>
<div><span class="label"><b>Message</b></span><?php echo $logMsg->message; ?> </div>
<div>
<span class="label"><b>Trace</b></span>
+8 -4
View File
@@ -41,8 +41,12 @@ try{
$banner->type=$mediaType;
$banner->customer = PostHandler::get("customer");
$banner->start = new Mongodate(strtotime(PostHandler::get("dateStart")));
$banner->end = new Mongodate(strtotime(PostHandler::get("dateEnd")));
// $banner->start = new Mongodate(strtotime(PostHandler::get("dateStart")));
// $banner->end = new Mongodate(strtotime(PostHandler::get("dateEnd")));
$banner->start = new MongoDB\BSON\UTCDateTime( strtotime(PostHandler::get("dateStart")) * 1000 );
$banner->end = new MongoDB\BSON\UTCDateTime( strtotime(PostHandler::get("dateEnd")) * 1000 );
$banner->link = PostHandler::get("link");
if (strcmp("",PostHandler::get("position"))==0){
@@ -226,11 +230,11 @@ try{
</div>
<div>
<span class="label">Data inizio:</span>
<input type="text" id="datepickerStart" name="dateStart" value="<?php echo ($edit)? date("d-m-Y",$banner->start->sec):date("d-m-Y");?>">
<input type="text" id="datepickerStart" name="dateStart" value="<?php echo ($edit)? date("d-m-Y",$banner->start->toDateTime()->getTimestamp()):date("d-m-Y");?>">
</div>
<div>
<span class="label">Data fine:</span>
<input type="text" id="datepickerEnd" name="dateEnd" value="<?php echo ($edit)? date("d-m-Y",$banner->end->sec):date("d-m-Y");?>">
<input type="text" id="datepickerEnd" name="dateEnd" value="<?php echo ($edit)? date("d-m-Y",$banner->end->toDateTime()->getTimestamp()):date("d-m-Y");?>">
</div>
<?php
echo '<div><span class="label">Generale</span><input type="checkbox" name="categories_'.BannerModel::GENERAL_CATEGORY.'" value="'.BannerModel::GENERAL_CATEGORY.'" '.(in_array(BannerModel::GENERAL_CATEGORY, $banner->categories)?'checked="checked"':"").' /><br/>';
+1 -1
View File
@@ -58,7 +58,7 @@ HTMLHelper::generateAdminHead();
$user = GlobalVariables::get("dao")->getFirst("UserModel",array("id"=>$commento->user));?>
<div class="commentoContainer">
<div style="width:60%; display:inline-block;margin:5px;"><b>Utente:</b><?php echo $user->nome." ".$user->cognome;?></div>
<div style="width:30%;display:inline-block;text-align:right;margin:5px;"><b>Data:</b><?php echo date("d-m-Y H:i",$commento->date->sec);?></div>
<div style="width:30%;display:inline-block;text-align:right;margin:5px;"><b>Data:</b><?php echo date("d-m-Y H:i",$commento->date->toDateTime()->getTimestamp());?></div>
<div style="margin:5px;"><b>Titolo:</b><?php echo $commento->titolo;?></div>
<div style="margin:5px;"><b>Commento:</b><?php echo $commento->testo;?></div>
</div>
+1 -1
View File
@@ -83,7 +83,7 @@ try{
<div class="commentoTitolo"><?php echo $commento->titolo; ?></div>
<div class="commentoTesto"><?php echo $commento->testo; ?></div>
<div class="commentoUser"><?php echo $userString; ?></div>
<div class="commentoDate"><?php echo date("d-m-Y H:i",$commento->date->sec); ?></div>
<div class="commentoDate"><?php echo date("d-m-Y H:i",$commento->date->toDateTime()->getTimestamp()); ?></div>
<div class="buttons">
<a class="green" href="javascript:void();">Accetta</a>
<a class="yellow" href="javascript:void();">Modifica</a>
+14 -6
View File
@@ -46,9 +46,13 @@ try {
// var_dump($skip);
$dateString = $_POST["year"]."-".$_POST["month"]."-".$_POST["day"];
// $notizieDateAll = GlobalVariables::get("dao")->count("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$gt'=>new MongoDate(strtotime($dateString)),
// '$lt'=>new MongoDate(strtotime($dateString." +1 day"))))
// );
$notizieDateAll = GlobalVariables::get("dao")->count("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$gt'=>new MongoDate(strtotime($dateString)),
'$lt'=>new MongoDate(strtotime($dateString." +1 day"))))
array("status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$gt'=>new MongoDB\BSON\UTCDateTime(strtotime($dateString) * 1000 ),
'$lt'=>new MongoDB\BSON\UTCDateTime( strtotime($dateString." +1 day") * 1000 ) ) )
);
if($notizieDateAll>0){
@@ -61,12 +65,16 @@ try {
}
// $notizieDate = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED, "about.data"=>array('$gt'=>new MongoDate(strtotime($dateString)),
// '$lt'=>new MongoDate(strtotime($dateString." +1 day")))),
// array("limit"=>$limit,"skip"=>$skip)
// );
$notizieDate = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED, "about.data"=>array('$gt'=>new MongoDate(strtotime($dateString)),
'$lt'=>new MongoDate(strtotime($dateString." +1 day")))),
array("status"=>NotiziaModel::STATUS_ACCEPTED, "about.data"=>array('$gt'=>new MongoDB\BSON\UTCDateTime( strtotime($dateString) * 1000 ),
'$lt'=>new MongoDB\BSON\UTCDateTime( strtotime( $dateString." +1 day" ) * 1000 ) ) ),
array("limit"=>$limit,"skip"=>$skip)
);
);
if (sizeof($notizieDate)>0){
$found=true;
$notizieDate = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $notizieDate);
+2 -2
View File
@@ -39,7 +39,7 @@ try {
'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);
$data = date("d",$articolo->about->data->toDateTime()->getTimestamp())." ".$mesi[date("n",$articolo->about->data->toDateTime()->getTimestamp())]." ".date("Y",$articolo->about->data->toDateTime()->getTimestamp())." ".date("H:i",$articolo->about->data->toDateTime()->getTimestamp());
$config = GlobalVariables::get("config");
$directLink = $config->pages->remoteLocationPath."articolo_".$articolo->id;
@@ -276,7 +276,7 @@ GUIHandler::generateHtmlHeaders(array("additionalMetadata"=>$additionalHeaders,"
<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 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->toDateTime()->getTimestamp())?></span></div>
</div>
</div>
<?php }
+2 -1
View File
@@ -33,7 +33,8 @@ try{
$category = intval($category);
$notizie = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>$category,"about.data"=>array('$lte'=>new MongoDate())),
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>$category,"about.data"=>array('$lte'=>new MongoDate())),
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>$category,"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>10)
);
+18 -17
View File
@@ -27,12 +27,13 @@ try {
$pageSelected="home";
$ansaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDate())),
// array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDate())),
array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>5));
$ansaIds = array();
if (sizeof($ansaNews)>0){
$ansaIds = array_map(function($ele){return new MongoId($ele->id);}, $ansaNews);
$ansaIds = array_map(function($ele){return new MongoDB\BSON\ObjectID($ele->id);}, $ansaNews);
$ansaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $ansaNews);
}
@@ -41,7 +42,7 @@ try {
$politicaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_POLITICA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>3)
);
if (sizeof($politicaNews)>0){
@@ -50,7 +51,7 @@ try {
$cronacaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CRONACA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>3)
);
if (sizeof($cronacaNews)>0){
@@ -59,7 +60,7 @@ try {
$sportNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SPORT,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>2)
);
if (sizeof($sportNews)>0){
@@ -68,7 +69,7 @@ try {
$culturaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CULTURA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>4)
);
if (sizeof($culturaNews)>0){
@@ -77,7 +78,7 @@ try {
$ristorantiNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_RISTORANTI,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>3)
);
if (sizeof($ristorantiNews)>0){
@@ -85,16 +86,16 @@ try {
}
$stats = GlobalVariables::get("dao")->aggregate("StatisticModel",PipelineHelper::getMostViewedOfLastDays(strtotime("-7 days"),4));
$idArray = array_map(function ($ele){ return new MongoId($ele["_id"]["notizia"]);}, $stats);
$idArray = array_map(function ($ele){ return new MongoDB\BSON\ObjectID( $ele["_id"]["notizia"] ); }, $stats);
$lastsNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$in'=>$idArray),"about.data"=>array('$lte'=>new MongoDate(),'$gte'=>new MongoDate(strtotime('-2 months')))),
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$in'=>$idArray),"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ),'$gte'=>new MongoDB\BSON\UTCDateTime(strtotime('-2 months') * 1000 ))),
array("sort"=>array("about.data"=>-1))
);
if (sizeof($lastsNews)<4){
$missing = 5-sizeof($lastsNews);
$add = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$nin'=>$idArray),"about.data"=>array('$lte'=>new MongoDate())),
array("status"=>NotiziaModel::STATUS_ACCEPTED,"_id"=>array('$nin'=>$idArray),"about.data"=>array('$lte'=>new MongoDBBSONUTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>$missing)
);
$lastsNews = array_merge($lastsNews,$add);
@@ -106,7 +107,7 @@ try {
$gossipNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_GOSSIP,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>1)
);
if (sizeof($gossipNews)>0){
@@ -115,7 +116,7 @@ try {
$professioniNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_MESTIERI,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>1)
);
if (sizeof($professioniNews)>0){
@@ -126,7 +127,7 @@ try {
*/
// $elezioni = GlobalVariables::get("dao")->getFirst("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SPECIALE_ELEZIONI,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// "about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
// array("sort"=>array("about.data"=>-1))
// );
// if (!is_null($elezioni)){
@@ -137,7 +138,7 @@ try {
$lastViaggi = GlobalVariables::get("dao")->getFirst("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_VIAGGI,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1))
);
if (!is_null($lastViaggi)){
@@ -148,7 +149,7 @@ try {
$animalNews = GlobalVariables::get("dao")->getFirst("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_ANIMALI,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1))
);
if (!is_null($animalNews)){
@@ -158,7 +159,7 @@ try {
$saluteNews = GlobalVariables::get("dao")->getFirst("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SALUTE,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1))
);
if (!is_null($saluteNews)){
@@ -384,7 +385,7 @@ catch (Exception $ex){
$i=0;
foreach($lastsNews as $last){
$i++;
$data = $mesi[date("n",$last->about->data->sec)]." ".date("Y",$last->about->data->sec);
$data = $mesi[date("n",$last->about->data->toDateTime()->getTimestamp())]." ".date("Y",$last->about->data->toDateTime()->getTimestamp());
$string = (strlen($last->titolo) > 103) ? substr($last->titolo,0,100).'...' : $last->titolo;?>
<a href="<?php echo $last->getAbsoluteUrl();?>" id="last_<?php echo $i;?>" class="lastContainer">
<div class="lastData"><?php echo $data;?></div>
+15 -5
View File
@@ -46,9 +46,14 @@ try {
// var_dump($skip);
$dateString = $_POST["year"]."-".$_POST["month"]."-".$_POST["day"];
// $notizieDateAll = GlobalVariables::get("dao")->count("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$gt'=>new MongoDate(strtotime($dateString)),
// '$lt'=>new MongoDate(strtotime($dateString." +1 day"))))
// );
$notizieDateAll = GlobalVariables::get("dao")->count("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$gt'=>new MongoDate(strtotime($dateString)),
'$lt'=>new MongoDate(strtotime($dateString." +1 day"))))
array("status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$gt'=>new MongoDB\BSON\UTCDateTime(strtotime($dateString) * 1000),
'$lt'=>new MongoDB\BSON\UTCDateTime(strtotime($dateString." +1 day") * 1000 ) ) )
);
if($notizieDateAll>0){
@@ -61,11 +66,16 @@ try {
}
// $notizieDate = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED, "about.data"=>array('$gt'=>new MongoDate(strtotime($dateString)),
// '$lt'=>new MongoDate(strtotime($dateString." +1 day")))),
// array("limit"=>$limit,"skip"=>$skip)
// );
$notizieDate = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED, "about.data"=>array('$gt'=>new MongoDate(strtotime($dateString)),
'$lt'=>new MongoDate(strtotime($dateString." +1 day")))),
array("status"=>NotiziaModel::STATUS_ACCEPTED, "about.data"=>array('$gt'=>new MongoDB\BSON\UTCDateTime(strtotime($dateString) * 1000),
'$lt'=>new MongoDB\BSON\UTCDateTime( strtotime($dateString." +1 day") * 1000 ) ) ),
array("limit"=>$limit,"skip"=>$skip)
);
);
if (sizeof($notizieDate)>0){
$found=true;
+2 -2
View File
@@ -39,7 +39,7 @@ try {
'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);
$data = date("d",$articolo->about->data->toDateTime()->getTimestamp())." ".$mesi[date("n",$articolo->about->data->toDateTime()->getTimestamp())]." ".date("Y",$articolo->about->data->toDateTime()->getTimestamp())." ".date("H:i",$articolo->about->data->toDateTime()->getTimestamp());
$config = GlobalVariables::get("config");
$directLink = $config->pages->remoteLocationPath."articolo_".$articolo->id;
@@ -228,7 +228,7 @@ GUIHandlerMobile::generateHtmlHeaders(array("additionalMetadata"=>$additionalHea
<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 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->toDateTime()->getTimestamp())?></span></div>
</div>
</div>
<?php }
+7 -2
View File
@@ -30,10 +30,15 @@ try{
$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)
// );
$notizie = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>$category,"about.data"=>array('$lte'=>new MongoDate())),
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>$category,"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
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);
+48 -16
View File
@@ -26,69 +26,101 @@ try {
// $day = date("d");
$pageSelected="home";
// $ansaNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4));
$ansaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDate())),
array("sort"=>array("about.data"=>-1),"limit"=>4));
array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>4));
$ansaIds = array();
if (sizeof($ansaNews)>0){
$ansaIds = array_map(function($ele){return new MongoId($ele->id);}, $ansaNews);
$ansaIds = array_map(function($ele){return new MongoDB\BSON\ObjectID($ele->id);}, $ansaNews);
$ansaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $ansaNews);
}
// $politicaNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_POLITICA,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$politicaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_POLITICA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
array("sort"=>array("about.data"=>-1),"limit"=>4)
);
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_POLITICA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>4)
);
if (sizeof($politicaNews)>0){
$politicaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $politicaNews);
}
// $cronacaNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CRONACA,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$cronacaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CRONACA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>4)
);
);
if (sizeof($cronacaNews)>0){
$cronacaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $cronacaNews);
}
// $sportNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SPORT,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$sportNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SPORT,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>4)
);
);
if (sizeof($sportNews)>0){
$sportNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $sportNews);
}
// $culturaNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CULTURA,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$culturaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CULTURA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>4)
);
if (sizeof($culturaNews)>0){
$culturaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $culturaNews);
}
// $foodNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_RISTORANTI,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$foodNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_RISTORANTI,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>4)
);
if (sizeof($foodNews)>0){
$foodNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $foodNews);
}
// $professioniNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_MESTIERI,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$professioniNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_MESTIERI,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())),
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>4)
);
);
if (sizeof($professioniNews)>0){
$professioniNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $professioniNews);
}
+1 -1
View File
@@ -22,7 +22,7 @@ try {
'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);
$data = date("d",$articolo->about->data->toDateTime()->getTimestamp())." ".$mesi[date("n",$articolo->about->data->toDateTime()->getTimestamp())]." ".date("Y",$articolo->about->data->toDateTime()->getTimestamp());
$mediaMetaInfo = '';
if ($media->mediaType == MediaModel::TYPE_LOCALVIDEO || $media->mediaType == MediaModel::TYPE_YOUTUBE){
+11 -11
View File
@@ -11,12 +11,12 @@ try {
$notizie = GlobalVariables::get("dao")->query("NotiziaModel",
array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDate())),
array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.data"=>-1),"limit"=>5));
$ansaIds = array();
if (sizeof($notizie)>0){
$ansaIds = array_map(function($ele){return new MongoId($ele->id);}, $notizie);
$ansaIds = array_map(function($ele){return new MongoDB\BSON\ObjectID($ele->id);}, $notizie);
}
$notizie = array_merge( $notizie, GlobalVariables::get("dao")->query("NotiziaModel",
@@ -24,7 +24,7 @@ try {
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_POLITICA,
'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>3)
) );
@@ -35,7 +35,7 @@ try {
array(
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_CRONACA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>3)
) );
@@ -45,7 +45,7 @@ try {
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_SPORT,
'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>2)
) );
@@ -54,7 +54,7 @@ try {
array(
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_CULTURA,'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>4)
) );
@@ -64,7 +64,7 @@ try {
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_RISTORANTI,
'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>3)
) );
@@ -74,7 +74,7 @@ try {
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_GOSSIP,
'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>2)
) );
@@ -84,7 +84,7 @@ try {
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_VIAGGI,
'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>1)
) );
@@ -94,7 +94,7 @@ try {
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_ANIMALI,
'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>1)
) );
@@ -104,7 +104,7 @@ try {
"status"=>NotiziaModel::STATUS_ACCEPTED,
"category"=>NotiziaModel::CATEGORY_SALUTE,
'_id'=>array('$nin'=>$ansaIds),
"about.data"=>array('$lte'=>new MongoDate())
"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))
),
array("sort"=>array("about.data"=>-1),"limit"=>1)
) );
+1 -1
View File
@@ -45,7 +45,7 @@ foreach(NotiziaModel::$NOTIZIE_CATEGORY as $category=>$data){
}
$latestArticles = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDate())),
array("status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ) )),
array("sort"=>array("about.data"=>-1),"limit"=>1000)
);