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

Source for file AdminLogin.php

Documentation is available at AdminLogin.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. /** Carica il gestore dei template (Smarty) */
  31. require_once $_SERVER["DOCUMENT_ROOT"]."/admin/include/smarty/libs/Smarty.class.php";
  32.  
  33. /**
  34.  * La pagina con il form per con la richiesta della password.
  35.  * 
  36.  * @package  MCMS
  37.  * @version  2
  38.  * @author   Silvio Moioli <silvio at moioli dot net>
  39.  */
  40. class AdminLogin extends AdminPage
  41. {
  42.     /** @var Author l'autore che deve essere autenticato */
  43.     var $author = null;
  44.     
  45.     /**
  46.      * Costruttore di default
  47.      *
  48.      * @param Author $author l'autore che deve essere autenticato
  49.      * @see AdminPage
  50.      */
  51.     function AdminLogin($author)
  52.     {
  53.         parent::AdminPage();
  54.         $this->author=$author;
  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.         return "Password richiesta!";
  66.     }
  67.     
  68.     /**
  69.      * Ritorna un array di stringhe XHTML relative al menu (barra di navigazione)
  70.      * di questa pagina.
  71.      *
  72.      * @return array vettore di stringhe XHTML rappresentante il menu della pagina
  73.      * @see Compilable
  74.      */
  75.     function getMenuEntries()
  76.     {
  77.         $authorID $this->author->getID();
  78.     
  79.         $menuEntries array("Immetti la tua password oppure...");
  80.         $menuEntries [p(a("do.php?goTo=AdminIndex",
  81.             "Torna alla selezione degli autori"));
  82.         
  83.         return $menuEntries;
  84.     }
  85.     
  86.     /**
  87.      * Ritorna il contenuto (XHTML) del corpo di questa pagina.
  88.      *
  89.      * @return string la stringa XHTML rappresentante il corpo della pagina
  90.      * @see Compilable
  91.      */
  92.     function getContents()
  93.     {
  94.         $authorID $this->author->getID();
  95.         
  96.         $contents p("Immetti la tua password nel campo qui sotto:");
  97.     
  98.         $action "do.php?";
  99.         $formContents "";
  100.         //Ricopia le variabili GET e POST se presenti
  101.         if (isset($_GET)) {
  102.             foreach ($_GET as $key => $value{
  103.                 $action .= "$key=$value&amp;";
  104.             }
  105.         }
  106.         if (isset($_POST)) {
  107.             foreach ($_POST as $key => $value{
  108.                 $formContents .= input("hidden"$key$value);
  109.             }
  110.         }
  111.                            
  112.         $formContents .= "Autore: ".getAuthorSignature($this->author).br();
  113.         $formContents .= input("hidden""username"$this->author->getID()).br();
  114.         $formContents .= input("password""password""").br();
  115.         $formContents .= submit();
  116.         
  117.         $contents .= form($action"POST"$formContents);
  118.         
  119.         return $contents;
  120.     }
  121.     
  122.    /**
  123.     * Questo metodo viene passato ad Auth per la visualizzazione della
  124.     * pagina di login.
  125.     */
  126.     function displayLoginPage()
  127.     {
  128.         $compiler new Compiler();
  129.         $compiler->display($this);
  130.     }
  131.     
  132.     /**
  133.      * Compila la pagina e la visualizza all'utente.
  134.      */
  135.     function display()
  136.     {
  137.         $smarty new Smarty();
  138.         //Assegno le variabili a Smarty
  139.         $smarty->assign('title',$this->getTitle());
  140.         $smarty->assign('menuEntries',$this->getMenuEntries());
  141.         $smarty->assign('contents',$this->getContents());
  142.     
  143.         //Elaboro la pagina vera e propria
  144.         $smarty->display("adminTemplate.tpl");
  145.     }
  146. }
  147.  
  148. ?>

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