configuration=&$c; $this->module=new module($c->module); $this->step=$step; if (!$noload) { $file=$this->module->dir."/step$step.php"; if (!is_readable($file)) { throw_exception("$mod step $step doesn't exist!"); } require($file); } $this->title=$this->module->steps[$step-1]; $this->next=isset($next)?$next:($this->step == $this->module->numsteps?null:$step+1); } public function output($rw=true) { global $conf; echo "
step\">"; if ($rw) echo '
Status'; if ($rw) { echo '

Step '.$this->step.': '.$this->title."

\n"; $scale=$conf['progressbar_width']/$this->module->numsteps; echo '
'."\n"; $this->echo_buttons(); } foreach ($this->data as $obj) { if (is_array($obj)) { if (!$obj[0]->status) { echo print_warning('Please complete this field:'); } $obj[0]->output($rw, $this->get_opt($obj[1])); } else { echo $obj; } } if ($rw) { echo '
'; $this->echo_buttons(); } echo '
'."\n"; } public function process() { global $request; if (!isset($request['wizard_submit'][$this->step])) { return $this->step; } $result=$this->next; foreach ($this->data as $obj) { if (is_array($obj)) { $value=$obj[0]->process(); $obj[0]->status=($value !== false); if ($obj[0]->status) { $this->set_opt($obj[1], $value); } else { $result=$this->step; debug('wizard', htmlentities("{$obj[1]} incomplete ($value)")); } } } return $result; } public function verify() { foreach ($this->data as $obj) { if (!is_array($obj)) continue; if (($val=$this->get_opt($obj[1])) === false) { return null; } elseif (!($obj[0]->status=$obj[0]->verify($val))) { return false; } } return true; } private function text($text) { $this->data[]=$text; } private function text_input($optname, $htmlname, $label) { $this->data[]=array(new text_input($htmlname, $label), $optname); } private function select($optname, $htmlname, $label, $options) { $this->data[]=array(new select($htmlname, $label, $options), $optname); } private function radio_array($optname, $htmlname, $label, $options) { $this->data[]=array(new radio_array($htmlname, $label, $options), $optname); } private function checkbox_array($optname, $htmlname, $label, $array, $delim=' ') { $this->data[]=array(new checkbox_array($htmlname, $label, $array, $delim=' '), $optname); } private function layered_checkbox_array($optname, $htmlname, $label, &$array, $delim=' ', $metadata) { $this->data[]=array(new layered_checkbox_array($htmlname, $label, $array, $delim, $metadata), $optname); } private function query($q) { return $GLOBALS['S']['pdo']->query($q); } private function set_opt($opt, $val) { return $this->configuration->set_opt($opt, $val); } private function get_opt($opt) { return $this->configuration->get_opt($opt); } private function delete_opt($name) { return $this->configuration->delete_opt($name); } private function echo_buttons() { echo ($this->step > 1?' ':' ').'
'; } } ?>