From a9df44dfe7a4caed90791b3673fe71823295bf79 Mon Sep 17 00:00:00 2001 From: Eudyptula Date: Tue, 28 Jul 2009 14:20:36 -0400 Subject: Converted frontend wizard form element classes to not be specific to the frontend wizard; removed keyword masked packages from package selection --- frontend/classes/forms.php | 284 ++++++++++++++++++++++ frontend/classes/wizard.php | 110 +++++++++ frontend/classes/wizard_api.php | 429 ---------------------------------- frontend/css/lca.css | 22 ++ frontend/css/wlca.css | 22 -- frontend/js/lca.js | 79 +++++++ frontend/js/wlca.js | 79 ------- frontend/modules/gentoo/step4.php | 2 +- shared/classes/1conf_build_common.php | 6 +- shared/classes/gentoo_profile.php | 6 +- todo | 1 - 11 files changed, 503 insertions(+), 537 deletions(-) create mode 100644 frontend/classes/forms.php create mode 100644 frontend/classes/wizard.php delete mode 100644 frontend/classes/wizard_api.php create mode 100644 frontend/css/lca.css delete mode 100644 frontend/css/wlca.css create mode 100644 frontend/js/lca.js delete mode 100644 frontend/js/wlca.js diff --git a/frontend/classes/forms.php b/frontend/classes/forms.php new file mode 100644 index 0000000..39843e9 --- /dev/null +++ b/frontend/classes/forms.php @@ -0,0 +1,284 @@ +htmlname=htmlentities($htmlname); + $this->label=htmlentities($label); + } + public function output($rw=true, $val=false) { + echo "$this->label: "; + } + public function process() { + global $request; + return isset($request[$this->htmlname])?$request[$this->htmlname]:false; + } + public function verify($val) { + return $val !== false; + } +} +class text_input extends form_element { + public function output($rw=true, $val=false) { + parent::output($rw, $val); + echo $rw?"htmlname\"".($val===false?'':'value="'.htmlentities($val).'"').' />':($val===false?'':htmlentities($val)); + echo "
\n"; + } +} +class select extends form_element { + private $options; + function __construct($htmlname, $label, $options) { + parent::__construct($htmlname, $label); + $this->options=$options; + } + public function output($rw=true, $val=false) { + parent::output($rw, $val); + if ($rw) { + echo ''; + echo "
\n"; + } + public function process() { + global $request; + $vals=array_keys($this->options); + if (isset($request[$this->htmlname]) && is_numeric($request[$this->htmlname]) && isset($vals[$request[$this->htmlname]])) { + return $vals[$request[$this->htmlname]]; + } else return false; + } + public function verify($val) { + return isset($this->options[$val]); + } +} +class radio_array extends select { + public function output($rw=true, $val=false) { + if (!$rw) return parent::output($rw, $val); + echo "$this->label:
\n"; + $i=0; + foreach ($this->options as $value => $label) { + echo "\thtmlname-$i\" name=\"$this->htmlname\" value=\"".$i."\"".($value == $val?' checked="checked"':'')."\" />
\n"; + $i++; + } + } +} +class checkbox_array extends form_element { + protected $array; + function __construct($htmlname, $label, $array, $delim=' ') { + parent::__construct($htmlname, $label); + $this->array=$array; + $this->delim=$delim; + } + public function output($rw=true, $val=false) { + $this->set_val($val); + if (strlen($this->label)) + echo "$this->label:
\n"; + $i=0; + foreach ($this->array as $value => $label) { + $label=htmlentities($label); + if ($rw) + echo "\thtmlname-$i\" name=\"$this->htmlname[$i]\"".($this->val_has($value)?' checked="checked"':'')." />
\n"; + elseif ($this->val_has($value)) + echo "$label
\n"; + $i++; + } + } + public function process() { + global $request; + $val=array(); + if (isset($request[$this->htmlname])) { + $vals=array_keys($this->array); + foreach ($request[$this->htmlname] as $i => $null) { + $val[]=$vals[$i]; + } + } + return implode($this->delim, $val); + } + public function verify($val) { + if ($val === false) return false; + if (strlen($val) == 0) return true; + $val=explode($this->delim, $val); + foreach ($val as $i => $value) { + if (isset($this->array[$value])) { + unset($val[$i]); + } + } + return count($val) == 0; + } + private $vals; + protected function set_val($val) { + $this->vals=explode($this->delim, $val); + } + protected function val_has($needle) { + return in_array($needle, $this->vals); + } +} +class layered_checkbox_array extends checkbox_array { + private $depth=0, $path_delims=array('', '/', '-'); + function __construct($htmlname, $label, &$array, $delim=' ', $metadata) { + parent::__construct($htmlname, $label, &$array, $delim); + $this->metadata=$metadata; + for ($i=current(&$array); is_array($i); $i=current($i)) $this->depth++; + global $S; + if (!in_array('lca', $S['scripts'])) { + $S['scripts'][]='lca'; + } + } + public function output($rw=true, $val=false) { + $this->set_val($val); + if ($this->label) { + echo '

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

'; + } + if ($rw) + $this->r_output($this->array); + else + $this->r_ro_output($this->array); + } + public function process() { + return implode($this->delim, $this->r_process($this->array)); + } + public function verify($val) { + if ($val === false) return false; + if (strlen($val) == 0) return true; + $val=explode($this->delim, $val); + $r=$this->r_verify($val, $this->array); + debug('lca', 'verify leftovers: '.implode(' ',$r)); + return count($r) == 0; + } + private function r_output(&$array, $depth=0, $path=null, $name=null) { + static $uid=0, $ucid=0; + $conf=&$this->metadata[0]; + if ($depth == 0) { + $search=$autosize=0; + for ($i=1; $imetadata); $i++) { + $m=&$this->metadata[$i]; + if (isset($m['tag'])) { + $autosize++; + } + if (isset($m['search'])) { + $search++; + } + } + if ($search) { + if (!isset($conf['id'])) { + $conf['id']=self::b36($uid++); + } + echo 'Search: Clear Show checked
'."\n"; + } + echo '
'."\n"; + foreach ($array as $name => &$val) { + $this->r_output($val, $depth+1, $name, $name); + $uid++; + } + echo '

No results

'; + echo "\n"; + } else { + $meta=$this->metadata[$depth]; + if (isset($meta['tag'])) { + echo '<'.$meta['tag'].' class="lcae'.(isset($meta['search'])?' lcas':'').(isset($meta['collapsed'])?' lca'.($meta['collapsed']?'c':'C'):'').(isset($meta['class'])?' '.$meta['class']:'').'" id="'.self::b36($uid).'"'.($depth > 1 && isset($this->metadata[$depth-1]['collapsed']) && $this->metadata[$depth-1]['collapsed'] && false?' style="display: none"':'').'>'; + if (isset($meta['collapsed']) && $depth < $this->depth) { + echo '±'; + } + } + if (isset($meta['checkbox'])) { + $enc=self::b36($ucid++); + echo 'val_has($this->format_label($array, $meta['checkbox'], $path, $name))?' checked="checked"':'').' />'."\n"; + } elseif (isset($meta['label'])) { + echo ''.$this->format_label($array, $meta['label'], $path, $name)."\n"; + } + if ($depth < $this->depth) { + foreach ($array as $name => &$val) { + $uid++; + $this->r_output($val, $depth+1, $path.$meta['delim'].$name, $name); + } + } + if (isset($meta['tag'])) { + echo '\n"; + } + } + } + private function r_process(&$array, $depth=0, $path=null, $name=null) { + static $ucid=0, $r; + if ($depth == 0) { + $r=array(); + foreach ($array as $name => &$val) { + $this->r_process($val, $depth+1, $name, $name); + } + return $r; + } else { + $meta=$this->metadata[$depth]; + if (isset($meta['checkbox'])) { + global $request; + if (isset($request[$this->htmlname][self::b36($ucid)])) { + $r[]=$this->format_label($array, $meta['checkbox'], $path, $name); + } + $ucid++; + } + if ($depth < $this->depth) { + foreach ($array as $name => &$val) + $this->r_process($val, $depth+1, $path.$meta['delim'].$name, $name); + } + } + } + private function &r_verify(&$vals, &$array, $depth=0, $path=null, $name=null) { + if ($depth == 0) { + foreach($array as $name => &$val) { + $this->r_verify($vals, $val, $depth+1, $name, $name); + } + return $vals; + } else { + $meta=$this->metadata[$depth]; + if (isset($meta['checkbox'])) { + $label=$this->format_label($array, $meta['checkbox'], $path, $name); + if (($i=array_search($label, $vals)) !== false) { + unset($vals[$i]); + } + } + if ($depth < $this->depth) { + 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->val_has($val)) { + 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; + $out=str_replace(array('%p', '%n'), array($path, $name), $label); + if (strpos($label, '$')) { + while (is_array(current($arg))) { + $arg=current($arg); + } + $out=eval("extract(\$arg, EXTR_PREFIX_INVALID, 'var_');\n".(strpos($label, 'return')===0?$out:"return <<<_XQ1\n$out\n_XQ1").";\n"); + } + return strpos($label, 'return')===0?$out:htmlentities($out); + } + private static function b36($n) { + return base_convert($n, 10, 36); + } +} +?> diff --git a/frontend/classes/wizard.php b/frontend/classes/wizard.php new file mode 100644 index 0000000..4d0d7b7 --- /dev/null +++ b/frontend/classes/wizard.php @@ -0,0 +1,110 @@ +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?' ':' ').'
'; + } +} +?> diff --git a/frontend/classes/wizard_api.php b/frontend/classes/wizard_api.php deleted file mode 100644 index 46814b5..0000000 --- a/frontend/classes/wizard_api.php +++ /dev/null @@ -1,429 +0,0 @@ -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) { - // print warning if rw is false? - if (!$obj->status) { - echo print_warning('Please complete this field.'); - } - $obj->output($rw); - } - 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 (!$obj->status=$obj->process()) { - $result=$this->step; - } - } - return $result; - } - public function verify() { - foreach ($this->data as $obj) { - if (!($obj->status=$obj->verify())) { - return $obj->status; - } - } - return true; - } - private function text($text) { - $this->data[]=new wizard_text($this->configuration, $text); - } - private function text_input($optname, $htmlname, $label) { - $this->data[]=new wizard_text_input($this->configuration, $optname, $htmlname, $label); - } - private function select($optname, $htmlname, $label, $options) { - $this->data[]=new wizard_select($this->configuration, $optname, $htmlname, $label, $options); - } - private function radio($optname, $htmlname, $label, $options) { - $this->data[]=new wizard_radio($this->configuration, $optname, $htmlname, $label, $options); - } - private function checkbox_array($optname, $htmlname, $label, $array, $delim=' ') { - $this->data[]=new wizard_checkbox_array($this->configuration, $optname, $htmlname, $label, $array, $delim=' '); - } - private function layered_checkbox_array($optname, $htmlname, $label, &$array, $delim=' ', $metadata) { - $this->data[]=new wizard_layered_checkbox_array($this->configuration, $optname, $htmlname, $label, $array, $delim, $metadata); - } - private function query($q) { - return $GLOBALS['S']['pdo']->query($q); - } - private function get_opt($opt) { - return $this->configuration->get_opt($opt); - } - private function echo_buttons() { - echo ($this->step > 1?' ':' ').'
'; - } -} -abstract class wizard { - public $status=true, $configuration; - function __construct(&$c) { - $this->configuration=&$c; - } - abstract public function output($rw=true); - abstract public function process(); - abstract public function verify(); - abstract public function clear(); - protected function get_opt($name) { - return $this->configuration->get_opt($name); - } - protected function set_opt($name, $val) { - debug('wizard', "$name=$val"); - if (substr($name, 0, 1) == ':') { - $this->configuration->$name=$val; - $this->configuration->write(); - } else { - $this->configuration->set_opt($name, $val); - } - } - protected function opt_is($name, $val) { - return $this->configuration->opt_is($name, $val); - } - protected function delete_opt($name) { - return $this->configuration->delete_opt($name); - } -} -class wizard_text extends wizard { - protected $text; - function __construct(&$c, $text) { - parent::__construct($c); - $this->text=$text; - } - public function output($rw=true) { - echo $this->text; - } - public function process() { - return true; - } - public function verify() { - return true; - } - public function clear() {} -} -abstract class wizard_input extends wizard { - protected $optname, $htmlname, $label; - function __construct(&$c, $optname, $htmlname, $label) { - parent::__construct($c); - $this->optname=$optname; - $this->htmlname=htmlentities($htmlname); - $this->label=htmlentities($label); - } - public function output($rw=true) { - echo "$this->label: "; - } - public function process() { - global $request; - if (isset($request[$this->optname])) { - self::set_opt($this->optname, $request[$this->optname]); - return true; - } else { - return false; - } - } - public function verify() { - return $this->get_opt($this->optname)!==null; - } - public function clear() { - return $this->delete_opt($this->optname); - } -} -class wizard_text_input extends wizard_input { - 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 { - private $options; - function __construct(&$c, $optname, $htmlname, $label, $options) { - parent::__construct($c, $optname, $htmlname, $label); - $this->options=$options; - } - public function output($rw=true) { - parent::output($rw); - if ($rw) { - echo ''; - echo "
\n"; - } - public function process() { - global $request; - $vals=array_keys($this->options); - if (isset($request[$this->htmlname]) && is_numeric($request[$this->htmlname]) && isset($vals[$request[$this->htmlname]])) { - $this->set_opt($this->optname, $vals[$request[$this->htmlname]]); - return true; - } else return false; - } - public function verify() { - if (($val=$this->get_opt($this->optname)) === null) return null; - return isset($this->options[$val]); - } -} -class wizard_radio extends wizard_select { - public function output($rw=true) { - if (!$rw) return parent::output($rw); - echo "$this->label:
\n"; - $i=0; - foreach ($this->options as $val => $label) { - echo "\thtmlname-$i\" name=\"$this->htmlname\" value=\"".$i."\"".($this->opt_is($this->optname, $val)?' checked="checked"':'')."\" />
\n"; - $i++; - } - } -} -class wizard_checkbox_array extends wizard_input { - protected $array; - function __construct(&$c, $optname, $htmlname, $label, $array, $delim=' ') { - parent::__construct($c, $optname, $htmlname, $label); - $this->array=$array; - $this->delim=$delim; - } - public function output($rw=true) { - if (strlen($this->label)) - echo "$this->label:
\n"; - $i=0; - foreach ($this->array as $val => $label) { - $label=htmlentities($label); - if ($rw) - echo "\thtmlname-$i\" name=\"$this->htmlname[$i]\"".($this->opt_has($this->optname, $val, $this->delim)?' checked="checked"':'')." />
\n"; - elseif ($this->opt_has($this->optname, $val, $this->delim)) - echo "$label
\n"; - $i++; - } - } - public function process() { - global $request; - $val=array(); - if (isset($request[$this->htmlname])) { - $vals=array_keys($this->array); - foreach ($request[$this->htmlname] as $i => $null) { - $val[]=$vals[$i]; - } - } - $this->set_opt($this->optname, implode($this->delim, $val)); - return true; - } - public function verify() { - if (($vals=$this->get_opt($this->optname)) === null) return null; - if (strlen($vals) == 0) return true; - $vals=explode($this->delim, $vals); - foreach ($vals as $i => $val) { - if (isset($this->array[$val])) { - unset($vals[$i]); - } - } - return count($vals) == 0; - } - private static $opt_cache; - protected function opt_has($name, $val, $delim=' ') { - if (!isset(self::$opt_cache[$name][$delim])) { - self::$opt_cache[$name][$delim]=explode($delim, $this->get_opt($name)); - } - return in_array($val, self::$opt_cache[$name][$delim]); - } -} -class wizard_layered_checkbox_array extends wizard_checkbox_array { - private $depth=0, $path_delims=array('', '/', '-'); - function __construct(&$c, $optname, $htmlname, $label, &$array, $delim=' ', $metadata) { - parent::__construct($c, $optname, $htmlname, $label, &$array, $delim); - $this->metadata=$metadata; - for ($i=current(&$array); is_array($i); $i=current($i)) $this->depth++; - global $S; - if (!in_array('wlca', $S['scripts'])) { - $S['scripts'][]='wlca'; - } - } - public function output($rw=true) { - if ($this->label) { - echo '

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

'; - } - 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))); - return true; - } - public function verify() { - if (($vals=$this->get_opt($this->optname)) === null) return null; - if (strlen($vals) == 0) return true; - $vals=explode($this->delim, $vals); - $r=$this->r_verify($vals, $this->array); - debug('wlca', 'got results: '.implode(' ',$r)); - return count($r) == 0; - } - private function r_output(&$array, $depth=0, $path=null, $name=null) { - static $uid=0, $ucid=0; - $conf=&$this->metadata[0]; - if ($depth == 0) { - $search=$autosize=0; - for ($i=1; $imetadata); $i++) { - $m=&$this->metadata[$i]; - if (isset($m['tag'])) { - $autosize++; - } - if (isset($m['search'])) { - $search++; - } - } - if ($search) { - if (!isset($conf['id'])) { - $conf['id']=self::b36($uid++); - } - echo 'Search: Clear Show checked
'."\n"; - } - echo '
'."\n"; - foreach ($array as $name => &$val) { - $this->r_output($val, $depth+1, $name, $name); - $uid++; - } - echo '

No results

'; - echo "\n"; - } else { - $meta=$this->metadata[$depth]; - if (isset($meta['tag'])) { - echo '<'.$meta['tag'].' class="wlcae'.(isset($meta['search'])?' wlcas':'').(isset($meta['collapsed'])?' wlca'.($meta['collapsed']?'c':'C'):'').(isset($meta['class'])?' '.$meta['class']:'').'" id="'.self::b36($uid).'"'.($depth > 1 && isset($this->metadata[$depth-1]['collapsed']) && $this->metadata[$depth-1]['collapsed'] && false?' style="display: none"':'').'>'; - if (isset($meta['collapsed']) && $depth < $this->depth) { - echo '±'; - } - } - if (isset($meta['checkbox'])) { - $enc=self::b36($ucid++); - echo 'opt_has($this->optname, $this->format_label($array, $meta['checkbox'], $path, $name), $this->delim)?' checked="checked"':'').' />'."\n"; - } elseif (isset($meta['label'])) { - echo ''.$this->format_label($array, $meta['label'], $path, $name)."\n"; - } - if ($depth < $this->depth) { - foreach ($array as $name => &$val) { - $uid++; - $this->r_output($val, $depth+1, $path.$meta['delim'].$name, $name); - } - } - if (isset($meta['tag'])) { - echo '\n"; - } - } - } - private function r_process(&$array, $depth=0, $path=null, $name=null) { - static $ucid=0, $r; - if ($depth == 0) { - $r=array(); - foreach ($array as $name => &$val) { - $this->r_process($val, $depth+1, $name, $name); - } - return $r; - } else { - $meta=$this->metadata[$depth]; - if (isset($meta['checkbox'])) { - global $request; - if (isset($request[$this->htmlname][self::b36($ucid)])) { - $r[]=$this->format_label($array, $meta['checkbox'], $path, $name); - } - $ucid++; - } - if ($depth < $this->depth) { - foreach ($array as $name => &$val) - $this->r_process($val, $depth+1, $path.$meta['delim'].$name, $name); - } - } - } - private function &r_verify(&$vals, &$array, $depth=0, $path=null, $name=null) { - if ($depth == 0) { - foreach($array as $name => &$val) { - $this->r_verify($vals, $val, $depth+1, $name, $name); - } - return $vals; - } else { - $meta=$this->metadata[$depth]; - if (isset($meta['checkbox'])) { - $label=$this->format_label($array, $meta['checkbox'], $path, $name); - if (($i=array_search($label, $vals)) !== false) { - unset($vals[$i]); - } - } - if ($depth < $this->depth) { - 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; - $out=str_replace(array('%p', '%n'), array($path, $name), $label); - if (strpos($label, '$')) { - while (is_array(current($arg))) { - $arg=current($arg); - } - $out=eval("extract(\$arg, EXTR_PREFIX_INVALID, 'var_');\n".(strpos($label, 'return')===0?$out:"return <<<_XQ1\n$out\n_XQ1").";\n"); - } - return strpos($label, 'return')===0?$out:htmlentities($out); - } - private static function b36($n) { - return base_convert($n, 10, 36); - } -} -?> diff --git a/frontend/css/lca.css b/frontend/css/lca.css new file mode 100644 index 0000000..90a4429 --- /dev/null +++ b/frontend/css/lca.css @@ -0,0 +1,22 @@ +.lca.autosize .lcae { + font-size: 87%; +} +.lca.autosize .lcae .lcae { + padding-left: 2em; +} +#plist { + max-height: 15em; + overflow: auto; + margin: 10px; + padding: 5px; + border: 1px dotted black; +} +.lcae a { + text-decoration: none; +} +#plist div.masked { + color: red; +} +.lcae label { + cursor: pointer; +} diff --git a/frontend/css/wlca.css b/frontend/css/wlca.css deleted file mode 100644 index 2ff94a9..0000000 --- a/frontend/css/wlca.css +++ /dev/null @@ -1,22 +0,0 @@ -.wlca.autosize .wlcae { - font-size: 87%; -} -.wlca.autosize .wlcae .wlcae { - padding-left: 2em; -} -#plist { - max-height: 15em; - overflow: auto; - margin: 10px; - padding: 5px; - border: 1px dotted black; -} -.wlcae a { - text-decoration: none; -} -#plist div.masked { - color: red; -} -.wlcae label { - cursor: pointer; -} diff --git a/frontend/js/lca.js b/frontend/js/lca.js new file mode 100644 index 0000000..39dc96d --- /dev/null +++ b/frontend/js/lca.js @@ -0,0 +1,79 @@ +var lca_last_search; +var lca_search_timeout; +var lca_found_last; +function lcat(id, set) { // Short for 'toggle' + tag=document.getElementById(id); + for (var i=1; i 0?"":"none"); + } + if (q.length == 0 && el.className.indexOf('lcac') != -1) { + lca_collapse(el.id); + } + } + if (depth == 0) { + el.childNodes[el.childNodes.length-1].style.display=found?"none":""; + } + return found; +} +function lca_show_checked(el, depth, maxdepth) { + if (depth == 0) { + lca_last_search=undefined; + } + var found=0; + for (var i=0; i 0?"":"none"); + } + } + if (depth == 0) { + el.childNodes[el.childNodes.length-1].style.display=found?"none":""; + } + return found; +} diff --git a/frontend/js/wlca.js b/frontend/js/wlca.js deleted file mode 100644 index 7c1b13e..0000000 --- a/frontend/js/wlca.js +++ /dev/null @@ -1,79 +0,0 @@ -var wlca_last_search; -var wlca_search_timeout; -var wlca_found_last; -function wlcat(id, set) { // Short for 'toggle' - tag=document.getElementById(id); - for (var i=1; i 0?"":"none"); - } - if (q.length == 0 && el.className.indexOf('wlcac') != -1) { - wlca_collapse(el.id); - } - } - if (depth == 0) { - el.childNodes[el.childNodes.length-1].style.display=found?"none":""; - } - return found; -} -function wlca_show_checked(el, depth, maxdepth) { - if (depth == 0) { - wlca_last_search=undefined; - } - var found=0; - for (var i=0; i 0?"":"none"); - } - } - if (depth == 0) { - el.childNodes[el.childNodes.length-1].style.display=found?"none":""; - } - return found; -} diff --git a/frontend/modules/gentoo/step4.php b/frontend/modules/gentoo/step4.php index 3e2e73a..11d0c1e 100644 --- a/frontend/modules/gentoo/step4.php +++ b/frontend/modules/gentoo/step4.php @@ -1,6 +1,6 @@ get_opt('profile')); -$pkgs=$profile->get_packages(); +$pkgs=$profile->get_packages(true); $meta=array( array('id' => 'plist', 'autosize'=> true), array('delim' => '', 'tag' => 'div', 'label' => '%n', 'collapsed' => true), diff --git a/shared/classes/1conf_build_common.php b/shared/classes/1conf_build_common.php index 35ba6e6..f5721a4 100644 --- a/shared/classes/1conf_build_common.php +++ b/shared/classes/1conf_build_common.php @@ -41,14 +41,14 @@ abstract class conf_build_common extends sql_row_obj { } return $opts; } - // Returns the value (or object if $get_obj is true) of the option given by $name, or null if unset + // Returns the value (or object if $get_obj is true) of the option given by $name, or false if unset public function get_opt($name, $get_obj=false) { $opts=$this->get_opts($get_obj); - return isset($opts[$name])?$opts[$name]:null; + return array_key_exists($name, $opts)?$opts[$name]:false; } // Returns true if the given option is set and equals the given value, false otherwise public function opt_is($name, $val) { - return (($r=$this->get_opt($name)) !== null && $r == $val); + return ($this->get_opt($name) == $val); } // Generates a unique id and sets status to 1, writes self to db and returns id public function init() { diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php index b29bf05..51cc5a4 100644 --- a/shared/classes/gentoo_profile.php +++ b/shared/classes/gentoo_profile.php @@ -195,13 +195,15 @@ class sql_gentoo_profile extends sql_row_obj { } return true; } - public function &get_packages() { + public function &get_packages($omit_masked=false) { global $S; $r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id); $p=array(); while ($pkg=$r->fetch(PDO::FETCH_ASSOC)) { $pkg=new sql_gentoo_package($pkg); - $p[$pkg->bcat][$pkg->lcat][$pkg->name][$pkg->version]=$pkg->to_array(); + $array=$pkg->to_array(); + if (!($omit_masked && $array['masked'])) + $p[$pkg->bcat][$pkg->lcat][$pkg->name][$pkg->version]=$array; } return $p; } diff --git a/todo b/todo index ac95675..b55aeac 100644 --- a/todo +++ b/todo @@ -1,7 +1,6 @@ Write a live git ebuild Add a profiles management page/backend utility Add cleanup functions to the frontend and backend (tasks dir in backend containing scripts that can be launched through frontend) -Support ~arch installation (when ~arch not in ACCEPT_KEYWORDS) Move bundler selection out of gentoo module and generalize it Allow config viewing for builds, not just configurations Add `flags` column to configurations, builds, use it to implement public and private things -- cgit v1.2.3-65-gdbad