exit(1);
}
-require_once INSTALLDIR . '/lib/apiprivateauth.php';
-
/**
* Returns the most recent notices (default 20) posted by everybody
*
</statuses>
@endverbatim
*/
-
class ApiTimelinePublicAction extends ApiPrivateAuthAction
{
-
var $notices = null;
/**
* @return boolean success flag
*
*/
-
function prepare($args)
{
parent::prepare($args);
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
*
* @return void
*/
-
function showTimeline()
{
$sitename = common_config('site', 'name');
$sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
+ // TRANS: Title for site timeline. %s is the StatusNet sitename.
$title = sprintf(_("%s public timeline"), $sitename);
$taguribase = TagURI::base();
$id = "tag:$taguribase:PublicTimeline";
$link = common_local_url('public');
$self = $this->getSelfUri();
+ // TRANS: Subtitle for site timeline. %s is the StatusNet sitename.
$subtitle = sprintf(_("%s updates from everyone!"), $sitename);
switch($this->format) {
case 'json':
$this->showJsonTimeline($this->notices);
break;
+ case 'as':
+ header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
+ $doc = new ActivityStreamJSONDocument($this->auth_user);
+ $doc->setTitle($title);
+ $doc->addLink($link, 'alternate', 'text/html');
+ $doc->addItemsFromNotices($this->notices);
+ $this->raw($doc->asString());
+ break;
default:
+ // TRANS: Client error displayed when coming across a non-supported API method.
$this->clientError(_('API method not found.'), $code = 404);
break;
}
*
* @return array notices
*/
-
function getNotices()
{
$notices = array();
- $notice = Notice::publicStream(
- ($this->page - 1) * $this->count, $this->count, $this->since_id,
- $this->max_id
- );
+ $profile = ($this->auth_user) ? $this->auth_user->getProfile() : null;
- while ($notice->fetch()) {
- $notices[] = clone($notice);
- }
+ $stream = new PublicNoticeStream($profile);
+
+ $notice = $stream->getNotices(($this->page - 1) * $this->count,
+ $this->count,
+ $this->since_id,
+ $this->max_id);
+
+ $notices = $notice->fetchAll();
+
+ NoticeList::prefill($notices);
return $notices;
}
*
* @return boolean true
*/
-
function isReadOnly($args)
{
return true;
*
* @return string datestamp of the latest notice in the stream
*/
-
function lastModified()
{
if (!empty($this->notices) && (count($this->notices) > 0)) {
*
* @return string etag
*/
-
function etag()
{
if (!empty($this->notices) && (count($this->notices) > 0)) {
return '"' . implode(
':',
array($this->arg('action'),
+ common_user_cache_hash($this->auth_user),
common_language(),
strtotime($this->notices[0]->created),
strtotime($this->notices[$last]->created))
return null;
}
-
}