From fee733f823b5c264ac4e69c1aaeeb18054ac8dd8 Mon Sep 17 00:00:00 2001 From: Lorenzo Giacomelli Date: Wed, 27 Jan 2016 17:53:35 +0100 Subject: [PATCH] Aggiunta memo per la creazione di notizie media e renderer; Aggiunto sistema di visualizzazione commenti legati alla notizia; Creato model per commenti; --- oth/docs/memo/commentiCollection.txt | 1 + oth/docs/memo/mediaCollection.txt | 6 +- oth/docs/memo/mediaRenderer.txt | 3 + oth/docs/memo/notiziaCollection.txt | 15 ++++- private/lib/dao/lib.inclusion.php | 2 + private/lib/dao/models/CommentiModel.php | 28 ++++++++ private/lib/dao/models/NotiziaModel.php | 16 +++++ public/admin/editNotizie.php | 16 ++++- public/admin/homeNotizie.php | 24 +++---- public/admin/notiziaCommentiList.php | 84 ++++++++++++++++++++++++ public/style/admin.css | 15 ++++- 11 files changed, 193 insertions(+), 17 deletions(-) create mode 100644 oth/docs/memo/commentiCollection.txt create mode 100644 oth/docs/memo/mediaRenderer.txt create mode 100644 private/lib/dao/models/CommentiModel.php create mode 100644 public/admin/notiziaCommentiList.php diff --git a/oth/docs/memo/commentiCollection.txt b/oth/docs/memo/commentiCollection.txt new file mode 100644 index 0000000..1cbd4f8 --- /dev/null +++ b/oth/docs/memo/commentiCollection.txt @@ -0,0 +1 @@ +commenti{notizia,status} \ No newline at end of file diff --git a/oth/docs/memo/mediaCollection.txt b/oth/docs/memo/mediaCollection.txt index f411310..b28b04f 100644 --- a/oth/docs/memo/mediaCollection.txt +++ b/oth/docs/memo/mediaCollection.txt @@ -1,3 +1,3 @@ -MediaLocalVideo,MediaImage,Mediapdf {path} -MediaYoutube {link} -MediaHtml5 {code} \ No newline at end of file + + + diff --git a/oth/docs/memo/mediaRenderer.txt b/oth/docs/memo/mediaRenderer.txt new file mode 100644 index 0000000..f411310 --- /dev/null +++ b/oth/docs/memo/mediaRenderer.txt @@ -0,0 +1,3 @@ +MediaLocalVideo,MediaImage,Mediapdf {path} +MediaYoutube {link} +MediaHtml5 {code} \ No newline at end of file diff --git a/oth/docs/memo/notiziaCollection.txt b/oth/docs/memo/notiziaCollection.txt index 1ccebe8..db0c8f7 100644 --- a/oth/docs/memo/notiziaCollection.txt +++ b/oth/docs/memo/notiziaCollection.txt @@ -2,9 +2,22 @@ "titolo":"", "sottotitolo":"", "testo":"", + "category":"", "isAnsa":false, "about":{ "author":"", - "date":"" + "date":"", + "owner":"" + } + "mediaReference" = array(), + "deleted" : false, + "mainMedia":null, + "sondaggio":{ + "titolo":"fgsgfsd", + "voci":[ + {"nome":"Mi Piace", "voti":6}, + {"nome":"Non mi piace","voti":2} + ], + "votanti":["asndijansidj","sadmas","asdas"] } } \ No newline at end of file diff --git a/private/lib/dao/lib.inclusion.php b/private/lib/dao/lib.inclusion.php index 5e0e0c7..1922768 100644 --- a/private/lib/dao/lib.inclusion.php +++ b/private/lib/dao/lib.inclusion.php @@ -24,6 +24,8 @@ require_once(dirname(__FILE__)."/models/NotiziaModel.php"); require_once(dirname(__FILE__)."/models/AdminModel.php"); require_once(dirname(__FILE__)."/models/UserModel.php"); +require_once(dirname(__FILE__)."/models/CommentiModel.php"); + require_once(dirname(__FILE__)."/models/MailModel.php"); require_once(dirname(__FILE__)."/models/MailTemplateModel.php"); diff --git a/private/lib/dao/models/CommentiModel.php b/private/lib/dao/models/CommentiModel.php new file mode 100644 index 0000000..dabf013 --- /dev/null +++ b/private/lib/dao/models/CommentiModel.php @@ -0,0 +1,28 @@ +hasProperty("notizia") || strcmp($this->notizia,"")==0){ + throw new CoreException("Impossible to build CommentiModel without field notizia"); + } + + if (!$this->hasProperty("date")){ + $this->date = new MongoDate(); + } + + } + + public static function getCollectionName(){ + return "commenti"; + } +} +?> \ No newline at end of file diff --git a/private/lib/dao/models/NotiziaModel.php b/private/lib/dao/models/NotiziaModel.php index 2480ed7..e024a63 100644 --- a/private/lib/dao/models/NotiziaModel.php +++ b/private/lib/dao/models/NotiziaModel.php @@ -27,6 +27,22 @@ class NotiziaModel extends HasMediaModel{ 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; + + public static $NOTIZIE_CATEGORY = array( + self::CATEGORY_POLITICA=>array("label"=>"Politica","mainMenu"=>true), + self::CATEGORY_CRONACA=>array("label"=>"Cronaca","mainMenu"=>true), + self::CATEGORY_SPORT=>array("label"=>"Sport","mainMenu"=>true), + self::CATEGORY_CULTURA=>array("label"=>"Cultura","mainMenu"=>true), + self::CATEGORY_GOSSIP=>array("label"=>"Gossip","mainMenu"=>true), + self::CATEGORY_ANIMALI=>array("label"=>"Mondo Animale","mainMenu"=>false) + ); + public static function getCollectionName(){ return "notizia"; } diff --git a/public/admin/editNotizie.php b/public/admin/editNotizie.php index 7123e5a..275cae3 100644 --- a/public/admin/editNotizie.php +++ b/public/admin/editNotizie.php @@ -51,6 +51,7 @@ try{ $notizia->titolo = PostHandler::get("titolo"); $notizia->sottotitolo = PostHandler::get("sottotitolo"); $notizia->testo = PostHandler::get("testo"); + $notizia->category = PostHandler::get("category"); if(strcmp(PostHandler::get("author"), "")==0){ $notizia->about->author = AdminLoginManager::getLogged()->nome." ".AdminLoginManager::getLogged()->cognome; } @@ -107,6 +108,20 @@ try{
Sottotitolo:
+
+ +
Data: about->data->sec):date("d-m-Y");?>">
@@ -118,7 +133,6 @@ try{ Submit - \ No newline at end of file diff --git a/public/admin/notiziaCommentiList.php b/public/admin/notiziaCommentiList.php new file mode 100644 index 0000000..60a7a4c --- /dev/null +++ b/public/admin/notiziaCommentiList.php @@ -0,0 +1,84 @@ +hasRole(AdminModel::ADMIN_TYPE_EDITORE_SUPERVISOR)){ + GUIHandler::redirect("admin/index.php"); +} + +try{ + $error = ""; + $notiziaId = PostHandler::get("id"); + + if(!is_null($notiziaId) && strcmp($notiziaId, "")!=0){ +// $std = new stdClass(); + +// $std->user = "569ce4f71991f75342f29e5f"; +// $std->notizia = $notiziaId; +// $std->titolo = "Commento nuovo"; +// $std->testo = "Nuono commento dove prima non ve ne erano, orsù tutti a commentareeeeeeeeeeeeeeeeeeee!!!!!!!!!!!!!!!!!!!!!!!!1"; +// $std->status = "accettato"; +// $comm = new CommentiModel($std); +// GlobalVariables::get("dao")->save($comm); + + + $commenti = GlobalVariables::get("dao")->query("CommentiModel", + array('$and'=>array(array("notizia"=>$notiziaId),array("status"=>"accettato"))), + array("sort"=>array("date"=>-1)) + ); + + } + +}catch(GUIException $ex){ + $error = $ex->getMessage(); +}catch (Exception $exec){ + $msg = LogModel::fromException($exec); + GlobalVariables::get("dao")->save($msg); + $error = "Si è verificato un errore inatteso durante l'esecuzione della pagina. Contattare il supporto tecnico comunicando il seguente codice di erore '".$msg->getCode()."'"; + +// LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage()); +// $error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico."; +} + +MenuGenerator::generateMenu(); +HTMLHelper::generateAdminHead(); +?> + +
+
+
+ 0){ + foreach($commenti as $commento){ + $user = GlobalVariables::get("dao")->getFirst("UserModel",array("id"=>$commento->user));?> +
+
Utente:nome." ".$user->cognome;?>
+
Data:date->sec);?>
+
Titolo:titolo;?>
+
Commento:testo;?>
+
+ + + + + +
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/public/style/admin.css b/public/style/admin.css index eae52f7..b86c97e 100644 --- a/public/style/admin.css +++ b/public/style/admin.css @@ -48,7 +48,7 @@ div.formBtns a:hover{background-color:rgb(204, 217, 255);} */ -.notiziaContainer{margin-right:255px;background-color:#f2f2f2;overflow:auto;} +.notiziaContainer{margin-right:280px;background-color:#f2f2f2;overflow:auto;} .notiziaContainer h1,.notiziaContainer h2,.notiziaContainer h3{padding:10px;} .notiziaMenu{display:inline-block;background-color:#33ccff;position:absolute; width:250px;right:20px;top:20px;} .notiziaMenu a{text-decoration:none;color:black;cursor:pointer;} @@ -63,3 +63,16 @@ div.formBtns a:hover{background-color:rgb(204, 217, 255);} */ .mediaElement.selected > img{opacity:0.4;} + +/* + ____ _ _ + / ___|___ _ __ ___ _ __ ___ ___ _ __ | |_(_) +| | / _ \| '_ ` _ \| '_ ` _ \ / _ \ '_ \| __| | +| |__| (_) | | | | | | | | | | | __/ | | | |_| | + \____\___/|_| |_| |_|_| |_| |_|\___|_| |_|\__|_| + +*/ + +.commentoContainer{border:2px solid black; border-left:0px; border-right:0px; border-top:0px; padding: 5px; margin: 15px 5px} + +