]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/tagnoticestream.php
0e287744dd0215b4c8bf6ec5b418266987dafaa8
[quix0rs-gnu-social.git] / lib / tagnoticestream.php
1 <?php
2
3 class TagNoticeStream extends CachingNoticeStream
4 {
5     function __construct($tag)
6     {
7         parent::__construct(new RawTagNoticeStream($tag),
8                             'notice_tag:notice_ids:' . Cache::keyize($tag));
9     }
10 }
11
12 class RawTagNoticeStream extends NoticeStream
13 {
14     protected $tag;
15
16     function __construct($tag)
17     {
18         $this->tag = $tag;
19     }
20
21     function getNoticeIds($offset, $limit, $since_id, $max_id)
22     {
23         $nt = new Notice_tag();
24
25         $nt->tag = $this->tag;
26
27         $nt->selectAdd();
28         $nt->selectAdd('notice_id');
29
30         Notice::addWhereSinceId($nt, $since_id, 'notice_id');
31         Notice::addWhereMaxId($nt, $max_id, 'notice_id');
32
33         $nt->orderBy('created DESC, notice_id DESC');
34
35         if (!is_null($offset)) {
36             $nt->limit($offset, $limit);
37         }
38
39         $ids = array();
40
41         if ($nt->find()) {
42             while ($nt->fetch()) {
43                 $ids[] = $nt->notice_id;
44             }
45         }
46
47         return $ids;
48     }
49 }