123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class TagNoticeStream extends ScopingNoticeStream
- {
- function __construct($tag, $profile = -1)
- {
- if (is_int($profile) && $profile == -1) {
- $profile = Profile::current();
- }
- parent::__construct(new CachingNoticeStream(new RawTagNoticeStream($tag),
- 'notice_tag:notice_ids:' . Cache::keyize($tag)));
- }
- }
- class RawTagNoticeStream extends NoticeStream
- {
- protected $tag;
- function __construct($tag)
- {
- $this->tag = $tag;
- }
- function getNoticeIds($offset, $limit, $since_id, $max_id)
- {
- $nt = new Notice_tag();
- $nt->tag = $this->tag;
- $nt->selectAdd();
- $nt->selectAdd('notice_id');
- Notice::addWhereSinceId($nt, $since_id, 'notice_id');
- Notice::addWhereMaxId($nt, $max_id, 'notice_id');
- if (!empty($this->selectVerbs)) {
- $nt->joinAdd(array('notice_id', 'notice:id'));
- $filter = array_keys(array_filter($this->selectVerbs));
- if (!empty($filter)) {
-
- $nt->whereAddIn('notice.verb', $filter, 'string');
- }
- $filter = array_keys(array_filter($this->selectVerbs, function ($v) { return !$v; }));
- if (!empty($filter)) {
-
- $nt->whereAddIn('!notice.verb', $filter, 'string');
- }
- }
- $nt->orderBy('notice.created DESC, notice_id DESC');
- if (!is_null($offset)) {
- $nt->limit($offset, $limit);
- }
- $ids = array();
- if ($nt->find()) {
- while ($nt->fetch()) {
- $ids[] = $nt->notice_id;
- }
- }
- return $ids;
- }
- }
|