3 * Plain messagelist like GF uses
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://../COPYING
9 require_once 'lib/iface.Messagelist.php';
11 class Messagelist_Flat
implements Messagelist
23 function __construct($topicid, Messagestyle
$mo, $mpp, $page)
26 throw new Exception('<blink>CANNOT DIVIDE BY ZERO</blink>');
29 $this->msgs
= SO2
::$DB->q('SELECT userid, mtime, topicid, replyto, score, marks, messageid, INET_NTOA(origin_ip) AS ip '.
30 'FROM messages WHERE topicid = ? ORDER BY mtime ASC LIMIT ?, ?',
31 array($topicid, $mpp*$page, $mpp), SO2_PDO
::QOBJ
)->fetchAll(PDO
::FETCH_ASSOC
);
32 $this->postcount
= SO2
::$DB->q('SELECT COUNT(*) FROM messages WHERE topicid = ?', $topicid, SO2_PDO
::QVALUE
);
34 list($this->topicid
, $this->mo
, $this->mpp
, $this->page
) = func_get_args();
37 public function display()
39 foreach ( $this->msgs
as $m ) {
40 if ( $m['score'] < SO2
::$User->cutoff
&& SO2
::$User->userid
!= $m['userid'] )
41 $m['mtext'] = sprintf(self
::MODMSG
, SO2
::$User->cutoff
);
42 $this->mo
->display($m);
46 public function pagelist()
48 // Not enough to fill one page
49 if ( $this->postcount
< $this->mpp
) {
53 $list = range(0, $this->postcount
/$this->mpp
);
56 foreach ( $list as $pagenum ) {
58 case $this->page
-1: // current page in script is off by one from display here
59 $str .= sprintf('<dd class="prev"><a href="messagelist?topic=%d;page=%d;length=%d" rel="prev">%d</a></dd>',
60 $this->topicid
, $pagenum, $this->mpp
, $pagenum+
1); break;
62 $str .= '<dd class="curpage">'.($pagenum+
1).'</dd>'; break;
64 $str .= sprintf('<dd class="next"><a href="messagelist?topic=%d;page=%d;length=%d" rel="next">%d</a></dd>',
65 $this->topicid
, $pagenum, $this->mpp
, $pagenum+
1); break;
67 $str .= sprintf('<dd><a href="messagelist?topic=%d;page=%d;length=%d">%d</a></dd>',
68 $this->topicid
, $pagenum, $this->mpp
, $pagenum+
1); break;