|
MediaWiki
1.23.0
|
A foreign repository with a remote MediaWiki with an API thingy. More...


Public Member Functions | |
| __construct ( $info) | |
| canCacheThumbs () | |
| Are we locally caching the thumbnails? More... | |
| enumFiles ( $callback) | |
| fetchImageQuery ( $query) | |
| fileExistsBatch (array $files) | |
| findBySha1 ( $hash) | |
| getApiUrl () | |
| getFileProps ( $virtualUrl) | |
| getImageInfo ( $data) | |
| getInfo () | |
| Get information about the repo - overrides/extends the parent class's information. More... | |
| getThumbError ( $name, $width=-1, $height=-1, $otherParams='', $lang=null) | |
| getThumbUrl ( $name, $width=-1, $height=-1, &$result=null, $otherParams='') | |
| getThumbUrlFromCache ( $name, $width, $height, $params="") | |
| Return the imageurl from cache if possible. More... | |
| getZonePath ( $zone) | |
| Get the local directory corresponding to one of the basic zones. More... | |
| getZoneUrl ( $zone, $ext=null) | |
| httpGetCached ( $target, $query, $cacheTTL=3600) | |
| HTTP GET request to a mediawiki API (with caching) More... | |
| newFile ( $title, $time=false) | |
| Per docs in FileRepo, this needs to return false if we don't support versioned files. More... | |
Public Member Functions inherited from FileRepo | |
| __construct (array $info=null) | |
| canTransformVia404 () | |
| Returns true if the repository can transform files via a 404 handler. More... | |
| checkRedirect (Title $title) | |
| Checks if there is a redirect named as $title. More... | |
| cleanDir ( $dir) | |
| Deletes a directory if empty. More... | |
| cleanupBatch (array $files, $flags=0) | |
| Deletes a batch of files. More... | |
| cleanupDeletedBatch (array $storageKeys) | |
| Delete files in the deleted directory if they are not referenced in the filearchive table. More... | |
| concatenate (array $srcPaths, $dstPath, $flags=0) | |
| Concatenate a list of temporary files into a target file location. More... | |
| delete ( $srcRel, $archiveRel) | |
| Move a file to the deletion archive. More... | |
| deleteBatch (array $sourceDestPairs) | |
| Move a group of files to the deletion archive. More... | |
| fileExists ( $file) | |
| Checks existence of a a file. More... | |
| findBySha1s (array $hashes) | |
| Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes. More... | |
| findFile ( $title, $options=array()) | |
| Find an instance of the named file created at the specified time Returns false if the file does not exist. More... | |
| findFileFromKey ( $sha1, $options=array()) | |
| Find an instance of the file with this key, created at the specified time Returns false if the file does not exist. More... | |
| findFiles (array $items, $flags=0) | |
| Find many files at once. More... | |
| findFilesByPrefix ( $prefix, $limit) | |
| Return an array of files where the name starts with $prefix. More... | |
| freeTemp ( $virtualUrl) | |
| Remove a temporary file or mark it for garbage collection. More... | |
| getBackend () | |
| Get the file backend instance. More... | |
| getDeletedHashPath ( $key) | |
| Get a relative path for a deletion archive key, e.g. More... | |
| getDescriptionRenderUrl ( $name, $lang=null) | |
| Get the URL of the content-only fragment of the description page. More... | |
| getDescriptionStylesheetUrl () | |
| Get the URL of the stylesheet to apply to description pages. More... | |
| getDescriptionUrl ( $name) | |
| Get the URL of an image description page. More... | |
| getDisplayName () | |
| Get the human-readable name of the repo. More... | |
| getErrorCleanupFunction () | |
| Get a callback function to use for cleaning error message parameters. More... | |
| getFileSha1 ( $virtualUrl) | |
| Get the sha1 (base 36) of a file with a given virtual URL/storage path. More... | |
| getFileSize ( $virtualUrl) | |
| Get the size of a file with a given virtual URL/storage path. More... | |
| getFileTimestamp ( $virtualUrl) | |
| Get the timestamp of a file with a given virtual URL/storage path. More... | |
| getHashLevels () | |
| Get the number of hash directory levels. More... | |
| getHashPath ( $name) | |
| Get a relative path including trailing slash, e.g. More... | |
| getLocalCacheKey () | |
| Get a key for this repo in the local cache domain. More... | |
| getLocalCopy ( $virtualUrl) | |
| Get a local FS copy of a file with a given virtual URL/storage path. More... | |
| getLocalReference ( $virtualUrl) | |
| Get a local FS file with a given virtual URL/storage path. More... | |
| getName () | |
| Get the name of this repository, as specified by $info['name]' to the constructor. More... | |
| getNameFromTitle (Title $title) | |
| Get the name of a file from its title object. More... | |
| getReadOnlyReason () | |
| Get an explanatory message if this repo is read-only. More... | |
| getRootDirectory () | |
| Get the public zone root storage directory of the repository. More... | |
| getRootUrl () | |
| Get the public root URL of the repository. More... | |
| getSharedCacheKey () | |
| Get a key on the primary cache for this repository. More... | |
| getTempHashPath ( $suffix) | |
| Get a relative path including trailing slash, e.g. More... | |
| getTempRepo () | |
| Get an temporary FileRepo associated with this repo. More... | |
| getThumbScriptUrl () | |
| Get the URL of thumb.php. More... | |
| getUploadStash (User $user=null) | |
| Get an UploadStash associated with this repo. More... | |
| getVirtualUrl ( $suffix=false) | |
| Get a URL referring to this repository, with the private mwrepo protocol. More... | |
| getZoneHandlerUrl ( $zone) | |
| Get the thumb zone URL configured to be handled by scripts like thumb_handler.php. More... | |
| invalidateImageRedirect (Title $title) | |
| Invalidates image redirect cache related to that image Doesn't do anything for repositories that don't support image redirects. More... | |
| isLocal () | |
| Returns true if this the local file repository. More... | |
| makeUrl ( $query='', $entry='index') | |
| Make an url to this repo. More... | |
| nameForThumb ( $name) | |
| Get the portion of the file that contains the origin file name. More... | |
| newFatal ( $message) | |
| Create a new fatal error. More... | |
| newGood ( $value=null) | |
| Create a new good result. More... | |
| paranoidClean ( $param) | |
| Path disclosure protection function. More... | |
| passThrough ( $param) | |
| Path disclosure protection function. More... | |
| publish ( $srcPath, $dstRel, $archiveRel, $flags=0, array $options=array()) | |
| Copy or move a file either from a storage path, virtual URL, or file system path, into this repository at the specified destination location. More... | |
| publishBatch (array $ntuples, $flags=0) | |
| Publish a batch of files. More... | |
| quickCleanDir ( $dir) | |
| Deletes a directory if empty. More... | |
| quickImport ( $src, $dst, $options=null) | |
| Import a file from the local file system into the repo. More... | |
| quickImportBatch (array $triples) | |
| Import a batch of files from the local file system into the repo. More... | |
| quickPurge ( $path) | |
| Purge a file from the repo. More... | |
| quickPurgeBatch (array $paths) | |
| Purge a batch of files from the repo. More... | |
| resolveVirtualUrl ( $url) | |
| Get the backend storage path corresponding to a virtual URL. More... | |
| store ( $srcPath, $dstZone, $dstRel, $flags=0) | |
| Store a file to a given destination. More... | |
| storeBatch (array $triplets, $flags=0) | |
| Store a batch of files. More... | |
| storeTemp ( $originalName, $srcPath) | |
| Pick a random name in the temp zone and store a file to it. More... | |
| streamFile ( $virtualUrl, $headers=array()) | |
| Attempt to stream a file with the given virtual URL/storage path. More... | |
| validateFilename ( $filename) | |
| Determine if a relative path is valid, i.e. More... | |
Static Public Member Functions | |
| static | getUserAgent () |
| The user agent the ForeignAPIRepo will use. More... | |
| static | httpGet ( $url, $timeout='default', $options=array()) |
| Like a Http:get request, but with custom User-Agent. More... | |
Static Public Member Functions inherited from FileRepo | |
| static | isVirtualUrl ( $url) |
| Determine if a string is an mwrepo:// URL. More... | |
Public Attributes | |
| const | VERSION = "2.1" |
Public Attributes inherited from FileRepo | |
| int | $descriptionCacheExpiry |
| bool | $fetchDescription |
| Whether to fetch commons image description pages and display them on the local wiki *. More... | |
| const | DELETE_SOURCE = 1 |
| const | NAME_AND_TIME_ONLY = 1 |
| const | OVERWRITE = 2 |
| const | OVERWRITE_SAME = 4 |
| const | SKIP_LOCKING = 8 |
Protected Member Functions | |
| assertWritableRepo () | |
Protected Member Functions inherited from FileRepo | |
| enumFilesInStorage ( $callback) | |
| Call a callback function for every public file in the repository. More... | |
| getZoneLocation ( $zone) | |
| The the storage container and base path of a zone. More... | |
| initDirectory ( $dir) | |
| Creates a directory with the appropriate zone permissions. More... | |
| initZones ( $doZones=array()) | |
| Check if a single zone or list of zones is defined for usage. More... | |
| resolveToStoragePath ( $path) | |
| If a path is a virtual URL, resolve it to a storage path. More... | |
Static Protected Member Functions | |
| static | getIIProps () |
Static Protected Member Functions inherited from FileRepo | |
| static | getHashPathForLevel ( $name, $levels) |
Protected Attributes | |
| int | $apiThumbCacheExpiry = 86400 |
| Check back with Commons after a day (24*60*60) *. More... | |
| int | $fileCacheExpiry = 2592000 |
| Redownload thumbnail files after a month (86400*30) *. More... | |
| $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' ) | |
| array | $mFileExists = array() |
Protected Attributes inherited from FileRepo | |
| int | $abbrvThreshold |
| File names over this size will use the short form of thumbnail names. More... | |
| $articleUrl | |
| FileBackend | $backend |
| int | $deletedHashLevels |
| The number of directory levels for hash-based division of deleted files *. More... | |
| $descBaseUrl | |
| string | $favicon |
| The URL of the repo's favicon, if any *. More... | |
| $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' ) | |
| Factory functions for creating new files Override these in the base class. More... | |
| $fileFactoryKey = false | |
| int | $hashLevels |
| The number of directory levels for hash-based division of files *. More... | |
| bool | $initialCapital |
| Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter. More... | |
| $oldFileFactory = false | |
| $oldFileFactoryKey = false | |
| string | $pathDisclosureProtection = 'simple' |
| May be 'paranoid' to remove all parameters from error messages, 'none' to leave the paths in unchanged, or 'simple' to replace paths with placeholders. More... | |
| $scriptDirUrl | |
| string | $scriptExtension |
| Script extension of the MediaWiki installation, equivalent to $wgScriptExtension, e.g. More... | |
| string | $thumbScriptUrl |
| URL of thumb.php *. More... | |
| $thumbUrl | |
| bool | $transformVia404 |
| Whether to skip media file transformation on parse and rely on a 404 handler instead. More... | |
| bool | $url |
| Public zone URL. More... | |
| Array | $zones = array() |
| Map of zones to config *. More... | |
Static Protected Attributes | |
| static | $imageInfoProps |
| List of iiprop values for the thumbnail fetch queries. More... | |
Private Attributes | |
| array | $mQueryCache = array() |
A foreign repository with a remote MediaWiki with an API thingy.
Example config:
$wgForeignFileRepos[] = array( 'class' => 'ForeignAPIRepo', 'name' => 'shared', 'apibase' => 'http://en.wikipedia.org/w/api.php', 'fetchDescription' => true, // Optional 'descriptionCacheExpiry' => 3600, );
Definition at line 39 of file ForeignAPIRepo.php.
| ForeignAPIRepo::__construct | ( | $info | ) |
| $info | array|null |
Definition at line 67 of file ForeignAPIRepo.php.
References canCacheThumbs(), and global.
|
protected |
| MWException |
Reimplemented from FileRepo.
Definition at line 584 of file ForeignAPIRepo.php.
| ForeignAPIRepo::canCacheThumbs | ( | ) |
Are we locally caching the thumbnails?
Definition at line 448 of file ForeignAPIRepo.php.
Referenced by __construct(), and getThumbUrlFromCache().
| ForeignAPIRepo::enumFiles | ( | $callback | ) |
| array | string | $callback |
| MWException |
Reimplemented from FileRepo.
Definition at line 577 of file ForeignAPIRepo.php.
| ForeignAPIRepo::fetchImageQuery | ( | $query | ) |
| array | $query |
Definition at line 184 of file ForeignAPIRepo.php.
References $query, array(), FormatJson\decode(), global, and httpGetCached().
Referenced by fileExistsBatch(), findBySha1(), getThumbError(), and getThumbUrl().
| ForeignAPIRepo::fileExistsBatch | ( | array | $files | ) |
| array | $files |
Reimplemented from FileRepo.
Definition at line 121 of file ForeignAPIRepo.php.
References $f, $file, $files, $n, array(), as, fetchImageQuery(), FileBackend\isStoragePath(), and wfWarn().
| ForeignAPIRepo::findBySha1 | ( | $hash | ) |
| string | $hash |
Reimplemented from FileRepo.
Definition at line 227 of file ForeignAPIRepo.php.
References $hash, $ret, array(), as, fetchImageQuery(), ForeignAPIFile\getProps(), Title\makeTitle(), and NS_FILE.
| ForeignAPIRepo::getApiUrl | ( | ) |
| ForeignAPIRepo::getFileProps | ( | $virtualUrl | ) |
| string | $virtualUrl |
Reimplemented from FileRepo.
Definition at line 176 of file ForeignAPIRepo.php.
|
staticprotected |
| ForeignAPIRepo::getImageInfo | ( | $data | ) |
| array | $data |
Definition at line 211 of file ForeignAPIRepo.php.
References as.
Referenced by getThumbError(), and getThumbUrl().
| ForeignAPIRepo::getInfo | ( | ) |
Get information about the repo - overrides/extends the parent class's information.
Reimplemented from FileRepo.
Definition at line 466 of file ForeignAPIRepo.php.
References $query, array(), FormatJson\decode(), getApiUrl(), and httpGetCached().
| ForeignAPIRepo::getThumbError | ( | $name, | |
$width = -1, |
|||
$height = -1, |
|||
$otherParams = '', |
|||
$lang = null |
|||
| ) |
| string | $name | |
| int | $width | |
| int | $height | |
| string | $otherParams | |
| string | $lang | Language code for language of error |
Definition at line 285 of file ForeignAPIRepo.php.
References $name, array(), fetchImageQuery(), FileRepo\getDisplayName(), getImageInfo(), and wfDebug().
| ForeignAPIRepo::getThumbUrl | ( | $name, | |
$width = -1, |
|||
$height = -1, |
|||
| & | $result = null, |
||
$otherParams = '' |
|||
| ) |
| string | $name | |
| int | $width | |
| int | $height | |
| array | $result | Out parameter that will be changed by the function. |
| string | $otherParams |
Definition at line 256 of file ForeignAPIRepo.php.
References $name, array(), fetchImageQuery(), getImageInfo(), and wfDebug().
Referenced by getThumbUrlFromCache().
| ForeignAPIRepo::getThumbUrlFromCache | ( | $name, | |
| $width, | |||
| $height, | |||
$params = "" |
|||
| ) |
Return the imageurl from cache if possible.
If the url has been requested today, get it from cache Otherwise retrieve remote thumb url, check for local file.
| string | $name | is a dbkey form of a title |
| int | $width | |
| int | $height | |
| string | $params | Other rendering parameters (page number, etc) from handler's makeParamString. |
Definition at line 325 of file ForeignAPIRepo.php.
References FileRepo\$backend, $name, $params, $wgMemc, array(), canCacheThumbs(), FileBackend\fileExists(), FileRepo\getBackend(), FileBackend\getFileTimestamp(), FileRepo\getHashPath(), FileRepo\getLocalCacheKey(), getThumbUrl(), getZonePath(), getZoneUrl(), global, httpGet(), FileBackend\prepare(), FileBackend\quickCreate(), FileRepo\validateFilename(), and wfDebug().
|
static |
The user agent the ForeignAPIRepo will use.
Definition at line 456 of file ForeignAPIRepo.php.
References Http\userAgent(), and VERSION.
Referenced by httpGet().
| ForeignAPIRepo::getZonePath | ( | $zone | ) |
Get the local directory corresponding to one of the basic zones.
| string | $zone |
Reimplemented from FileRepo.
Definition at line 435 of file ForeignAPIRepo.php.
References array().
Referenced by getThumbUrlFromCache().
| ForeignAPIRepo::getZoneUrl | ( | $zone, | |
$ext = null |
|||
| ) |
| string | $zone | |
| string | null | $ext | Optional file extension |
Reimplemented from FileRepo.
Definition at line 419 of file ForeignAPIRepo.php.
References $ext, FileRepo\$thumbUrl, and FileRepo\$url.
Referenced by getThumbUrlFromCache().
Like a Http:get request, but with custom User-Agent.
| string | $url | |
| string | $timeout | |
| array | $options |
Definition at line 502 of file ForeignAPIRepo.php.
References $options, FileRepo\$url, MWHttpRequest\factory(), getUserAgent(), PROTO_HTTP, wfDebug(), and wfExpandUrl().
Referenced by getThumbUrlFromCache(), and httpGetCached().
| ForeignAPIRepo::httpGetCached | ( | $target, | |
| $query, | |||
$cacheTTL = 3600 |
|||
| ) |
HTTP GET request to a mediawiki API (with caching)
| string | $target | Used in cache key creation, mostly |
| array | $query | The query parameters for the API request |
| int | $cacheTTL | Time to live for the memcached caching |
Definition at line 539 of file ForeignAPIRepo.php.
References $query, FileRepo\$url, $wgMemc, array(), FileRepo\getLocalCacheKey(), global, httpGet(), FileRepo\makeUrl(), and wfAppendQuery().
Referenced by fetchImageQuery(), and getInfo().
| ForeignAPIRepo::newFile | ( | $title, | |
$time = false |
|||
| ) |
|
protected |
Check back with Commons after a day (24*60*60) *.
Definition at line 56 of file ForeignAPIRepo.php.
|
protected |
Redownload thumbnail files after a month (86400*30) *.
Definition at line 58 of file ForeignAPIRepo.php.
|
protected |
Definition at line 55 of file ForeignAPIRepo.php.
|
staticprotected |
List of iiprop values for the thumbnail fetch queries.
Definition at line 49 of file ForeignAPIRepo.php.
Definition at line 60 of file ForeignAPIRepo.php.
Definition at line 62 of file ForeignAPIRepo.php.
| const ForeignAPIRepo::VERSION = "2.1" |
Definition at line 43 of file ForeignAPIRepo.php.
Referenced by getUserAgent().