From e48fc17dce36492e61fc7be6d953813953fd82cd Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 18 Dec 2004 20:24:50 +0000 Subject: [PATCH] The wizard system now works! --- usr/local/www/wizard.php | 57 +++++++++++++++++--------- usr/local/www/wizards/setup_wizard.xml | 25 ++++++----- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/usr/local/www/wizard.php b/usr/local/www/wizard.php index e09828a3b6..5f8b7d5f51 100755 --- a/usr/local/www/wizard.php +++ b/usr/local/www/wizard.php @@ -56,19 +56,40 @@ $title = $pkg['step'][$stepid]['title']; $description = $pkg['step'][$stepid]['description']; if ($_POST) { - foreach ($pkg['step'][$stepid]['fields'] as $field) { - if($field['bindtofield'] <> "") { - // update field with posted values. - + foreach ($pkg['step'][$stepid]['fields']['field'] as $field) { + if($field['bindstofield'] <> "" and $field['type'] <> "submit") { + $fieldname = $field['name']; + $unset_fields = ""; + $fieldname = ereg_replace(" ", "", $fieldname); + $fieldname = strtolower($fieldname); + // update field with posted values. + if($field['unsetfield'] <> "") $unset_fields = "yes"; + if($field['bindstofield']) + update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields); } if($pkg['step'][$stepid]['stepsubmitphpaction']) { - eval($pkg['step'][$stepid]['stepsubmitphpaction']); + // run custom php code embedded in xml config. + eval($pkg['step'][$stepid]['stepsubmitphpaction']); } + write_config(); } + $stepid++; } -function update_config_field($field, $updatetext) { - $config[$field] = $updatetext; +function update_config_field($field, $updatetext, $unset) { + global $config; + $field_split = split("->",$field); + foreach ($field_split as $f) $field_conv .= "['" . $f . "']"; + if($field_conv == "") return; + if($unset <> "") { + $text = "unset(\$config" . $field_conv . ");"; + eval($text); + $text = "\$config" . $field_conv . "[] = \"" . $updatetext . "\";"; + eval($text); + } else { + $text = "\$config" . $field_conv . "[] = \"" . $updatetext . "\";"; + eval($text); + } } ?> @@ -81,19 +102,18 @@ function update_config_field($field, $updatetext) { - -

- + - +
+ + 
+ +

+ +

@@ -142,7 +162,7 @@ $config = $config_tmp; echo ":
"; echo "