home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / HTML / QuickForm / Action / Display.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  3.3 KB  |  90 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5.  * This action handles output of the form.
  6.  * 
  7.  * PHP versions 4 and 5
  8.  *
  9.  * LICENSE: This source file is subject to version 3.01 of the PHP license
  10.  * that is available through the world-wide-web at the following URI:
  11.  * http://www.php.net/license/3_01.txt If you did not receive a copy of
  12.  * the PHP License and are unable to obtain it through the web, please
  13.  * send a note to license@php.net so we can mail you a copy immediately.
  14.  *
  15.  * @category    HTML
  16.  * @package     HTML_QuickForm_Controller
  17.  * @author      Alexey Borzov <avb@php.net>
  18.  * @copyright   2003-2007 The PHP Group
  19.  * @license     http://www.php.net/license/3_01.txt PHP License 3.01
  20.  * @version     CVS: $Id: Display.php,v 1.7 2007/05/18 09:34:18 avb Exp $
  21.  * @link        http://pear.php.net/package/HTML_QuickForm_Controller
  22.  */
  23.  
  24. /**
  25.  * Class representing an action to perform on HTTP request.
  26.  */
  27. require_once 'HTML/QuickForm/Action.php';
  28.  
  29. /**
  30.  * This action handles output of the form.
  31.  *
  32.  * If you want to customize the form display, subclass this class and
  33.  * override the _renderForm() method, you don't need to change the perform()
  34.  * method itself.
  35.  *
  36.  * @category    HTML
  37.  * @package     HTML_QuickForm_Controller
  38.  * @author      Alexey Borzov <avb@php.net>
  39.  * @version     Release: 1.0.8
  40.  */
  41. class HTML_QuickForm_Action_Display extends HTML_QuickForm_Action
  42. {
  43.     function perform(&$page, $actionName)
  44.     {
  45.         $pageName = $page->getAttribute('id');
  46.         // If the original action was 'display' and we have values in container then we load them
  47.         // BTW, if the page was invalid, we should later call validate() to get the errors
  48.         list(, $oldName) = $page->controller->getActionName();
  49.         if ('display' == $oldName) {
  50.             // If the controller is "modal" we should not allow direct access to a page
  51.             // unless all previous pages are valid (see also bug #2323)
  52.             if ($page->controller->isModal() && !$page->controller->isValid($page->getAttribute('id'))) {
  53.                 $target =& $page->controller->getPage($page->controller->findInvalid());
  54.                 return $target->handle('jump');
  55.             }
  56.             $data =& $page->controller->container();
  57.             if (!empty($data['values'][$pageName])) {
  58.                 $page->loadValues($data['values'][$pageName]);
  59.                 $validate = false === $data['valid'][$pageName];
  60.             }
  61.         }
  62.         // set "common" defaults and constants
  63.         $page->controller->applyDefaults($pageName);
  64.         $page->isFormBuilt() or $page->buildForm();
  65.         // if we had errors we should show them again
  66.         if (isset($validate) && $validate) {
  67.             if (PEAR::isError($err = $page->validate())) {
  68.                 return $err;
  69.             }
  70.         }
  71.         return $this->_renderForm($page);
  72.     }
  73.  
  74.  
  75.    /**
  76.     * Actually outputs the form.
  77.     *
  78.     * If you want to customize the form's appearance (you most certainly will),
  79.     * then you should override this method. There is no need to override perform()
  80.     *
  81.     * @access private
  82.     * @param  HTML_QuickForm_Page  the page being processed
  83.     */
  84.     function _renderForm(&$page)
  85.     {
  86.         $page->display();
  87.     }
  88. }
  89. ?>
  90.