/** @var bool|string */
protected $page;
- /** @var bool|string Filesystem path to the thumb */
+ /** @var bool|string Filesystem path to the thumb */
protected $path;
/** @var bool|string Language code, false if not set */
protected $lang;
- /** @var bool|string Permanent storage path */
+ /** @var bool|string Permanent storage path */
protected $storagePath = false;
/**
}
/**
- * @param string $title
+ * @param string|null $title
* @param string|array $params Query parameters to add
* @return array
*/
throw new MWException( __METHOD__ . ' called in the old style' );
}
- $alt = isset( $options['alt'] ) ? $options['alt'] : '';
+ $alt = $options['alt'] ?? '';
- $query = isset( $options['desc-query'] ) ? $options['desc-query'] : '';
+ $query = $options['desc-query'] ?? '';
$attribs = [
'alt' => $alt,
* @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;
function toHtml( $options = [] ) {
return "<div class=\"MediaTransformError\" style=\"" .
"width: {$this->width}px; height: {$this->height}px; display:inline-block;\">" .
- $this->htmlMsg .
+ $this->getHtmlMsg() .
"</div>";
}
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() {
class TransformParameterError extends MediaTransformError {
function __construct( $params ) {
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() );
+ max( $params['width'] ?? 0, 120 ),
+ max( $params['height'] ?? 0, 120 ),
+ wfMessage( 'thumbnail_invalid_params' )
+ );
}
function getHttpStatusCode() {
class TransformTooBigImageAreaError extends MediaTransformError {
function __construct( $params, $maxImageArea ) {
$msg = wfMessage( 'thumbnail_toobigimagearea' );
+ $msg->params(
+ $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()
- );
+ max( $params['width'] ?? 0, 120 ),
+ max( $params['height'] ?? 0, 120 ),
+ $msg
+ );
}
function getHttpStatusCode() {