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

Source for file UserCategory.php

Documentation is available at UserCategory.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 UserCategory extends UserPage
  37. {
  38.     /** @var Category l'oggetto corrispondente a questa pagina */
  39.     var $category = null;
  40.           
  41.     /**
  42.      * Costruttore standard
  43.      *
  44.      * @param Site $site il sito a cui questa pagina appartiene
  45.      * @param Category $category l'oggetto corrispondente a questa pagina
  46.      * @see AdminPage
  47.      */
  48.     function UserCategory($site$category)
  49.     {
  50.         parent::UserPage($site);
  51.         $this->category = $category;
  52.     }
  53.     
  54.     /**
  55.      * Ritorna il titolo (in XHTML) di questa pagina.
  56.      *
  57.      * @return string una stringa XHTML rappresentante il titolo della pagina
  58.      * @see Compilable
  59.      */
  60.     function getTitle()
  61.     {
  62.         $home $this->site->getHomepage();
  63.         
  64.         return a(UserHomepage::staticGetFileName($this->site),$home->getTitle())." > ".
  65.             $this->category->getName();
  66.     }
  67.     
  68.     /**
  69.      * Ritorna una breve descrizione (solo testo) di questa pagina.
  70.      *
  71.      * @return string una stringa rappresentante la descrizione della pagina
  72.      * @see Compilable
  73.      */
  74.     function getDescription()
  75.     {
  76.         return $this->category->getDescription();
  77.     }
  78.     
  79.     /**
  80.      * Ritorna un array di stringhe XHTML relative al menu (barra di navigazione)
  81.      * di questa pagina.
  82.      *
  83.      * @return array vettore di stringhe XHTML rappresentante il menu della pagina
  84.      * @see Compilable
  85.      */
  86.     function getMenuEntries()
  87.     {
  88.         $siteID $this->site->getID();
  89.         
  90.         $menuEntries array(p("Torna alla ".a(
  91.             UserHomepage::staticGetFileName($this->site),"homepage")));
  92.         
  93.         $listElements array();
  94.         $articles $this->category->getArticles();
  95.         foreach ($articles as $i{
  96.             $articleID $i->getID();
  97.             $articleTitle $i->getTitle();
  98.             $listElements[a(UserArticle::staticGetFileName($i),
  99.                 $articleTitle);
  100.         }
  101.         $menuEntries []p("Articoli di questa sezione:".br().
  102.             unorderedList($listElements));
  103.             
  104.         return $menuEntries;
  105.     }
  106.     
  107.     /**
  108.      * Ritorna il contenuto (XHTML) del corpo di questa pagina.
  109.      *
  110.      * @return string la stringa XHTML rappresentante il corpo della pagina
  111.      * @see Compilable
  112.      */
  113.     function getContents()
  114.     {  
  115.         //Crea il contenuto della pagina
  116.         $contents p($this->category->getDescription());
  117.         $articles $this->category->getArticles();
  118.         foreach ($articles as $i{
  119.             $author $i->getAuthor();
  120.             $articleID $i->getID();
  121.             $articleTitle $i->getTitle();
  122.             $contents .= h1(a(UserArticle::staticGetFileName($i),$articleTitle));
  123.             $contents .= p($i->getDescription());
  124.             $contents .= getAuthorSignature($i->getAuthor());
  125.         }
  126.             
  127.         return $contents;
  128.     }
  129.     
  130.     /**
  131.      * Ritorna una stringa di parole chiave (solo testo, separate da virgole)
  132.      * di questa pagina.
  133.      *
  134.      * @return string la stringa rappresentante le parole chiave della pagina
  135.      * @see Compilable
  136.      */
  137.     function getKeywords()
  138.     {
  139.         return $this->category->getDescription();;
  140.     }
  141.     
  142.     /**
  143.      * Ritorna il nome del file in cui questa pagina deve essere salvata.
  144.      *
  145.      * @return string il nome del file
  146.      * @see Savable
  147.      */
  148.     function getFileName()
  149.     {
  150.         return $this->staticGetFileName($this->category);
  151.     }
  152.     
  153.     /**
  154.      * Versione statica del metodo precedente: ritorna il nome del
  155.      * file in cui questa pagina deve essere salvata.
  156.      *
  157.      * @return string il nome del file
  158.      * @see Savable
  159.      */
  160.     function staticGetFileName($category)
  161.     {
  162.         if (is_a($category,"Category")==false){
  163. //            print var_dump($category);
  164.             print var_dump(debug_backtrace());
  165.         }
  166.         $catName UserPage::fileName($category->getName()).
  167.             '___'.$category->getID();
  168.         return "/$catName/index.html";
  169.     }
  170.     
  171.     /**
  172.      * Ritorna il nome del file in cui questa pagina deve essere salvata
  173.      * (versione precedente).
  174.      *
  175.      * @return string il nome del file
  176.      * @see Savable
  177.      */
  178.     function getOldFileName()
  179.     {
  180.         return "cat".$this->category->getID().".html";
  181.     }
  182.  
  183. }
  184. ?>

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