Walky
Member
Hi !
I want to extend XenForo BBCOde ! SO I created a Listener and a Bcode file but this don't work :/
Here is my Listener.php file :
And my BbCode_Formatter_Base File
Where is the error ? Thanks
I want to extend XenForo BBCOde ! SO I created a Listener and a Bcode file but this don't work :/
Here is my Listener.php file :
PHP:
<?php
class TaggedUsers_Listener
{
public static function loadClassController($class, array &$extend)
{
if($class == "XenForo_BbCode_Formatter_Base")
{
$extend[] = "TaggedUsers_BbCode_Formatter_Base";
}
}
}
And my BbCode_Formatter_Base File
PHP:
<?php
class TaggedUsers_BbCode_Formatter_Base extends XFCP_TaggedUsers_BbCode_Formatter_Base
{
protected static $_taggedUsers = array();
public function getTags()
{
if ($this->_tags !== null)
{
return $this->_tags;
}
return array(
'user' => array(
'hasOption' => true,
'stopSmilies' => true,
'callback' => array($this, 'renderTagUser')
)
);
}
public function renderTagUser(array $tag, array $rendererStates)
{
$content = $this->renderSubTree($tag['children'], $rendererStates);
if ($content === '')
{
return '';
}
$userId = intval($tag['option']);
if (!$userId)
{
return $content;
}
$link = XenForo_Link::buildPublicLink('full:members', array('user_id' => $userId));
$username = $this->stringifyTree($tag['children']);
if (empty(self::$_taggedUsers[$userId])) {
$userModel = XenForo_Model::create('XenForo_Model_User');
$user = $userModel->getUserById($userId, array());
self::$_taggedUsers[$userId] = $user;
} else {
$user = self::$_taggedUsers[$userId];
}
$content = '<span class="style' . $user['display_style_group_id'] . '">' . $content . '</span>';
return $this->_wrapInHtml('<a href="' . htmlspecialchars($link) . '" class="username" data-user="' . $userId . ', ' . htmlspecialchars($username) . '">', '</a>', $content);
}
}
Where is the error ? Thanks