Direct.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4. * This action allows to go to a specific page of a 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: Direct.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. * This action allows to go to a specific page of a multipage form.
  28. *
  29. * Please note that the name for this action in addAction() should NOT be
  30. * 'direct', but the name of the page you wish to go to.
  31. *
  32. * @category HTML
  33. * @package HTML_QuickForm_Controller
  34. * @author Alexey Borzov <avb@php.net>
  35. * @version Release: 1.0.10
  36. */
  37. class HTML_QuickForm_Action_Direct extends HTML_QuickForm_Action
  38. {
  39. function perform(&$page, $actionName)
  40. {
  41. // save the form values and validation status to the session
  42. $page->isFormBuilt() or $page->buildForm();
  43. $pageName = $page->getAttribute('id');
  44. $data =& $page->controller->container();
  45. $data['values'][$pageName] = $page->exportValues();
  46. if (PEAR::isError($valid = $page->validate())) {
  47. return $valid;
  48. }
  49. $data['valid'][$pageName] = $valid;
  50. $target =& $page->controller->getPage($actionName);
  51. if (PEAR::isError($target)) {
  52. return $target;
  53. } else {
  54. return $target->handle('jump');
  55. }
  56. }
  57. }
  58. ?>