diff --git a/file/lib/data/chat/message/ChatMessage.class.php b/file/lib/data/chat/message/ChatMessage.class.php index 453cb2e..728e894 100755 --- a/file/lib/data/chat/message/ChatMessage.class.php +++ b/file/lib/data/chat/message/ChatMessage.class.php @@ -77,7 +77,12 @@ public function getFormattedMessage($outputType = 'text/html') { $message = $message['message']; case self::TYPE_NORMAL: case self::TYPE_ME: - if (!$this->enableHTML && $outputType == 'text/html') { + if ($this->enableBBCodes) { + $messageParser = \wcf\system\bbcode\MessageParser::getInstance(); + $messageParser->setOutputType($outputType); + $message = $messageParser->parse($message, $this->enableSmilies, $this->enableHTML, true, false); + } + else if (!$this->enableHTML && $outputType == 'text/html') { $message = \wcf\system\bbcode\SimpleMessageParser::getInstance()->parse($message, true, $this->enableSmilies); } break; @@ -85,6 +90,12 @@ public function getFormattedMessage($outputType = 'text/html') { if ($this->enableHTML) { $message = self::replaceUserLink($message, $outputType); } + + if ($this->enableBBCodes) { + $messageParser = \wcf\system\bbcode\MessageParser::getInstance(); + $messageParser->setOutputType($outputType); + $message = $messageParser->parse($message, $this->enableSmilies, $this->enableHTML, true, false); + } break; } diff --git a/file/lib/form/ChatForm.class.php b/file/lib/form/ChatForm.class.php index 546a75c..97acefd 100644 --- a/file/lib/form/ChatForm.class.php +++ b/file/lib/form/ChatForm.class.php @@ -22,6 +22,13 @@ class ChatForm extends AbstractForm { */ public $enableHTML = 0; + /** + * Should bbcodes be enabled for this message. + * + * @var integer + */ + public $enableBBCodes = CHAT_ENABLE_BBCODES; + /** * Should smilies be enabled for this message. * @@ -82,7 +89,7 @@ class ChatForm extends AbstractForm { * @see wcf\page\IPage::__run() */ public function __run() { - if (($this->request = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()) === $this) throw new IllegalLinkException(); + if (($this->request = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()) === $this) throw new \wcf\system\exception\IllegalLinkException(); parent::__run(); } @@ -141,8 +148,10 @@ public function save() { try { $command = $commandHandler->loadCommand(); - if ($command->enableSmilies != \wcf\system\chat\command\ICommand::SMILEY_USER) $this->enableSmilies = $command->enableSmilies; + if ($command->enableSmilies != \wcf\system\chat\command\ICommand::SETTING_USER) $this->enableSmilies = $command->enableSmilies; $this->enableHTML = $command->enableHTML; + if ($command->enableBBCodes != \wcf\system\chat\command\ICommand::SETTING_USER) $this->enableBBCodes = $command->enableBBCodes; + $type = $command->getType(); $this->message = $command->getMessage(); $receiver = $command->getReceiver(); @@ -202,6 +211,7 @@ public function save() { 'message' => $this->message, 'enableSmilies' => $this->enableSmilies, 'enableHTML' => $this->enableHTML, + 'enableBBCodes' => $this->enableBBCodes, 'color1' => $this->userData['color'][1], 'color2' => $this->userData['color'][2] ) diff --git a/file/lib/system/chat/command/AbstractCommand.class.php b/file/lib/system/chat/command/AbstractCommand.class.php index 5feccf9..8c2ab35 100644 --- a/file/lib/system/chat/command/AbstractCommand.class.php +++ b/file/lib/system/chat/command/AbstractCommand.class.php @@ -23,18 +23,30 @@ abstract class AbstractCommand implements ICommand { * Should HTML be enabled? * * @var integer + * @see \wcf\system\chat\command\ICommand::SETTING_OFF + * @see \wcf\system\chat\command\ICommand::SETTING_ON */ - public $enableHTML = 0; + public $enableHTML = ICommand::SETTING_OFF; + + /** + * Should BBCodes be enabled? + * + * @var integer + * @see \wcf\system\chat\command\ICommand::SETTING_OFF + * @see \wcf\system\chat\command\ICommand::SETTING_ON + * @see \wcf\system\chat\command\ICommand::SETTING_USER + */ + public $enableBBCodes = ICommand::SETTING_OFF; /** * Should smilies be enabled? * * @var integer - * @see \wcf\system\chat\command\ICommand::SMILEY_OFF - * @see \wcf\system\chat\command\ICommand::SMILEY_ON - * @see \wcf\system\chat\command\ICommand::SMILEY_USER + * @see \wcf\system\chat\command\ICommand::SETTING_OFF + * @see \wcf\system\chat\command\ICommand::SETTING_ON + * @see \wcf\system\chat\command\ICommand::SETTING_USER */ - public $enableSmilies = ICommand::SMILEY_OFF; + public $enableSmilies = ICommand::SETTING_OFF; public function __construct(CommandHandler $commandHandler) { EventHandler::getInstance()->fireAction($this, 'shouldInit'); diff --git a/file/lib/system/chat/command/CommandHandler.class.php b/file/lib/system/chat/command/CommandHandler.class.php index 4973236..567cc4b 100644 --- a/file/lib/system/chat/command/CommandHandler.class.php +++ b/file/lib/system/chat/command/CommandHandler.class.php @@ -70,7 +70,7 @@ public function loadCommand() { $parts = explode(' ', StringUtil::substring($this->text, StringUtil::length(static::COMMAND_CHAR)), 2); if ($this->isCommand($parts[0])) { - return new commands\Plain($this); + return new commands\PlainCommand($this); } $class = '\wcf\system\chat\command\commands\\'.ucfirst(strtolower($parts[0])).'Command'; diff --git a/file/lib/system/chat/command/ICommand.class.php b/file/lib/system/chat/command/ICommand.class.php index f288ea8..41d5025 100644 --- a/file/lib/system/chat/command/ICommand.class.php +++ b/file/lib/system/chat/command/ICommand.class.php @@ -12,25 +12,25 @@ */ interface ICommand { /** - * Smilies are forced to be disabled. + * Setting is forced to be disabled. * * @var integer */ - const SMILEY_OFF = 0; + const SETTING_OFF = 0; /** - * Smilies are forced to be enabled. + * Setting is forced to be enabled. * * @var integer */ - const SMILEY_ON = 1; + const SETTING_ON = 1; /** - * The user may decide whether smilies are on or off. + * The user may decide whether this setting is on or off. * * @var integer */ - const SMILEY_USER = 2; + const SETTING_USER = 2; /** * Returns the message-type for this command. diff --git a/file/lib/system/chat/command/commands/InfoCommand.class.php b/file/lib/system/chat/command/commands/InfoCommand.class.php index e94a21b..b553369 100644 --- a/file/lib/system/chat/command/commands/InfoCommand.class.php +++ b/file/lib/system/chat/command/commands/InfoCommand.class.php @@ -15,7 +15,8 @@ * @subpackage system.chat.command.commands */ class InfoCommand extends \wcf\system\chat\command\AbstractCommand { - public $enableHTML = 1; + public $enableBBCodes = self::SETTING_ON; + public $enableHTML = self::SETTING_ON; public $lines = array(); public $user = null; @@ -86,9 +87,9 @@ public function getType() { public function getMessage() { $lines = array(); foreach ($this->lines as $key => $val) { - $lines[] = ''.$key.': '.$val; + $lines[] = '[b]'.$key.':[/b] '.$val; } - return '