summaryrefslogtreecommitdiff
path: root/utils/forms.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/forms.php')
-rw-r--r--utils/forms.php66
1 files changed, 52 insertions, 14 deletions
diff --git a/utils/forms.php b/utils/forms.php
index 39e1a4c..d6fdada 100644
--- a/utils/forms.php
+++ b/utils/forms.php
@@ -89,14 +89,19 @@ class CheckBox {
{
$this->label = $label;
$this->name = $name;
- $this->value = $value;
+ if($value == true || $value == "on" || $value == "true" || $value == "yes")
+ $this->value = "checked ";
+ else
+ $this->value = "";
}
public function render($indent = "")
{
$str = $indent . "<div class=\"input\">\n";
- $str .= $indent . " <div class=\"label\">". xmlenc($this->label) ."</div>\n";
- $str .= $indent . " <div class=\"widget\"><input type=\"checkbox\" name=\"vars[".$this->name."]\" value=\"".xmlenc($this->value)."\"/></div>\n";
+ $str .= $indent . " <div class=\"label\">". xmlenc($this->label) ."</div>\n";
+ $str .= $indent . " <div class=\"widget\">".
+ "<input type=\"checkbox\" name=\"vars[".$this->name."]\" ".$this->value."value=\"on\"/>".
+ "</div>\n";
$str .= $indent . "</div>\n";
return $str;
}
@@ -132,7 +137,7 @@ class ComboBox {
class Hidden {
public $values;
-
+
public function Hidden($values)
{
$this->values = $values;
@@ -280,13 +285,14 @@ class ImageComboBox {
class ListEditor {
public $label, $name, $namewidget, $valuewidget, $values;
- public function ListEditor($label, $name, $namewidget, $valuewidget, $values = array())
+ public function ListEditor($label, $name, $namewidget, $valuewidget, $values = array(), $commalist = false)
{
$this->label = $label;
$this->name = $name;
$this->namewidget = $namewidget;
$this->valuewidget = $valuewidget;
$this->values = $values;
+ $this->commalist = $commalist;
}
public function render($indent = "")
@@ -354,11 +360,17 @@ class ListEditor {
$str .= $indent . "}\n";
$str .= $indent . "//-->\n";
$str .= $indent . "</script>\n";
- $str .= $indent . "<select multiple size=\"8\" id=\"items\" name=\"".$this->name."[]\">\n";
- if(sizeof($this->values)) {
- foreach($this->values as $key => $val) {
- $str .= $indent . " <option value=\"".$key.":".$val."\">".$key.":".$val."</option>\n";
- }
+ $str .= $indent . "<select style=\"min-width: 200px;\" multiple size=\"8\" id=\"items\" name=\"".$this->name."[]\">\n";
+ if($this->values) {
+ if($this->commalist) {
+ foreach($this->values as $val) {
+ $str .= $indent . " <option value=\"".$val."\">".$val."</option>\n";
+ }
+ } else {
+ foreach($this->values as $key => $val) {
+ $str .= $indent . " <option value=\"".$key.":".$val."\">".$key.":".$val."</option>\n";
+ }
+ }
}
$str .= $indent . "</select><br/>\n";
$str .= $indent . "<div class=\"button\" button onclick=\"moveUp()\">/\</div><br/>\n";
@@ -373,12 +385,38 @@ class ListEditor {
public function splitValues($values)
{
$out = array();
- foreach($values as $value) {
- $vals = explode(":", $value);
- $out[$vals[0]]=$vals[1];
- }
+ if($values) {
+ foreach($values as $value) {
+ $vals = explode(":", $value);
+
+ /*
+ $out[$vals[0]]=$vals[1];
+ */
+
+ $_keys = array_keys($out);
+ $_vals = array_values($out);
+
+ array_push($_keys, $vals[0]);
+ array_push($_vals, $vals[1]);
+
+ $out = array_combine($_keys, $_vals);
+ }
+ }
return $out;
}
+
+ function combineValues($values)
+ {
+ $out = array();
+ if($values) {
+ foreach($values as $k => $v) {
+ $value = $k.":".$v;
+ array_push($out, $value);
+ }
+ }
+ return $out;
+ }
+
}
class MultiList {