X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FMediaTransformOutput.php;h=5366c4fa442e2a54ad3a8808d70f2439ab393292;hb=e758226c91935a1df2b6fd3ed1f18922d8bfb45b;hp=b3a555aa5c93380eaef3e7d7298bdd5e9310859a;hpb=b3597ac6b2674a60cc1cf655b4ca7879ee37e977;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index b3a555aa5c..5366c4fa44 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -439,19 +439,12 @@ class ThumbnailImage extends MediaTransformOutput { * @ingroup Media */ class MediaTransformError extends MediaTransformOutput { - /** @var string HTML formatted version of the error */ - private $htmlMsg; - - /** @var string Plain text formatted version of the error */ - private $textMsg; + /** @var Message */ + private $msg; function __construct( $msg, $width, $height /*, ... */ ) { $args = array_slice( func_get_args(), 3 ); - $htmlArgs = array_map( 'htmlspecialchars', $args ); - $htmlArgs = array_map( 'nl2br', $htmlArgs ); - - $this->htmlMsg = wfMessage( $msg )->rawParams( $htmlArgs )->escaped(); - $this->textMsg = wfMessage( $msg )->rawParams( $htmlArgs )->text(); + $this->msg = wfMessage( $msg )->params( $args ); $this->width = intval( $width ); $this->height = intval( $height ); $this->url = false; @@ -461,21 +454,29 @@ class MediaTransformError extends MediaTransformOutput { function toHtml( $options = [] ) { return "
width}px; height: {$this->height}px; display:inline-block;\">" . - $this->htmlMsg . + $this->getHtmlMsg() . "
"; } function toText() { - return $this->textMsg; + return $this->msg->text(); } function getHtmlMsg() { - return $this->htmlMsg; + return $this->msg->escaped(); + } + + function getMsg() { + return $this->msg; } function isError() { return true; } + + function getHttpStatusCode() { + return 500; + } } /** @@ -488,7 +489,12 @@ class TransformParameterError extends MediaTransformError { parent::__construct( 'thumbnail_error', max( isset( $params['width'] ) ? $params['width'] : 0, 120 ), max( isset( $params['height'] ) ? $params['height'] : 0, 120 ), - wfMessage( 'thumbnail_invalid_params' )->text() ); + wfMessage( 'thumbnail_invalid_params' ) + ); + } + + function getHttpStatusCode() { + return 400; } } @@ -501,14 +507,18 @@ class TransformParameterError extends MediaTransformError { class TransformTooBigImageAreaError extends MediaTransformError { function __construct( $params, $maxImageArea ) { $msg = wfMessage( 'thumbnail_toobigimagearea' ); + $msg->rawParams( + $msg->getLanguage()->formatComputingNumbers( $maxImageArea, 1000, "size-$1pixel" ) + ); parent::__construct( 'thumbnail_error', max( isset( $params['width'] ) ? $params['width'] : 0, 120 ), max( isset( $params['height'] ) ? $params['height'] : 0, 120 ), - $msg->rawParams( - $msg->getLanguage()->formatComputingNumbers( - $maxImageArea, 1000, "size-$1pixel" ) - )->text() - ); + $msg + ); + } + + function getHttpStatusCode() { + return 400; } }