Direct.php 2.0 KB

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