1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Add language items

This commit is contained in:
Tim Düsterhus 2012-10-20 18:04:46 +02:00
parent 4606cca27b
commit 0587fdfa0f
6 changed files with 34 additions and 13 deletions

View File

@ -40,8 +40,7 @@ public function execute() {
'roomID' => $room->roomID, 'roomID' => $room->roomID,
'time' => TIME_NOW, 'time' => TIME_NOW,
'type' => \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION, 'type' => \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION,
// TODO: Language item 'message' => \wcf\system\WCF::getLanguage()->get('wcf.chat.information.chatUpdate')
'message' => 'Tims Chat was updated. Please refresh the page.'
) )
)); ));
$messageAction->executeAction(); $messageAction->executeAction();

View File

@ -59,8 +59,13 @@ public function getFormattedMessage($outputType = 'text/html') {
WCF::getTPL()->assign(@unserialize($message)); WCF::getTPL()->assign(@unserialize($message));
$message = WCF::getLanguage()->getDynamicVariable('wcf.chat.message.'.$this->type); $message = WCF::getLanguage()->getDynamicVariable('wcf.chat.message.'.$this->type);
break; break;
case self::TYPE_WHISPER: case self::TYPE_MODERATE:
$message = @unserialize($message); $message = @unserialize($message);
WCF::getTPL()->assign($message);
$message = WCF::getLanguage()->getDynamicVariable('wcf.chat.message.'.$this->type.'.'.$message['type']);
break;
case self::TYPE_WHISPER:
$message = $message['message']; $message = $message['message'];
case self::TYPE_NORMAL: case self::TYPE_NORMAL:
case self::TYPE_ME: case self::TYPE_ME:
@ -112,7 +117,7 @@ public function jsonify($raw = false) {
'formattedUsername' => $this->getFormattedUsername(), 'formattedUsername' => $this->getFormattedUsername(),
'formattedMessage' => (string) $this, 'formattedMessage' => (string) $this,
'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'), 'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'),
'separator' => ($this->type == self::TYPE_NORMAL) ? ': ' : ' ', 'separator' => ($this->type == self::TYPE_NORMAL || $this->type == self::TYPE_ERROR || $this->type == self::TYPE_INFORMATION) ? ': ' : ' ',
'message' => $this->getFormattedMessage('text/plain'), 'message' => $this->getFormattedMessage('text/plain'),
'sender' => (int) $this->sender, 'sender' => (int) $this->sender,
'username' => $this->getUsername(), 'username' => $this->getUsername(),

View File

@ -148,22 +148,23 @@ public function save() {
$receiver = $command->getReceiver(); $receiver = $command->getReceiver();
} }
catch (\wcf\system\chat\command\NotFoundException $e) { catch (\wcf\system\chat\command\NotFoundException $e) {
$this->message = WCF::getLanguage()->get('wcf.chat.command.error.notFound'); $this->message = WCF::getLanguage()->get('wcf.chat.error.notFound');
$type = chat\message\ChatMessage::TYPE_ERROR; $type = chat\message\ChatMessage::TYPE_ERROR;
$receiver = WCF::getUser()->userID; $receiver = WCF::getUser()->userID;
} }
catch (\wcf\system\chat\command\UserNotFoundException $e) { catch (\wcf\system\chat\command\UserNotFoundException $e) {
$this->message = WCF::getLanguage()->get('wcf.chat.command.error.userNotFound'); $this->message = WCF::getLanguage()->getDynamicVariable('wcf.chat.error.userNotFound', array('username' => $e->getUsername()));
$type = chat\message\ChatMessage::TYPE_ERROR; $type = chat\message\ChatMessage::TYPE_ERROR;
$receiver = WCF::getUser()->userID; $receiver = WCF::getUser()->userID;
$this->enableHTML = 1;
} }
catch (\wcf\system\exception\PermissionDeniedException $e) { catch (\wcf\system\exception\PermissionDeniedException $e) {
$this->message = WCF::getLanguage()->get('wcf.chat.command.error.permissionDenied'); $this->message = WCF::getLanguage()->get('wcf.chat.error.permissionDenied');
$type = chat\message\ChatMessage::TYPE_ERROR; $type = chat\message\ChatMessage::TYPE_ERROR;
$receiver = WCF::getUser()->userID; $receiver = WCF::getUser()->userID;
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->message = WCF::getLanguage()->get('wcf.chat.command.error.exception'); $this->message = WCF::getLanguage()->get('wcf.chat.error.exception');
$type = chat\message\ChatMessage::TYPE_ERROR; $type = chat\message\ChatMessage::TYPE_ERROR;
$receiver = WCF::getUser()->userID; $receiver = WCF::getUser()->userID;
} }

View File

@ -31,7 +31,7 @@ public function __construct(\wcf\system\chat\command\CommandHandler $commandHand
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array( $profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
'object' => $this->user 'object' => $this->user
)); ));
$this->link = '<a href="'.$profile.'">'.ChatUtil::gradient($this->user->username, $color[1], $color[2]).'</a>'; $this->link = '<a href="'.$profile.'" class="userLink" data-user-id="'.$this->user->userID.'">'.ChatUtil::gradient($this->user->username, $color[1], $color[2]).'</a>';
$this->didInit(); $this->didInit();
} }
@ -40,7 +40,7 @@ public function __construct(\wcf\system\chat\command\CommandHandler $commandHand
* @see \wcf\system\chat\command\IRestrictedChatCommand::checkPermission() * @see \wcf\system\chat\command\IRestrictedChatCommand::checkPermission()
*/ */
public function checkPermission() { public function checkPermission() {
parent::checkPermissions(); parent::checkPermission();
WCF::getSession()->checkPermissions(array('mod.chat.canRestore')); WCF::getSession()->checkPermissions(array('mod.chat.canRestore'));
} }
@ -49,13 +49,16 @@ public function checkPermission() {
* @see \wcf\system\chat\command\ICommand::getType() * @see \wcf\system\chat\command\ICommand::getType()
*/ */
public function getType() { public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION; return \wcf\data\chat\message\ChatMessage::TYPE_MODERATE;
} }
/** /**
* @see \wcf\system\chat\command\ICommand::getMessage() * @see \wcf\system\chat\command\ICommand::getMessage()
*/ */
public function getMessage() { public function getMessage() {
return 'restored '.$this->link; return serialize(array(
'link' => $this->link,
'type' => str_replace(array('wcf\system\chat\command\commands\\', 'command'), '', strtolower(get_class($this)))
));
} }
} }

View File

@ -29,7 +29,7 @@
min-height: 16px; min-height: 16px;
clear: both; clear: both;
time { time:first-child {
font-size: .8em; font-size: .8em;
&::before, &::after { &::before, &::after {
font-size: .8em; font-size: .8em;

View File

@ -86,6 +86,15 @@ Hinweis: Setzen Sie diese Einstellung nur, wenn Sie wissen, was sie bewirkt. Die
<item name="wcf.chat.kick"><![CDATA[Kicken]]></item> <item name="wcf.chat.kick"><![CDATA[Kicken]]></item>
<item name="wcf.chat.ban"><![CDATA[Bannen]]></item> <item name="wcf.chat.ban"><![CDATA[Bannen]]></item>
<item name="wcf.chat.profile"><![CDATA[Profil]]></item> <item name="wcf.chat.profile"><![CDATA[Profil]]></item>
<item name="wcf.chat.information"><![CDATA[Information]]></item>
<item name="wcf.chat.information.chatUpdate"><![CDATA[Der Chat wurde aktualisiert. Bitte lade die Seite neu, da es sonst zu Fehlern kommen kann.]]></item>
<item name="wcf.chat.error"><![CDATA[Fehler]]></item>
<item name="wcf.chat.error.notFound"><![CDATA[Der Befehl wurde nicht gefunden.]]></item>
<item name="wcf.chat.error.userNotFound"><![CDATA[Der Benutzer &bdquo;{$username}&ldquo; wurde nicht gefunden.]]></item>
<item name="wcf.chat.error.permissionDenied"><![CDATA[Sie dürfen diesen Befehl nicht verwenden.]]></item>
<item name="wcf.chat.error.exception"><![CDATA[Es gab ein Problem bei der Ausführung dieses Befehls. Bitte wenden Sie sich an einen Administrator.]]></item>
</category> </category>
<category name="wcf.chat.message"> <category name="wcf.chat.message">
@ -97,6 +106,10 @@ Hinweis: Setzen Sie diese Einstellung nur, wenn Sie wissen, was sie bewirkt. Die
<item name="wcf.chat.message.3"><![CDATA[ist jetzt abwesend{if $message}: {$message}{else}.{/if}]]></item> <item name="wcf.chat.message.3"><![CDATA[ist jetzt abwesend{if $message}: {$message}{else}.{/if}]]></item>
<!-- 4 = TYPE_BACK --> <!-- 4 = TYPE_BACK -->
<item name="wcf.chat.message.4"><![CDATA[ist jetzt wieder da.]]></item> <item name="wcf.chat.message.4"><![CDATA[ist jetzt wieder da.]]></item>
<!-- 4 = TYPE_MODERATE -->
<item name="wcf.chat.message.5.restore"><![CDATA[hat {@$link} zurückgesetzt.]]></item>
<item name="wcf.chat.message.5.mute"><![CDATA[hat {@$link} bis {@$until|time} geknebelt.]]></item>
<!-- 7 = TYPE_WHISPER --> <!-- 7 = TYPE_WHISPER -->
<item name="wcf.chat.message.7"><![CDATA[flüstert{if $showReceiver} an {$username}{/if}:]]></item> <item name="wcf.chat.message.7"><![CDATA[flüstert{if $showReceiver} an {$username}{/if}:]]></item>
</category> </category>