]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelinepublic.php
Merge branch 'master' into 0.9.x
[quix0rs-gnu-social.git] / actions / apitimelinepublic.php
index 30f9f4cda6735ac6dbf5899156d1d08d819e9b48..353973b6533a9d76fe25008a773db90dbb716272 100644 (file)
@@ -29,6 +29,7 @@
  * @author    Robin Millette <robin@millette.info>
  * @author    Zach Copley <zach@status.net>
  * @copyright 2009 StatusNet, Inc.
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
@@ -143,10 +144,8 @@ require_once INSTALLDIR . '/lib/apiprivateauth.php';
     </statuses>
 @endverbatim
 */
-
 class ApiTimelinePublicAction extends ApiPrivateAuthAction
 {
-
     var $notices = null;
 
     /**
@@ -157,7 +156,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      * @return boolean success flag
      *
      */
-
     function prepare($args)
     {
         parent::prepare($args);
@@ -176,7 +174,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      *
      * @return void
      */
-
     function handle($args)
     {
         parent::handle($args);
@@ -188,16 +185,17 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      *
      * @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) {
@@ -219,7 +217,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
 
             header('Content-Type: application/atom+xml; charset=utf-8');
 
-            $atom = new AtomNoticeFeed();
+            $atom = new AtomNoticeFeed($this->auth_user);
 
             $atom->setId($id);
             $atom->setTitle($title);
@@ -236,7 +234,16 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
         case 'json':
             $this->showJsonTimeline($this->notices);
             break;
+        case 'as':
+            header('Content-Type: application/json; charset=utf-8');
+            $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 trying to handle an unknown API method.
             $this->clientError(_('API method not found.'), $code = 404);
             break;
         }
@@ -247,7 +254,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      *
      * @return array notices
      */
-
     function getNotices()
     {
         $notices = array();
@@ -271,7 +277,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      *
      * @return boolean true
      */
-
     function isReadOnly($args)
     {
         return true;
@@ -282,7 +287,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      *
      * @return string datestamp of the latest notice in the stream
      */
-
     function lastModified()
     {
         if (!empty($this->notices) && (count($this->notices) > 0)) {
@@ -300,7 +304,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      *
      * @return string etag
      */
-
     function etag()
     {
         if (!empty($this->notices) && (count($this->notices) > 0)) {
@@ -310,6 +313,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
             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))
@@ -319,5 +323,4 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
 
         return null;
     }
-
 }