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

Source for file UserArticle.php

Documentation is available at UserArticle.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 un articolo di un sito.
  31.  * 
  32.  * @package  MCMS
  33.  * @version  2
  34.  * @author   Silvio Moioli <silvio at moioli dot net>
  35.  */
  36. class UserArticle extends UserPage
  37. {
  38.     /** @var Homepage l'oggetto corrispondente alla home del sito */
  39.     var $homepage = null;
  40.     /** @var Article l'oggetto corrispondente a questa pagina */
  41.     var $article = null;
  42.           
  43.     /**
  44.      * Costruttore standard
  45.      *
  46.      * @param Site $site il sito a cui questa pagina appartiene
  47.      * @param Article $article l'oggetto corrispondente a questa pagina
  48.      * @see AdminPage
  49.      */
  50.     function UserArticle($site$article)
  51.     {
  52.         parent::UserPage($site);
  53.         $this->article = $article;
  54.         $this->homepage = $site->getHomepage();
  55.     }
  56.     
  57.     /**
  58.      * Ritorna il titolo (in XHTML) di questa pagina.
  59.      *
  60.      * @return string una stringa XHTML rappresentante il titolo della pagina
  61.      * @see Compilable
  62.      */
  63.     function getTitle()
  64.     {
  65.         $category $this->article->getCategory();
  66.         
  67.         return a(UserHomepage::staticGetFileName($this->site),
  68.             $this->homepage->getTitle())." > ".
  69.             a(UserCategory::staticGetFileName($category),
  70.             $category->getName()).
  71.             " > ".$this->article->getTitle();
  72.     }
  73.     
  74.     /**
  75.      * Ritorna una breve descrizione (solo testo) di questa pagina.
  76.      *
  77.      * @return string una stringa rappresentante la descrizione della pagina
  78.      * @see Compilable
  79.      */
  80.     function getDescription()
  81.     {
  82.         return $this->article->getDescription();
  83.     }
  84.     
  85.     /**
  86.      * Ritorna un array di stringhe XHTML relative al menu (barra di navigazione)
  87.      * di questa pagina.
  88.      *
  89.      * @return array vettore di stringhe XHTML rappresentante il menu della pagina
  90.      * @see Compilable
  91.      */
  92.     function getMenuEntries()
  93.     {
  94.         $siteID $this->site->getID();
  95.         $category $this->article->getCategory();
  96.         
  97.         //Crea il menu per gli articoli correlati, quelli della
  98.         //stessa categoria e il ritorno alla home
  99.         $menuEntries array(p("Torna alla ".a(
  100.             UserHomepage::staticGetFileName($this->site),"homepage")));
  101.     
  102.         //Se ci sono articoli correlati, li inserisco nel menu
  103.         if ($this->article->getCorrelatedArticlesCount(>  0{
  104.             $correlated $this->article->getCorrelatedArticles();
  105.             $listEntries array();
  106.             foreach ($correlated as $i{
  107.                 $articleTitle $i->getTitle();
  108.                 $listEntries []a(UserArticle::staticGetFileName($i),
  109.                     $articleTitle).";";
  110.             }
  111.             $menuEntries[p("Articoli correlati:".br().unorderedList($listEntries));
  112.         }
  113.         
  114.         //Se ci sono altri articoli nella stessa categoria, li inserisco nel menu
  115.         if ($this->article->getNeighbourArticlesCount(>0{
  116.             $listEntries array();
  117.             $neighbours $this->article->getNeighbourArticles();
  118.             foreach ($neighbours as $i{
  119.                 $articleTitle $i->getTitle();
  120.                 $listEntries[a(UserArticle::staticGetFileName($i),
  121.                     $articleTitle).";";
  122.             }
  123.             $menuEntries[p("Articoli della stessa categoria ".
  124.                 $category->getName().br().unorderedList($listEntries));
  125.         }
  126.         return $menuEntries;
  127.     }
  128.     
  129.     /**
  130.      * Ritorna il contenuto (XHTML) del corpo di questa pagina.
  131.      *
  132.      * @return string la stringa XHTML rappresentante il corpo della pagina
  133.      * @see Compilable
  134.      */
  135.     function getContents()
  136.     {
  137.         $site $this->site;
  138.         $articleID $this->article->getID();
  139.         $siteID $site->getID();
  140.         $homepage $site->getHomepage();
  141.     
  142.         //Crea il contenuto della pagina
  143.         $author $this->article->getAuthor();
  144.         $contents $this->article->getContents().$this->article->getDate().
  145.             ", Articolo di: ".
  146.             getAuthorSignature($this->article->getAuthor());
  147.             
  148.         return $contents;
  149.     }
  150.     
  151.     /**
  152.      * Ritorna una stringa di parole chiave (solo testo, separate da virgole)
  153.      * di questa pagina.
  154.      *
  155.      * @return string la stringa rappresentante le parole chiave della pagina
  156.      * @see Compilable
  157.      */
  158.     function getKeywords()
  159.     {
  160.         return $this->article->getDescription();
  161.     }
  162.     
  163.     /**
  164.      * Ritorna il nome del file in cui questa pagina deve essere salvata.
  165.      *
  166.      * @return string il nome del file
  167.      * @see Savable
  168.      */
  169.     function getFileName()
  170.     {
  171.         return $this->staticGetFileName($this->article);
  172.     }
  173.     
  174.     /**
  175.      * Versione statica del metodo precedente: ritorna il nome del
  176.      * file in cui questa pagina deve essere salvata.
  177.      *
  178.      * @return string il nome del file
  179.      * @see Savable
  180.      */
  181.     function staticGetFileName($article)
  182.     {
  183.         $category $article->getCategory();
  184.         $catName UserPage::fileName($category->getName()).'___'.$category->getID();
  185.         $artName UserPage::fileName($article->getTitle()).'___'.$article->getID();
  186.         return "/$catName/$artName.html";
  187.     }
  188.         
  189.     /**
  190.      * Ritorna il nome del file in cui questa pagina deve essere salvata
  191.      * (versione precedente).
  192.      *
  193.      * @return string il nome del file
  194.      * @see Savable
  195.      */
  196.     function getOldFileName()
  197.     {
  198.         return "art".$this->article->getID().".html";
  199.     }
  200. }
  201. ?>

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