Go to the documentation of this file.
50 $this->mExists = $exists;
61 $data =
$repo->fetchImageQuery( [
64 'prop' =>
'imageinfo',
68 'iiextmetadatamultilang' => 1,
71 $info =
$repo->getImageInfo( $data );
74 $lastRedirect = isset( $data[
'query'][
'redirects'] )
75 ? count( $data[
'query'][
'redirects'] ) - 1
77 if ( $lastRedirect >= 0 ) {
80 $img =
new self( $newtitle,
$repo, $info,
true );
97 return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype|extmetadata';
124 return parent::transform( $params, $flags );
129 $otherParams = $this->handler->makeParamString( $params );
130 $width = $params[
'width'] ?? -1;
131 $height = $params[
'height'] ?? -1;
133 $thumbUrl = $this->repo->getThumbUrlFromCache(
139 if ( $thumbUrl ===
false ) {
142 return $this->repo->getThumbError(
151 return $this->handler->getTransform( $this,
'bogus', $thumbUrl, $params );
161 return isset( $this->mInfo[
'width'] ) ? intval( $this->mInfo[
'width'] ) : 0;
169 return isset( $this->mInfo[
'height'] ) ? intval( $this->mInfo[
'height'] ) : 0;
176 if ( isset( $this->mInfo[
'metadata'] ) ) {
177 return serialize( self::parseMetadata( $this->mInfo[
'metadata'] ) );
188 return $this->mInfo[
'extmetadata'] ??
null;
196 if ( !is_array( $metadata ) ) {
200 foreach ( $metadata as $meta ) {
211 return isset( $this->mInfo[
'size'] ) ? intval( $this->mInfo[
'size'] ) :
null;
218 return isset( $this->mInfo[
'url'] ) ? strval( $this->mInfo[
'url'] ) :
null;
229 if ( isset( $this->mInfo[
'descriptionshorturl'] ) ) {
230 return $this->mInfo[
'descriptionshorturl'];
231 } elseif ( isset( $this->mInfo[
'pageid'] ) ) {
232 $url = $this->repo->makeUrl( [
'curid' => $this->mInfo[
'pageid'] ] );
233 if (
$url !==
false ) {
245 if (
$type ==
'text' ) {
246 return isset( $this->mInfo[
'user'] ) ? strval( $this->mInfo[
'user'] ) :
null;
258 return isset( $this->mInfo[
'comment'] ) ? strval( $this->mInfo[
'comment'] ) :
null;
265 return isset( $this->mInfo[
'sha1'] )
266 ? Wikimedia\base_convert( strval( $this->mInfo[
'sha1'] ), 16, 36, 31 )
275 isset( $this->mInfo[
'timestamp'] )
276 ? strval( $this->mInfo[
'timestamp'] )
285 if ( !isset( $this->mInfo[
'mime'] ) ) {
287 $this->mInfo[
'mime'] = $magic->guessTypesForExtension( $this->
getExtension() );
290 return $this->mInfo[
'mime'];
297 if ( isset( $this->mInfo[
'mediatype'] ) ) {
298 return $this->mInfo[
'mediatype'];
302 return $magic->getMediaType(
null, $this->
getMimeType() );
309 return $this->mInfo[
'descriptionurl'] ??
false;
318 if ( !$this->repo->canCacheThumbs() ) {
324 $path .= $suffix .
'/';
334 $iter = $this->repo->getBackend()->getFileList( [
'dir' => $dir ] );
338 foreach ( $iter as
$file ) {
352 $services = MediaWikiServices::getInstance();
353 $url = $this->repo->getDescriptionRenderUrl(
354 $this->
getName(), $services->getContentLanguage()->getCode() );
355 $key = $this->repo->getLocalCacheKey(
'RemoteFileDescription',
'url', md5(
$url ) );
357 $services->getMainWANObjectCache()->delete( $key );
364 $key = $this->repo->getLocalCacheKey(
'ForeignAPIRepo',
'ThumbUrl', $this->
getName() );
365 MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
376 foreach ( $files as
$file ) {
377 $purgeList[] =
"{$dir}{$file}";
380 # Delete the thumbnails
381 $this->repo->quickPurgeBatch( $purgeList );
382 # Clear out the thumbnail directory if empty
383 $this->repo->quickCleanDir( $dir );
getExtension()
Get the file extension, e.g.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
getThumbPath( $suffix='')
Only useful if we're locally caching thumbs anyway...
static newFromTitle(Title $title, $repo)
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
isTransformedLocally()
The thumbnail is created on the foreign server and fetched over internet.
string $path
The storage path corresponding to one of the zones.
Implements some public methods and some protected utility functions which are required by multiple ch...
getDBkey()
Get the main part with underscores.
purgeCache( $options=[])
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
string $url
The URL corresponding to one of the four basic zones.
getDescriptionShortUrl()
Get short description URL for a file based on the foreign API response, or if unavailable,...
__construct( $title, $repo, $info, $exists=false)
getDescription( $audience=self::FOR_PUBLIC, User $user=null)
canRender()
Checks if the output of transform() for this file is likely to be valid.
getName()
Return the name of this file.
transform( $params, $flags=0)
purgeThumbnails( $options=[])
Represents a title within MediaWiki.
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
static parseMetadata( $metadata)
static getProps()
Get the property string for iiprop and aiprop.
getHandler()
Get a MediaHandler instance for this file.
Foreign file accessible through api.php requests.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.