Special Ops 2.50
[specialops2.git] / lib / Topiclist_Default.php
blobfad22db9f8eee33100f5887e42bcc236f6bb6f8a
1 <?php
2 /**
3 * Default topic list
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://../COPYING
7 * @version 2.99
8 */
9 class Topiclist_Default extends Topiclist_Lite implements Topiclist
11 public function display()
13 echo
14 "<table>\n",
15 '<col/><col/><col class="num"/><col/>',"\n",
16 "<thead>\n",
17 "<tr>\n",
18 ' <th scope="col">Topic Name</th>',"\n",
19 ' <th scope="col">Created By</th>',"\n",
20 ' <th scope="col">Posts</th>',"\n",
21 ' <th scope="col">Last Post</th>',"\n",
22 "</tr>\n",
23 "</thead>\n",
24 "<tbody>\n";
26 // Guaranteed to be O(log n) or your money back!
27 $q = SO2::$DB->q(
28 'SELECT topics.topicid, topic_title, topics.userid, messageid, mtime, messages.userid AS lastpostuid, posts '.
29 'FROM topics LEFT JOIN messages ON lastpost = messageid '.
30 'WHERE boardid = @boardid GROUP BY topicid ORDER BY mtime DESC LIMIT ?, ?',
31 array($this->page*$this->tpp, $this->tpp), SO2_PDO::QOBJ);
32 $topics = $q->fetchAll();
34 $a = 1;
36 foreach ( $topics as $topic ) {
37 printf(
38 '<tr class="content c%d u%d">'."\n".
39 ' <td><a class="topic" href="messagelist?%d">%s</a></td>'."\n".
40 " <td>%s</td>\n".
41 " <td>%d</td>\n".
42 " <td><small>%s<br/>By: %s</small></td>\n".
43 "</tr>\n",
44 (++$a&1),
45 $topic['userid'],
46 $topic['topicid'],
47 $topic['topic_title'],
48 SO2::$Page->namelink($topic['userid']),
49 $topic['posts'],
50 SO2::$Page->fdate($topic['mtime']),
51 SO2::$Page->namelink($topic['lastpostuid'])
54 echo "</tbody>\n</table>\n";