mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Remove text/plain output
This commit is contained in:
parent
805d7a3a11
commit
90b27972b0
@ -57,7 +57,7 @@ public function __toString() {
|
||||
* @param string $outputType outputtype for messageparser
|
||||
* @return string
|
||||
*/
|
||||
public function getFormattedMessage($outputType = 'text/html') {
|
||||
public function getFormattedMessage() {
|
||||
$message = $this->message;
|
||||
|
||||
switch ($this->type) {
|
||||
@ -70,24 +70,15 @@ public function getFormattedMessage($outputType = 'text/html') {
|
||||
case self::TYPE_MODERATE:
|
||||
$message = unserialize($message);
|
||||
$message = WCF::getLanguage()->getDynamicVariable('chat.message.'.$this->type.'.'.$message['type'], $message ?: array());
|
||||
$message = self::replaceUserLink($message, $outputType);
|
||||
break;
|
||||
case self::TYPE_WHISPER:
|
||||
$message = unserialize($message);
|
||||
$message = $message['message'];
|
||||
case self::TYPE_NORMAL:
|
||||
case self::TYPE_ME:
|
||||
$messageParser = \wcf\system\bbcode\MessageParser::getInstance();
|
||||
$messageParser->setOutputType($outputType);
|
||||
$message = $messageParser->parse($message, $this->enableSmilies, $this->enableHTML, true, false);
|
||||
break;
|
||||
default:
|
||||
if ($this->enableHTML) {
|
||||
$message = self::replaceUserLink($message, $outputType);
|
||||
}
|
||||
|
||||
$messageParser = \wcf\system\bbcode\MessageParser::getInstance();
|
||||
$messageParser->setOutputType($outputType);
|
||||
$messageParser->setOutputType('text/html');
|
||||
$message = $messageParser->parse($message, $this->enableSmilies, $this->enableHTML, true, false);
|
||||
break;
|
||||
}
|
||||
@ -118,45 +109,6 @@ public function getUsername($colored = false) {
|
||||
return $username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a userLink in a message.
|
||||
*/
|
||||
public static function replaceUserLink($message, $outputType) {
|
||||
static $regex = null;
|
||||
if ($regex === null) $regex = new Regex('<span class="userLink" data-user-id="(\d+)" />');
|
||||
|
||||
if ($outputType === 'text/html') {
|
||||
return $regex->replace($message, new \wcf\system\Callback(function ($matches) {
|
||||
return self::getUserLink($matches[1]);
|
||||
}));
|
||||
}
|
||||
else {
|
||||
return $regex->replace($message, new \wcf\system\Callback(function ($matches) {
|
||||
self::getUserLink($matches[1]);
|
||||
|
||||
return self::$users[$matches[1]]->username;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a fully colored userlink.
|
||||
*/
|
||||
public static function getUserLink($userID) {
|
||||
if (!isset(self::$users[$userID])) {
|
||||
self::$users[$userID] = $user = new \wcf\data\user\User($userID);
|
||||
|
||||
// Username + link to profile
|
||||
$color = ChatUtil::readUserData('color', $user);
|
||||
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
|
||||
'object' => $user
|
||||
));
|
||||
self::$users[$userID]->userLink = '<a href="'.$profile.'" class="userLink" data-user-id="'.$user->userID.'">'.ChatUtil::gradient($user->username, $color[1], $color[2]).'</a>';
|
||||
}
|
||||
|
||||
return self::$users[$userID]->userLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this message into json-form.
|
||||
*
|
||||
@ -181,7 +133,7 @@ public function jsonify($raw = false) {
|
||||
'formattedMessage' => $this->getFormattedMessage(),
|
||||
'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'),
|
||||
'separator' => $separator,
|
||||
'message' => $this->getFormattedMessage('text/plain'),
|
||||
'message' => $this->message,
|
||||
'sender' => (int) $this->sender,
|
||||
'username' => $this->getUsername(),
|
||||
'time' => (int) $this->time,
|
||||
|
@ -43,7 +43,7 @@ public function prune() {
|
||||
/**
|
||||
* Validates message sending.
|
||||
*/
|
||||
public function validateSend() {
|
||||
public function validateSend() {
|
||||
// read parameters
|
||||
$this->readString('text');
|
||||
$this->readBoolean('enableSmilies');
|
||||
|
@ -26,11 +26,10 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
||||
if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException(rtrim($commandHandler->getParameters(), ','));
|
||||
|
||||
// Username + link to profile
|
||||
$color = ChatUtil::readUserData('color', $this->user);
|
||||
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
|
||||
'object' => $this->user
|
||||
'object' => $this->user
|
||||
));
|
||||
$this->lines[WCF::getLanguage()->get('wcf.user.username')] = '<span class="userLink" data-user-id="'.$this->user->userID.'" />';
|
||||
$this->lines[WCF::getLanguage()->get('wcf.user.username')] = "[url='".$profile."']".$this->user->username.'[/url]';
|
||||
|
||||
// Away-Status
|
||||
if (ChatUtil::readUserData('away', $this->user) !== null) {
|
||||
|
@ -30,7 +30,10 @@ public function getMessage() {
|
||||
$users = $room->getUsers();
|
||||
$tmp = array();
|
||||
foreach ($users as $user) {
|
||||
$tmp[] = '<span class="userLink" data-user-id="'.$user->userID.'" />';
|
||||
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
|
||||
'object' => $user
|
||||
));
|
||||
$tmp[] = "[url='".$profile."']".$user->username.'[/url]';
|
||||
}
|
||||
if (!empty($tmp)) $lines[] = '[b]'.$room.':[/b] '.implode(', ', $tmp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user