function showContent() { $notice = Notice_tag::getStream($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); $nl = new NoticeList($notice, $this); $cnt = $nl->show(); $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->page, 'tag', array('tag' => $this->tag)); }
function getNotices($limit = 0) { $tag = $this->tag; if (is_null($tag)) { return null; } $notice = Notice_tag::getStream($tag->tag)->getNotices(0, $limit == 0 ? NOTICES_PER_PAGE : $limit); return $notice->fetchAll(); }
function getNotices($limit = 0) { $tag = $this->tag; if (is_null($tag)) { return null; } $notice = Notice_tag::getStream($tag->tag, 0, $limit == 0 ? NOTICES_PER_PAGE : $limit); while ($notice->fetch()) { $notices[] = clone $notice; } return $notices; }
function timeline($args, $apidata) { parent::handle($args); common_debug("in tags api action"); $this->auth_user = $apidata['user']; $tag = $apidata['api_arg']; if (empty($tag)) { $this->clientError('Not Found', 404, $apidata['content-type']); return; } $sitename = common_config('site', 'name'); $title = sprintf(_("Notices tagged with %s"), $tag); $taguribase = common_config('integration', 'taguri'); $id = "tag:{$taguribase}:TagTimeline:" . $tag; $link = common_local_url('tag', array('tag' => $tag)); $subtitle = sprintf(_('Updates tagged with %1$s on %2$s!'), $tag, $sitename); $page = (int) $this->arg('page', 1); $count = (int) $this->arg('count', 20); $max_id = (int) $this->arg('max_id', 0); $since_id = (int) $this->arg('since_id', 0); $since = $this->arg('since'); # XXX: support max_id, since_id, and since arguments $notice = Notice_tag::getStream($tag, ($page - 1) * $count, $count + 1); switch ($apidata['content-type']) { case 'xml': $this->show_xml_timeline($notice); break; case 'rss': $this->show_rss_timeline($notice, $title, $link, $subtitle, $suplink); break; case 'atom': if (isset($apidata['api_arg'])) { $selfuri = common_root_url() . 'api/laconica/tags/timeline/' . $apidata['api_arg'] . '.atom'; } else { $selfuri = common_root_url() . 'api/laconica/tags/timeline.atom'; } $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri); break; case 'json': $this->show_json_timeline($notice); break; default: $this->clientError(_('API method not found!'), $code = 404); } }
protected function prepare(array $args = array()) { parent::prepare($args); $taginput = $this->trimmed('tag'); $this->tag = common_canonical_tag($taginput); if (empty($this->tag)) { common_redirect(common_local_url('publictagcloud'), 301); } // after common_canonical_tag we have a lowercase, no-specials tag string if ($this->tag !== $taginput) { common_redirect(common_local_url('tag', array('tag' => $this->tag)), 301); } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; common_set_returnto($this->selfUrl()); $this->notice = Notice_tag::getStream($this->tag)->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if ($this->page > 1 && $this->notice->N == 0) { // TRANS: Client error when page not found (404). $this->clientError(_('No such page.'), 404); } return true; }
function prepare($args) { parent::prepare($args); $taginput = $this->trimmed('tag'); $this->tag = common_canonical_tag($taginput); if (!$this->tag) { common_redirect(common_local_url('publictagcloud'), 301); return false; } if ($this->tag != $taginput) { common_redirect(common_local_url('tag', array('tag' => $this->tag)), 301); return false; } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; common_set_returnto($this->selfUrl()); $this->notice = Notice_tag::getStream($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if ($this->page > 1 && $this->notice->N == 0) { // TRANS: Server error when page not found (404) $this->serverError(_('您访问的网页不存在'), $code = 404); } return true; }
protected function getNotices() { $stream = Notice_tag::getStream($this->tag->tag)->getNotices(0, $this->limit); return $stream->fetchAll(); }
/** * Get notices * * @return array notices */ function getNotices() { $notices = array(); $notice = Notice_tag::getStream($this->tag, ($this->page - 1) * $this->count, $this->count + 1); while ($notice->fetch()) { $notices[] = clone $notice; } return $notices; }
/** * Get notices * * @return array notices */ function getNotices() { $notice = Notice_tag::getStream($this->tag)->getNotices(($this->page - 1) * $this->count, $this->count + 1, $this->since_id, $this->max_id); return $notice->fetchAll(); }