Introducing TargetedRss10Action for simplifying RSS 1.0
This commit is contained in:
parent
1cbf2510e7
commit
e46b2803a7
|
@ -42,52 +42,12 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class AllrssAction extends Rss10Action
|
||||
class AllrssAction extends TargetedRss10Action
|
||||
{
|
||||
var $user = null;
|
||||
|
||||
/**
|
||||
* Initialization.
|
||||
*
|
||||
* @param array $args Web and URL arguments
|
||||
*
|
||||
* @return boolean false if user doesn't exist
|
||||
*
|
||||
*/
|
||||
function prepare($args)
|
||||
protected function getNotices()
|
||||
{
|
||||
parent::prepare($args);
|
||||
$nickname = $this->trimmed('nickname');
|
||||
$this->user = User::getKV('nickname', $nickname);
|
||||
|
||||
if (!$this->user) {
|
||||
// TRANS: Client error when user not found for an rss related action.
|
||||
$this->clientError(_('No such user.'));
|
||||
} else {
|
||||
$this->notices = $this->getNotices($this->limit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notices
|
||||
*
|
||||
* @param integer $limit max number of notices to return
|
||||
*
|
||||
* @return array notices
|
||||
*/
|
||||
function getNotices($limit=0)
|
||||
{
|
||||
$stream = new InboxNoticeStream($this->user->getProfile());
|
||||
$notice = $stream->getNotices(0, $limit, null, null);
|
||||
|
||||
$notices = array();
|
||||
|
||||
while ($notice->fetch()) {
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
|
||||
return $notices;
|
||||
$stream = new InboxNoticeStream($this->target);
|
||||
return $stream->getNotices(0, $this->limit)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,33 +57,17 @@ class AllrssAction extends Rss10Action
|
|||
*/
|
||||
function getChannel()
|
||||
{
|
||||
$user = $this->user;
|
||||
$c = array('url' => common_local_url('allrss',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
$this->target->getNickname())),
|
||||
// TRANS: Message is used as link title. %s is a user nickname.
|
||||
'title' => sprintf(_('%s and friends'), $user->nickname),
|
||||
'title' => sprintf(_('%s and friends'), $this->target->getNickname()),
|
||||
'link' => common_local_url('all',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
$this->target->getNickname())),
|
||||
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
||||
'description' => sprintf(_('Updates from %1$s and friends on %2$s!'),
|
||||
$user->nickname, common_config('site', 'name')));
|
||||
$this->target->getNickname(), common_config('site', 'name')));
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image.
|
||||
*
|
||||
* @return string user avatar URL or null
|
||||
*/
|
||||
function getImage()
|
||||
{
|
||||
$user = $this->user;
|
||||
$profile = $user->getProfile();
|
||||
if (!$profile) {
|
||||
return null;
|
||||
}
|
||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ define('MEMBERS_PER_SECTION', 27);
|
|||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class groupRssAction extends Rss10Action
|
||||
class GroupRssAction extends TargetedRss10Action
|
||||
{
|
||||
/** group we're viewing. */
|
||||
var $group = null;
|
||||
protected $group = null;
|
||||
|
||||
/**
|
||||
* Is this page read-only?
|
||||
|
@ -56,18 +56,8 @@ class groupRssAction extends Rss10Action
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the action
|
||||
*
|
||||
* Reads and validates arguments and instantiates the attributes.
|
||||
*
|
||||
* @param array $args $_REQUEST args
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
function prepare($args)
|
||||
protected function doStreamPreparation()
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
$nickname_arg = $this->arg('nickname');
|
||||
$nickname = common_canonical_nickname($nickname_arg);
|
||||
|
@ -86,52 +76,32 @@ class groupRssAction extends Rss10Action
|
|||
|
||||
$local = Local_group::getKV('nickname', $nickname);
|
||||
|
||||
if (!$local) {
|
||||
if (!$local instanceof Local_group) {
|
||||
// TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
}
|
||||
|
||||
$this->group = User_group::getKV('id', $local->group_id);
|
||||
|
||||
if (!$this->group) {
|
||||
// TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
}
|
||||
|
||||
$this->notices = $this->getNotices($this->limit);
|
||||
return true;
|
||||
$this->group = $local->getGroup();
|
||||
$this->target = $this->group->getProfile();
|
||||
}
|
||||
|
||||
function getNotices($limit=0)
|
||||
protected function getNotices()
|
||||
{
|
||||
$group = $this->group;
|
||||
|
||||
if (is_null($group)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$notices = array();
|
||||
$notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
|
||||
|
||||
while ($notice->fetch()) {
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
|
||||
return $notices;
|
||||
$stream = $this->group->getNotices(0, $this->limit);
|
||||
return $stream->fetchAll();
|
||||
}
|
||||
|
||||
function getChannel()
|
||||
{
|
||||
$group = $this->group;
|
||||
$c = array('url' => common_local_url('grouprss',
|
||||
array('nickname' =>
|
||||
$group->nickname)),
|
||||
$this->target->getNickname())),
|
||||
// TRANS: Message is used as link title. %s is a user nickname.
|
||||
'title' => sprintf(_('%s timeline'), $group->nickname),
|
||||
'link' => common_local_url('showgroup', array('nickname' => $group->nickname)),
|
||||
'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
|
||||
'link' => common_local_url('showgroup', array('nickname' => $this->target->getNickname())),
|
||||
// TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
|
||||
'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
|
||||
$group->nickname, common_config('site', 'name')));
|
||||
$this->target->getNickname(), common_config('site', 'name')));
|
||||
return $c;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,19 +44,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
*/
|
||||
class NoticesearchrssAction extends Rss10Action
|
||||
{
|
||||
function init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->notices = $this->getNotices();
|
||||
return true;
|
||||
}
|
||||
|
||||
function getNotices($limit=0)
|
||||
protected function getNotices()
|
||||
{
|
||||
$q = $this->trimmed('q');
|
||||
$notices = array();
|
||||
|
@ -66,8 +54,7 @@ class NoticesearchrssAction extends Rss10Action
|
|||
$search_engine = $notice->getSearchEngine('notice');
|
||||
$search_engine->set_sort_mode('chron');
|
||||
|
||||
if (!$limit) $limit = 20;
|
||||
$search_engine->limit(0, $limit, true);
|
||||
$search_engine->limit(0, $this->limit, true);
|
||||
if (false === $search_engine->query($q)) {
|
||||
$cnt = 0;
|
||||
} else {
|
||||
|
|
|
@ -44,29 +44,6 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
*/
|
||||
class PublicrssAction extends Rss10Action
|
||||
{
|
||||
/**
|
||||
* Read arguments and initialize members
|
||||
*
|
||||
* @param array $args Arguments from $_REQUEST
|
||||
* @return boolean success
|
||||
*/
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->notices = $this->getNotices($this->limit);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization.
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notices
|
||||
*
|
||||
|
@ -74,15 +51,10 @@ class PublicrssAction extends Rss10Action
|
|||
*
|
||||
* @return array notices
|
||||
*/
|
||||
function getNotices($limit=0)
|
||||
protected function getNotices()
|
||||
{
|
||||
$notices = array();
|
||||
$notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit);
|
||||
while ($notice->fetch()) {
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
|
||||
return $notices;
|
||||
$stream = Notice::publicStream(0, $this->limit);
|
||||
return $stream->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,64 +21,30 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
|
||||
// Formatting of RSS handled by Rss10Action
|
||||
|
||||
class RepliesrssAction extends Rss10Action
|
||||
class RepliesrssAction extends TargetedRss10Action
|
||||
{
|
||||
var $user = null;
|
||||
|
||||
function prepare($args)
|
||||
protected function getNotices()
|
||||
{
|
||||
parent::prepare($args);
|
||||
$nickname = $this->trimmed('nickname');
|
||||
$this->user = User::getKV('nickname', $nickname);
|
||||
|
||||
if (!$this->user) {
|
||||
// TRANS: Client error displayed when providing a non-existing nickname in a RSS 1.0 action.
|
||||
$this->clientError(_('No such user.'));
|
||||
} else {
|
||||
$this->notices = $this->getNotices($this->limit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function getNotices($limit=0)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
$notice = $user->getReplies(0, ($limit == 0) ? 48 : $limit);
|
||||
|
||||
$notices = array();
|
||||
|
||||
while ($notice->fetch()) {
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
|
||||
return $notices;
|
||||
$stream = $this->target->getReplies(0, $this->limit);
|
||||
return $stream->fetchAll();
|
||||
}
|
||||
|
||||
function getChannel()
|
||||
{
|
||||
$user = $this->user;
|
||||
$c = array('url' => common_local_url('repliesrss',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
$this->target->getNickname())),
|
||||
// TRANS: RSS reply feed title. %s is a user nickname.
|
||||
'title' => sprintf(_("Replies to %s"), $user->nickname),
|
||||
'title' => sprintf(_("Replies to %s"), $this->target->getNickname()),
|
||||
'link' => common_local_url('replies',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
array('nickname' => $this->target->getNickname())),
|
||||
// TRANS: RSS reply feed description.
|
||||
// TRANS: %1$s is a user nickname, %2$s is the StatusNet site name.
|
||||
'description' => sprintf(_('Replies to %1$s on %2$s.'),
|
||||
$user->nickname, common_config('site', 'name')));
|
||||
$this->target->getNickname(), common_config('site', 'name')));
|
||||
return $c;
|
||||
}
|
||||
|
||||
function getImage()
|
||||
{
|
||||
$profile = $this->user->getProfile();
|
||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||
}
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -20,33 +20,25 @@
|
|||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
// Formatting of RSS handled by Rss10Action
|
||||
|
||||
class TagrssAction extends Rss10Action
|
||||
{
|
||||
var $tag;
|
||||
protected $tag;
|
||||
|
||||
function prepare($args) {
|
||||
parent::prepare($args);
|
||||
protected function doStreamPreparation()
|
||||
{
|
||||
$tag = common_canonical_tag($this->trimmed('tag'));
|
||||
$this->tag = Notice_tag::getKV('tag', $tag);
|
||||
if (!$this->tag) {
|
||||
if (!$this->tag instanceof Notice_tag) {
|
||||
// TRANS: Client error when requesting a tag feed for a non-existing tag.
|
||||
$this->clientError(_('No such tag.'));
|
||||
} else {
|
||||
$this->notices = $this->getNotices($this->limit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function getNotices($limit=0)
|
||||
protected function getNotices()
|
||||
{
|
||||
$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();
|
||||
$stream = Notice_tag::getStream($this->tag->tag)->getNotices(0, $this->limit);
|
||||
return $stream->fetchAll();
|
||||
}
|
||||
|
||||
function getChannel()
|
||||
|
|
|
@ -21,94 +21,48 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
|
||||
// Formatting of RSS handled by Rss10Action
|
||||
|
||||
class UserrssAction extends Rss10Action
|
||||
class UserrssAction extends TargetedRss10Action
|
||||
{
|
||||
var $tag = null;
|
||||
protected $tag = null;
|
||||
|
||||
protected function prepare(array $args=array())
|
||||
protected function doStreamPreparation()
|
||||
{
|
||||
parent::prepare($args);
|
||||
$nickname = $this->trimmed('nickname');
|
||||
$this->user = User::getKV('nickname', $nickname);
|
||||
$this->tag = $this->trimmed('tag');
|
||||
}
|
||||
|
||||
if (!$this->user) {
|
||||
// TRANS: Client error displayed when user not found for an action.
|
||||
$this->clientError(_('No such user.'));
|
||||
}
|
||||
|
||||
protected function getNotices()
|
||||
{
|
||||
if (!empty($this->tag)) {
|
||||
$this->notices = $this->getTaggedNotices();
|
||||
} else {
|
||||
$this->notices = $this->getNotices();
|
||||
$stream = $this->target->getTaggedNotices($this->tag, 0, $this->limit);
|
||||
return $stream->fetchAll();
|
||||
}
|
||||
// otherwise we fetch a normal user stream
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getTaggedNotices()
|
||||
{
|
||||
$notice = $this->user->getTaggedNotices(
|
||||
$this->tag,
|
||||
0,
|
||||
($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
$notices = array();
|
||||
while ($notice->fetch()) {
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
|
||||
return $notices;
|
||||
}
|
||||
|
||||
|
||||
function getNotices()
|
||||
{
|
||||
$notice = $this->user->getNotices(
|
||||
0,
|
||||
($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit
|
||||
);
|
||||
|
||||
$notices = array();
|
||||
while ($notice->fetch()) {
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
|
||||
return $notices;
|
||||
$stream = $this->target->getNotices(0, $this->limit);
|
||||
return $stream->fetchAll();
|
||||
}
|
||||
|
||||
function getChannel()
|
||||
{
|
||||
$user = $this->user;
|
||||
$profile = $user->getProfile();
|
||||
$c = array('url' => common_local_url('userrss',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
$this->target->getNickname())),
|
||||
// TRANS: Message is used as link title. %s is a user nickname.
|
||||
'title' => sprintf(_('%s timeline'), $user->nickname),
|
||||
'link' => $profile->profileurl,
|
||||
'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
|
||||
'link' => $this->target->getUrl(),
|
||||
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
||||
'description' => sprintf(_('Updates from %1$s on %2$s!'),
|
||||
$user->nickname, common_config('site', 'name')));
|
||||
$this->target->getNickname(), common_config('site', 'name')));
|
||||
return $c;
|
||||
}
|
||||
|
||||
function getImage()
|
||||
{
|
||||
$profile = $this->user->getProfile();
|
||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||
}
|
||||
|
||||
// override parent to add X-SUP-ID URL
|
||||
|
||||
function initRss($limit=0)
|
||||
function initRss()
|
||||
{
|
||||
$url = common_local_url('sup', null, null, $this->user->id);
|
||||
$url = common_local_url('sup', null, null, $this->target->getID());
|
||||
header('X-SUP-ID: '.$url);
|
||||
parent::initRss($limit);
|
||||
parent::initRss();
|
||||
}
|
||||
|
||||
function isReadOnly($args)
|
||||
|
|
|
@ -50,7 +50,7 @@ class Local_group extends Managed_DataObject
|
|||
$group->find(true);
|
||||
if (!$group instanceof User_group) {
|
||||
common_log(LOG_ERR, 'User_group does not exist for Local_group: '.$this->group_id);
|
||||
throw new NoResultException($group);
|
||||
throw new NoSuchGroupException(array('id' => $this->group_id));
|
||||
}
|
||||
return $group;
|
||||
}
|
||||
|
|
|
@ -242,6 +242,11 @@ class Profile extends Managed_DataObject
|
|||
return null;
|
||||
}
|
||||
|
||||
function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||
{
|
||||
return Reply::stream($this->getID(), $offset, $limit, $since_id, $before_id);
|
||||
}
|
||||
|
||||
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||
{
|
||||
$stream = new TaggedProfileNoticeStream($this, $tag);
|
||||
|
|
|
@ -55,10 +55,9 @@ class Reply extends Managed_DataObject
|
|||
return $result;
|
||||
}
|
||||
|
||||
function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||
static function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||
{
|
||||
$stream = new ReplyNoticeStream($user_id);
|
||||
|
||||
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class Rss10Action extends ManagedAction
|
|||
{
|
||||
$this->limit = $this->int('limit');
|
||||
|
||||
if ($this->limit == 0) {
|
||||
if (empty($this->limit)) {
|
||||
$this->limit = DEFAULT_RSS_LIMIT;
|
||||
}
|
||||
|
||||
|
@ -73,10 +73,19 @@ class Rss10Action extends ManagedAction
|
|||
|
||||
common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
|
||||
$this->show_basic_auth_error();
|
||||
return;
|
||||
// the above calls 'exit'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->doStreamPreparation();
|
||||
|
||||
$this->notices = $this->getNotices($this->limit);
|
||||
}
|
||||
|
||||
protected function doStreamPreparation()
|
||||
{
|
||||
// for example if we need to set $this->target or something
|
||||
}
|
||||
|
||||
function show_basic_auth_error()
|
||||
|
@ -98,7 +107,7 @@ class Rss10Action extends ManagedAction
|
|||
* @return array an array of Notice objects sorted in reverse chron
|
||||
*/
|
||||
|
||||
function getNotices()
|
||||
protected function getNotices($limit=0)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
|
|
@ -44,54 +44,12 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class BookmarksrssAction extends Rss10Action
|
||||
class BookmarksrssAction extends TargetedRss10Action
|
||||
{
|
||||
/** The user whose bookmarks to display */
|
||||
|
||||
var $user = null;
|
||||
|
||||
/**
|
||||
* Find the user to display by supplied nickname
|
||||
*
|
||||
* @param array $args Arguments from $_REQUEST
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
$nickname = $this->trimmed('nickname');
|
||||
$this->user = User::getKV('nickname', $nickname);
|
||||
|
||||
if (!$this->user) {
|
||||
// TRANS: Client error displayed when trying to get the RSS feed with bookmarks of a user that does not exist.
|
||||
$this->clientError(_('No such user.'));
|
||||
} else {
|
||||
$this->notices = $this->getNotices($this->limit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notices
|
||||
*
|
||||
* @param integer $limit max number of notices to return
|
||||
*
|
||||
* @return array notices
|
||||
*/
|
||||
function getNotices($limit=0)
|
||||
protected function getNotices()
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
$notice = new BookmarksNoticeStream($this->user->id, true);
|
||||
$notice = $notice->getNotices(0, NOTICES_PER_PAGE);
|
||||
|
||||
$notices = array();
|
||||
while ($notice->fetch()) {
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
return $notices;
|
||||
$stream = new BookmarksNoticeStream($this->target->getID(), true);
|
||||
return $stream->getNotices(0, $this->limit)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,31 +59,19 @@ class BookmarksrssAction extends Rss10Action
|
|||
*/
|
||||
function getChannel()
|
||||
{
|
||||
$user = $this->user;
|
||||
$c = array('url' => common_local_url('bookmarksrss',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
$this->target->getNickname())),
|
||||
// TRANS: Title of RSS feed with bookmarks of a user.
|
||||
// TRANS: %s is a user's nickname.
|
||||
'title' => sprintf(_("%s's bookmarks"), $user->nickname),
|
||||
'title' => sprintf(_("%s's bookmarks"), $this->target->getNickname()),
|
||||
'link' => common_local_url('bookmarks',
|
||||
array('nickname' =>
|
||||
$user->nickname)),
|
||||
$this->target->getNickname())),
|
||||
// TRANS: Desciption of RSS feed with bookmarks of a user.
|
||||
// TRANS: %1$s is a user's nickname, %2$s is the name of the StatusNet site.
|
||||
'description' => sprintf(_('Bookmarks posted by %1$s on %2$s!'),
|
||||
$user->nickname, common_config('site', 'name')));
|
||||
$this->target->getNickname(), common_config('site', 'name')));
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function getImage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,50 +43,15 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class FavoritesrssAction extends Rss10Action
|
||||
class FavoritesrssAction extends TargetedRss10Action
|
||||
{
|
||||
/** The user whose favorites to display */
|
||||
|
||||
var $user = null;
|
||||
|
||||
/**
|
||||
* Find the user to display by supplied nickname
|
||||
*
|
||||
* @param array $args Arguments from $_REQUEST
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
function prepare($args)
|
||||
protected function getNotices()
|
||||
{
|
||||
parent::prepare($args);
|
||||
// is this our own stream?
|
||||
$own = $this->scoped instanceof Profile ? $this->target->getID() === $this->scoped->getID() : false;
|
||||
|
||||
$nickname = $this->trimmed('nickname');
|
||||
$this->user = User::getKV('nickname', $nickname);
|
||||
|
||||
if (!$this->user) {
|
||||
// TRANS: Client error displayed when trying to get the RSS feed with favorites of a user that does not exist.
|
||||
$this->clientError(_('No such user.'));
|
||||
} else {
|
||||
$this->notices = $this->getNotices($this->limit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notices
|
||||
*
|
||||
* @param integer $limit max number of notices to return
|
||||
*
|
||||
* @return array notices
|
||||
*/
|
||||
function getNotices($limit=0)
|
||||
{
|
||||
$notice = Fave::stream($this->user->id, 0, $limit, $false);
|
||||
$notices = array();
|
||||
while ($notice->fetch()) {
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
return $notices;
|
||||
$stream = Fave::stream($this->target->getID(), 0, $this->limit, $own);
|
||||
return $stream->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,15 +77,4 @@ class FavoritesrssAction extends Rss10Action
|
|||
$user->nickname, common_config('site', 'name')));
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function getImage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user