MediaTransformError.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Base class for the output of file transformation methods.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. * @ingroup Media
  22. */
  23. /**
  24. * Basic media transform error class
  25. *
  26. * @ingroup Media
  27. */
  28. class MediaTransformError extends MediaTransformOutput {
  29. /** @var Message */
  30. private $msg;
  31. function __construct( $msg, $width, $height, ...$args ) {
  32. $this->msg = wfMessage( $msg )->params( $args );
  33. $this->width = intval( $width );
  34. $this->height = intval( $height );
  35. $this->url = false;
  36. $this->path = false;
  37. }
  38. function toHtml( $options = [] ) {
  39. return "<div class=\"MediaTransformError\" style=\"" .
  40. "width: {$this->width}px; height: {$this->height}px; display:inline-block;\">" .
  41. $this->getHtmlMsg() .
  42. "</div>";
  43. }
  44. function toText() {
  45. return $this->msg->text();
  46. }
  47. function getHtmlMsg() {
  48. return $this->msg->escaped();
  49. }
  50. function getMsg() {
  51. return $this->msg;
  52. }
  53. function isError() {
  54. return true;
  55. }
  56. function getHttpStatusCode() {
  57. return 500;
  58. }
  59. }