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

Source for file Homepage.php

Documentation is available at Homepage.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.  * Interfaccia per la gestione dell'homepage di ogni sito.
  27.  *
  28.  * @package  MCMS
  29.  * @version  2
  30.  * @author   Silvio Moioli <silvio at moioli dot net>
  31.  *
  32.  */
  33.  
  34. /** Carica la classe base di MCMS per l'interfacciamento al Database */
  35. require_once $_SERVER["DOCUMENT_ROOT"]."/admin/lib/model/Engine.php";
  36. /**
  37.  * Carica la classe per le pagine (Page)
  38.  */
  39. require_once $_SERVER["DOCUMENT_ROOT"]."/admin/lib/model/Page.php";
  40.  
  41. /**
  42.  * Interfaccia per la gestione dell'homepage di ogni sito.
  43.  *
  44.  * Permette di utilizzare il database in modo trasparente: creare oggetti
  45.  * di questa classe e operare sugli attributi tramite gli appositi metodi
  46.  * modificherā automaticamente il database sottostante.
  47.  * 
  48.  * @package  MCMS
  49.  * @version  2
  50.  * @author   Silvio Moioli <silvio at moioli dot net>
  51.  *
  52.  */
  53.  
  54. class Homepage extends Page
  55. {
  56.     //Attributi ereditati: $ID e $engine
  57.  
  58.     //Costruttori   
  59.         /**
  60.      * Costruttore di lettura
  61.      *
  62.      * Costruttore "di lettura" (costruisce una homepage da un record del
  63.      * database giā esistente).
  64.      * Nota: le homepages sono create direttamente dal costruttore di
  65.      * Site. All'atto della costruzione di un nuovo sito, infatti, verrā
  66.      * anche creata una nuova homepage.
  67.      * Per i costruttori "di scrittura", quindi, vedere la classe Site
  68.      * nel file Site.php.
  69.      *
  70.      * @param int $ID l'ID del database sottostante
  71.      * @param Engine $engine un motore per interagire con il database
  72.      *  sottostante
  73.      * @return mixed l'homepage se la costruzione č andata a buon fine, altrimenti
  74.      *  un PEAR_Error
  75.      * @see Engine
  76.      */
  77.     function Homepage($ID$engine)
  78.     {
  79.         $this->Page($ID$engine);
  80.     }
  81.     
  82.     //Metodi
  83.         /**
  84.      * Getter per il campo Motto dalla tabella Homepage.
  85.      * 
  86.      * Ritorna una stringa con il "motto" del sito (es. "Clarence: a wwworld
  87.      * apart"), che sarā visualizzata nella home.
  88.      *
  89.      * @return mixed una stringa con il motto se l'operazione č andata a buon fine,
  90.      *  altrimenti un DB_ERROR.
  91.      */
  92.      function getSlogan()
  93.      {
  94.         $thisEngine $this->getEngine();
  95.         $thisDB $thisEngine->getDB();
  96.         $thisID $thisDB->escapeSimple($this->getID());
  97.         $res $thisDB->getOne("SELECT `motto homepage` FROM `homepages`".
  98.                                "WHERE `id pagina` = '$thisIDLIMIT 1;");
  99.         
  100.         #$thisDB->disconnect();
  101.         return $res;
  102.      }
  103.     
  104.     /**
  105.      * Setter per il campo Motto dalla tabella Homepage.
  106.      * 
  107.      * Cambia il motto visualizzato nella homepage.
  108.      *
  109.      * @param string $slogan il nuovo motto del sito.
  110.      * @return mixed true se l'operazione č andata a buon fine, altrimenti
  111.      *  un DB_ERROR
  112.      */
  113.      function setSlogan($slogan)
  114.      {
  115.         $thisEngine $this->getEngine();
  116.         $thisDB $thisEngine->getDB();
  117.         $thisID $thisDB->escapeSimple($this->getID());
  118.         $slogan $thisDB->escapeSimple($thisDB->escapeSimple($slogan));
  119.         $thisDB->query("UPDATE `homepagesSET `motto homepage`='$slogan'".
  120.                        "WHERE `id pagina` = '$thisID';");
  121.         
  122.         #$thisDB->disconnect();
  123.         return true;
  124.      }  
  125. }
  126. ?>

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