From d8b0423d152ca27682b001f2c4d386d9c5dd361e Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 27 Nov 2016 15:44:45 -0500 Subject: Add suggest menu for user mentions in text editor --- app/Formatter/UserMentionFormatter.php | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 app/Formatter/UserMentionFormatter.php (limited to 'app/Formatter/UserMentionFormatter.php') diff --git a/app/Formatter/UserMentionFormatter.php b/app/Formatter/UserMentionFormatter.php new file mode 100644 index 00000000..395fc463 --- /dev/null +++ b/app/Formatter/UserMentionFormatter.php @@ -0,0 +1,60 @@ +users = $users; + return $this; + } + + /** + * Apply formatter + * + * @access public + * @return array + */ + public function format() + { + $result = array(); + + foreach ($this->users as $user) { + $html = $this->helper->avatar->small( + $user['id'], + $user['username'], + $user['name'], + $user['email'], + $user['avatar_path'], + 'avatar-inline' + ); + + $html .= ' '.$this->helper->text->e($user['username']); + + if (! empty($user['name'])) { + $html .= ' '.$this->helper->text->e($user['name']).''; + } + + $result[] = array( + 'value' => $user['username'], + 'html' => $html, + ); + } + + return $result; + } +} \ No newline at end of file -- cgit v1.2.3