47 |
* |
* |
48 |
*/ |
*/ |
49 |
function FormWizard() { |
function FormWizard() { |
50 |
user_error(__CLASS__."::".__FUNCTION." - this class isn't done yet."); |
//user_error(__CLASS__."::".__FUNCTION__." - this class isn't done yet."); |
51 |
$this->_session_test(); |
$this->_session_test(); |
52 |
$this->set_form_name( "form_wizard" ); |
$this->set_form_name( "form_wizard" ); |
53 |
$this->set_form_action( $_SERVER["PHP_SELF"] ); |
$this->set_form_action( $_SERVER["PHP_SELF"] ); |
93 |
$container->add( $this->render_error($indent_level, $output_debug) ); |
$container->add( $this->render_error($indent_level, $output_debug) ); |
94 |
} else { |
} else { |
95 |
//there are no errors! |
//there are no errors! |
96 |
ddd( "have we visited?" ); |
debug( "have we visited?" ,null,4); |
97 |
//ddd( $_REQUEST ); |
//debug( $_REQUEST ); |
98 |
if (@$_REQUEST[FORM_VISITED] == 1) { |
if (isset($_REQUEST[FORM_VISITED]) && $_REQUEST[FORM_VISITED] == 1) { |
99 |
//looks like the form has been processed? |
//looks like the form has been processed? |
100 |
ddd( "confirmed = ".$this->_confirmed ); |
debug( "confirmed = ".$this->_confirmed ); |
101 |
ddd( "curr step = ".$this->_current_step() ); |
debug( "curr step = ".$this->_current_step() ); |
102 |
if (!$this->_confirmed && $this->_vars["on_confirm"]) { |
if (!$this->_confirmed && $this->_vars["on_confirm"]) { |
103 |
ddd("FINAL DUDE!"); |
debug("FINAL DUDE!"); |
104 |
$container->add( $this->render_confirm($indent_level, $output_debug) ); |
$container->add( $this->render_confirm($indent_level, $output_debug) ); |
105 |
} else { |
} else { |
106 |
//Looks like the action worked |
//Looks like the action worked |
107 |
$success = $this->_form_content->form_success(); |
$success = $this->_form_content->form_success(); |
108 |
|
debug("DO ACTION!"); |
109 |
if ($this->_form_success_render) { |
if ($this->_form_success_render) { |
110 |
$container->add( $this->render_form($indent_level, $output_debug, $success) ); |
$container->add( $this->render_form($indent_level, $output_debug, $success) ); |
111 |
} else { |
} else { |
145 |
//if it has been visited. Otherwise |
//if it has been visited. Otherwise |
146 |
//it just gets rendered. |
//it just gets rendered. |
147 |
if (@$_REQUEST[FORM_VISITED] == 1) { |
if (@$_REQUEST[FORM_VISITED] == 1) { |
148 |
ddd("PROCESS STEP ".$this->_current_step()); |
debug("PROCESS STEP ".$this->_current_step()); |
149 |
$this->_form_content->set_action($_REQUEST[FORM_ACTION]); |
$this->_form_content->set_action($_REQUEST[FORM_ACTION]); |
150 |
|
|
151 |
//let see if this was a confirmation page. |
//let see if this was a confirmation page. |
162 |
//need to validate the form. |
//need to validate the form. |
163 |
if ($this->can_validate()) { |
if ($this->can_validate()) { |
164 |
//looks like we should do validation |
//looks like we should do validation |
165 |
$this->do_validation(); |
if ($_REQUEST[WIZARD_ACTION] != WIZARD_PREV) { |
166 |
|
//we don't need to validate if we haven't |
167 |
|
//finished this step yet. |
168 |
|
$this->do_validation(); |
169 |
|
} |
170 |
} |
} |
171 |
if (!$this->_has_errors) { |
if (!$this->_has_errors) { |
172 |
//no errors were found |
//no errors were found |
175 |
if (!$this->_has_errors) { |
if (!$this->_has_errors) { |
176 |
//ok this step validated. lets display the next. |
//ok this step validated. lets display the next. |
177 |
//mark this step as visited |
//mark this step as visited |
178 |
$current_step = $this->_current_step(); |
$current_step = $this->_current_step(); |
179 |
$this->_step_visited( $current_step ); |
debug( "CURRENT STEP ".$current_step); |
|
ddd( "CURRENT STEP ".$current_step); |
|
180 |
|
|
181 |
switch ($_REQUEST[WIZARD_ACTION]) { |
switch ($_REQUEST[WIZARD_ACTION]) { |
182 |
case WIZARD_NEXT: |
case WIZARD_NEXT: |
183 |
ddd("NEXT"); |
debug("NEXT"); |
184 |
if ($current_step == $this->_vars["num_steps"]) { |
if ($current_step == $this->_vars["num_steps"]) { |
185 |
|
debug("SHOW CONFIRMATION"); |
186 |
//we need to show the confirmation |
//we need to show the confirmation |
187 |
//don't process |
//don't process |
188 |
$this->_vars["on_confirm"] = TRUE; |
$this->_vars["on_confirm"] = TRUE; |
189 |
ddd("ASS"); |
$this->_step_visited( $current_step ); |
190 |
|
$this->_set_current_step($current_step+1); |
191 |
} else { |
} else { |
192 |
|
$this->_step_visited( $current_step ); |
193 |
$this->_set_current_step($current_step+1); |
$this->_set_current_step($current_step+1); |
194 |
unset($_REQUEST[FORM_VISITED]); |
unset($_REQUEST[FORM_VISITED]); |
195 |
$this->_form_content = &$this->_steps[$this->_current_step()-1]["form"]; |
$this->_form_content = &$this->_steps[$this->_current_step()-1]["form"]; |
196 |
$this->_process_form(); |
//$this->_process_form(); |
197 |
} |
} |
198 |
break; |
break; |
199 |
|
|
200 |
case WIZARD_PREV: |
case WIZARD_PREV: |
201 |
|
debug("PREV"); |
202 |
$this->_set_current_step($current_step-1); |
$this->_set_current_step($current_step-1); |
203 |
unset($_REQUEST[FORM_VISITED]); |
unset($_REQUEST[FORM_VISITED]); |
204 |
$this->_form_content = &$this->_steps[$this->_current_step()-1]["form"]; |
$this->_form_content = &$this->_steps[$this->_current_step()-1]["form"]; |
205 |
ddd("PREV"); |
//$this->_process_form(); |
|
$this->_process_form(); |
|
206 |
break; |
break; |
207 |
} |
} |
208 |
} |
} |
209 |
} |
} |
210 |
} |
} |
211 |
} |
} |
212 |
ddd("bail"); |
debug("bail"); |
213 |
} |
} |
214 |
|
|
215 |
|
|
227 |
* @return string - the raw html |
* @return string - the raw html |
228 |
*/ |
*/ |
229 |
function render_confirm( $indent_level, $output_debug ) { |
function render_confirm( $indent_level, $output_debug ) { |
230 |
ddd("BUILD CONFIRM"); |
debug("BUILD CONFIRM"); |
231 |
//build the $this->_form object. |
//build the $this->_form object. |
232 |
$this->_build_form_tag(); |
$this->_build_form_tag(); |
233 |
|
|
294 |
if (!isset($_REQUEST[WIZARD_VISITED])) { |
if (!isset($_REQUEST[WIZARD_VISITED])) { |
295 |
|
|
296 |
$this->_vars[WIZARD_ID] = uniqid("wizard_"); |
$this->_vars[WIZARD_ID] = uniqid("wizard_"); |
297 |
ddd( $this->_vars ); |
//debug( $this->_vars ); |
298 |
|
|
299 |
$this->_init_session(); |
$this->_init_session(); |
300 |
$this->_vars["to_step"] = 2; |
$this->_vars["to_step"] = 2; |
309 |
// $this->_vars["to_step"] = WIZARD_NEXT; |
// $this->_vars["to_step"] = WIZARD_NEXT; |
310 |
//} |
//} |
311 |
} |
} |
312 |
//ddd( $_SESSION ); |
//debug( $_SESSION ); |
313 |
|
|
314 |
//initialize all of the Forms |
//initialize all of the Forms |
315 |
//so they retain their data. |
//so they retain their data. |
397 |
*/ |
*/ |
398 |
function _build_toolbar() { |
function _build_toolbar() { |
399 |
$current_step = $this->_current_step(); |
$current_step = $this->_current_step(); |
400 |
|
xxx("current step ".$current_step); |
401 |
if ($this->_vars["on_confirm"]) { |
if ($this->_vars["on_confirm"]) { |
402 |
$current_step++; |
$current_step++; |
403 |
$step_title = "Confirmation"; |
$step_title = "Confirmation"; |
424 |
} |
} |
425 |
|
|
426 |
//add the confirmation step |
//add the confirmation step |
427 |
|
xxx($step_num); |
428 |
$c->add( $arrow ); |
$c->add( $arrow ); |
429 |
$c->add( $this->_build_step_image( $step_num, "Confirmation" ) ); |
$c->add( $this->_build_step_image( $step_num, "Confirmation" ) ); |
430 |
|
|
452 |
html_img("/phphtmllib/images/wizard/previous_step.png")); |
html_img("/phphtmllib/images/wizard/previous_step.png")); |
453 |
$c->add( $link ); |
$c->add( $link ); |
454 |
} |
} |
455 |
|
|
456 |
|
if ($current_step == $this->_vars["num_steps"]+1) { |
457 |
|
$link = html_a("javascript:wizard_submit2('".WIZARD_FINAL."',".($current_step).");", |
458 |
|
html_img("/phphtmllib/images/wizard/finish_steps.png") ); |
459 |
|
|
460 |
if ($current_step != $this->_vars["num_steps"]) { |
$c->add( _HTML_SPACE, _HTML_SPACE, $link); |
461 |
|
} else { |
462 |
$link = html_a("javascript:wizard_submit2('".WIZARD_NEXT."',".($current_step+1).");", |
$link = html_a("javascript:wizard_submit2('".WIZARD_NEXT."',".($current_step+1).");", |
463 |
html_img("/phphtmllib/images/wizard/next_step.png") ); |
html_img("/phphtmllib/images/wizard/next_step.png") ); |
464 |
$c->add( $link ); |
$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); |
|
465 |
} |
} |
466 |
|
|
467 |
|
|
483 |
$title = "Step ".$step_num." "; |
$title = "Step ".$step_num." "; |
484 |
|
|
485 |
$current_step = $this->_current_step(); |
$current_step = $this->_current_step(); |
486 |
if ($this->_vars["on_confirm"]) { |
//if ($this->_vars["on_confirm"]) { |
487 |
$current_step++; |
//$current_step++; |
488 |
} |
//} |
489 |
|
|
490 |
if ($step_num == $current_step) { |
if ($step_num == $current_step) { |
491 |
$title .= " (Current) : ".$step_title; |
$title .= " (Current) : ".$step_title; |
492 |
$img = html_img("/phphtmllib/images/wizard/".$step_num."_red.png", 30, 30, 0, |
$img = html_img("/phphtmllib/images/wizard/".$step_num."_red.png", 30, 30, 0, |
493 |
$title, NULL, $title); |
$title, NULL, $title); |
494 |
|
|
495 |
} else if ($this->_is_step_visited($step_num)) { |
} else if ($this->_is_step_visited($step_num) || |
496 |
|
$current_step == $this->_vars["num_steps"]+1) { |
497 |
$title .= " (Completed) : ".$step_title; |
$title .= " (Completed) : ".$step_title; |
498 |
$img = html_img("/phphtmllib/images/wizard/".$step_num."_black.png", 30, 30 ,0, |
$img = html_img("/phphtmllib/images/wizard/".$step_num."_black.png", 30, 30 ,0, |
499 |
$title, NULL, $title); |
$title, NULL, $title); |
547 |
* @param int - the new step # |
* @param int - the new step # |
548 |
*/ |
*/ |
549 |
function _set_current_step($step) { |
function _set_current_step($step) { |
550 |
ddd( "SET STEP ".$step); |
debug( "SET STEP ".$step); |
551 |
$_SESSION[$this->_vars[WIZARD_ID]]["current_step"] = $step; |
$_SESSION[$this->_vars[WIZARD_ID]]["current_step"] = $step; |
552 |
} |
} |
553 |
|
|