3 * SO2 default topic list layout
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://../COPYING
10 require_once 'lib/iface.Topiclist.php';
12 class Topiclist_Default
implements Topiclist
20 function __construct($tpp = 35, $page = 0)
26 list($this->topicsum
) = $DB->query('SELECT COUNT(*) FROM `topics` WHERE `boardid` = @boardid')->fetch_row();
29 public function display()
34 'SELECT `topics`.`topicid`, `topic_title`, `topics`.`userid`, `alias`, `messageid`, `mtime`,
35 (SELECT COUNT(*) FROM `messages` WHERE `messages`.`topicid` = `topics`.`topicid`) AS `posts`
37 LEFT JOIN `messages` ON `lastpost` = `messageid`
38 LEFT JOIN `users` ON `topics`.`userid` = `users`.`userid`
39 WHERE `boardid` = @boardid
42 LIMIT '.($this->page
*$this->tpp
).', '.$this->tpp
);
46 '<col/><col/><col class="num"/><col/>',"\n",
49 ' <th scope="col">Topic</th>',"\n",
50 ' <th scope="col">Creator</th>',"\n",
51 ' <th scope="col">Posts</th>',"\n",
52 ' <th scope="col">Last Post</th>',"\n",
59 while ( $topic = $topics->fetch_assoc() ) {
61 '<tr class="content c%d">'."\n".
62 ' <td><a class="topic" href="messagelist?%d">%s</a></td>'."\n".
69 $topic['topic_title'],
70 $user->namelink($topic['userid'], $topic['alias']),
72 $user->fdate($topic['mtime'])
75 echo "</tbody>\n</table>\n";
78 public function pagelist()
83 if ( $this->topicsum
< $this->tpp
) {
87 if ( 0 == $this->tpp
) {
89 trigger_error(__METHOD__
.': $tpp was 0, changing to 5 instead', E_USER_WARNING
);
92 for ( $i = 0; $i < $this->topicsum
; $i +
= $this->tpp
) {
93 if ( $i/$this->tpp
== $this->page
) {
94 $list[] = '<dd class="curpage">['.($i/$this->tpp+
1).']</dd>';
96 $rel = $i/$this->tpp
== $this->page+
1
98 : ( $i/$this->tpp
== $this->page
-1
102 $list[] = sprintf('<dd%s><a href="topiclist?board=%d;page=%d;length=%d"%s>%d</a></dd>',
103 $rel ?
' class="'.$rel.'"' : '', $boardid, ($i/$this->tpp
), $this->tpp
, $rel ?
' rel="'.$rel.'"' : '', ($i/$this->tpp+
1));
107 return "\n\t".implode("\n\t", $list)."\n";