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

Source for file UserHomepage.php

Documentation is available at UserHomepage.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'homepage di un sito.
  31.  * 
  32.  * @package  MCMS
  33.  * @version  2
  34.  * @author   Silvio Moioli <silvio at moioli dot net>
  35.  */
  36. class UserHomepage extends UserPage
  37. {
  38.     /** @var Homepage l'oggetto corrispondente a questa pagina */
  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 UserHomepage($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.         return $this->homepage->getTitle()." - ".$this->homepage->getSlogan();
  62.     }
  63.     
  64.     /**
  65.      * Ritorna una breve descrizione (solo testo) di questa pagina.
  66.      *
  67.      * @return string una stringa rappresentante la descrizione della pagina
  68.      * @see Compilable
  69.      */
  70.     function getDescription()
  71.     {
  72.         return $this->site->getShortURL().' - '.$this->homepage->getSlogan();
  73.     }
  74.     
  75.     /**
  76.      * Ritorna un array di stringhe XHTML relative al menu (barra di navigazione)
  77.      * di questa pagina.
  78.      *
  79.      * @return array vettore di stringhe XHTML rappresentante il menu della pagina
  80.      * @see Compilable
  81.      */
  82.     function getMenuEntries()
  83.     {
  84.         $categories $this->site->getCategories();
  85.         $listEntries array();
  86.         foreach ($categories as $i{
  87.             $id $i->getID();
  88.             $name $i->getName();
  89.             $desc $i->getDescription();
  90.             $entry a(UserCategory::staticGetFileName($i),
  91.                 $name)." - ".$desc;
  92.             $listEntries[]=$entry;
  93.         }
  94.         $menuEntries array(p("Sezioni del sito:").unorderedList($listEntries));
  95.         return $menuEntries;
  96.     }
  97.     
  98.     /**
  99.      * Ritorna il contenuto (XHTML) del corpo di questa pagina.
  100.      *
  101.      * @return string la stringa XHTML rappresentante il corpo della pagina
  102.      * @see Compilable
  103.      */
  104.     function getContents()
  105.     {
  106.         $site $this->site;
  107.         $siteID $site->getID();
  108.         $homepage $this->homepage;
  109.         $categories $site->getCategories();
  110.  
  111.         $contents $homepage->getContents();
  112.         $contents .= h1("Le notizie");
  113.         //Aggiunge le notizie in prima pagina
  114.         $news $site->getNews();
  115.         $newscount 0;
  116.         foreach ($news as $i{
  117.             //Massimo 5 notizie sulla homepage
  118.             if ($newscount >= 5{
  119.                 $contents .= h2(a(UserNews::staticGetFileName($this->site),
  120.                     "Tutte le notizie..."));
  121.                 break;
  122.             }
  123.             $newscount++;
  124.             $newsTitle $i->getTitle();
  125.             $newsID $i->getID();
  126.             $content $i->getContents().br();
  127.             $author $i->getAuthor();
  128.             $authorString 
  129.     
  130.             $date $i->getDate();
  131.             $contents .= h2(b($newsTitle).br().$date,"notizia$newscount");
  132.             
  133.             //Aggiunge gli articoli correlati
  134.             $correlati $i->getCorrelatedArticles();
  135.             $ncorrelati $i->getCorrelatedArticlesCount();
  136.             if ($ncorrelati>0{
  137.                 $temp "";
  138.                 foreach ($correlati as $correlato{
  139.                     $idCorrelato $correlato->getID();
  140.                     $titoloCorrelato $correlato->getTitle();
  141.                     $temp .= a(UserArticle::staticGetFileName($correlato),
  142.                         $titoloCorrelato);
  143.                     $ncorrelati--;
  144.                     if ($ncorrelati >0{
  145.                         //Ci sono altri articoli, metto una virgola
  146.                         $temp .= ", ";
  147.                     }
  148.                 }
  149.                 $contents .= p("Articoli correlati a questa notizia: ".$temp);
  150.             }
  151.             //Aggiunge il corpo della notizia e la firma dell'autore
  152.             $contents .= p($content).br().getAuthorSignature($author);
  153.         }
  154.  
  155.         return $contents;
  156.     }
  157.     
  158.     /**
  159.      * Ritorna una stringa di parole chiave (solo testo, separate da virgole)
  160.      * di questa pagina.
  161.      *
  162.      * @return string la stringa rappresentante le parole chiave della pagina
  163.      * @see Compilable
  164.      */
  165.     function getKeywords()
  166.     {
  167.         return $this->homepage->getKeywords();
  168.     }
  169.         
  170.     /**
  171.      * Ritorna il nome del file in cui questa pagina deve essere salvata.
  172.      *
  173.      * @return string il nome del file
  174.      * @see Savable
  175.      */
  176.     function getFileName()
  177.     {
  178.         return $this->staticGetFileName($this->site);
  179.     }
  180.     
  181.     /**
  182.      * Versione statica del metodo precedente: ritorna il nome del
  183.      * file in cui questa pagina deve essere salvata.
  184.      *
  185.      * @return string il nome del file
  186.      * @see Savable
  187.      */
  188.     function staticGetFileName($site)
  189.     {
  190.         return "/index".$site->getID().".html";
  191.     }
  192.         
  193.     /**
  194.      * Ritorna il nome del file in cui questa pagina deve essere salvata
  195.      * (versione precedente).
  196.      *
  197.      * @return string il nome del file
  198.      * @see Savable
  199.      */
  200.     function getOldFileName()
  201.     {
  202.         return "index".$this->site->getID().".html";
  203.     }
  204. }
  205. ?>

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