Go to the documentation of this file.
73 parent::__construct( $info );
76 $this->mApiBase = isset( $info[
'apibase'] ) ? $info[
'apibase'] :
null;
78 if ( isset( $info[
'apiThumbCacheExpiry'] ) ) {
79 $this->apiThumbCacheExpiry = $info[
'apiThumbCacheExpiry'];
81 if ( isset( $info[
'fileCacheExpiry'] ) ) {
82 $this->fileCacheExpiry = $info[
'fileCacheExpiry'];
84 if ( !$this->scriptDirUrl ) {
86 $this->scriptDirUrl = dirname( $this->mApiBase );
90 $this->url = $wgLocalFileRepo[
'url'];
93 $this->thumbUrl = $this->url .
'/thumb';
102 return $this->mApiBase;
128 if ( isset( $this->mFileExists[
$f] ) ) {
129 $results[$k] = $this->mFileExists[
$f];
131 } elseif ( self::isVirtualUrl(
$f ) ) {
132 # @todo FIXME: We need to be able to handle virtual
133 # URLs better, at least when we know they refer to the
135 $results[$k] =
false;
138 $results[$k] =
false;
140 wfWarn(
"Got mwstore:// path '$f'." );
145 'titles' => implode(
$files,
'|' ),
146 'prop' =>
'imageinfo' )
149 if ( isset( $data[
'query'][
'pages'] ) ) {
150 # First, get results from the query. Note we only care whether the image exists,
151 # not whether it has a description page.
152 foreach ( $data[
'query'][
'pages']
as $p ) {
153 $this->mFileExists[$p[
'title']] = ( $p[
'imagerepository'] !==
'' );
155 # Second, copy the results to any redirects that were queried
156 if ( isset( $data[
'query'][
'redirects'] ) ) {
157 foreach ( $data[
'query'][
'redirects']
as $r ) {
158 $this->mFileExists[$r[
'from']] = $this->mFileExists[$r[
'to']];
161 # Third, copy the results to any non-normalized titles that were queried
162 if ( isset( $data[
'query'][
'normalized'] ) ) {
163 foreach ( $data[
'query'][
'normalized']
as $n ) {
164 $this->mFileExists[
$n[
'from']] = $this->mFileExists[
$n[
'to']];
167 # Finally, copy the results to the output
169 $results[$key] = $this->mFileExists[
$file];
195 'redirects' =>
'true'
198 if ( !isset(
$query[
'uselang'] ) ) {
199 $query[
'uselang'] = $wgLanguageCode;
216 if ( $data && isset( $data[
'query'][
'pages'] ) ) {
217 foreach ( $data[
'query'][
'pages']
as $info ) {
218 if ( isset( $info[
'imageinfo'][0] ) ) {
219 return $info[
'imageinfo'][0];
233 'aisha1base36' =>
$hash,
235 'list' =>
'allimages',
238 if ( isset( $results[
'query'][
'allimages'] ) ) {
239 foreach ( $results[
'query'][
'allimages']
as $img ) {
241 if ( !isset( $img[
'name'] ) ) {
262 'titles' =>
'File:' .
$name,
263 'iiprop' => self::getIIProps(),
264 'iiurlwidth' => $width,
265 'iiurlheight' => $height,
266 'iiurlparam' => $otherParams,
267 'prop' =>
'imageinfo' ) );
270 if ( $data && $info && isset( $info[
'thumburl'] ) ) {
271 wfDebug( __METHOD__ .
" got remote thumb " . $info[
'thumburl'] .
"\n" );
274 return $info[
'thumburl'];
289 function getThumbError(
$name, $width = -1, $height = -1, $otherParams =
'', $lang =
null ) {
291 'titles' =>
'File:' .
$name,
292 'iiprop' => self::getIIProps(),
293 'iiurlwidth' => $width,
294 'iiurlheight' => $height,
295 'iiurlparam' => $otherParams,
296 'prop' =>
'imageinfo',
301 if ( $data && $info && isset( $info[
'thumberror'] ) ) {
302 wfDebug( __METHOD__ .
" got remote thumb error " . $info[
'thumberror'] .
"\n" );
305 'thumbnail_error_remote',
340 $sizekey =
"$width:$height:$params";
343 $knownThumbUrls =
$wgMemc->get( $key );
344 if ( !$knownThumbUrls ) {
346 $knownThumbUrls =
array();
348 if ( isset( $knownThumbUrls[$sizekey] ) ) {
349 wfDebug( __METHOD__ .
': Got thumburl from local cache: ' .
350 "{$knownThumbUrls[$sizekey]} \n" );
352 return $knownThumbUrls[$sizekey];
360 if ( !$foreignUrl ) {
361 wfDebug( __METHOD__ .
" Could not find thumburl\n" );
367 $fileName = rawurldecode( pathinfo( $foreignUrl, PATHINFO_BASENAME ) );
369 wfDebug( __METHOD__ .
" The deduced filename $fileName is not safe\n" );
374 $localFilename = $localPath .
"/" . $fileName;
376 rawurlencode(
$name ) .
"/" . rawurlencode( $fileName );
379 && isset( $metadata[
'timestamp'] )
381 wfDebug( __METHOD__ .
" Thumbnail was already downloaded before\n" );
383 $remoteModified = strtotime( $metadata[
'timestamp'] );
385 $diff = abs( $modified - $current );
386 if ( $remoteModified < $modified && $diff < $this->fileCacheExpiry ) {
388 $knownThumbUrls[$sizekey] = $localUrl;
389 $wgMemc->set( $key, $knownThumbUrls, $this->apiThumbCacheExpiry );
397 wfDebug( __METHOD__ .
" Could not download thumb\n" );
402 # @todo FIXME: Delete old thumbs that aren't being used. Maintenance script?
404 $params =
array(
'dst' => $localFilename,
'content' => $thumb );
406 wfDebug( __METHOD__ .
" could not write to thumb path '$localFilename'\n" );
410 $knownThumbUrls[$sizekey] = $localUrl;
411 $wgMemc->set( $key, $knownThumbUrls, $this->apiThumbCacheExpiry );
412 wfDebug( __METHOD__ .
" got local thumb $localUrl, saving to cache \n" );
430 return parent::getZoneUrl( $zone,
$ext );
440 $supported =
array(
'public',
'thumb' );
441 if ( in_array( $zone, $supported ) ) {
442 return parent::getZonePath( $zone );
453 return ( $this->apiThumbCacheExpiry > 0 );
471 $info = parent::getInfo();
477 'meta' =>
'siteinfo',
478 'siprop' =>
'general',
485 $general = $siteInfo[
'query'][
'general'];
487 $info[
'articlepath'] = $general[
'articlepath'];
488 $info[
'server'] = $general[
'server'];
490 if ( isset( $general[
'favicon'] ) ) {
491 $info[
'favicon'] = $general[
'favicon'];
510 wfDebug(
"ForeignAPIRepo: HTTP GET: $url\n" );
513 if ( !isset(
$options[
'timeout'] ) ) {
519 $status = $req->execute();
521 if ( $status->isOK() ) {
522 return $req->getContent();
533 return join(
'|', self::$imageInfoProps );
544 if ( $this->mApiBase ) {
550 if ( !isset( $this->mQueryCache[
$url] ) ) {
563 $wgMemc->set( $key, $data, $cacheTTL );
566 if ( count( $this->mQueryCache ) > 100 ) {
568 $this->mQueryCache =
array();
571 $this->mQueryCache[
$url] = $data;
574 return $this->mQueryCache[
$url];
582 throw new MWException(
'enumFiles is not supported by ' . get_class( $this ) );
589 throw new MWException( get_class( $this ) .
': write operations are not supported.' );
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
int $apiThumbCacheExpiry
Check back with Commons after a day (24*60*60) *.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
see documentation in includes Linker php for Linker::makeImageLink & $time
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static getUserAgent()
The user agent the ForeignAPIRepo will use.
validateFilename( $filename)
Determine if a relative path is valid, i.e.
makeUrl( $query='', $entry='index')
Make an url to this repo.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
int $fileCacheExpiry
Redownload thumbnail files after a month (86400*30) *.
static userAgent()
A standard user-agent we can use for external requests.
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
getThumbUrlFromCache( $name, $width, $height, $params="")
Return the imageurl from cache if possible.
Base class for file repositories.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
getFileTimestamp(array $params)
Get the last-modified timestamp of the file at a storage path.
static isStoragePath( $path)
Check if a given path is a "mwstore://" path.
getFileProps( $virtualUrl)
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
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
quickCreate(array $params)
Performs a single quick create operation.
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
presenting them properly to the user as errors is done by the caller $title
Allows to change the fields on the form that will be generated $name
getDisplayName()
Get the human-readable name of the repo.
getThumbUrl( $name, $width=-1, $height=-1, &$result=null, $otherParams='')
fileExists(array $params)
Check if a file exists at a storage path in the backend.
fileExistsBatch(array $files)
prepare(array $params)
Prepare a storage directory for usage.
getBackend()
Get the file backend instance.
getLocalCacheKey()
Get a key for this repo in the local cache domain.
static $imageInfoProps
List of iiprop values for the thumbnail fetch queries.
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
if(PHP_SAPI !='cli') $file
getZoneUrl( $zone, $ext=null)
getHashPath( $name)
Get a relative path including trailing slash, e.g.
A foreign repository with a remote MediaWiki with an API thingy.
newFile( $title, $time=false)
Per docs in FileRepo, this needs to return false if we don't support versioned files.
httpGetCached( $target, $query, $cacheTTL=3600)
HTTP GET request to a mediawiki API (with caching)
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
getZonePath( $zone)
Get the local directory corresponding to one of the basic zones.
bool $url
Public zone URL.
static getProps()
Get the property string for iiprop and aiprop.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
static httpGet( $url, $timeout='default', $options=array())
Like a Http:get request, but with custom User-Agent.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Foreign file accessible through api.php requests.
getThumbError( $name, $width=-1, $height=-1, $otherParams='', $lang=null)
static factory( $url, $options=null)
Generate a new request object.
getInfo()
Get information about the repo - overrides/extends the parent class's information.
canCacheThumbs()
Are we locally caching the thumbnails?
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.