--- nfo/php/libs/com.newsblob.phphtmllib/form/FormWizard.inc 2004/05/06 16:27:23 1.2
+++ nfo/php/libs/com.newsblob.phphtmllib/form/FormWizard.inc 2005/08/11 14:09:26 1.3
@@ -2,13 +2,14 @@
/**
* This file contains the FormWizard class.
*
- * $Id: FormWizard.inc,v 1.2 2004/05/06 16:27:23 jonen Exp $
+ * $Id: FormWizard.inc,v 1.3 2005/08/11 14:09:26 jonen Exp $
*
- * @author Walter A. Boring IV
+ * @author Walter A. Boring IV
* @package phpHtmlLib
* @subpackage FormProcessing
*
* @copyright LGPL - See LICENCE
+ * @todo Finish this. It doesn't work now.
*
*/
@@ -23,11 +24,22 @@
define("WIZARD_JUMP", "JUMP");
define("WIZARD_FINAL", "FINAL");
+
+/**
+ * This is a magic container that allows you
+ * to chain together multiple FormContent objects
+ * to automatically create a Wizard process.
+ *
+ * @package phpHtmlLib
+ * @subpackage FormProcessing
+ *
+ * @todo Finish this. It doesn't work now.
+ */
class FormWizard extends FormProcessor {
/**
* This holds the array of
- * step objects for the
+ * step objects for the
* wizard
*/
var $_steps = array();
@@ -74,7 +86,7 @@
/**
- * This function renders the
+ * This function renders the
* FormWizard
*
*/
@@ -175,11 +187,11 @@
if (!$this->_has_errors) {
//ok this step validated. lets display the next.
//mark this step as visited
- $current_step = $this->_current_step();
+ $current_step = $this->_current_step();
debug( "CURRENT STEP ".$current_step);
switch ($_REQUEST[WIZARD_ACTION]) {
- case WIZARD_NEXT:
+ case WIZARD_NEXT:
debug("NEXT");
if ($current_step == $this->_vars["num_steps"]) {
debug("SHOW CONFIRMATION");
@@ -201,7 +213,7 @@
debug("PREV");
$this->_set_current_step($current_step-1);
unset($_REQUEST[FORM_VISITED]);
- $this->_form_content = &$this->_steps[$this->_current_step()-1]["form"];
+ $this->_form_content = &$this->_steps[$this->_current_step()-1]["form"];
//$this->_process_form();
break;
}
@@ -282,12 +294,12 @@
/**
- * This function initializes all of the fields we
+ * This function initializes all of the fields we
* need to keep track of for the internal state
* of the wizard. It also walks each of the
* step FormContent objects and initializes them.
- *
- * We save some of the state of the wizard in
+ *
+ * We save some of the state of the wizard in
* the session.
*/
function _init() {
@@ -296,7 +308,7 @@
$this->_vars[WIZARD_ID] = uniqid("wizard_");
//debug( $this->_vars );
- $this->_init_session();
+ $this->_init_session();
$this->_vars["to_step"] = 2;
} else {
$this->_vars[WIZARD_ID] = $_REQUEST[WIZARD_ID];
@@ -307,7 +319,7 @@
// $this->_vars["to_step"] = WIZARD_FINAL;
//} else {
// $this->_vars["to_step"] = WIZARD_NEXT;
- //}
+ //}
}
//debug( $_SESSION );
@@ -322,7 +334,7 @@
/**
* This function sets the _form_content
* object for the current step we are operating on.
- * The parent FormProcessor needs this object set
+ * The parent FormProcessor needs this object set
* in order to process the step correctly.
*
*/
@@ -413,13 +425,13 @@
$step_num = 1;
foreach( $this->_steps as $step ) {
$c->add( $this->_build_step_image( $step_num, $step["title"] ) );
-
+
if ($step_num != $this->_vars["num_steps"]) {
$arrow = html_img("/phphtmllib/images/wizard/arrow.png");
$arrow->set_style("vertical-align:super");
$c->add( $arrow );
}
-
+
$step_num++;
}
@@ -448,18 +460,18 @@
$c->set_style("padding-top: 5px;");
if ($current_step != 1) {
- $link = html_a("javascript:wizard_submit2('".WIZARD_PREV."',".($current_step-1).");",
+ $link = html_a("javascript:wizard_submit2('".WIZARD_PREV."',".($current_step-1).");",
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).");",
+ $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);
+ $c->add( _HTML_SPACE, _HTML_SPACE, $link);
} else {
- $link = html_a("javascript:wizard_submit2('".WIZARD_NEXT."',".($current_step+1).");",
+ $link = html_a("javascript:wizard_submit2('".WIZARD_NEXT."',".($current_step+1).");",
html_img("/phphtmllib/images/wizard/next_step.png") );
$c->add( $link );
}
@@ -489,7 +501,7 @@
if ($step_num == $current_step) {
$title .= " (Current) : ".$step_title;
- $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,
$title, NULL, $title);
} else if ($this->_is_step_visited($step_num) ||
@@ -503,7 +515,7 @@
$img = html_img("/phphtmllib/images/wizard/".$step_num."_gray.png", 30,30,0,
$title, NULL, $title);
}
-
+
return $img;
}
@@ -514,18 +526,18 @@
/*****************************************/
/**
- * This method initializes the session
+ * This method initializes the session
* variable that we use
*
*/
function _init_session() {
- //create a unique id for this wizard
- //so we can have multple wizards
+ //create a unique id for this wizard
+ //so we can have multple wizards
//running per session.
$_SESSION[$this->_vars[WIZARD_ID]] = array();
$_SESSION[$this->_vars[WIZARD_ID]];
$this->_set_current_step(1);
-
+
//mark all steps as NOT visited
for ($i=0; $i<=$this->_vars["num_steps"]-1; $i++) {
$this->_step_visited($i, FALSE);
@@ -553,7 +565,7 @@
/**
- * This sets the state variable for the
+ * This sets the state variable for the
* step to let us know it has been visited or not
*
* @param int - the step to mark
@@ -574,7 +586,7 @@
return $_SESSION[$this->_vars[WIZARD_ID]]["visited_steps"][$step_num];
} else {
return FALSE;
- }
+ }
}
/**
@@ -589,7 +601,7 @@
/**
* This ensures that we have sessions started
- *
+ *
*/
function _session_test() {
if (!session_id()) {