home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / xamp / xampp-win32.exe / xampp / Display.php < prev    next >
Encoding:
PHP Script  |  2004-10-01  |  3.4 KB  |  81 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.4 2004/10/01 09:48:37 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.4 $
  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.             // If the controller is "modal" we should not allow direct access to a page
  44.             // unless all previous pages are valid (see also bug #2323)
  45.             if ($page->controller->isModal() && !$page->controller->isValid($page->getAttribute('id'))) {
  46.                 $target =& $page->controller->getPage($page->controller->findInvalid());
  47.                 $target->handle('jump');
  48.             }
  49.             $data =& $page->controller->container();
  50.             if (!empty($data['values'][$pageName])) {
  51.                 $page->loadValues($data['values'][$pageName]);
  52.                 $validate = false === $data['valid'][$pageName];
  53.             }
  54.         }
  55.         // set "common" defaults and constants
  56.         $page->controller->applyDefaults($pageName);
  57.         $page->isFormBuilt() or $page->buildForm();
  58.         // if we had errors we should show them again
  59.         if (isset($validate) && $validate) {
  60.             $page->validate();
  61.         }
  62.         $this->_renderForm($page);
  63.     }
  64.  
  65.  
  66.    /**
  67.     * Actually outputs the form.
  68.     * 
  69.     * If you want to customize the form's appearance (you most certainly will),
  70.     * then you should override this method. There is no need to override perform()
  71.     * 
  72.     * @access public
  73.     * @param  object HTML_QuickForm_Page  the page being processed
  74.     */
  75.     function _renderForm(&$page)
  76.     {
  77.         $page->display();
  78.     }
  79. }
  80. ?>
  81.