3 * SO2 default topic list layout
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://../COPYING
10 require_once 'lib/iface.Topiclist.php';
12 class Topiclist_Lite
implements Topiclist
18 function __construct($tpp = 35, $page = 0)
22 $this->topicsum
= SO2
::$DB->query('SELECT COUNT(*) FROM topics WHERE boardid = @boardid')->fetchColumn(0);
25 public function display()
29 'SELECT topics.topicid, topic_title, topics.userid, messageid, mtime, '.
30 '(SELECT COUNT(*) FROM messages WHERE messages.topicid = topics.topicid) AS posts '.
31 'FROM topics LEFT JOIN messages ON lastpost = messageid '.
32 'WHERE boardid = @boardid '.
34 'ORDER BY mtime DESC '.
35 'LIMIT ?, ?', array($this->page
*$this->tpp
, $this->tpp
), SO2_PDO
::QOBJ
);
36 $topics = $q->fetchAll();
40 ' <col/><col/><col class="num"/><col/>',"\n",
43 ' <th scope="col">Topic</th>',"\n",
44 ' <th scope="col">Creator</th>',"\n",
45 ' <th scope="col">Posts</th>',"\n",
46 ' <th scope="col">Last Post</th>',"\n",
53 foreach ( $topics as $topic ) {
55 ' <tr class="content c%d u%d">'."\n".
56 ' <td><a class="topic" href="messagelist?%d">%s</a></td>'."\n".
64 $topic['topic_title'],
65 SO2
::$Page->namelink($topic['userid']),
67 SO2
::$Page->fdate($topic['mtime'])
70 echo " </tbody>\n</table>\n";
73 public function pagelist()
75 global $boardid; // This is a nasty hack
78 if ( $this->topicsum
< $this->tpp
) {
82 if ( 0 == $this->tpp
) {
84 trigger_error(__METHOD__
.': $tpp was 0, changing to 5 instead', E_USER_WARNING
);
87 for ( $i = 0; $i < $this->topicsum
; $i +
= $this->tpp
) {
88 if ( $i/$this->tpp
== $this->page
) {
89 $list[] = '<dd class="curpage">['.($i/$this->tpp+
1).']</dd>';
91 $rel = ( $i/$this->tpp
== $this->page+
1
93 : ( $i/$this->tpp
== $this->page
-1
96 $list[] = sprintf('<dd%s><a href="topiclist?board=%d;page=%d;length=%d"%s>%d</a></dd>',
97 ( $rel ?
' class="'.$rel.'"' : '' ),
101 ( $rel ?
' rel="'.$rel.'"' : '' ),
107 return "\n\t".implode("\n\t", $list)."\n";