<ul> <?php if ($this->message) { ?> <li class="notice"> <?php echo $this->message; ?> </li> <?php } if ($this->num_messages > count($this->messages)) { ?> <li class="notice"> There are <strong><?php echo Tools::formatMultiple($this->num_messages, 'message'); ?> </strong> in this room's history. <a href="/room/<?php echo $this->room['name']; ?> /history">[view entire room history]</a> </li> <?php } foreach ($this->messages as $message) { $new_day = date($code, $message['timestamp']); if ($day != $new_day) { if ($new_day == $today) { $title = 'Today'; } else { $title = date('l, F jS Y', $message['timestamp']);
<ul id="dates"> <?php foreach ($this->dates as $date => $num) { ?> <li><a href="/room/<?php echo $this->room['name']; ?> /history/<?php echo $date; ?> "><?php echo $date; ?> </a> (<?php echo Tools::formatMultiple($num, 'message'); ?> )</li> <?php } ?> </ul> <?php } else { ?> <fieldset id="chats"> <?php $this->showPage('chats'); ?>
public static function parseMessage($room_id, $message) { if (substr($message, 0, 1) == '/') { $tokens = explode(' ', $message); $remainder = substr($message, strlen($tokens[0]), strlen($message)); $type = self::TYPE_NORMAL; switch ($tokens[0]) { /* case '/id': $type = self::TYPE_HTML; $id = implode(' ', $tokens); $id = Database::clean(substr($id, 3, strlen($id))); $msg = self::getMessageById($id); $url = 'TODO'; #$message = sprintf('<span class="app app-search">Found the search term "%s" %s</span>', $term, Tools::formatMultiple($results, 'time')); $message = sprintf('<a class="app app-id" href="%s" target="_blank"><%s> %s</a>', $url, $msg['name'], $msg['message']); break; */ case '/me': $message = $remainder; $type = self::TYPE_EMOTE; break; case '/search': $type = self::TYPE_HTML; $term = implode(' ', $tokens); $term = Database::clean(substr($term, 8, strlen($term))); $results = self::getSearchResults($term, $room_id); $message = sprintf('<span class="app app-search">Found the search term "%s" %s</span>', $term, Tools::formatMultiple($results, 'time')); break; case '/seen': $type = self::TYPE_HTML; $user = implode(' ', $tokens); if ($user) { $user = Database::clean(substr($user, 6, strlen($user))); $results = self::getMessagesByRoomIdAndUser($room_id, $user, 1); if ($results) { $last_seen = Tools::formatTimeDiff(2, $results[0]['timestamp']); $url = self::formatMessageLink($results[0]); $message = sprintf('<span class="app app-seen">%s was last seen <a href="%s" target="_blank">%s</a></span>', $user, $url, $last_seen); } else { $message = sprintf('<span class="app app-seen">%s has never posted in this room!</span>', $user); } } else { $message = '<span class="app app-seen">Seen who?</span>'; } break; case '/tgen': $type = self::TYPE_HTML; if ($tokens[1] == 'best') { $message = self::getTgenBest(); } else { $message = self::getTgen($tokens[1]); } break; case '/topic': $type = self::TYPE_HTML; $topic = implode(' ', $tokens); $topic = Database::clean(substr($topic, 7, strlen($topic))); $results = self::setTopicByRoomId($room_id, $topic); $message = sprintf('<span class="app app-topic">The topic is now "%s"</span>', $topic); break; } return array('message' => $message, 'type' => $type); } return false; }