2019-03-30 11:16:51 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Base class for the output of file transformation methods.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Media
|
|
|
|
|
*/
|
|
|
|
|
|
2024-06-16 18:23:55 +00:00
|
|
|
use MediaWiki\Message\Message;
|
|
|
|
|
|
2019-03-30 11:16:51 +00:00
|
|
|
/**
|
|
|
|
|
* Basic media transform error class
|
|
|
|
|
*
|
2020-06-29 12:13:29 +00:00
|
|
|
* @newable
|
2020-07-13 09:00:30 +00:00
|
|
|
* @stable to extend
|
2019-03-30 11:16:51 +00:00
|
|
|
* @ingroup Media
|
|
|
|
|
*/
|
|
|
|
|
class MediaTransformError extends MediaTransformOutput {
|
|
|
|
|
/** @var Message */
|
|
|
|
|
private $msg;
|
|
|
|
|
|
2020-06-29 12:13:29 +00:00
|
|
|
/**
|
2020-07-13 08:53:06 +00:00
|
|
|
* @stable to call
|
2020-06-29 12:13:29 +00:00
|
|
|
*
|
|
|
|
|
* @param string $msg
|
|
|
|
|
* @param int $width
|
|
|
|
|
* @param int $height
|
|
|
|
|
* @param mixed ...$args
|
|
|
|
|
*/
|
2020-05-16 21:42:24 +00:00
|
|
|
public function __construct( $msg, $width, $height, ...$args ) {
|
2019-03-30 11:16:51 +00:00
|
|
|
$this->msg = wfMessage( $msg )->params( $args );
|
2023-03-08 20:44:20 +00:00
|
|
|
$this->width = (int)$width;
|
|
|
|
|
$this->height = (int)$height;
|
2019-03-30 11:16:51 +00:00
|
|
|
$this->url = false;
|
|
|
|
|
$this->path = false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 23:57:36 +00:00
|
|
|
public function toHtml( $options = [] ) {
|
2019-03-30 11:16:51 +00:00
|
|
|
return "<div class=\"MediaTransformError\" style=\"" .
|
|
|
|
|
"width: {$this->width}px; height: {$this->height}px; display:inline-block;\">" .
|
|
|
|
|
$this->getHtmlMsg() .
|
|
|
|
|
"</div>";
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 23:57:36 +00:00
|
|
|
public function toText() {
|
2019-03-30 11:16:51 +00:00
|
|
|
return $this->msg->text();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 23:57:36 +00:00
|
|
|
public function getHtmlMsg() {
|
2019-03-30 11:16:51 +00:00
|
|
|
return $this->msg->escaped();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 23:57:36 +00:00
|
|
|
public function getMsg() {
|
2019-03-30 11:16:51 +00:00
|
|
|
return $this->msg;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 23:57:36 +00:00
|
|
|
public function isError() {
|
2019-03-30 11:16:51 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-10 12:58:33 +00:00
|
|
|
/**
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2020-07-10 12:58:33 +00:00
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2020-05-17 23:57:36 +00:00
|
|
|
public function getHttpStatusCode() {
|
2019-03-30 11:16:51 +00:00
|
|
|
return 500;
|
|
|
|
|
}
|
|
|
|
|
}
|