MCMS
[ class tree: MCMS ] [ index: MCMS ] [ all elements ]

Source for file UserNews.php

Documentation is available at UserNews.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | MCMS: a PHP Content Management System for creating accessible sites. |
  5. // | Copyright (C) 2005  Silvio Moioli                                    |
  6. // |                                                                      |
  7. // | This program is free software; you can redistribute it and/or modify |
  8. // | it under the terms of the GNU General Public License as published by |
  9. // | the Free Software Foundation; either version 2 of the License, or    |
  10. // | (at your option) any later version.                                  |
  11. // |                                                                      |
  12. // | This program is distributed in the hope that it will be useful,      |
  13. // | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  14. // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
  15. // | GNU General Public License for more details.                         |
  16. // |                                                                      |
  17. // | You should have received a copy of the GNU General Public License    |
  18. // | along with this program; if not, write to the Free Software          |
  19. // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 |
  20. // +----------------------------------------------------------------------+
  21. // | Authors: Silvio Moioli <silvio at moioli dot net> www.moioli.net     |
  22. // +----------------------------------------------------------------------+
  23. //
  24. //$Id:
  25.  
  26. require_once $_SERVER["DOCUMENT_ROOT"]."/admin/lib/view/UserPage.php";
  27. require_once $_SERVER["DOCUMENT_ROOT"]."/admin/lib/view/Tagger.php";
  28.  
  29. /**
  30.  * Rappresenta l'elenco completo delle notizie di un sito.
  31.  * 
  32.  * @package  MCMS
  33.  * @version  2
  34.  * @author   Silvio Moioli <silvio at moioli dot net>
  35.  */
  36. class UserNews extends UserPage
  37. {
  38.     /** @var Homepage l'oggetto corrispondente alla home del sito */
  39.     var $homepage = null;
  40.           
  41.     /**
  42.      * Costruttore standard
  43.      *
  44.      * @param Site $site il sito a cui questa pagina appartiene
  45.      * @see AdminPage
  46.      */
  47.     function UserNews($site)
  48.     {
  49.         parent::UserPage($site);
  50.         $this->homepage=$site->getHomepage();
  51.     }
  52.     
  53.     /**
  54.      * Ritorna il titolo (in XHTML) di questa pagina.
  55.      *
  56.      * @return string una stringa XHTML rappresentante il titolo della pagina
  57.      * @see Compilable
  58.      */
  59.     function getTitle()
  60.     {
  61.         $siteID $this->site->getID();
  62.         return a(UserHomepage::staticGetFileName($this->site),
  63.             $this->homepage->getTitle())." > Elenco completo delle notizie";
  64.     }
  65.     
  66.     /**
  67.      * Ritorna una breve descrizione (solo testo) di questa pagina.
  68.      *
  69.      * @return string una stringa rappresentante la descrizione della pagina
  70.      * @see Compilable
  71.      */
  72.     function getDescription()
  73.     {
  74.         return "Notizie del sito ".$this->site->getShortURL();
  75.     }
  76.     
  77.     /**
  78.      * Ritorna un array di stringhe XHTML relative al menu (barra di navigazione)
  79.      * di questa pagina.
  80.      *
  81.      * @return array vettore di stringhe XHTML rappresentante il menu della pagina
  82.      * @see Compilable
  83.      */
  84.     function getMenuEntries()
  85.     {
  86.         return array(p("Torna alla ".a(
  87.             UserHomepage::staticGetFileName($this->site),"homepage")));
  88.     }
  89.     
  90.     /**
  91.      * Ritorna il contenuto (XHTML) del corpo di questa pagina.
  92.      *
  93.      * @return string la stringa XHTML rappresentante il corpo della pagina
  94.      * @see Compilable
  95.      */
  96.     function getContents()
  97.     {
  98.         $site $this->site;
  99.         $siteID $site->getID();
  100.         $homepage $site->getHomepage();
  101.         $categories $site->getCategories();
  102.     
  103.         $contents h1("Torna alla ".a(
  104.             UserHomepage::staticGetFileName($this->site),"homepage di ".
  105.             $homepage->getTitle()));
  106.     
  107.         //Aggiunge tutte le notizie
  108.         $news $site->getNews();
  109.         $newscount 0;
  110.         foreach ($news as $i{
  111.             $newsTitle $i->getTitle();
  112.             $newsID $i->getID();
  113.             $content $i->getContents();
  114.             $author $i->getAuthor();
  115.             $authorString getAuthorSignature($author);
  116.             $date $i->getDate();
  117.             $contents .= h2("$date - $newsTitle","notizia$newsID");
  118.        
  119.             //Aggiunge gli articoli correlati
  120.             $correlati $i->getCorrelatedArticles();
  121.             $ncorrelati count($correlati);
  122.             if ($ncorrelati>0{
  123.                 $temp "";
  124.                 foreach ($correlati as $correlato{
  125.                     $idCorrelato $correlato->getID();
  126.                     $titleCorrelato $correlato->getTitle();
  127.                     $temp .= a(UserArticle::staticGetFileName($correlato),
  128.                         $titleCorrelato).br();
  129.                     $ncorrelati--;
  130.                 }
  131.                 $contents .= p("Articoli correlati a questa notizia$temp");
  132.             }
  133.             
  134.             //Aggiunge i contenuti
  135.             $contents .= p($content.br().$authorString);
  136.         }
  137.  
  138.  
  139.         return $contents;
  140.     }
  141.     
  142.     /**
  143.      * Ritorna una stringa di parole chiave (solo testo, separate da virgole)
  144.      * di questa pagina.
  145.      *
  146.      * @return string la stringa rappresentante le parole chiave della pagina
  147.      * @see Compilable
  148.      */
  149.     function getKeywords()
  150.     {
  151.         $home $this->site->getHomepage()
  152.         return $home->getKeywords();
  153.     }
  154.     
  155.     /**
  156.      * Ritorna il nome del file in cui questa pagina deve essere salvata.
  157.      *
  158.      * @return string il nome del file
  159.      * @see Savable
  160.      */
  161.     function getFileName()
  162.     {
  163.         return $this->staticGetFileName($this->site);
  164.     }
  165.     
  166.     /**
  167.      * Versione statica del metodo precedente: ritorna il nome del
  168.      * file in cui questa pagina deve essere salvata.
  169.      *
  170.      * @return string il nome del file
  171.      * @see Savable
  172.      */
  173.     function staticGetFileName($site)
  174.     {
  175.         return "/notizie___".$site->getID().".html";
  176.     }
  177.     
  178.     /**
  179.      * Ritorna il nome del file in cui questa pagina deve essere salvata
  180.      * (versione precedente).
  181.      *
  182.      * @return string il nome del file
  183.      * @see Savable
  184.      */
  185.     function getOldFileName()
  186.     {
  187.         return "news".$this->site->getID().".html";
  188.     }
  189. }
  190. ?>

Documentation generated on Wed, 26 Jul 2006 21:45:00 +0200 by phpDocumentor 1.3.0RC6