]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/apiaction.php
Merge remote branch 'gitorious/0.9.x' into 0.9.x
[quix0rs-gnu-social.git] / lib / apiaction.php
index 0074b7dc535b834c40d24918b23eb8be92e8c775..afba8ab634b9f0009e5ea0ef7c7fdfb73f56ea7a 100644 (file)
@@ -462,7 +462,6 @@ class ApiAction extends Action
         $entry = array();
 
         if (Event::handle('StartRssEntryArray', array($notice, &$entry))) {
-
             $profile = $notice->getProfile();
 
             // We trim() to avoid extraneous whitespace in the output
@@ -552,7 +551,6 @@ class ApiAction extends Action
         $notifications = false;
 
         if ($source->isSubscribed($target)) {
-
             $sub = Subscription::pkeyGet(array('subscriber' =>
                 $source->id, 'subscribed' => $target->id));
 
@@ -738,7 +736,6 @@ class ApiAction extends Action
 
     function showXmlTimeline($notice)
     {
-
         $this->initDocument('xml');
         $this->elementStart('statuses', array('type' => 'array',
                                               'xmlns:statusnet' => 'http://status.net/schema/api/1/'));
@@ -763,7 +760,6 @@ class ApiAction extends Action
 
     function showRssTimeline($notice, $title, $link, $subtitle, $suplink = null, $logo = null, $self = null)
     {
-
         $this->initDocument('rss');
 
         $this->element('title', null, $title);
@@ -819,7 +815,6 @@ class ApiAction extends Action
 
     function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null, $logo=null)
     {
-
         $this->initDocument('atom');
 
         $this->element('title', null, $title);
@@ -863,7 +858,6 @@ class ApiAction extends Action
 
     function showRssGroups($group, $title, $link, $subtitle)
     {
-
         $this->initDocument('rss');
 
         $this->element('title', null, $title);
@@ -1250,23 +1244,29 @@ class ApiAction extends Action
 
         // Do not emit error header for JSONP
         if (!isset($this->callback)) {
-            header('HTTP/1.1 '.$code.' '.$status_string);
+            header('HTTP/1.1 ' . $code . ' ' . $status_string);
         }
 
-        if ($format == 'xml') {
+        switch($format) {
+        case 'xml':
             $this->initDocument('xml');
             $this->elementStart('hash');
             $this->element('error', null, $msg);
             $this->element('request', null, $_SERVER['REQUEST_URI']);
             $this->elementEnd('hash');
             $this->endDocument('xml');
-        } elseif ($format == 'json'){
+            break;
+        case 'json':
             $this->initDocument('json');
             $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
             print(json_encode($error_array));
             $this->endDocument('json');
-        } else {
-
+            break;
+        case 'text':
+            header('Content-Type: text/plain; charset=utf-8');
+            print $msg;
+            break;
+        default:
             // If user didn't request a useful format, throw a regular client error
             throw new ClientException($msg, $code);
         }
@@ -1362,7 +1362,6 @@ class ApiAction extends Action
     function getTargetUser($id)
     {
         if (empty($id)) {
-
             // Twitter supports these other ways of passing the user ID
             if (is_numeric($this->arg('id'))) {
                 return User::staticGet($this->arg('id'));