Display.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4. * This action handles output of the form.
  5. *
  6. * PHP versions 4 and 5
  7. *
  8. * LICENSE: This source file is subject to version 3.01 of the PHP license
  9. * that is available through the world-wide-web at the following URI:
  10. * http://www.php.net/license/3_01.txt If you did not receive a copy of
  11. * the PHP License and are unable to obtain it through the web, please
  12. * send a note to license@php.net so we can mail you a copy immediately.
  13. *
  14. * @category HTML
  15. * @package HTML_QuickForm_Controller
  16. * @author Alexey Borzov <avb@php.net>
  17. * @copyright 2003-2009 The PHP Group
  18. * @license http://www.php.net/license/3_01.txt PHP License 3.01
  19. * @version SVN: $Id: Display.php 289084 2009-10-02 06:53:09Z avb $
  20. * @link http://pear.php.net/package/HTML_QuickForm_Controller
  21. */
  22. /**
  23. * This action handles output of the form.
  24. *
  25. * If you want to customize the form display, subclass this class and
  26. * override the _renderForm() method, you don't need to change the perform()
  27. * method itself.
  28. *
  29. * @category HTML
  30. * @package HTML_QuickForm_Controller
  31. * @author Alexey Borzov <avb@php.net>
  32. * @version Release: 1.0.10
  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. // Modified by Chamilo team, 16-MAR-2010.
  48. //$target->handle('jump');
  49. return $target->handle('jump');
  50. //
  51. }
  52. $data =& $page->controller->container();
  53. if (!empty($data['values'][$pageName])) {
  54. $page->loadValues($data['values'][$pageName]);
  55. $validate = false === $data['valid'][$pageName];
  56. }
  57. }
  58. // set "common" defaults and constants
  59. $page->controller->applyDefaults($pageName);
  60. $page->isFormBuilt() or $page->buildForm();
  61. // if we had errors we should show them again
  62. if (isset($validate) && $validate) {
  63. if (PEAR::isError($err = $page->validate())) {
  64. return $err;
  65. }
  66. }
  67. // Modified by Chamilo team, 16-MAR-2010.
  68. //$this->_renderForm($page);
  69. return $this->_renderForm($page);
  70. //
  71. }
  72. /**
  73. * Actually outputs the form.
  74. *
  75. * If you want to customize the form's appearance (you most certainly will),
  76. * then you should override this method. There is no need to override perform()
  77. *
  78. * @access private
  79. * @param HTML_QuickForm_Page the page being processed
  80. */
  81. function _renderForm(&$page)
  82. {
  83. $page->display();
  84. }
  85. }
  86. ?>