]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apimediaupload.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into inline-comments
[quix0rs-gnu-social.git] / actions / apimediaupload.php
index ec316edc8d78b1c50d5573db9a10bad8ac9707d0..0b08dbedf1bc1dec517b0e8e26307ca1e9e4d280 100644 (file)
@@ -43,7 +43,6 @@ require_once INSTALLDIR . '/lib/mediafile.php';
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-
 class ApiMediaUploadAction extends ApiAuthAction
 {
     /**
@@ -57,13 +56,13 @@ class ApiMediaUploadAction extends ApiAuthAction
      *
      * @return void
      */
-
     function handle($args)
     {
         parent::handle($args);
 
         if ($_SERVER['REQUEST_METHOD'] != 'POST') {
             $this->clientError(
+                // TRANS: Client error. POST is a HTTP command. It should not be translated.
                 _('This method requires a POST.'),
                 400, $this->format
             );
@@ -77,9 +76,11 @@ class ApiMediaUploadAction extends ApiAuthAction
             && empty($_POST)
             && ($_SERVER['CONTENT_LENGTH'] > 0)
         ) {
-             $msg = _('The server was unable to handle that much POST ' .
-                    'data (%s bytes) due to its current configuration.');
-
+            // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
+            // TRANS: %s is the number of bytes of the CONTENT_LENGTH.
+            $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.',
+                      'The server was unable to handle that much POST data (%s bytes) due to its current configuration.',
+                      intval($_SERVER['CONTENT_LENGTH']));
             $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
             return;
         }
@@ -88,15 +89,16 @@ class ApiMediaUploadAction extends ApiAuthAction
 
         try {
             $upload = MediaFile::fromUpload('media', $this->auth_user);
-        } catch (ClientException $ce) {
-            $this->clientError($ce->getMessage());
+        } catch (Exception $e) {
+            $this->clientError($e->getMessage(), $e->getCode());
             return;
         }
 
         if (isset($upload)) {
             $this->showResponse($upload);
         } else {
-            $this->clientError('Upload failed.');
+            // TRANS: Client error displayed when uploading a media file has failed.
+            $this->clientError(_('Upload failed.'));
             return;
         }
     }
@@ -123,7 +125,6 @@ class ApiMediaUploadAction extends ApiAuthAction
      * Overrided clientError to show a more Twitpic-like error
      *
      * @param String $msg an error message
-     *
      */
     function clientError($msg)
     {
@@ -137,5 +138,4 @@ class ApiMediaUploadAction extends ApiAuthAction
         $this->elementEnd('rsp');
         $this->endDocument();
     }
-
 }