summaryrefslogtreecommitdiff
path: root/app/Helper
diff options
context:
space:
mode:
Diffstat (limited to 'app/Helper')
-rw-r--r--app/Helper/AvatarHelper.php64
-rw-r--r--app/Helper/UrlHelper.php35
-rw-r--r--app/Helper/UserHelper.php19
3 files changed, 92 insertions, 26 deletions
diff --git a/app/Helper/AvatarHelper.php b/app/Helper/AvatarHelper.php
new file mode 100644
index 00000000..c4e27ed9
--- /dev/null
+++ b/app/Helper/AvatarHelper.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Kanboard\Helper;
+
+use Kanboard\Core\Base;
+
+/**
+ * Avatar Helper
+ *
+ * @package helper
+ * @author Frederic Guillot
+ */
+class AvatarHelper extends Base
+{
+ /**
+ * Render user avatar
+ *
+ * @access public
+ * @param string $user_id
+ * @param string $username
+ * @param string $name
+ * @param string $email
+ * @param string $css
+ * @param int $size
+ * @return string
+ */
+ public function render($user_id, $username, $name, $email, $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, $size);
+ }
+
+ return '<div class="avatar avatar-'.$size.' '.$css.'">'.$html.'</div>';
+ }
+
+ /**
+ * Render small user avatar
+ *
+ * @access public
+ * @param string $user_id
+ * @param string $username
+ * @param string $name
+ * @param string $email
+ * @return string
+ */
+ public function small($user_id, $username, $name, $email, $css = '')
+ {
+ return $this->render($user_id, $username, $name, $email, $css, 20);
+ }
+
+ /**
+ * Get a small avatar for the current user
+ *
+ * @access public
+ * @return string
+ */
+ public function currentUserSmall($css = '')
+ {
+ $user = $this->userSession->getAll();
+ return $this->small($user['id'], $user['username'], $user['name'], $user['email'], $css);
+ }
+}
diff --git a/app/Helper/UrlHelper.php b/app/Helper/UrlHelper.php
index cad9fdef..095c4af4 100644
--- a/app/Helper/UrlHelper.php
+++ b/app/Helper/UrlHelper.php
@@ -29,18 +29,37 @@ class UrlHelper extends Base
}
/**
- * HTML Link tag
+ * Button Link Element
*
* @access public
- * @param string $label Link label
+ * @param string $icon Font-Awesome icon
+ * @param string $label Link label
* @param string $controller Controller name
- * @param string $action Action name
- * @param array $params Url parameters
- * @param boolean $csrf Add a CSRF token
- * @param string $class CSS class attribute
+ * @param string $action Action name
+ * @param array $params Url parameters
+ * @param string $class CSS class attribute
+ * @return string
+ */
+ public function button($icon, $label, $controller, $action, array $params = array(), $class = '')
+ {
+ $icon = '<i class="fa '.$icon.' fa-fw"></i> ';
+ $class = 'btn '.$class;
+ return $this->link($icon.$label, $controller, $action, $params, false, $class);
+ }
+
+ /**
+ * Link element
+ *
+ * @access public
+ * @param string $label Link label
+ * @param string $controller Controller name
+ * @param string $action Action name
+ * @param array $params Url parameters
+ * @param boolean $csrf Add a CSRF token
+ * @param string $class CSS class attribute
* @param string $title
- * @param boolean $new_tab Open the link in a new tab
- * @param string $anchor Link Anchor
+ * @param boolean $new_tab Open the link in a new tab
+ * @param string $anchor Link Anchor
* @return string
*/
public function link($label, $controller, $action, array $params = array(), $csrf = false, $class = '', $title = '', $new_tab = false, $anchor = '')
diff --git a/app/Helper/UserHelper.php b/app/Helper/UserHelper.php
index cbdb4af8..ee7d8ba5 100644
--- a/app/Helper/UserHelper.php
+++ b/app/Helper/UserHelper.php
@@ -156,23 +156,6 @@ class UserHelper extends Base
*/
public function getFullname(array $user = array())
{
- return $this->user->getFullname(empty($user) ? $this->sessionStorage->user : $user);
- }
-
- /**
- * Display gravatar image
- *
- * @access public
- * @param string $email
- * @param string $alt
- * @return string
- */
- public function avatar($email, $alt = '')
- {
- if (! empty($email) && $this->config->get('integration_gravatar') == 1) {
- return '<img class="avatar" src="https://www.gravatar.com/avatar/'.md5(strtolower($email)).'?s=25" alt="'.$this->helper->text->e($alt).'" title="'.$this->helper->text->e($alt).'">';
- }
-
- return '';
+ return $this->user->getFullname(empty($user) ? $this->userSession->getAll() : $user);
}
}