47 parent::__construct( $title,
$repo );
62 'titles' =>
'File:' . $title->getDBkey(),
63 'iiprop' => self::getProps(),
64 'prop' =>
'imageinfo',
68 'iiextmetadatamultilang' => 1,
74 $lastRedirect =
isset(
$data[
'query'][
'redirects'] )
75 ? count(
$data[
'query'][
'redirects'] ) - 1
77 if ( $lastRedirect >= 0 ) {
78 $newtitle = Title::newFromText(
$data[
'query'][
'redirects'][$lastRedirect][
'to'] );
80 $img->redirectedFrom( $title->getDBkey() );
96 return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype|extmetadata';
123 return parent::transform(
$params, $flags );
129 $width =
$params[
'width'] ?? -1;
130 $height =
$params[
'height'] ?? -1;
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 return $this->mInfo[
'extmetadata'] ??
null;
199 foreach ( $metadata as $meta ) {
210 return isset( $this->mInfo[
'size'] ) ?
intval( $this->mInfo[
'size'] ) :
null;
217 return isset( $this->mInfo[
'url'] ) ?
strval( $this->mInfo[
'url'] ) :
null;
228 if (
isset( $this->mInfo[
'descriptionshorturl'] ) ) {
229 return $this->mInfo[
'descriptionshorturl'];
231 $url = $this->repo->makeUrl( [
'curid' => $this->mInfo[
'pageid'] ] );
232 if (
$url !==
false ) {
244 if (
$type ==
'text' ) {
245 return isset( $this->mInfo[
'user'] ) ?
strval( $this->mInfo[
'user'] ) :
null;
257 return isset( $this->mInfo[
'comment'] ) ?
strval( $this->mInfo[
'comment'] ) :
null;
264 return isset( $this->mInfo[
'sha1'] )
274 isset( $this->mInfo[
'timestamp'] )
275 ?
strval( $this->mInfo[
'timestamp'] )
284 if ( !
isset( $this->mInfo[
'mime'] ) ) {
285 $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
286 $this->mInfo[
'mime'] = $magic->guessTypesForExtension( $this->
getExtension() );
289 return $this->mInfo[
'mime'];
296 if (
isset( $this->mInfo[
'mediatype'] ) ) {
297 return $this->mInfo[
'mediatype'];
299 $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
301 return $magic->getMediaType(
null, $this->
getMimeType() );
308 return $this->mInfo[
'descriptionurl'] ??
false;
317 if ( !$this->repo->canCacheThumbs() ) {
321 $path = $this->repo->getZonePath(
'thumb' ) .
'/' . $this->
getHashPath();
323 $path .= $suffix .
'/';
333 $iter = $this->repo->getBackend()->getFileList( [
'dir' => $dir ] );
337 foreach ( $iter as $file ) {
351 $services = MediaWikiServices::getInstance();
352 $url = $this->repo->getDescriptionRenderUrl(
354 $key = $this->repo->getLocalCacheKey(
'RemoteFileDescription',
'url',
md5(
$url ) );
356 $services->getMainWANObjectCache()->delete( $key );
363 $key = $this->repo->getLocalCacheKey(
'ForeignAPIRepo',
'ThumbUrl', $this->
getName() );
364 MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
375 foreach ( $files as $file ) {
376 $purgeList[] =
"{$dir}{$file}";
379 # Delete the thumbnails
380 $this->repo->quickPurgeBatch( $purgeList );
381 # Clear out the thumbnail directory if empty
382 $this->repo->quickCleanDir( $dir );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Implements some public methods and some protected utility functions which are required by multiple ch...
string $url
The URL corresponding to one of the four basic zones.
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
getName()
Return the name of this file.
canRender()
Checks if the output of transform() for this file is likely to be valid.
getExtension()
Get the file extension, e.g.
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
string $path
The storage path corresponding to one of the zones.
getHandler()
Get a MediaHandler instance for this file.
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
Foreign file accessible through api.php requests.
getThumbPath( $suffix='')
Only useful if we're locally caching thumbs anyway...
__construct( $title, $repo, $info, $exists=false)
purgeCache( $options=[])
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
isTransformedLocally()
The thumbnail is created on the foreign server and fetched over internet.
static parseMetadata( $metadata)
static newFromTitle(Title $title, $repo)
purgeThumbnails( $options=[])
getDescription( $audience=self::FOR_PUBLIC, User $user=null)
transform( $params, $flags=0)
getDescriptionShortUrl()
Get short description URL for a file based on the foreign API response, or if unavailable,...
static getProps()
Get the property string for iiprop and aiprop.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
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 configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
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
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file