summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/modules/gentoo_portage/setup.php1
-rw-r--r--frontend/classes/form.php53
-rw-r--r--frontend/classes/form_elements.php (renamed from frontend/classes/forms.php)0
-rw-r--r--frontend/classes/wizard.php69
4 files changed, 73 insertions, 50 deletions
diff --git a/backend/modules/gentoo_portage/setup.php b/backend/modules/gentoo_portage/setup.php
index 93dbad8..b6accfb 100644
--- a/backend/modules/gentoo_portage/setup.php
+++ b/backend/modules/gentoo_portage/setup.php
@@ -6,6 +6,7 @@ $makeconf=array(
'pkgdir' => $S['conf']['pkgdir_root'].'/'.$profile->pkgdir,
'chost' => $headers['chost'],
'accept_keywords' => $headers['accept_keywords'],
+ 'accept_properties' => '-interactive',
'root' => $imagedir,
'port_logdir' => "$workdir/log",
'emerge_log_dir' => "$workdir/log",
diff --git a/frontend/classes/form.php b/frontend/classes/form.php
new file mode 100644
index 0000000..51f548f
--- /dev/null
+++ b/frontend/classes/form.php
@@ -0,0 +1,53 @@
+<?php
+class form {
+ protected $elements=array();
+ function output($rw=true, $vals=array()) {
+ foreach ($this->elements as $name => &$el) {
+ if (is_object($el)) {
+ if (!$el->status)
+ echo print_warning('Please complete this field:');
+ $el->output($rw, isset($vals[$name])?$vals[$name]:false);
+ } else {
+ echo $el;
+ }
+ }
+ }
+ function process() {
+ $vals=array();
+ foreach ($this->elements as $name => &$el) {
+ if (!is_object($el)) continue;
+ $vals[$name]=$el->process();
+ $el->status=$vals[$name] !== false;
+ }
+ return $vals;
+ }
+ function verify($vals) {
+ foreach ($this->elements as $name => &$el) {
+ if (!is_object($el)) continue;
+ if (!isset($vals[$name]))
+ return null;
+ elseif (!($el->status=$el->verify($vals[$name])))
+ return false;
+ }
+ return true;
+ }
+ public function text($text) {
+ $this->elements[]=$text;
+ }
+ public function text_input($optname, $htmlname, $label) {
+ $this->elements[$optname]=new text_input($htmlname, $label);
+ }
+ public function select($optname, $htmlname, $label, $options) {
+ $this->elements[$optname]=new select($htmlname, $label, $options);
+ }
+ public function radio_array($optname, $htmlname, $label, $options) {
+ $this->elements[$optname]=new radio_array($htmlname, $label, $options);
+ }
+ public function checkbox_array($optname, $htmlname, $label, $array, $delim=' ') {
+ $this->elements[$optname]=new checkbox_array($htmlname, $label, $array, $delim=' ');
+ }
+ public function layered_checkbox_array($optname, $htmlname, $label, &$array, $delim=' ', $metadata) {
+ $this->elements[$optname]=new layered_checkbox_array($htmlname, $label, $array, $delim, $metadata);
+ }
+}
+?>
diff --git a/frontend/classes/forms.php b/frontend/classes/form_elements.php
index 6e5b43e..6e5b43e 100644
--- a/frontend/classes/forms.php
+++ b/frontend/classes/form_elements.php
diff --git a/frontend/classes/wizard.php b/frontend/classes/wizard.php
index de37e72..31d02e9 100644
--- a/frontend/classes/wizard.php
+++ b/frontend/classes/wizard.php
@@ -1,6 +1,6 @@
<?php
-class wizard_step {
- public $configuration, $module, $step, $title, $next, $data=array();
+class wizard_step extends form {
+ public $configuration, $module, $step, $title, $next;
function __construct(&$c, $step, $noload=false) {
$this->configuration=&$c;
$this->module=new module($c->module);
@@ -26,16 +26,7 @@ class wizard_step {
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) {
- 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;
- }
- }
+ parent::output($rw, $this->get_opts());
if ($rw) {
echo '<br/>';
$this->echo_buttons();
@@ -43,52 +34,30 @@ class wizard_step {
echo '</div>'."\n";
}
public function process() {
- if (!isset($_REQUEST['wizard_submit'][$this->step])) {
+ 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)"));
- }
+ $vals=parent::process();
+ foreach ($vals as $name => $value) {
+ if ($this->elements[$name]->status) {
+ $this->set_opt($name, $value);
+ } else {
+ $result=$this->step;
+ debug('wizard', htmlentities("$name 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;
+ return parent::verify($this->get_opts());
}
- 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 get_opts() {
+ $vals=array();
+ foreach ($this->elements as $name => &$el) {
+ if (!is_object($el)) continue;
+ $vals[$name]=$this->get_opt($name);
+ }
+ return $vals;
}
private function set_opt($opt, $val) {
return $this->configuration->set_opt($opt, $val);