summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/classes/wizard_api.php')
-rw-r--r--frontend/classes/wizard_api.php89
1 files changed, 64 insertions, 25 deletions
diff --git a/frontend/classes/wizard_api.php b/frontend/classes/wizard_api.php
index 381a267..049f3cc 100644
--- a/frontend/classes/wizard_api.php
+++ b/frontend/classes/wizard_api.php
@@ -15,21 +15,28 @@ class wizard_step {
$this->title=$this->module->steps[$step-1];
$this->next=isset($next)?$next:($this->step == $this->module->numsteps?null:$step+1);
}
- public function output() {
+ public function output($rw=true) {
global $conf;
echo "<div class=\"wizard\" id=\"step$this->step\">";
- echo '<form action="'.url('config/'.$this->configuration->id).'" method="post"><a style="float: right" href="'.url('config/'.$this->configuration->id.'/status').'">Status</a><h3>Step '.$this->step.': '.$this->title."</h3>\n";
- $scale=$conf['progressbar_width']/$this->module->numsteps;
- echo '<img src="'.url('images/full.gif').'" style="border-left: 1px solid black; border-top: 1px solid black; border-bottom: 1px solid black; width: '.$this->step*$scale.'px; height: 15px" /><img src="'.url('images/empty.gif').'" style="border-right: 1px solid black; border-top: 1px solid black; border-bottom: 1px solid black; width: '.(count($this->module->steps)-$this->step)*$scale.'px; height: 15px" /><br/>'."\n";
- $this->echo_buttons();
+ if ($rw)
+ echo '<form action="'.url('config/'.$this->configuration->id).'" method="post"><a style="float: right" href="'.url('config/'.$this->configuration->id.'/status').'">Status</a>';
+ if ($rw) {
+ echo '<h3>Step '.$this->step.': '.$this->title."</h3>\n";
+ $scale=$conf['progressbar_width']/$this->module->numsteps;
+ echo '<img src="'.url('images/full.gif').'" style="border-left: 1px solid black; border-top: 1px solid black; border-bottom: 1px solid black; width: '.$this->step*$scale.'px; height: 15px" /><img src="'.url('images/empty.gif').'" style="border-right: 1px solid black; border-top: 1px solid black; border-bottom: 1px solid black; width: '.(count($this->module->steps)-$this->step)*$scale.'px; height: 15px" /><br/>'."\n";
+ $this->echo_buttons();
+ }
foreach ($this->data as $obj) {
+ // print warning if rw is false?
if (!$obj->status) {
echo print_warning('Please complete this field.');
}
- $obj->output();
+ $obj->output($rw);
+ }
+ if ($rw) {
+ echo '<br/>';
+ $this->echo_buttons();
}
- echo '<br/>';
- $this->echo_buttons();
echo '</div>'."\n";
}
public function process() {
@@ -86,7 +93,7 @@ abstract class wizard {
function __construct(&$c) {
$this->configuration=&$c;
}
- abstract public function output();
+ abstract public function output($rw=true);
abstract public function process();
abstract public function verify();
abstract public function clear();
@@ -115,7 +122,7 @@ class wizard_text extends wizard {
parent::__construct($c);
$this->text=$text;
}
- public function output() {
+ public function output($rw=true) {
echo $this->text;
}
public function process() {
@@ -134,7 +141,7 @@ abstract class wizard_input extends wizard {
$this->htmlname=htmlentities($htmlname);
$this->label=htmlentities($label);
}
- public function output() {
+ public function output($rw=true) {
echo "$this->label: ";
}
public function process() {
@@ -154,9 +161,10 @@ abstract class wizard_input extends wizard {
}
}
class wizard_text_input extends wizard_input {
- public function output() {
- parent::output();
- echo "<input name=\"$this->htmlname\" /><br/>\n";
+ public function output($rw=true) {
+ parent::output($rw);
+ echo $rw?"<input name=\"$this->htmlname\"".(($val=$this->get_opt($this->optname)) === null?'':'value="'.htmlentities($val).'"').' />':htmlentities($this->get_opt($this->optname));
+ echo "<br/>\n";
}
}
class wizard_select extends wizard_input {
@@ -165,14 +173,22 @@ class wizard_select extends wizard_input {
parent::__construct($c, $optname, $htmlname, $label);
$this->options=$options;
}
- public function output() {
- parent::output();
- echo '<select name="'.$this->htmlname.'">'."\n";
- $i=0;
+ public function output($rw=true) {
+ parent::output($rw);
+ if ($rw) {
+ echo '<select name="'.$this->htmlname.'">'."\n";
+ $i=0;
+ }
foreach ($this->options as $val => $label) {
- echo "\t".'<option value="'.$i++.'"'.($this->opt_is($this->optname, $val)?' selected="selected"':'').'>'.htmlentities($label).'</option>'."\n";
+ if ($rw)
+ echo "\t".'<option value="'.$i++.'"'.($this->opt_is($this->optname, $val)?' selected="selected"':'').'>'.htmlentities($label).'</option>'."\n";
+ elseif ($this->opt_is($this->optname, $val))
+ echo htmlentities($label);
}
- echo '</select>'."\n";
+ if ($rw)
+ echo "</select>\n";
+ else
+ echo "<br/>\n";
}
public function process() {
global $request;
@@ -188,7 +204,8 @@ class wizard_select extends wizard_input {
}
}
class wizard_radio extends wizard_select {
- public function output() {
+ public function output($rw=true) {
+ if (!$rw) return parent::output($rw);
echo "$this->label:<br/>\n";
$i=0;
foreach ($this->options as $val => $label) {
@@ -204,7 +221,7 @@ class wizard_checkbox_array extends wizard_input {
$this->array=$array;
$this->delim=$delim;
}
- public function output() {
+ public function output($rw=true) {
echo "$this->label:<br/>\n";
$i=0;
foreach ($this->array as $val => $label) {
@@ -251,11 +268,14 @@ class wizard_layered_checkbox_array extends wizard_checkbox_array {
$S['scripts'][]='wlca';
}
}
- public function output() {
+ public function output($rw=true) {
if ($this->label) {
echo '<h4>'.htmlentities($this->label).'</h4>';
}
- $this->r_output($this->array);
+ if ($rw)
+ $this->r_output($this->array);
+ else
+ $this->r_ro_output($this->array);
}
public function process() {
$this->set_opt($this->optname, implode($this->delim, $this->r_process($this->array)));
@@ -359,12 +379,31 @@ class wizard_layered_checkbox_array extends wizard_checkbox_array {
}
}
if ($depth < $this->depth) {
- foreach($array as $name => &$val)
+ foreach ($array as $name => &$val)
$this->r_verify($vals, $val, $depth+1, $path.$meta['delim'].$name, $name);
}
return $vals;
}
}
+ private function r_ro_output(&$array, $depth=0, $path=null, $name=null) {
+ if ($depth == 0) {
+ foreach ($array as $name => &$val) {
+ $this->r_ro_output($val, $depth+1, $name, $name);
+ }
+ } else {
+ $meta=$this->metadata[$depth];
+ if (isset($meta['checkbox'])) {
+ $val=$this->format_label($array, $meta['checkbox'], $path, $name);
+ if ($this->opt_has($this->optname, $val, $this->delim)) {
+ echo $this->format_label($array, $meta['label'], $path, $name)."<br/>\n";
+ }
+ }
+ if ($depth < $this->depth) {
+ foreach ($array as $name => &$val)
+ $this->r_ro_output($val, $depth+1, $path.$meta['delim'].$name, $name);
+ }
+ }
+ }
private function format_label(&$array, $label='%p', $path, $name) {
$arg=$array;
$label=str_replace(array('%p', '%n'), array($path, $name), $label);