summaryrefslogtreecommitdiff
path: root/plugins/Customizer/Helper/ThemeHelper.php
diff options
context:
space:
mode:
authorDzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl>2019-12-10 11:34:53 +0100
committerDzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl>2019-12-10 11:34:53 +0100
commitb8fa0246803dab40cf57d40b45984c53046f2d55 (patch)
treedc92b167c7542137c385614a1d558e57669a4339 /plugins/Customizer/Helper/ThemeHelper.php
parent2a43146236fd8fb16f84398d85720ad84aa0a0b1 (diff)
Plugins directory and local modifications
Diffstat (limited to 'plugins/Customizer/Helper/ThemeHelper.php')
-rw-r--r--plugins/Customizer/Helper/ThemeHelper.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/plugins/Customizer/Helper/ThemeHelper.php b/plugins/Customizer/Helper/ThemeHelper.php
new file mode 100644
index 00000000..c2f767d1
--- /dev/null
+++ b/plugins/Customizer/Helper/ThemeHelper.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Kanboard\Plugin\Customizer\Helper;
+
+use Kanboard\Core\Base;
+
+class ThemeHelper extends Base
+{
+
+ public function reverseSelect($name, array $options, array $values = array(), array $errors = array(), array $attributes = array(), $class = '')
+ {
+ $html = '<select name="'.$name.'" id="form-'.$name.'" class="'.$class.'" '.implode(' ', $attributes).'>';
+ foreach ($options as $id => $value) {
+ $html .= '<option value="'.$this->helper->text->e($value).'"';
+ if (isset($values->$name) && $value == $values->$name) {
+ $html .= ' selected="selected"';
+ }
+ if (isset($values[$name]) && $value == $values[$name]) {
+ $html .= ' selected="selected"';
+ }
+ $html .= '>'.$this->helper->text->e($id).'</option>';
+ }
+ $html .= '</select>';
+ $html .= $this->errorList($errors, $name);
+ return $html;
+ }
+
+ public function reverseSelectOnChange($name, array $options, array $values = array(), array $errors = array(), array $attributes = array(), $class = '')
+ {
+ $html = '<select name="'.$name.'" id="userthemeSelection" class="'.$class.'" '.implode(' ', $attributes).'>';
+ foreach ($options as $id => $value) {
+ $html .= '<option value="'.$this->helper->text->e($value).'"';
+ if (isset($values->$name) && $value == $values->$name) {
+ $html .= ' selected="selected"';
+ }
+ if (isset($values[$name]) && $value == $values[$name]) {
+ $html .= ' selected="selected"';
+ }
+ $html .= '>'.$this->helper->text->e($id).'</option>';
+ }
+ $html .= '</select>';
+ $html .= $this->errorList($errors, $name);
+ return $html;
+ }
+
+ private function errorClass(array $errors, $name)
+ {
+ return ! isset($errors[$name]) ? '' : ' form-error';
+ }
+
+ private function errorList(array $errors, $name)
+ {
+ $html = '';
+ if (isset($errors[$name])) {
+ $html .= '<ul class="form-errors">';
+ foreach ($errors[$name] as $error) {
+ $html .= '<li>'.$this->helper->text->e($error).'</li>';
+ }
+ $html .= '</ul>';
+ }
+ return $html;
+ }
+
+ }