PageRenderTime 23ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/common/libraries/plugin/pear/HTML/QuickForm/Action/Next.php

https://bitbucket.org/gugli/chamilo-dev
PHP | 85 lines | 42 code | 7 blank | 36 comment | 5 complexity | 780d7009ad56616081e9fe5ae5e39b4e MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, LGPL-3.0, GPL-3.0, MIT, GPL-2.0
  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-2007 The PHP Group
  18. * @license http://www.php.net/license/3_01.txt PHP License 3.01
  19. * @version CVS: $Id: Next.php 137 2009-11-09 13:24:37Z vanpouckesven $
  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 'next' button of wizard-type multipage form.
  28. *
  29. * @category HTML
  30. * @package HTML_QuickForm_Controller
  31. * @author Alexey Borzov <avb@php.net>
  32. * @version Release: 1.0.9
  33. */
  34. class HTML_QuickForm_Action_Next 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. {
  45. return $valid;
  46. }
  47. $data['valid'][$pageName] = $valid;
  48. // Modal form and page is invalid: don't go further
  49. if ($page->controller->isModal() && ! $data['valid'][$pageName])
  50. {
  51. return $page->handle('display');
  52. }
  53. // More pages?
  54. if (null !== ($nextName = $page->controller->getNextName($pageName)))
  55. {
  56. $next = & $page->controller->getPage($nextName);
  57. return $next->handle('jump');
  58. // Consider this a 'finish' button, if there is no explicit one
  59. }
  60. elseif ($page->controller->isModal())
  61. {
  62. if ($page->controller->isValid())
  63. {
  64. return $page->handle('process');
  65. }
  66. else
  67. {
  68. // this should redirect to the first invalid page
  69. return $page->handle('jump');
  70. }
  71. }
  72. else
  73. {
  74. return $page->handle('display');
  75. }
  76. }
  77. }
  78. ?>