Missing closing "
[specialops2.git] / lib / class.Topiclist_TL.php
blob5b31d679cd218b1ba2851e9fbd1d65c7dcfab922
1 <?php
2 /**
3 * TL-style topic list
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://../COPYING
7 * @version $Id$
8 */
9 class Topiclist_TL extends Topiclist_Default implements Topiclist
11 const ID = 1;
12 const Name = 'Twisted Legacy';
14 public function display()
16 global $DB, $user;
18 echo
19 "<table>\n",
20 "<thead>\n",
21 "<tr>\n",
22 ' <th scope="col">Topic Name</th>',"\n",
23 ' <th scope="col">Created By</th>',"\n",
24 ' <th scope="col">Posts</th>',"\n",
25 ' <th scope="col">Last Post</th>',"\n",
26 "</tr>\n",
27 "</thead>\n",
28 "<tbody>\n";
30 // flying spaghetti code monster
31 $topics = $DB->query(
32 'SELECT `topics`.`topicid`, `topic_title`, `topics`.`userid`, `alias`,
33 `messageid`, `mtime`, `messages`.`userid` AS `lastposterid`,
34 (SELECT COUNT(*) FROM `messages`
35 WHERE `messages`.`topicid` = `topics`.`topicid`) AS `posts`,
36 (SELECT `alias` FROM `users`
37 WHERE `users`.`userid` = `messages`.`userid`) AS `lastposter`
38 FROM `topics`
39 LEFT JOIN `messages` ON `lastpost` = `messageid`
40 LEFT JOIN `users` ON `topics`.`userid` = `users`.`userid`
41 WHERE `boardid` = @boardid
42 GROUP BY `topicid`
43 ORDER BY `mtime` DESC
44 LIMIT '.($this->page*$this->tpp).', '.$this->tpp, MYSQLI_USE_RESULT);
46 $a = 1;
48 while ( $topic = $topics->fetch_assoc() ) {
49 printf(
50 '<tr class="content c%d">'."\n".
51 ' <td><a class="topic" href="messagelist?%d">%s</a></td>'."\n".
52 " <td>%s</td>\n".
53 " <td>%d</td>\n".
54 " <td><small>%s<br/>By: %s</small></td>\n".
55 "</tr>\n",
56 (++$a&1),
57 $topic['topicid'],
58 $topic['topic_title'],
59 $user->namelink($topic['userid'], $topic['alias']),
60 $topic['posts'],
61 $user->fdate($topic['mtime']),
62 $user->namelink($topic['lastposterid'], $topic['lastposter'])
65 echo "</tbody>\n</table>\n";