Improved the CSS id/class stuff.
[specialops2.git] / lib / class.topiclist_tl.php
blob7d5961c9ac5a6aede189aa3b8805a50d54e0fffb
1 <?php
2 // $Id$
4 class topiclist_tl extends topiclist_default implements topiclist
6 const ID = 1;
7 const Name = 'Twisted Legacy';
9 public function display()
11 global $DB, $user;
13 echo
14 '<table id="topiclist" class="',__CLASS__,"\">\n",
15 "<thead>\n",
16 "<tr>\n",
17 ' <th scope="col">Topic Name</th>',"\n",
18 ' <th scope="col">Created By</th>',"\n",
19 ' <th scope="col">Messages</th>',"\n",
20 ' <th scope="col">Last Post</th>',"\n",
21 "</tr>\n",
22 "</thead>\n",
23 "<tbody>\n";
25 // flying spaghetti code monster
26 $topics = $DB->query(
27 'SELECT `topics`.`topicid`, `topic_title`, `topics`.`userid`, `alias`,
28 `messageid`, `mtime`, `messages`.`userid` AS `lastposterid`,
29 (SELECT COUNT(*) FROM `messages` WHERE `messages`.`topicid` = `topics`.`topicid`) AS `posts`,
30 (SELECT `alias` FROM `users` WHERE `users`.`userid` = `messages`.`userid`) AS `lastposter`
31 FROM `topics`
32 LEFT JOIN `messages` ON `lastpost` = `messageid`
33 LEFT JOIN `users` ON `topics`.`userid` = `users`.`userid`
34 WHERE `boardid` = @boardid
35 GROUP BY `topicid`
36 ORDER BY `mtime` DESC
37 LIMIT '.($this->page*$this->tpp).', '.$this->tpp, MYSQLI_USE_RESULT);
39 $a = 1;
41 while ( $topic = $topics->fetch_assoc() ) {
42 printf(
43 '<tr class="content c%d">'."\n".
44 ' <td><a class="topic" href="messagelist?%d">%s</a></td>'."\n".
45 " <td>%s</td>\n".
46 " <td>%d</td>\n".
47 " <td><small>%s<br/>By: %s</small></td>\n".
48 "</tr>\n",
49 (++$a&1),
50 $topic['topicid'],
51 $topic['topic_title'],
52 $user->namelink($topic['userid'], $topic['alias']),
53 $topic['posts'],
54 $user->fdate($topic['mtime']),
55 $user->namelink($topic['lastposterid'], $topic['lastposter'])
58 echo "</tbody>\n</table>";