summaryrefslogtreecommitdiff
path: root/plugins/Customizer/Helper
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Customizer/Helper')
-rw-r--r--plugins/Customizer/Helper/DynamicAvatar.php59
-rw-r--r--plugins/Customizer/Helper/ThemeHelper.php64
2 files changed, 123 insertions, 0 deletions
diff --git a/plugins/Customizer/Helper/DynamicAvatar.php b/plugins/Customizer/Helper/DynamicAvatar.php
new file mode 100644
index 00000000..cf7ab83f
--- /dev/null
+++ b/plugins/Customizer/Helper/DynamicAvatar.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Kanboard\Plugin\Customizer\Helper;
+
+use Kanboard\Helper\AvatarHelper;
+use Kanboard\Core\Base;
+/**
+ * Avatar Helper
+ *
+ * @package helper
+ * @author Craig Crosby
+ */
+class DynamicAvatar extends AvatarHelper
+{
+
+ public function dynamicRender($user_id, $username, $name, $email, $avatar_path, $css = 'avatar-left', $size = 48)
+ {
+ if (empty($user_id) && empty($username)) {
+ $html = $this->avatarManager->renderDefault($size);
+ } else {
+ $html = $this->avatarManager->render($user_id, $username, $name, $email, $avatar_path, $size);
+ }
+ return '<div id="'.$css.'" class="avatar avatar-dyn '.$css.'">'.$html.'</div>';
+ }
+
+ public function dynamic($user_id, $username, $name, $email, $avatar_path, $css = '', $size)
+ {
+ return $this->dynamicRender($user_id, $username, $name, $email, $avatar_path, $css, $size);
+ }
+
+ public function currentUserDynamic($css = '')
+ {
+ $user = $this->userSession->getAll();
+ return $this->dynamic($user['id'], $user['username'], $user['name'], $user['email'], $user['avatar_path'], $css, $this->configModel->get('av_size', '20'));
+ }
+
+ public function boardDynamicRender($user_id, $username, $name, $email, $avatar_path, $css = 'avatar-left', $size = 48)
+ {
+ if (empty($user_id) && empty($username)) {
+ $html = $this->avatarManager->renderDefault($size);
+ } else {
+ $html = $this->avatarManager->render($user_id, $username, $name, $email, $avatar_path, $size);
+ }
+ return '<div id="'.$css.'" class="avatar avatar-bdyn '.$css.'">'.$html.'</div>';
+ }
+
+ public function boardDynamic($user_id, $username, $name, $email, $avatar_path, $css = '', $size)
+ {
+ return $this->boardDynamicRender($user_id, $username, $name, $email, $avatar_path, $css, $size);
+ }
+
+ public function boardCurrentUserDynamic($css = '')
+ {
+ $user = $this->userSession->getAll();
+ return $this->boardDynamic($user['id'], $user['username'], $user['name'], $user['email'], $user['avatar_path'], $css, $this->configModel->get('b_av_size', '20'));
+ }
+
+
+ }
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;
+ }
+
+ }