109 lines
5.1 KiB
PHP
109 lines
5.1 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 07/gen/2016
|
|
*/
|
|
|
|
/**
|
|
* Campi:
|
|
* titolo
|
|
* sottotitolo
|
|
* testo
|
|
* about {
|
|
* author
|
|
* data
|
|
* }
|
|
* @author rik
|
|
*
|
|
*/
|
|
class NotiziaModel extends HasMediaModel{
|
|
const STATUS_PENDING = 1;
|
|
const STATUS_ACCEPTED = 2;
|
|
const STATUS_REJECTED = 3;
|
|
|
|
public static $NOTIZIA_STATUS = array(
|
|
self::STATUS_PENDING=>array("label"=>"Valutazione"),
|
|
self::STATUS_ACCEPTED=>array("label"=>"Accettata"),
|
|
self::STATUS_REJECTED=>array("label"=>"Respinta")
|
|
);
|
|
|
|
const CATEGORY_POLITICA = 1;
|
|
const CATEGORY_CRONACA = 2;
|
|
const CATEGORY_SPORT = 3;
|
|
const CATEGORY_CULTURA = 4;
|
|
const CATEGORY_GOSSIP = 5;
|
|
const CATEGORY_ANIMALI = 6;
|
|
const CATEGORY_VIAGGI = 7;
|
|
const CATEGORY_RISTORANTI = 8;
|
|
const CATEGORY_MESTIERI = 9;
|
|
const CATEGORY_CASA = 10;
|
|
const CATEGORY_SALUTE = 11;
|
|
const CATEGORY_ANNUNCI = 12;
|
|
const CATEGORY_FISCOELAVORO = 13;
|
|
const CATEGORY_RUBRICHE = 14;
|
|
const CATEGORY_SPECIALE_ELEZIONI = 15;
|
|
const CATEGORY_SMARRITI = 16;
|
|
const CATEGORY_RITROVATI = 17;
|
|
const CATEGORY_CONSIGLI_ESPERTI = 18;
|
|
|
|
public static $NOTIZIE_CATEGORY = array(
|
|
self::CATEGORY_POLITICA=>array("label"=>"Politica","mainMenu"=>true,"hidden"=>false,"pages"=>array("list"=>"politica.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_CRONACA=>array("label"=>"Cronaca","mainMenu"=>true, "hidden"=>false,"pages"=>array("list"=>"cronaca.php"),"color"=>"red","isSubmenu"=>null),
|
|
self::CATEGORY_SPORT=>array("label"=>"Sport","mainMenu"=>true, "hidden"=>false,"pages"=>array("list"=>"sport.php"),"color"=>"#4f8f2f","isSubmenu"=>null),
|
|
self::CATEGORY_CULTURA=>array("label"=>"Cultura&Spettacolo","mainMenu"=>true, "hidden"=>false,"pages"=>array("list"=>"cultura.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_GOSSIP=>array("label"=>"Gossip","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"gossip.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_ANIMALI=>array("label"=>"Mondo Animale","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"animali.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_VIAGGI=>array("label"=>"Viaggi","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"viaggi.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_RISTORANTI=>array("label"=>"Food&Drink","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"ristoranti.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_MESTIERI=>array("label"=>"Professioni e Mestieri","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"mestieri.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_CASA=>array("label"=>"Casa","mainMenu"=>false, "hidden"=>true,"pages"=>array("list"=>"casa.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_SALUTE=>array("label"=>"Salute","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"salute.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_ANNUNCI=>array("label"=>"Annunci","mainMenu"=>false, "hidden"=>true,"pages"=>array("list"=>"annunci.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_FISCOELAVORO=>array("label"=>"Fisco e Lavoro","mainMenu"=>false, "hidden"=>true,"pages"=>array("list"=>"fiscoelavoro.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_RUBRICHE=>array("label"=>"Rubriche","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"rubriche.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_SPECIALE_ELEZIONI=>array("label"=>"Speciale Elezioni","mainMenu"=>false, "hidden"=>true,"pages"=>array("list"=>"specialeElezioni.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
self::CATEGORY_SMARRITI=>array("label"=>"Smarriti","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"animaliSmarriti.php"),"color"=>"#3e3e3e","isSubmenu"=>self::CATEGORY_ANIMALI),
|
|
self::CATEGORY_RITROVATI=>array("label"=>"Ritrovati","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"animaliRitrovati.php"),"color"=>"#3e3e3e","isSubmenu"=>self::CATEGORY_ANIMALI),
|
|
self::CATEGORY_CONSIGLI_ESPERTI=>array("label"=>"I consigli degli esperti","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"consigliEsperti.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
|
|
);
|
|
|
|
public static function getCollectionName(){
|
|
return "notizia";
|
|
}
|
|
|
|
public function __set($attr,$value){
|
|
if (strcmp("category", $attr)==0 || strcmp("status", $attr)==0){
|
|
$value = intval($value);
|
|
}
|
|
return parent::__set($attr, $value);
|
|
}
|
|
|
|
public function buildAutoShortenedUrl(){
|
|
$shortened = strtolower($this->titolo);
|
|
$shortened = preg_replace("/[^a-z0-9-_]/", " ", $shortened);
|
|
$shortened = preg_replace("/\s+/", " ", trim($shortened) );
|
|
$eles = explode(" ", $shortened);
|
|
$eles = array_slice($eles, 0, 15);
|
|
$this->shortenedUrl = implode("_", $eles);
|
|
}
|
|
|
|
public function getAbsoluteUrl(){
|
|
$link = "articolo_".strval($this->id);
|
|
if ($this->hasProperty("shortenedUrl")){
|
|
$link = "art_".$this->shortenedUrl.".html";
|
|
}
|
|
|
|
GUIHandler::getBaseUrl().$link;
|
|
}
|
|
public function getAbsoluteMobileUrl(){
|
|
$link = "articolo_".strval($this->id);
|
|
if ($this->hasProperty("shortenedUrl")){
|
|
$link = "art_".$this->shortenedUrl;
|
|
}
|
|
|
|
GUIHandlerMobile::getBaseUrl().$link;
|
|
}
|
|
}
|
|
|
|
?>
|