'Page One',
'two' => 'Page Two',
'three' => 'Page Three',
);
*/
require_once "$TOPDIR/jq/jsonwrapper.php";
function displayWizard($pages) {
$keys = array_keys($pages);
if (isset($_REQUEST['page'])) { // navigate to another page in the wizard
$page = $_REQUEST['page'];
$action = $_REQUEST['action'];
$step = (isset($_REQUEST['step']) ? $_REQUEST['step'] : 0);
// Figure out the function for this page. Search the keys.
if ($action == 'cancel') {
$k = 0;
$step = 0;
// should we unset all the _SESSION variables?
}
else { // some action other than cancel
$k = array_search($page, $keys);
if ($k === FALSE) { msg('E',"Page $page not found in the wizard."); exit; }
if ($action == 'back') {
$k--;
$step = 0;
if ($k < 0) { msg('E',"Can't go backward past the 1st page ($page)."); exit; }
}
elseif ($action == 'next') {
$k++;
if ($k >= count($pages)) { $k = 0; } // this was the Finish button - go back to the beginning
}
elseif ($action == 'step') {
// do the next step on this page. Both k and step are already set correctly.
}
}
// Run the function for this page
//dumpGlobals();
if (isset($_REQUEST['output'])) { insertWizardOutputHeader(); }
if ($action != 'step') configureButtons($k, $pages);
$keys[$k]($action, $step);
}
else { // initial display of the wizard - show the 1st page
echo "
\n"; // end the outer wizard pane
}
} // end of displayWizard()
//-----------------------------------------------------------------------------
// Disable buttons as appropriate and set current page
function configureButtons($k, $arr) {
$keys = array_keys($arr);
//echo "
currentPage=", $keys[$k], ".
\n";
echo "\n";
}
//-----------------------------------------------------------------------------
// Display a list of tasks to be done.
function insertProgressTable($tasks) {
global $TOPDIR;
echo "
\n";
}
//-----------------------------------------------------------------------------
// Instruct the client-side to move on to the next step in this page.
function nextStep($step, $done) {
// Was using JSON, but that is more difficult with all the utilities that can directly display errors they encounter.
//echo json_encode(array('step' => (integer)++$step, 'done' => FALSE, 'error' => ''));
$func = (isset($_REQUEST['output']) ? 'parent.wizardStep' : 'wizardStep');
echo "";
}
//-----------------------------------------------------------------------------
// Used for the html that we send to the iframe
function insertWizardOutputHeader() {
echo <<
EOS1;
}
?>