1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Add date to message if they are from a previous day

This commit is contained in:
Tim Düsterhus 2014-10-31 02:19:33 +01:00
parent 979fe68fc2
commit 80db5cf3c9
5 changed files with 11 additions and 3 deletions

View File

@ -13,7 +13,7 @@
{foreach from=$messages item="message"} {foreach from=$messages item="message"}
<tr> <tr>
<td class="columnID">{$message->messageID}</td> <td class="columnID">{$message->messageID}</td>
<td style="width: 1px !important;">{$message->time|date:"H:i:s"}</td> <td style="width: 1px !important;">{$message->time|date:"chat.global.timeFormat"}</td>
<td class="columnIcon"><p class="framed">{@$message->getUserProfile()->getAvatar()->getImageTag(24)}</p></td> <td class="columnIcon"><p class="framed">{@$message->getUserProfile()->getAvatar()->getImageTag(24)}</p></td>
<td class="columnTitle columnUsername right" style="width: 1px !important;">{$message->username}</td> <td class="columnTitle columnUsername right" style="width: 1px !important;">{$message->username}</td>
<td>{@$message->getFormattedMessage("text/simplified-html")}</td> <td>{@$message->getFormattedMessage("text/simplified-html")}</td>

View File

@ -1,5 +1,5 @@
{foreach from=$messages item=$rawMessage}{* {foreach from=$messages item=$rawMessage}{*
*}{assign var=message value=$rawMessage->jsonify(true)}{* *}{assign var=message value=$rawMessage->jsonify(true)}{*
*}({$message['time']|date:'H:i:s'}) {$message[username]|str_pad:15:' ':STR_PAD_LEFT}{$message[separator]} {$message[message]} *}({$message['time']|date:'chat.global.timeFormat'}) {$message[username]|str_pad:15:' ':STR_PAD_LEFT}{$message[separator]} {$message[message]}
{/foreach} {/foreach}

View File

@ -153,10 +153,12 @@ public function jsonify($raw = false) {
break; break;
} }
$time = \wcf\util\DateUtil::getDateTimeByTimestamp($this->time);
$startOfDay = new \DateTime('today', WCF::getUser()->getTimezone());
$array = array( $array = array(
'formattedUsername' => $this->getUsername(true), 'formattedUsername' => $this->getUsername(true),
'formattedMessage' => $this->getFormattedMessage('text/html'), 'formattedMessage' => $this->getFormattedMessage('text/html'),
'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'), 'formattedTime' => ($time->getTimestamp() < $startOfDay->getTimestamp() ? \wcf\util\DateUtil::format($time, 'chat.global.dateFormat').' ' : '').\wcf\util\DateUtil::format($time, 'chat.global.timeFormat'),
'separator' => $separator, 'separator' => $separator,
'message' => $this->getFormattedMessage('text/plain'), 'message' => $this->getFormattedMessage('text/plain'),
'sender' => (int) $this->sender, 'sender' => (int) $this->sender,

View File

@ -193,6 +193,9 @@ Probieren Sie, den Chat neu zu laden<!-- , bei Risiken und Nebenwirkungen fragen
<item name="chat.global.privateChannelTopic"><![CDATA[{literal}Sie befinden sich in einem privaten Kanal mit „{$username}“.{/literal}]]></item> <item name="chat.global.privateChannelTopic"><![CDATA[{literal}Sie befinden sich in einem privaten Kanal mit „{$username}“.{/literal}]]></item>
<item name="chat.global.closePrivateChannel"><![CDATA[Privaten Kanal schließen]]></item> <item name="chat.global.closePrivateChannel"><![CDATA[Privaten Kanal schließen]]></item>
<item name="chat.global.closeTopic"><![CDATA[Thema ausblenden]]></item> <item name="chat.global.closeTopic"><![CDATA[Thema ausblenden]]></item>
<item name="chat.global.timeFormat"><![CDATA[H:i:s]]></item>
<item name="chat.global.dateFormat"><![CDATA[Y-m-d]]></item>
</category> </category>
<category name="chat.header"> <category name="chat.header">

View File

@ -193,6 +193,9 @@ Please try to reload the chat.]]></item>
<item name="chat.global.privateChannelTopic"><![CDATA[{literal}You are in a private conversation with “{$username}”{/literal}]]></item> <item name="chat.global.privateChannelTopic"><![CDATA[{literal}You are in a private conversation with “{$username}”{/literal}]]></item>
<item name="chat.global.closePrivateChannel"><![CDATA[Close Private Conversation]]></item> <item name="chat.global.closePrivateChannel"><![CDATA[Close Private Conversation]]></item>
<item name="chat.global.closeTopic"><![CDATA[Hide Topic]]></item> <item name="chat.global.closeTopic"><![CDATA[Hide Topic]]></item>
<item name="chat.global.timeFormat"><![CDATA[g:i:sa]]></item>
<item name="chat.global.dateFormat"><![CDATA[Y-m-d]]></item>
</category> </category>
<category name="chat.header"> <category name="chat.header">