]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
show a single notice in atom entry format
authorEvan Prodromou <evan@status.net>
Sun, 24 Oct 2010 19:58:53 +0000 (15:58 -0400)
committerEvan Prodromou <evan@status.net>
Sun, 24 Oct 2010 19:58:53 +0000 (15:58 -0400)
actions/apistatusesshow.php
lib/apiaction.php
lib/router.php

index 84f8079db553a906367d6d2e0dff542cf9e16315..c0eab15a440c519712a4237dea125c6519d2606f 100644 (file)
@@ -105,8 +105,8 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
     {
         parent::handle($args);
 
-        if (!in_array($this->format, array('xml', 'json'))) {
-            $this->clientError(_('API method not found.'), $code = 404);
+        if (!in_array($this->format, array('xml', 'json', 'atom'))) {
+            $this->clientError(_('API method not found.'), 404);
             return;
         }
 
@@ -122,10 +122,18 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
     function showNotice()
     {
         if (!empty($this->notice)) {
-            if ($this->format == 'xml') {
+            switch ($this->format) {
+            case 'xml':
                 $this->showSingleXmlStatus($this->notice);
-            } elseif ($this->format == 'json') {
+                break;
+            case 'json':
                 $this->show_single_json_status($this->notice);
+                break;
+            case 'atom':
+                $this->showSingleAtomStatus($this->notice);
+                break;
+            default:
+                throw new Exception(sprintf(_("Unsupported format: %s"), $this->format));
             }
         } else {
 
index 4e9dbb310bcfc4e10253c5b39e59840ba009eae3..8a7be31502f29e89ca02f5370a22b4d89f0351ac 100644 (file)
@@ -726,6 +726,12 @@ class ApiAction extends Action
         $this->endDocument('xml');
     }
 
+    function showSingleAtomStatus($notice)
+    {
+        header('Content-Type: application/atom+xml; charset=utf-8');
+        print $notice->asAtomEntry(true, true, true, $this->auth_user);
+    }
+
     function show_single_json_status($notice)
     {
         $this->initDocument('json');
index 9aaac7dfe39cb8cbc051ed264868a545b3e8fb0f..834445f09b688d659f2ffd48f77561a71d28fe03 100644 (file)
@@ -399,12 +399,12 @@ class Router
 
             $m->connect('api/statuses/show.:format',
                         array('action' => 'ApiStatusesShow',
-                              'format' => '(xml|json)'));
+                              'format' => '(xml|json|atom)'));
 
             $m->connect('api/statuses/show/:id.:format',
                         array('action' => 'ApiStatusesShow',
                               'id' => '[0-9]+',
-                              'format' => '(xml|json)'));
+                              'format' => '(xml|json|atom)'));
 
             $m->connect('api/statuses/update.:format',
                         array('action' => 'ApiStatusesUpdate',