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

Source for file AdminEditNews.php

Documentation is available at AdminEditNews.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. /** Importa la classe di base per l"interfaccia utente (autore) */
  27. require_once $_SERVER["DOCUMENT_ROOT"]."/admin/lib/view/AdminPage.php";
  28. /** Importa la libreria per semplificare l"aggiunta di tag XML */
  29. require_once $_SERVER["DOCUMENT_ROOT"]."/admin/lib/view/Tagger.php";
  30.  
  31. /**
  32.  * Rappresenta la pagina di modifica di una notizia. Presenta una finestra
  33.  * per l'input dell'XHTML.
  34.  * 
  35.  * @package  MCMS
  36.  * @version  2
  37.  * @author   Silvio Moioli <silvio at moioli dot net>
  38.  */
  39. class AdminEditNews extends AdminPage {
  40.  
  41.     /** @var Author l'autore che accede a questa pagina */
  42.     var $author = null;
  43.     /** @var Site il sito a cui appartiene la notizia da modificare o aggiungere */
  44.     var $site = null;
  45.     /** @var News la notizia da modificare, null se è una nuova notizia */
  46.     var $news = null;
  47.     /** @var string "new" se si aggiunge una nuova notizia o "edit" altrimenti */
  48.     var $mode = "new";
  49.     /** @var bool true se Javascript è in uso per la modifica dell'XHTML */
  50.     var $javascript = true;
  51.     
  52.     /** @var string titolo proposto all'utente per questa notizia */
  53.     var $defaultTitle = "Nuova notizia";
  54.     /** @var string parole chiave proposte all'utente per questa notizia */
  55.     var $defaultKeywords = "parole chiave";
  56.     /** @var string fonte proposta all'utente per questa notizia */
  57.     var $defaultSource = "";
  58.     /** @var string contenuti (XHTML) proposti all'utente per questa notizia */
  59.     var $defaultContents = "Inserisci i tuoi contenuti <b>qui</b>.";
  60.     /** @var array articoli correlati proposti all'utente per questo notizia */
  61.     var $defaultCorrelatedArticles = array();
  62.     
  63.     /**
  64.      * Costruttore standard.
  65.      *
  66.      * @see AdminPage
  67.      * @param Author $author l'autore della nuova notizia o della notizia
  68.      *  da modificare
  69.      * @param Site $site il sito a cui la nuova notizia o la notizia da
  70.      *  modificare appartiene
  71.      * @param News $news la notizia da modificare o null
  72.      * @param string $mode "new" o "modify" a seconda che si voglia creare
  73.      *  una nuova notizia o modificarne una esistente
  74.      * @param bool $javascript indica la possibilità di usare il JavaScript
  75.      *  per l'editor XHTML
  76.      */
  77.     function AdminEditNews($author$site$news$mode$javascript)
  78.     {
  79.         parent::AdminPage();
  80.         $this->author=$author;    
  81.         $this->site=$site;
  82.         $this->news=$news;
  83.         $this->mode=$mode;
  84.         $this->javascript=$javascript;
  85.         if ($mode == "edit"){
  86.             $this->defaultTitle = $news->getTitle();
  87.             $this->defaultKeywords = $news->getKeywords();
  88.             $this->defaultSource = $news->getSource();
  89.             $this->defaultContents = $news->getContents();
  90.             $this->defaultCorrelatedArticles = $news->getCorrelatedArticles();
  91.         }
  92.     }
  93.     
  94.     /**
  95.      * Cambia il titolo proposto all'utente per questa notizia
  96.      *
  97.      * @param string $defaultTitle il nuovo titolo
  98.      */
  99.     function setDefaultTitle($defaultTitle)
  100.     {
  101.         $this->defaultTitle = $defaultTitle;
  102.     }
  103.     
  104.     /**
  105.      * Cambia le parole chiave proposte all'utente per questa notizia
  106.      *
  107.      * @param string $defaultKeywords le nuove parole chiave
  108.      */
  109.     function setDefaultKeywords($defaultKeywords)
  110.     {
  111.         $this->defaultKeywords = $defaultKeywords;
  112.     }
  113.     
  114.     /**
  115.      * Cambia la fonte proposta all'utente per questa notizia
  116.      *
  117.      * @param string $defaultSource la nuova fonte
  118.      */
  119.     function setDefaultSource($defaultSource)
  120.     {
  121.         $this->defaultSource = $defaultSource;
  122.     }
  123.     
  124.     /**
  125.      * Cambia i contenuti (XHTML) proposti all'utente per questa notizia
  126.      *
  127.      * @param string $defaultContents i nuovi contenuti
  128.      */
  129.     function setDefaultContents($defaultContents)
  130.     {
  131.         $this->defaultContents = $defaultContents;
  132.     }
  133.     
  134.     /**
  135.      * Cambia gli articoli correlati proposti all'utente per questa notizia
  136.      *
  137.      * @param array $defaultCorrelatedArticles i nuovi articoli correlati
  138.      */
  139.     function setDefaultCorrelatedArticles($defaultCorrelatedArticles)
  140.     {
  141.         $this->defaultCorrelatedArticles = $defaultCorrelatedArticles;
  142.     }
  143.    
  144.     /**
  145.      * Ritorna il titolo (in XHTML) di questa pagina.
  146.      *
  147.      * @return string una stringa XHTML rappresentante il titolo della pagina
  148.      * @see Compilable
  149.      */
  150.     function getTitle()
  151.     {
  152.         $authorID $this->author->getID();
  153.         $siteID $this->site->getID();
  154.         $title a("do.php?goTo=AdminMain&amp;authorID=$authorID",
  155.             "Il Progettista")." > ".
  156.             a("do.php?goTo=AdminManageSite&amp;authorID=$authorID&amp;".
  157.             "siteID=$siteID"$this->site->getShortURL())." > ".
  158.             a("do.php?goTo=AdminListNews&amp;authorID=$authorID&amp;".
  159.             "siteID=$siteID","Notizie")." > ".$this->defaultTitle;
  160.         return $title;
  161.     }
  162.     
  163.     /**
  164.      * Ritorna un array di stringhe XHTML relative al menu (barra di navigazione)
  165.      * di questa pagina.
  166.      *
  167.      * @return array vettore di stringhe XHTML rappresentante il menu della pagina
  168.      * @see Compilable
  169.      */
  170.     function getMenuEntries()
  171.     {
  172.         $authorID $this->author->getID();
  173.         $siteID $this->site->getID();
  174.         $menuEntries array(p(a("do.php?goTo=AdminManageSite&amp;".
  175.             "siteID=$siteID&amp;authorID=$authorID",
  176.             "Annulla e torna alla gestione del sito").br().
  177.             a("do.php?goTo=AdminListNews&amp;siteID=$siteID&amp;authorID=$authorID",
  178.             "Annulla e torna alla gestione delle notizie")));
  179.         return $menuEntries;
  180.     }
  181.     
  182.     /**
  183.      * Ritorna il contenuto (XHTML) del corpo di questa pagina.
  184.      *
  185.      * @return string la stringa XHTML rappresentante il corpo della pagina
  186.      * @see Compilable
  187.      */
  188.     function getContents()
  189.     {
  190.         $authorID $this->author->getID();
  191.         $siteID $this->site->getID();
  192.         $newsID 0;
  193.         $action "addNews";
  194.         if ($this->news != null){
  195.             $newsID $this->news->getID();
  196.             $action "editNews";
  197.         }
  198.         
  199.         $contents h1("Contenuti della notizia").
  200.             p("Da questa pagina puoi gestire i contenuti della notizia.").
  201.             form("do.php?action=$action&amp;authorID=$authorID&amp;".
  202.             "siteID=$siteID&amp;newsID=$newsID&amp;goTo=AdminListNews&amp;mode=$this->mode""POST",
  203.             
  204.             p("Titolo della notizia: ".
  205.             input("text","title","$this->defaultTitle").br().
  206.             "Parole-chiave della notizia: ".
  207.             input("text","keywords","$this->defaultKeywords").br().
  208.             "URL della fonte da cui la notizia &egrave; tratta: ".
  209.             input("text","source","$this->defaultSource").br().
  210.             "Il progettista consiglia: puoi lasciare questo campo vuoto se la 
  211.             notizia &egrave; tua!".br().
  212.             "Contenuti della notizia:".br().
  213.             HTMLEditor($this->defaultContents$this->javascript).br().
  214.             "Articoli correlati a questa notizia:".br().
  215.             $this->checkboxes().br().
  216.             "Quando hai finito, clicca sul bottone qui sotto:".br().
  217.             submit()
  218.         ));
  219.         
  220.         return $contents;
  221.     }
  222.     
  223.     /**
  224.      * Ritorna il codice XHTML delle checkbox per la correlazione degli articoli
  225.      *
  226.      * @access private
  227.      * @return string la stringa XHTML rappresentante le checkbox
  228.      */
  229.     function checkboxes()
  230.     {
  231.         $allArticles $this->site->getArticles();
  232.         $listElements array();
  233.         $count 0;
  234.         $correlatedArticleIDs array();            
  235.         foreach ($this->defaultCorrelatedArticles as $i{
  236.             $correlatedArticleIDs[$i->getID();
  237.         }
  238.         foreach ($allArticles as $i{
  239.             $articleID $i->getID();
  240.             $listElements []checkbox("article$count"in_array($articleID$correlatedArticleIDs)).
  241.             $i->getTitle().input("hidden""article$count"."ID",$articleID);               
  242.             $count++;
  243.         }
  244.         return unorderedList($listElements);
  245.     }
  246. }
  247. ?>

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