Guest User

Untitled

a guest
May 16th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <?php
  2.  
  3. // :3
  4. class Dark_TaigaChat_BbCode_Formatter_Tenori extends XenForo_BbCode_Formatter_Base
  5. {
  6.  
  7. /**
  8. * List of tags which should be displayed
  9. *
  10. * @var boolean|array True=all, false=none, array=display these
  11. */
  12. public $displayableTags = true;
  13.  
  14.  
  15. public function getTagsAgain(){
  16. $this->_tags = null;
  17. $this->_tags = $this->getTags();
  18. $this->preLoadData();
  19. }
  20.  
  21. public function getTags()
  22. {
  23. if ($this->_tags !== null)
  24. {
  25. return $this->_tags;
  26. }
  27.  
  28. $tags = parent::getTags();
  29.  
  30. foreach ($tags AS $tagName => &$tag)
  31. {
  32. if ($this->displayableTags === false || (is_array($this->displayableTags) && !in_array($tagName, $this->displayableTags)))
  33. {
  34. unset($tags[$tagName]);
  35. }
  36. }
  37. return $tags;
  38. }
  39.  
  40. protected static $_taggedUsers = array();
  41.  
  42. /**
  43. *
  44. * @see XenForo_BbCode_Formatter_Base::renderTagUser()
  45. */
  46. public function renderTagUser(array $tag, array $rendererStates)
  47. {
  48. $content = $this->renderSubTree($tag['children'], $rendererStates);
  49. if ($content === '') {
  50. return '';
  51. }
  52.  
  53. $userId = intval($tag['option']);
  54. if (!$userId) {
  55. return $content;
  56. }
  57. $link = XenForo_Link::buildPublicLink('full:members', array(
  58. 'user_id' => $userId
  59. ));
  60. $username = $this->stringifyTree($tag['children']);
  61.  
  62. if (empty(self::$_taggedUsers[$userId])) {
  63. $userModel = XenForo_Model::create('XenForo_Model_User');
  64. $user = $userModel->getUserById($userId, array());
  65. self::$_taggedUsers[$userId] = $user;
  66. } else {
  67. $user = self::$_taggedUsers[$userId];
  68. }
  69. $content = '<span class="style' . $user['display_style_group_id'] . '">' . $content . '</span>';
  70.  
  71. return $this->_wrapInHtml(
  72. '<a href="' . htmlspecialchars($link) . '" class="username" data-user="' . $userId . ', ' .
  73. htmlspecialchars($username) . '">', '</a>', $content);
  74. } /* END renderTagUser */
  75.  
  76. }
Add Comment
Please, Sign In to add comment