- <?php
- /* vim: set number autoindent tabstop=2 shiftwidth=2 softtabstop=2: */
-
- /**
- * Next action
- *
- * PHP versions 4 and 5
- *
- * LICENSE: This source file is subject to version 3.0 of the PHP license
- * that is available through the world-wide-web at the following URI:
- * http://www.php.net/license/3_0.txt. If you did not receive a copy of
- * the PHP License and are unable to obtain it through the web, please
- * send a note to license@php.net so we can mail you a copy immediately.
- *
- * @category HTML
- * @package HTML_QuickForm_Wizard
- * @author Fabio Ambrosanio <fabio@ambrosanio.com>
- * @license http://www.php.net/license/3_01.txt PHP
- * @version @package_version@
- *
- * $Id: next.php,v 1.3 2007/02/18 18:35:50 fabamb Exp $
- */
-
- require_once 'HTML/QuickForm/Action/Next.php';
-
- /**
- * This class implements "next" action that is to validate and save form's data and go to the next page
- *
- */
- class HTML_QuickForm_Wizard_next extends HTML_QuickForm_Action_Next
- {
- function perform(&$page, $actionName)
- {
- // save the form values and validation status to the session
- $page->isFormBuilt() or $page->buildForm();
- $pageName = $page->getAttribute('id');
- $data =& $page->controller->container();
- $data['values'][$pageName] = $page->exportValues();
- if (PEAR::isError($valid = $page->validate())) {
- return $valid;
- }
- $data['valid'][$pageName] = $valid;
-
- // Modal form and page is invalid: don't go further
- if ($page->controller->isModal() && !$data['valid'][$pageName]) {
- return $page->handle('display');
- }
-
- // check if this page is final
- if ($page->controller->isFinal($pageName)) {
- return $page->handle('process');
- }
-
- // get next page from wizard
- if (null !== ($nextName = $page->controller->getNextName($pageName))) {
-
- // sets valid all page between the actual and the next one
- $keys = $page->controller->getPageNames();
- $start = array_search($pageName, $keys);
- $stop = array_search($nextName, $keys);
- for($i = $start+1; $i < $stop; $i++) {
- $key = $keys[$i];
- if (!is_array($data['values'][$keys[$i]])) {
- $data['values'][$keys[$i]] = array();
- }
- $data['valid'][$key] = true;
- }
-
- // jumps to the next page
- $next =& $page->controller->getPage($nextName);
- return $next->handle('jump');
- } else {
- // Consider this a 'finish' button, if there is no explicit one
- if($page->controller->isModal()) {
- if ($page->controller->isValid()) {
- return $page->handle('process');
- } else {
- // this should redirect to the first invalid page
- return $page->handle('jump');
- }
- } else {
- return $page->handle('display');
- }
- }
- }
- }
- ?>