Go to the documentation of this file.
48 $this->mExists = $exists;
59 $data =
$repo->fetchImageQuery( [
62 'prop' =>
'imageinfo',
66 'iiextmetadatamultilang' => 1,
69 $info =
$repo->getImageInfo( $data );
72 $lastRedirect = isset( $data[
'query'][
'redirects'] )
73 ?
count( $data[
'query'][
'redirects'] ) - 1
75 if ( $lastRedirect >= 0 ) {
77 $img =
new self( $newtitle,
$repo, $info,
true );
96 return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype|extmetadata';
132 $thumbUrl = $this->repo->getThumbUrlFromCache(
138 if ( $thumbUrl ===
false ) {
141 return $this->repo->getThumbError(
150 return $this->
handler->getTransform( $this,
'bogus', $thumbUrl,
$params );
160 return isset( $this->mInfo[
'width'] ) ? intval( $this->mInfo[
'width'] ) : 0;
168 return isset( $this->mInfo[
'height'] ) ? intval( $this->mInfo[
'height'] ) : 0;
175 if ( isset( $this->mInfo[
'metadata'] ) ) {
176 return serialize( self::parseMetadata( $this->mInfo[
'metadata'] ) );
187 if ( isset( $this->mInfo[
'extmetadata'] ) ) {
188 return $this->mInfo[
'extmetadata'];
199 if ( !is_array( $metadata ) ) {
203 foreach ( $metadata
as $meta ) {
214 return isset( $this->mInfo[
'size'] ) ? intval( $this->mInfo[
'size'] ) :
null;
221 return isset( $this->mInfo[
'url'] ) ? strval( $this->mInfo[
'url'] ) :
null;
232 if ( isset( $this->mInfo[
'descriptionshorturl'] ) ) {
233 return $this->mInfo[
'descriptionshorturl'];
234 } elseif ( isset( $this->mInfo[
'pageid'] ) ) {
235 $url = $this->repo->makeUrl( [
'curid' => $this->mInfo[
'pageid'] ] );
236 if (
$url !==
false ) {
248 if (
$type ==
'text' ) {
249 return isset( $this->mInfo[
'user'] ) ? strval( $this->mInfo[
'user'] ) :
null;
261 return isset( $this->mInfo[
'comment'] ) ? strval( $this->mInfo[
'comment'] ) :
null;
268 return isset( $this->mInfo[
'sha1'] )
269 ? Wikimedia\base_convert( strval( $this->mInfo[
'sha1'] ), 16, 36, 31 )
278 isset( $this->mInfo[
'timestamp'] )
279 ? strval( $this->mInfo[
'timestamp'] )
288 if ( !isset( $this->mInfo[
'mime'] ) ) {
290 $this->mInfo[
'mime'] = $magic->guessTypesForExtension( $this->
getExtension() );
293 return $this->mInfo[
'mime'];
300 if ( isset( $this->mInfo[
'mediatype'] ) ) {
301 return $this->mInfo[
'mediatype'];
305 return $magic->getMediaType(
null, $this->
getMimeType() );
312 return isset( $this->mInfo[
'descriptionurl'] )
313 ? $this->mInfo[
'descriptionurl']
323 if ( $this->repo->canCacheThumbs() ) {
340 $iter = $this->repo->getBackend()->getFileList( [
'dir' =>
$dir ] );
343 foreach ( $iter
as $file ) {
358 $url = $this->repo->getDescriptionRenderUrl( $this->
getName(), $wgContLang->getCode() );
359 $key = $this->repo->getLocalCacheKey(
'RemoteFileDescription',
'url', md5(
$url ) );
368 $key = $this->repo->getLocalCacheKey(
'ForeignAPIRepo',
'ThumbUrl', $this->
getName() );
380 foreach ( $files
as $file ) {
381 $purgeList[] =
"{$dir}{$file}";
384 # Delete the thumbnails
385 $this->repo->quickPurgeBatch( $purgeList );
386 # Clear out the thumbnail directory if empty
387 $this->repo->quickCleanDir(
$dir );
getExtension()
Get the file extension, e.g.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
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.
isTransformedLocally()
The thumbnail is created on the foreign server and fetched over internet.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
string $path
The storage path corresponding to one of the zones.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves set to a MediaTransformOutput the error message to be returned in an array you should do so by altering $wgNamespaceProtection and $wgNamespaceContentModels outside the handler
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)
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
when a variable name is used in a it is silently declared as a new masking the global
static singleton()
Get an instance of this class.
getDescription( $audience=self::FOR_PUBLIC, User $user=null)
canRender()
Checks if the output of transform() for this file is likely to be valid.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
getName()
Return the name of this file.
transform( $params, $flags=0)
purgeThumbnails( $options=[])
Represents a title within MediaWiki.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
static getMainWANInstance()
Get the main WAN cache object.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static parseMetadata( $metadata)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
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.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
the array() calling protocol came about after MediaWiki 1.4rc1.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang