X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapimediaupload.php;h=b4f8709fe23071d82b283c36b1f90f9ee602c395;hb=33e2f5b449d477e55bda7029f9e826d889e41eb5;hp=7aa88c186bcc58c3592393e6d90bda8f7596feaf;hpb=338aa4bf1d36e11a354c67796509c6d1fec2aac2;p=quix0rs-gnu-social.git diff --git a/actions/apimediaupload.php b/actions/apimediaupload.php index 7aa88c186b..b4f8709fe2 100644 --- a/actions/apimediaupload.php +++ b/actions/apimediaupload.php @@ -30,9 +30,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiauth.php'; -require_once INSTALLDIR . '/lib/mediafile.php'; - /** * Upload an image via the API. Returns a shortened URL for the image * to the user. @@ -43,7 +40,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 +53,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 +73,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; } @@ -87,7 +85,7 @@ class ApiMediaUploadAction extends ApiAuthAction $upload = null; try { - $upload = MediaFile::fromUpload('media', $this->auth_user); + $upload = MediaFile::fromUpload('media', $this->auth_user->getProfile()); } catch (Exception $e) { $this->clientError($e->getMessage(), $e->getCode()); return; @@ -96,6 +94,7 @@ class ApiMediaUploadAction extends ApiAuthAction if (isset($upload)) { $this->showResponse($upload); } else { + // TRANS: Client error displayed when uploading a media file has failed. $this->clientError(_('Upload failed.')); return; } @@ -123,7 +122,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 +135,4 @@ class ApiMediaUploadAction extends ApiAuthAction $this->elementEnd('rsp'); $this->endDocument(); } - }