commit 6bea187f3f18ce2afc518ad09427fcb8b9c3d9ee
parent 2d959f6ddd57542d4b82adb0c72d7ee119cdb488
Author: Jan Dankert <devnull@localhost>
Date: Sun, 3 Dec 2017 01:37:12 +0100
Komponente "radiobox" umgestellt auf eine Klasse.
Diffstat:
3 files changed, 72 insertions(+), 19 deletions(-)
diff --git a/themes/default/include/html/radiobox/Radiobox.class.php b/themes/default/include/html/radiobox/Radiobox.class.php
@@ -0,0 +1,31 @@
+<?php
+
+class RadioboxComponent extends Component
+{
+
+ public $list;
+
+ public $name;
+
+ public $default;
+
+ public $onchange;
+
+ public $title;
+
+ public $class;
+
+ public function begin()
+ {
+ $this->include( 'radiobox/component-radio-box.php');
+
+ if ( isset($this->default))
+ $value = $this->value($this->default);
+ else
+ $value = '$'.$this->varname($this->name);
+
+ echo '<?php component_radio_box('.$this->value($this->name).',$'.$this->varname($this->list).','.$value.') ?>';
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/themes/default/include/html/radiobox/component-radio-box.php b/themes/default/include/html/radiobox/component-radio-box.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ *
+ * @param unknown $name
+ * @param unknown $values
+ * @param unknown $value
+ */
+function component_radio_box($name, $values, $value)
+{
+ foreach ($values as $box_key => $box_value)
+ {
+ if (is_array($box_value))
+ {
+ $box_key = $box_value['key'];
+ $box_title = $box_value['title'];
+ $box_value = $box_value['value'];
+ }
+// elseif ($valuesAreLanguageKeys)
+// {
+// $box_title = lang($box_value . '_DESC');
+// $box_value = lang($box_value);
+// }
+ else
+ {
+ $box_title = '';
+ }
+
+ $id = REQUEST_ID.'_'.$name.'_'.$box_key;
+ echo '<input type="radio" id="'.$id.'" name="'.$name.'" value="' . $box_key . '" title="' . $box_title . '"';
+
+ if ((string) $box_key == $value)
+ echo ' checked="checked"';
+
+ echo ' /> <label for="'.$id.'">'.$box_value.'</label><br />';
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/themes/default/include/html/radiobox/radiobox-begin.inc.php b/themes/default/include/html/radiobox/radiobox-begin.inc.php
@@ -1,18 +0,0 @@
-<?php $attr_tmp_list = $$attr_list;
- if ( isset($$attr_name) && isset($attr_tmp_list[$$attr_name]) )
- $attr_tmp_default = $$attr_name;
- elseif ( isset($attr_default) )
- $attr_tmp_default = $attr_default;
- else
- $attr_tmp_default = '';
-
- foreach( $attr_tmp_list as $box_key=>$box_value )
- {
- $box_value = is_array($box_value)?(isset($box_value['lang'])?langHtml($box_value['lang']):$box_value['value']):$box_value;
- $id = REQUEST_ID.'_'.$attr_name.'_'.$box_key;
- echo '<input id="'.$id.'" name="'.$attr_name.'" type="radio" class="'.$attr_class.'" value="'.$box_key.'"';
- if ($box_key==$attr_tmp_default)
- echo ' checked="checked"';
- echo ' /> <label for="'.$id.'">'.$box_value.'</label><br />';
- }
-?>-
\ No newline at end of file