MediaWiki
REL1_19
|
A foreign repository with a remote MediaWiki with an API thingy. More...
Public Member Functions | |
__construct ($info) | |
append ($srcPath, $toAppendPath, $flags=0) | |
appendFinish ($toAppendPath) | |
canCacheThumbs () | |
Are we locally caching the thumbnails? | |
concatenate ($fileList, $targetPath, $flags=0) | |
Concatenate a list of files into a target file location. | |
deleteBatch ($sourceDestPairs) | |
Move a group of files to the deletion archive. | |
enumFiles ($callback) | |
Call a callback function for every public regular file in the repository. | |
fetchImageQuery ($query) | |
fileExistsBatch ($files, $flags=0) | |
Checks existence of an array of files. | |
findBySha1 ($hash) | |
Get an array or iterator of file objects for files that have a given SHA-1 content hash. | |
getFileProps ($virtualUrl) | |
Get properties of a file with a given virtual URL/storage path. | |
getImageInfo ($data) | |
getThumbUrl ($name, $width=-1, $height=-1, &$result=null, $otherParams= '') | |
getThumbUrlFromCache ($name, $width, $height, $params="") | |
Return the imageurl from cache if possible. | |
getZonePath ($zone) | |
Get the local directory corresponding to one of the basic zones. | |
getZoneUrl ($zone) | |
newFile ($title, $time=false) | |
Per docs in FileRepo, this needs to return false if we don't support versioned files. | |
publishBatch ($triplets, $flags=0) | |
Publish a batch of files. | |
storeBatch ($triplets, $flags=0) | |
No-ops. | |
storeTemp ($originalName, $srcPath) | |
Pick a random name in the temp zone and store a file to it. | |
Static Public Member Functions | |
static | getUserAgent () |
The user agent the ForeignAPIRepo will use. | |
static | httpGet ($url, $timeout= 'default', $options=array()) |
Like a Http:get request, but with custom User-Agent. | |
Public Attributes | |
$apiThumbCacheExpiry = 86400 | |
$fileCacheExpiry = 2592000 | |
$fileFactory = array( 'ForeignAPIFile', 'newFromTitle' ) | |
Factory functions for creating new files Override these in the base class. | |
const | VERSION = "2.1" |
Protected Attributes | |
$mFileExists = 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 24 of file ForeignAPIRepo.php.
ForeignAPIRepo::__construct | ( | $ | info | ) |
Definition at line 39 of file ForeignAPIRepo.php.
References $wgLocalFileRepo, and canCacheThumbs().
ForeignAPIRepo::append | ( | $ | srcPath, |
$ | toAppendPath, | ||
$ | flags = 0 |
||
) |
Definition at line 94 of file ForeignAPIRepo.php.
ForeignAPIRepo::appendFinish | ( | $ | toAppendPath | ) |
Definition at line 98 of file ForeignAPIRepo.php.
Are we locally caching the thumbnails?
Definition at line 342 of file ForeignAPIRepo.php.
Referenced by __construct(), and getThumbUrlFromCache().
ForeignAPIRepo::concatenate | ( | $ | srcPaths, |
$ | dstPath, | ||
$ | flags = 0 |
||
) |
Concatenate a list of files into a target file location.
$srcPaths | Array Ordered list of source virtual URLs/storage paths |
$dstPath | String Target file system path |
$flags | Integer: bitwise combination of the following flags: self::DELETE_SOURCE Delete the source files |
Reimplemented from FileRepo.
Definition at line 90 of file ForeignAPIRepo.php.
ForeignAPIRepo::deleteBatch | ( | $ | sourceDestPairs | ) |
Move a group of files to the deletion archive.
If no valid deletion archive is configured, this may either delete the file or throw an exception, depending on the preference of the repository.
The overwrite policy is determined by the repository -- currently LocalRepo assumes a naming scheme in the deleted zone based on content hash, as opposed to the public zone which is assumed to be unique.
$sourceDestPairs | Array of source/destination pairs. Each element is a two-element array containing the source file path relative to the public root in the first element, and the archive file path relative to the deleted zone root in the second element. |
Reimplemented from FileRepo.
Definition at line 106 of file ForeignAPIRepo.php.
ForeignAPIRepo::enumFiles | ( | $ | callback | ) |
Call a callback function for every public regular file in the repository.
This only acts on the current version of files, not any old versions. May use either the database or the filesystem.
$callback | Array|string |
Reimplemented from FileRepo.
Definition at line 379 of file ForeignAPIRepo.php.
ForeignAPIRepo::fetchImageQuery | ( | $ | query | ) |
Definition at line 141 of file ForeignAPIRepo.php.
References FileRepo\$url, $wgMemc, FormatJson\decode(), FileRepo\getLocalCacheKey(), httpGet(), FileRepo\makeUrl(), and wfAppendQuery().
Referenced by fileExistsBatch(), findBySha1(), and getThumbUrl().
ForeignAPIRepo::fileExistsBatch | ( | $ | files, |
$ | flags = 0 |
||
) |
Checks existence of an array of files.
$files | Array: Virtual URLs (or storage paths) of files to check |
$flags | Integer: bitwise combination of the following flags: self::FILES_ONLY Mark file as existing only if it is a file (not directory) |
Reimplemented from FileRepo.
Definition at line 110 of file ForeignAPIRepo.php.
References $f, $file, $files, and fetchImageQuery().
ForeignAPIRepo::findBySha1 | ( | $ | hash | ) |
Get an array or iterator of file objects for files that have a given SHA-1 content hash.
STUB
Reimplemented from FileRepo.
Definition at line 187 of file ForeignAPIRepo.php.
References fetchImageQuery(), ForeignAPIFile\getProps(), and Title\makeTitle().
ForeignAPIRepo::getFileProps | ( | $ | virtualUrl | ) |
Get properties of a file with a given virtual URL/storage path.
Properties should ultimately be obtained via FSFile::getProps().
$virtualUrl | string |
Reimplemented from FileRepo.
Definition at line 137 of file ForeignAPIRepo.php.
ForeignAPIRepo::getImageInfo | ( | $ | data | ) |
Definition at line 176 of file ForeignAPIRepo.php.
Referenced by getThumbUrl().
ForeignAPIRepo::getThumbUrl | ( | $ | name, |
$ | width = -1 , |
||
$ | height = -1 , |
||
&$ | result = null , |
||
$ | otherParams = '' |
||
) |
Definition at line 205 of file ForeignAPIRepo.php.
References $result, 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.
$name | String is a dbkey form of a title | |
$width | ||
$height | ||
String | $param | Other rendering parameters (page number, etc) from handler's makeParamString. |
Definition at line 235 of file ForeignAPIRepo.php.
References FileRepo\$backend, $result, $wgMemc, canCacheThumbs(), FileRepo\fileExists(), FileRepo\getBackend(), FileRepo\getFileTimestamp(), FileRepo\getHashPath(), FileRepo\getLocalCacheKey(), getThumbUrl(), getZonePath(), getZoneUrl(), httpGet(), FileRepo\validateFilename(), wfDebug(), wfRestoreWarnings(), and wfSuppressWarnings().
static ForeignAPIRepo::getUserAgent | ( | ) | [static] |
The user agent the ForeignAPIRepo will use.
Definition at line 349 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.
Reimplemented from FileRepo.
Definition at line 330 of file ForeignAPIRepo.php.
Referenced by getThumbUrlFromCache().
ForeignAPIRepo::getZoneUrl | ( | $ | zone | ) |
Reimplemented from FileRepo.
Definition at line 316 of file ForeignAPIRepo.php.
Referenced by getThumbUrlFromCache().
static ForeignAPIRepo::httpGet | ( | $ | url, |
$ | timeout = 'default' , |
||
$ | options = array() |
||
) | [static] |
Like a Http:get request, but with custom User-Agent.
Definition at line 357 of file ForeignAPIRepo.php.
References $options, FileRepo\$url, MWHttpRequest\factory(), getUserAgent(), wfDebug(), and wfExpandUrl().
Referenced by fetchImageQuery(), and getThumbUrlFromCache().
ForeignAPIRepo::newFile | ( | $ | title, |
$ | time = false |
||
) |
ForeignAPIRepo::publishBatch | ( | $ | triplets, |
$ | flags = 0 |
||
) |
Publish a batch of files.
$triplets | Array: (source, dest, archive) triplets as per publish() |
$flags | Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible |
Reimplemented from FileRepo.
Definition at line 102 of file ForeignAPIRepo.php.
ForeignAPIRepo::storeBatch | ( | $ | triplets, |
$ | flags = 0 |
||
) |
ForeignAPIRepo::storeTemp | ( | $ | originalName, |
$ | srcPath | ||
) |
Pick a random name in the temp zone and store a file to it.
Returns a FileRepoStatus object with the file Virtual URL in the value, file can later be disposed using FileRepo::freeTemp().
$originalName | String: the base name of the file as specified by the user. The file extension will be maintained. |
$srcPath | String: the current location of the file. |
Reimplemented from FileRepo.
Definition at line 86 of file ForeignAPIRepo.php.
ForeignAPIRepo::$apiThumbCacheExpiry = 86400 |
Definition at line 32 of file ForeignAPIRepo.php.
ForeignAPIRepo::$fileCacheExpiry = 2592000 |
Definition at line 34 of file ForeignAPIRepo.php.
ForeignAPIRepo::$fileFactory = array( 'ForeignAPIFile', 'newFromTitle' ) |
Factory functions for creating new files Override these in the base class.
Reimplemented from FileRepo.
Definition at line 30 of file ForeignAPIRepo.php.
ForeignAPIRepo::$mFileExists = array() [protected] |
Definition at line 37 of file ForeignAPIRepo.php.
ForeignAPIRepo::$mQueryCache = array() [protected] |
Definition at line 36 of file ForeignAPIRepo.php.
const ForeignAPIRepo::VERSION = "2.1" |
Definition at line 28 of file ForeignAPIRepo.php.
Referenced by getUserAgent().