home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Display.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  3.0 KB  |  75 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0                                                      |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Alexey Borzov <avb@php.net>                                  |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Display.php,v 1.3 2004/03/02 21:15:45 avb Exp $
  20.  
  21. require_once 'HTML/QuickForm/Action.php';
  22.  
  23. /**
  24.  * This action handles the output of the form.
  25.  * 
  26.  * If you want to customize the form display, subclass this class and
  27.  * override the _renderForm() method, you don't need to change the perform()
  28.  * method itself.
  29.  * 
  30.  * @author  Alexey Borzov <avb@php.net>
  31.  * @package HTML_QuickForm_Controller
  32.  * @version $Revision: 1.3 $
  33.  */
  34. class HTML_QuickForm_Action_Display extends HTML_QuickForm_Action
  35. {
  36.     function perform(&$page, $actionName)
  37.     {
  38.         $pageName = $page->getAttribute('id');
  39.         // If the original action was 'display' and we have values in container then we load them
  40.         // BTW, if the page was invalid, we should later call validate() to get the errors
  41.         list(, $oldName) = $page->controller->getActionName();
  42.         if ('display' == $oldName) {
  43.             $data =& $page->controller->container();
  44.             if (!empty($data['values'][$pageName])) {
  45.                 $page->loadValues($data['values'][$pageName]);
  46.                 $validate = false === $data['valid'][$pageName];
  47.             }
  48.         }
  49.         // set "common" defaults and constants
  50.         $page->controller->applyDefaults($pageName);
  51.         $page->isFormBuilt() or $page->buildForm();
  52.         // if we had errors we should show them again
  53.         if (isset($validate) && $validate) {
  54.             $page->validate();
  55.         }
  56.         $this->_renderForm($page);
  57.     }
  58.  
  59.  
  60.    /**
  61.     * Actually outputs the form.
  62.     * 
  63.     * If you want to customize the form's appearance (you most certainly will),
  64.     * then you should override this method. There is no need to override perform()
  65.     * 
  66.     * @access public
  67.     * @param  object HTML_QuickForm_Page  the page being processed
  68.     */
  69.     function _renderForm(&$page)
  70.     {
  71.         $page->display();
  72.     }
  73. }
  74. ?>
  75.