--- nfo/php/libs/com.newsblob.phphtmllib/form/FormWizard.inc 2003/09/20 00:18:43 1.1 +++ nfo/php/libs/com.newsblob.phphtmllib/form/FormWizard.inc 2004/05/06 16:27:23 1.2 @@ -2,7 +2,7 @@ /** * This file contains the FormWizard class. * - * $Id: FormWizard.inc,v 1.1 2003/09/20 00:18:43 jonen Exp $ + * $Id: FormWizard.inc,v 1.2 2004/05/06 16:27:23 jonen Exp $ * * @author Walter A. Boring IV * @package phpHtmlLib @@ -47,7 +47,7 @@ * */ function FormWizard() { - user_error(__CLASS__."::".__FUNCTION." - this class isn't done yet."); + //user_error(__CLASS__."::".__FUNCTION__." - this class isn't done yet."); $this->_session_test(); $this->set_form_name( "form_wizard" ); $this->set_form_action( $_SERVER["PHP_SELF"] ); @@ -93,19 +93,19 @@ $container->add( $this->render_error($indent_level, $output_debug) ); } else { //there are no errors! - ddd( "have we visited?" ); - //ddd( $_REQUEST ); - if (@$_REQUEST[FORM_VISITED] == 1) { + debug( "have we visited?" ,null,4); + //debug( $_REQUEST ); + if (isset($_REQUEST[FORM_VISITED]) && $_REQUEST[FORM_VISITED] == 1) { //looks like the form has been processed? - ddd( "confirmed = ".$this->_confirmed ); - ddd( "curr step = ".$this->_current_step() ); + debug( "confirmed = ".$this->_confirmed ); + debug( "curr step = ".$this->_current_step() ); if (!$this->_confirmed && $this->_vars["on_confirm"]) { - ddd("FINAL DUDE!"); + debug("FINAL DUDE!"); $container->add( $this->render_confirm($indent_level, $output_debug) ); } else { //Looks like the action worked $success = $this->_form_content->form_success(); - + debug("DO ACTION!"); if ($this->_form_success_render) { $container->add( $this->render_form($indent_level, $output_debug, $success) ); } else { @@ -145,7 +145,7 @@ //if it has been visited. Otherwise //it just gets rendered. if (@$_REQUEST[FORM_VISITED] == 1) { - ddd("PROCESS STEP ".$this->_current_step()); + debug("PROCESS STEP ".$this->_current_step()); $this->_form_content->set_action($_REQUEST[FORM_ACTION]); //let see if this was a confirmation page. @@ -162,7 +162,11 @@ //need to validate the form. if ($this->can_validate()) { //looks like we should do validation - $this->do_validation(); + if ($_REQUEST[WIZARD_ACTION] != WIZARD_PREV) { + //we don't need to validate if we haven't + //finished this step yet. + $this->do_validation(); + } } if (!$this->_has_errors) { //no errors were found @@ -171,39 +175,41 @@ if (!$this->_has_errors) { //ok this step validated. lets display the next. //mark this step as visited - $current_step = $this->_current_step(); - $this->_step_visited( $current_step ); - ddd( "CURRENT STEP ".$current_step); + $current_step = $this->_current_step(); + debug( "CURRENT STEP ".$current_step); switch ($_REQUEST[WIZARD_ACTION]) { case WIZARD_NEXT: - ddd("NEXT"); + debug("NEXT"); if ($current_step == $this->_vars["num_steps"]) { + debug("SHOW CONFIRMATION"); //we need to show the confirmation //don't process $this->_vars["on_confirm"] = TRUE; - ddd("ASS"); + $this->_step_visited( $current_step ); + $this->_set_current_step($current_step+1); } else { + $this->_step_visited( $current_step ); $this->_set_current_step($current_step+1); unset($_REQUEST[FORM_VISITED]); $this->_form_content = &$this->_steps[$this->_current_step()-1]["form"]; - $this->_process_form(); - } + //$this->_process_form(); + } break; case WIZARD_PREV: + debug("PREV"); $this->_set_current_step($current_step-1); unset($_REQUEST[FORM_VISITED]); - $this->_form_content = &$this->_steps[$this->_current_step()-1]["form"]; - ddd("PREV"); - $this->_process_form(); + $this->_form_content = &$this->_steps[$this->_current_step()-1]["form"]; + //$this->_process_form(); break; } } } } } - ddd("bail"); + debug("bail"); } @@ -221,7 +227,7 @@ * @return string - the raw html */ function render_confirm( $indent_level, $output_debug ) { - ddd("BUILD CONFIRM"); + debug("BUILD CONFIRM"); //build the $this->_form object. $this->_build_form_tag(); @@ -288,7 +294,7 @@ if (!isset($_REQUEST[WIZARD_VISITED])) { $this->_vars[WIZARD_ID] = uniqid("wizard_"); - ddd( $this->_vars ); + //debug( $this->_vars ); $this->_init_session(); $this->_vars["to_step"] = 2; @@ -303,7 +309,7 @@ // $this->_vars["to_step"] = WIZARD_NEXT; //} } - //ddd( $_SESSION ); + //debug( $_SESSION ); //initialize all of the Forms //so they retain their data. @@ -391,6 +397,7 @@ */ function _build_toolbar() { $current_step = $this->_current_step(); + xxx("current step ".$current_step); if ($this->_vars["on_confirm"]) { $current_step++; $step_title = "Confirmation"; @@ -417,6 +424,7 @@ } //add the confirmation step + xxx($step_num); $c->add( $arrow ); $c->add( $this->_build_step_image( $step_num, "Confirmation" ) ); @@ -444,16 +452,16 @@ html_img("/phphtmllib/images/wizard/previous_step.png")); $c->add( $link ); } + + if ($current_step == $this->_vars["num_steps"]+1) { + $link = html_a("javascript:wizard_submit2('".WIZARD_FINAL."',".($current_step).");", + html_img("/phphtmllib/images/wizard/finish_steps.png") ); - if ($current_step != $this->_vars["num_steps"]) { + $c->add( _HTML_SPACE, _HTML_SPACE, $link); + } else { $link = html_a("javascript:wizard_submit2('".WIZARD_NEXT."',".($current_step+1).");", html_img("/phphtmllib/images/wizard/next_step.png") ); $c->add( $link ); - } else { - $link = html_a("javascript:wizard_submit2('".WIZARD_FINAL."',".($current_step).");", - html_img("/phphtmllib/images/wizard/finish_steps.png") ); - - $c->add( _HTML_SPACE, _HTML_SPACE, $link); } @@ -475,16 +483,17 @@ $title = "Step ".$step_num." "; $current_step = $this->_current_step(); - if ($this->_vars["on_confirm"]) { - $current_step++; - } + //if ($this->_vars["on_confirm"]) { + //$current_step++; + //} if ($step_num == $current_step) { $title .= " (Current) : ".$step_title; $img = html_img("/phphtmllib/images/wizard/".$step_num."_red.png", 30, 30, 0, $title, NULL, $title); - } else if ($this->_is_step_visited($step_num)) { + } else if ($this->_is_step_visited($step_num) || + $current_step == $this->_vars["num_steps"]+1) { $title .= " (Completed) : ".$step_title; $img = html_img("/phphtmllib/images/wizard/".$step_num."_black.png", 30, 30 ,0, $title, NULL, $title); @@ -538,7 +547,7 @@ * @param int - the new step # */ function _set_current_step($step) { - ddd( "SET STEP ".$step); + debug( "SET STEP ".$step); $_SESSION[$this->_vars[WIZARD_ID]]["current_step"] = $step; }