Next.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4. * The action for a 'next' button of wizard-type multipage 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: Next.php 289084 2009-10-02 06:53:09Z avb $
  20. * @link http://pear.php.net/package/HTML_QuickForm_Controller
  21. */
  22. /**
  23. * The action for a 'next' button of wizard-type multipage form.
  24. *
  25. * @category HTML
  26. * @package HTML_QuickForm_Controller
  27. * @author Alexey Borzov <avb@php.net>
  28. * @version Release: 1.0.10
  29. */
  30. class HTML_QuickForm_Action_Next extends HTML_QuickForm_Action
  31. {
  32. function perform(&$page, $actionName)
  33. {
  34. // save the form values and validation status to the session
  35. $page->isFormBuilt() or $page->buildForm();
  36. $pageName = $page->getAttribute('id');
  37. $data =& $page->controller->container();
  38. $data['values'][$pageName] = $page->exportValues();
  39. if (PEAR::isError($valid = $page->validate())) {
  40. return $valid;
  41. }
  42. $data['valid'][$pageName] = $valid;
  43. // Modal form and page is invalid: don't go further
  44. if ($page->controller->isModal() && !$data['valid'][$pageName]) {
  45. return $page->handle('display');
  46. }
  47. // More pages?
  48. if (null !== ($nextName = $page->controller->getNextName($pageName))) {
  49. $next =& $page->controller->getPage($nextName);
  50. // Modified by Chamilo team, 16-MAR-2010.
  51. //$next->handle('jump');
  52. return $next->handle('jump');
  53. //
  54. // Consider this a 'finish' button, if there is no explicit one
  55. } elseif($page->controller->isModal()) {
  56. if ($page->controller->isValid()) {
  57. // Modified by Chamilo team, 16-MAR-2010.
  58. //$page->handle('process');
  59. return $page->handle('process');
  60. //
  61. } else {
  62. // this should redirect to the first invalid page
  63. // Modified by Chamilo team, 16-MAR-2010.
  64. //$page->handle('jump');
  65. return $page->handle('jump');
  66. //
  67. }
  68. } else {
  69. // Modified by Chamilo team, 16-MAR-2010.
  70. //$page->handle('display');
  71. return $page->handle('display');
  72. //
  73. }
  74. }
  75. }
  76. ?>