Go to the documentation of this file.
54 return MediaWikiServices::getInstance()
55 ->getMediaHandlerFactory()->getHandler(
$type );
155 return implode(
';', $version );
170 if ( !is_array( $metadata ) ) {
172 Wikimedia\suppressWarnings();
174 Wikimedia\restoreWarnings();
285 final public function getTransform( $image, $dstPath, $dstUrl, $params ) {
286 return $this->
doTransform( $image, $dstPath, $dstUrl, $params, self::TRANSFORM_LATER );
303 abstract public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 );
317 if ( !
$ext || $magic->isMatchingExtension(
$ext,
$mime ) ===
false ) {
320 $knownExt = $magic->getExtensionFromMimeTypeOrNull(
$mime );
321 if ( $knownExt !==
null ) {
322 return [ $knownExt,
$mime ];
479 $numPages =
$file->pageCount();
485 for ( $i = 1; $i <= $numPages; $i++ ) {
487 if ( is_string( $curPage ) ) {
488 $document .= $curPage .
"\n";
491 if ( $document !==
'' ) {
550 foreach ( $metadataArray as $tag => $vals ) {
551 $v = $this->
formatTag( $tag, $vals, $context );
552 if ( $v ===
false ) {
555 } elseif ( $v ===
null ) {
557 unset( $metadataArray[$tag] );
560 $metadataArray[$tag] = [
'_formatted' => $v ];
561 if ( isset( $v[
'_type'] ) ) {
562 $metadataArray[$tag][
'_type'] = $v[
'_type'];
563 unset( $metadataArray[$tag][
'_formatted'][
'_type'] );
571 foreach ( $formatted as $name => $value ) {
572 $tag = strtolower( $name );
574 in_array( $tag, $visibleFields ) ?
'visible' :
'collapsed',
596 protected function formatTag(
string $key, $vals, $context =
false ) {
635 protected static function addMeta( &$array, $visibility,
$type, $id, $value, $param =
false ) {
637 if ( $msg->exists() ) {
638 $name = $msg->text();
645 wfDebug( __METHOD__ .
' Unknown metadata name: ' . $id );
648 $array[$visibility][] = [
688 return htmlspecialchars(
$wgLang->formatSize(
$file->getSize() ) );
699 ->params(
'<span class="mime-type">' .
$file->getMimeType() .
'</span>' )->parse();
710 public static function fitBoxWidth( $boxWidth, $boxHeight, $maxHeight ) {
711 $idealWidth = $boxWidth * $maxHeight / $boxHeight;
712 $roundedUp = ceil( $idealWidth );
713 if ( round( $roundedUp * $boxHeight / $boxWidth ) > $maxHeight ) {
714 return floor( $idealWidth );
774 if ( file_exists( $dstPath ) ) {
775 $thumbstat = stat( $dstPath );
776 if ( $thumbstat[
'size'] == 0 || $retval != 0 ) {
777 $result = unlink( $dstPath );
781 sprintf(
'Removing bad %d-byte thumbnail "%s". unlink() succeeded',
782 $thumbstat[
'size'], $dstPath ) );
785 sprintf(
'Removing bad %d-byte thumbnail "%s". unlink() failed',
786 $thumbstat[
'size'], $dstPath ) );
857 # Keep error output limited (T59985)
858 $errMessage = trim( substr( $err, 0, self::MAX_ERR_LOG_SIZE ) );
861 sprintf(
'thumbnail failed on %s: error %d "%s" from "%s"',
1000 $pageRangesByDimensions = [];
1002 foreach ( $pagesByDimensions as $dimensions => $pageList ) {
1004 $firstPage = $pageList[0];
1005 $lastPage = $firstPage - 1;
1007 foreach ( $pageList as $page ) {
1008 if ( $page > $lastPage + 1 ) {
1009 if ( $firstPage != $lastPage ) {
1010 $ranges[] =
"$firstPage-$lastPage";
1012 $ranges[] =
"$firstPage";
1021 if ( $firstPage != $lastPage ) {
1022 $ranges[] =
"$firstPage-$lastPage";
1024 $ranges[] =
"$firstPage";
1027 $pageRangesByDimensions[ $dimensions ] = $ranges;
1030 $dimensionsString = [];
1031 foreach ( $pageRangesByDimensions as $dimensions => $pageRanges ) {
1032 $dimensionsString[] =
"$dimensions:" . implode(
',', $pageRanges );
1035 return implode(
'/', $dimensionsString );
1047 return [
'X-Content-Dimensions' =>
'' ];
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
wfHostname()
Get host name of the current machine, for use in error reporting.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Implements some public methods and some protected utility functions which are required by multiple ch...
getLocalRefPath()
Get an FS copy or original of this file and return the path.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static newGood( $value=null)
Factory function for good results.
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
unserialize( $serialized)
if(!is_readable( $file)) $ext