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

Display messages in their appropriate tab.

This commit is contained in:
Maximilian Mader 2013-08-02 19:38:13 +02:00
parent 3a44dbe850
commit cc73d89672
2 changed files with 70 additions and 27 deletions

View File

@ -57,33 +57,63 @@
<nav class="tabMenu"> <nav class="tabMenu">
<ul> <ul>
{section name=tabLoop loop=24 step=3} {section name=tabLoop loop=24 step=3}
<li> {if $messages[$tabLoop * 2]|isset || $messages[$tabLoop * 2 + 1]|isset || $messages[$tabLoop * 2 + 2]|isset || $messages[$tabLoop * 2 + 3]|isset || $messages[$tabLoop * 2 + 4]|isset || $messages[$tabLoop * 2 + 5]|isset}
{assign var=anchor value='timeTab-'|concat:$tabLoop} <li>
<a href="{@$__wcf->getAnchor($anchor)}">{if $tabLoop < 10}0{/if}{$tabLoop}:00 - {if $tabLoop + 2 < 10}0{/if}{$tabLoop + 2}:59</a> {assign var=anchor value='timeTab-'|concat:$tabLoop}
</li> <a href="{@$__wcf->getAnchor($anchor)}">{if $tabLoop < 10}0{/if}{$tabLoop}:00 - {if $tabLoop + 2 < 10}0{/if}{$tabLoop + 2}:59</a>
</li>
{/if}
{/section} {/section}
</ul> </ul>
</nav> </nav>
{section name=contentLoop loop=24 step=3} {section name=contentLoop loop=24 step=3}
<div id="timeTab-{$contentLoop}" class="container containerPadding tabMenuContainer tabMenuContent"> {if $messages[$contentLoop * 2]|isset || $messages[$contentLoop * 2 + 1]|isset || $messages[$contentLoop * 2 + 2]|isset || $messages[$contentLoop * 2 + 3]|isset || $messages[$contentLoop * 2 + 4]|isset || $messages[$contentLoop * 2 + 5]|isset}
<nav class="menu"> <div id="timeTab-{$contentLoop}" class="container containerPadding tabMenuContainer tabMenuContent">
<ul> <nav class="menu">
{section name=subTabLoop loop=6} <ul>
{section name=subTabLoop loop=6}
{if $messages[$contentLoop * 2 + $subTabLoop]|isset}
{assign var=subAnchor value='timeTab-'|concat:$contentLoop|concat:'-subTab-'|concat:$subTabLoop}
<li>
<a href="{@$__wcf->getAnchor($subAnchor)}">{if $contentLoop + $subTabLoop / 2 < 10}0{/if}{$contentLoop + $subTabLoop / 2|floor}:{if $subTabLoop % 2 == 0}0{/if}{($subTabLoop % 2) * 30} - {if $contentLoop + $subTabLoop / 2 < 10}0{/if}{$contentLoop + $subTabLoop / 2|floor}:{($subTabLoop % 2) * 30 + 29}</a>
</li>
{/if}
{/section}
</ul>
</nav>
{section name=subTabLoop loop=6}
{if $messages[$contentLoop * 2 + $subTabLoop]|isset}
{assign var=subAnchor value='timeTab-'|concat:$contentLoop|concat:'-subTab-'|concat:$subTabLoop} {assign var=subAnchor value='timeTab-'|concat:$contentLoop|concat:'-subTab-'|concat:$subTabLoop}
<li><a href="{@$__wcf->getAnchor($subAnchor)}">{if $contentLoop + $subTabLoop / 2 < 10}0{/if}{$contentLoop + $subTabLoop / 2|floor}:{if $subTabLoop % 2 == 0}0{/if}{($subTabLoop % 2) * 30} - {if $contentLoop + $subTabLoop / 2 < 10}0{/if}{$contentLoop + $subTabLoop / 2|floor}:{($subTabLoop % 2) * 30 + 29}</a> <div id="{$subAnchor}" class="hidden tabularBox">
</li> <table class="table">
{/section} <thead>
</ul> <tr>
</nav> <th>{lang}wcf.global.objectID{/lang}</th>
<th>{lang}chat.general.time{/lang}</th>
{section name=subTabLoop loop=6} <th colspan="2">{lang}wcf.user.username{/lang}</th>
{assign var=subAnchor value='timeTab-'|concat:$contentLoop|concat:'-subTab-'|concat:$subTabLoop} <th>{lang}chat.acp.log.message{/lang}</th>
<div id="{$subAnchor}" class="hidden"> </tr>
{#$contentLoop / 3} - {#$subTabLoop} </thead>
</div>
{/section} <tbody>
</div> {foreach from=$messages[$contentLoop * 2 + $subTabLoop] item='message'}
<tr>
<td class="columnID">{$message->messageID}</td>
<td style="width: 1px !important;">{$message->time|date:'H:i:s'}</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>{@$message->getFormattedMessage('text/simplified-html')}</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
{/if}
{/section}
</div>
{/if}
{/section} {/section}
</div> </div>
{/if} {/if}

View File

@ -78,26 +78,39 @@ public function readData() {
parent::readData(); parent::readData();
try { try {
if($this->date > TIME_NOW) { if ($this->date > TIME_NOW) {
throw new \wcf\system\exception\UserInputException('date', 'inFuture'); throw new \wcf\system\exception\UserInputException('date', 'inFuture');
} }
} catch(\wcf\system\exception\UserInputException $e) { } catch (\wcf\system\exception\UserInputException $e) {
$this->errorField = $e->getField(); $this->errorField = $e->getField();
$this->errorType = $e->getType(); $this->errorType = $e->getType();
return; return;
} }
try { try {
if($this->date < strtotime('today 00:00:00 -'.ceil(CHAT_LOG_ARCHIVETIME / 1440).'day')) { if ($this->date < strtotime('today 00:00:00 -'.ceil(CHAT_LOG_ARCHIVETIME / 1440).'day')) {
throw new \wcf\system\exception\UserInputException('date', 'tooLongAgo'); throw new \wcf\system\exception\UserInputException('date', 'tooLongAgo');
} }
} catch(\wcf\system\exception\UserInputException $e) { } catch (\wcf\system\exception\UserInputException $e) {
$this->errorField = $e->getField(); $this->errorField = $e->getField();
$this->errorType = $e->getType(); $this->errorType = $e->getType();
return; return;
} }
$this->messages = \chat\data\message\ViewableMessageList::getMessagesBetween($this->room, $this->date, $this->date + 86399); $messages = \chat\data\message\ViewableMessageList::getMessagesBetween($this->room, $this->date, $this->date + 86399);
foreach ($messages as $message) {
$hour = ((int) date('H', $message->time)) * 2;
$minutes = (int) date('i', $message->time);
if ($minutes >= 30) {
$hour += 1;
}
$this->messages[$hour][] = $message;
}
} }
/** /**
@ -108,7 +121,7 @@ public function readParameters() {
$this->rooms = \chat\data\room\RoomCache::getInstance()->getRooms(); $this->rooms = \chat\data\room\RoomCache::getInstance()->getRooms();
foreach($this->rooms as $id => $room) { foreach ($this->rooms as $id => $room) {
if (!$room->permanent) if (!$room->permanent)
unset($this->rooms[$key]); unset($this->rooms[$key]);
} }