From f852ea2a5df175f9969e7e2fe160e894aeaac043 Mon Sep 17 00:00:00 2001 From: Eudyptula Date: Wed, 15 Jul 2009 17:15:54 -0400 Subject: Added viewing of chosen options to status viewer --- frontend/classes/wizard_api.php | 89 ++++++++++++++++++++++--------- frontend/pages/configurations/manager.php | 3 +- frontend/pages/configurations/status.php | 17 +++--- todo | 1 + 4 files changed, 78 insertions(+), 32 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 "
step\">"; - echo '
Status

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

\n"; - $scale=$conf['progressbar_width']/$this->module->numsteps; - echo '
'."\n"; - $this->echo_buttons(); + 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) { + // print warning if rw is false? if (!$obj->status) { echo print_warning('Please complete this field.'); } - $obj->output(); + $obj->output($rw); + } + if ($rw) { + echo '
'; + $this->echo_buttons(); } - echo '
'; - $this->echo_buttons(); echo '
'."\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 "htmlname\" />
\n"; + public function output($rw=true) { + parent::output($rw); + echo $rw?"htmlname\"".(($val=$this->get_opt($this->optname)) === null?'':'value="'.htmlentities($val).'"').' />':htmlentities($this->get_opt($this->optname)); + echo "
\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 ''."\n"; + $i=0; + } foreach ($this->options as $val => $label) { - echo "\t".''."\n"; + if ($rw) + echo "\t".''."\n"; + elseif ($this->opt_is($this->optname, $val)) + echo htmlentities($label); } - echo ''."\n"; + if ($rw) + echo "\n"; + else + echo "
\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:
\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:
\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 '

'.htmlentities($this->label).'

'; } - $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)."
\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); diff --git a/frontend/pages/configurations/manager.php b/frontend/pages/configurations/manager.php index 148a470..68297fe 100644 --- a/frontend/pages/configurations/manager.php +++ b/frontend/pages/configurations/manager.php @@ -44,10 +44,11 @@ function body_configurations_manager() { if ($c->status > 0) { echo 'id")."\">Step $c->status"; } elseif ($c->status == 0) { - echo 'Ready (id/status").'">modify)'; + echo 'Ready'; } else { echo $c->status; } + echo ' (id/status").'">view)'; echo ''.$c->summary().''; $builds=$c->get_builds(); if ($builds) { diff --git a/frontend/pages/configurations/status.php b/frontend/pages/configurations/status.php index ebeeab3..d27efd4 100644 --- a/frontend/pages/configurations/status.php +++ b/frontend/pages/configurations/status.php @@ -24,12 +24,11 @@ function body_configurations_status() { $status=true; $good=0; for ($i=1; $i<=$module->numsteps; $i++) { - $r[$i]='
  • '; - $step=new wizard_step($c, $i, !$status); - $r[$i].=($status?'id/$i")."\">$step->title":$step->title); + $steps[$i]=new wizard_step($c, $i, !$status); + $r[$i]=($status?'id/$i")."\">{$steps[$i]->title}":$steps[$i]->title); if ($status) { $r[$i].=' - '; - $good+=($status=$step->verify())?1:0; + $good+=($status=$steps[$i]->verify())?1:0; if ($status === null) $r[$i].='Incomplete'; elseif ($status) @@ -37,10 +36,16 @@ function body_configurations_status() { else $r[$i].='INVALID'; } - $r[$i].='
  • '; } echo '

    '.($c->name?htmlentities($c->name):$c->id).": $good of $module->numsteps steps complete

    \n"; - echo '
      '.implode('', $r).'
    '; + echo '
      '; + foreach ($steps as $i => $step) { + echo '
    1. '; + echo $r[$i]; + $step->output(false); + echo '
    2. '; + } + echo '
    '; if ($good < $module->numsteps) echo 'id/".($good+1)).'">Finish configuration'; } diff --git a/todo b/todo index e8a6bbf..ae16bcf 100644 --- a/todo +++ b/todo @@ -21,3 +21,4 @@ Simplify status to numeric on builds - varchar isn't necessary Move gentoo_profiles setup out of the general setup.php, allow per-module setup Move bundler selection out of gentoo module and generalize it (switch to builds instead of configurations) Improve the quality of base system creation (if necessary) +Allow config viewing for builds, not just logs -- cgit v1.2.3-65-gdbad