Submit.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4. * The action for a 'submit' button.
  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: Submit.php 289084 2009-10-02 06:53:09Z avb $
  20. * @link http://pear.php.net/package/HTML_QuickForm_Controller
  21. */
  22. /**
  23. * Class representing an action to perform on HTTP request.
  24. */
  25. require_once 'HTML/QuickForm/Action.php';
  26. /**
  27. * The action for a 'submit' button.
  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_Submit extends HTML_QuickForm_Action
  35. {
  36. function perform(&$page, $actionName)
  37. {
  38. // save the form values and validation status to the session
  39. $page->isFormBuilt() or $page->buildForm();
  40. $pageName = $page->getAttribute('id');
  41. $data =& $page->controller->container();
  42. $data['values'][$pageName] = $page->exportValues();
  43. if (PEAR::isError($valid = $page->validate())) {
  44. return $valid;
  45. }
  46. $data['valid'][$pageName] = $valid;
  47. // All pages are valid, process
  48. if ($page->controller->isValid()) {
  49. // Modified by Chamilo team, 16-MAR-2010.
  50. //$page->handle('process');
  51. return $page->handle('process');
  52. //
  53. // Current page is invalid, display it
  54. } elseif (!$data['valid'][$pageName]) {
  55. // Modified by Chamilo team, 16-MAR-2010.
  56. //$page->handle('display');
  57. return $page->handle('display');
  58. //
  59. // Some other page is invalid, redirect to it
  60. } else {
  61. $target =& $page->controller->getPage($page->controller->findInvalid());
  62. // Modified by Chamilo team, 16-MAR-2010.
  63. //$target->handle('jump');
  64. return $target->handle('jump');
  65. //
  66. }
  67. }
  68. }
  69. ?>