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 ''; + return '[list][*]'.implode('[*]', $lines).'[/list]'; } /** diff --git a/file/lib/system/chat/command/commands/RestoreCommand.class.php b/file/lib/system/chat/command/commands/RestoreCommand.class.php index 79d4ce7..54c6415 100644 --- a/file/lib/system/chat/command/commands/RestoreCommand.class.php +++ b/file/lib/system/chat/command/commands/RestoreCommand.class.php @@ -24,14 +24,7 @@ public function __construct(\wcf\system\chat\command\CommandHandler $commandHand $this->user = User::getUserByUsername(rtrim($commandHandler->getParameters(), ',')); if (!$this->user->userID) throw new \wcf\system\chat\command\UserNotFoundException(rtrim($commandHandler->getParameters(), ',')); - // Username + link to profile - $color = array(1 => ChatUtil::getRandomNumber(), 2 => ChatUtil::getRandomNumber() * 0xFFFF); - ChatUtil::writeUserData(array('color' => $color), $this->user); - - $profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array( - 'object' => $this->user - )); - $this->link = ''.ChatUtil::gradient($this->user->username, $color[1], $color[2]).''; + $this->link = ''; $this->didInit(); } diff --git a/file/lib/system/chat/command/commands/WhereCommand.class.php b/file/lib/system/chat/command/commands/WhereCommand.class.php index a30404f..7c643a0 100644 --- a/file/lib/system/chat/command/commands/WhereCommand.class.php +++ b/file/lib/system/chat/command/commands/WhereCommand.class.php @@ -11,7 +11,8 @@ * @subpackage system.chat.command.commands */ class WhereCommand extends \wcf\system\chat\command\AbstractCommand { - public $enableHTML = 1; + public $enableHTML = self::SETTING_ON; + public $enableBBCodes = self::SETTING_ON; /** * @see \wcf\system\chat\command\ICommand::getType() @@ -30,16 +31,12 @@ public function getMessage() { $users = $room->getUsers(); $tmp = array(); foreach ($users as $user) { - $profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array( - 'object' => $user - )); - - $tmp[] = ''.$user.''; + $tmp[] = ''; } - if (!empty($tmp)) $lines[] = ''.$room.': '.implode(', ', $tmp); + if (!empty($tmp)) $lines[] = '[b]'.$room.':[/b] '.implode(', ', $tmp); } - return ''; + return '[list][*]'.implode('[*]', $lines).'[/list]'; } /** diff --git a/install.sql b/install.sql index 26f040f..65edfbc 100644 --- a/install.sql +++ b/install.sql @@ -18,6 +18,7 @@ CREATE TABLE wcf1_chat_message ( type TINYINT(3) NOT NULL DEFAULT 1, message MEDIUMTEXT NOT NULL, enableSmilies TINYINT(1) NOT NULL DEFAULT 1, + enableBBCodes TINYINT(1) NOT NULL DEFAULT 0, enableHTML TINYINT(1) NOT NULL DEFAULT 0, color1 INT(10) NOT NULL DEFAULT 0, color2 INT(10) NOT NULL DEFAULT 0, diff --git a/option.xml b/option.xml index 755e290..da050c7 100644 --- a/option.xml +++ b/option.xml @@ -37,6 +37,12 @@ 1 5 +