3 * Plain messagelist like GF uses
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
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 $this->msgs
= $DB->query('SELECT `messages`.`userid`, `alias`, `mtime`, `mtext`, `replyto`,
27 `score`, `marks`, `messages`.`messageid`, INET_NTOA(`origin_ip`) AS `ip`
28 FROM `message-data` NATURAL LEFT JOIN `messages` NATURAL LEFT JOIN `users`
29 WHERE `topicid` = '.$topicid.'
30 ORDER BY `mtime` ASC LIMIT '.($mpp*$page).', '.$mpp);
31 list($this->postcount
) = $DB->query('SELECT COUNT(*) FROM `messages` WHERE `topicid` = '.$topicid)->fetch_row();
32 list($this->topicid
, $this->mo
, $this->mpp
, $this->page
) = func_get_args();
35 public function display()
37 while ( $m = $this->msgs
->fetch_assoc() ) {
38 $this->mo
->display($m);
42 public function pagelist()
46 if ( $this->postcount
< $this->mpp
) {
50 if ( 0 == $this->mpp
) {
52 trigger_error(__METHOD__
.': $mpp was 0, changing to 5 instead', E_USER_WARNING
);
55 for ( $i = 0; $i < $this->postcount
; $i +
= $this->mpp
) {
56 if ( $i/$this->mpp
== $this->page
) {
57 $list[] = '['.($i/$this->mpp+
1).']';
59 $rel = $i/$this->mpp
== $this->page+
1 ?
' rel="next"' :
60 ( $i/$this->mpp
== $this->page
-1 ?
' rel="prev"' : '' );
61 $list[] = sprintf('<a href="messagelist?topic=%d;page=%d;length=%d"%s>%d</a>',
62 $this->topicid
, ($i/$this->mpp
), $this->mpp
, $rel, ($i/$this->mpp+
1));
66 return '<dd>'.implode('</dd> <dd>', $list).'</dd>';