MediaWiki
REL1_22
|
A foreign repository with a remote MediaWiki with an API thingy. More...
Public Member Functions | |
__construct ($info) | |
canCacheThumbs () | |
Are we locally caching the thumbnails? | |
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. | |
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. | |
getZonePath ($zone) | |
Get the local directory corresponding to one of the basic zones. | |
getZoneUrl ($zone, $ext=null) | |
httpGetCached ($target, $query, $cacheTTL=3600) | |
HTTP GET request to a mediawiki API (with caching) | |
newFile ($title, $time=false) | |
Per docs in FileRepo, this needs to return false if we don't support versioned files. | |
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 Member Functions | |
assertWritableRepo () | |
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 39 of file ForeignAPIRepo.php.
ForeignAPIRepo::__construct | ( | $ | info | ) |
$info | array|null |
Definition at line 57 of file ForeignAPIRepo.php.
References canCacheThumbs(), and global.
ForeignAPIRepo::assertWritableRepo | ( | ) | [protected] |
MWException |
Reimplemented from FileRepo.
Definition at line 539 of file ForeignAPIRepo.php.
Are we locally caching the thumbnails?
Definition at line 416 of file ForeignAPIRepo.php.
Referenced by __construct(), and getThumbUrlFromCache().
ForeignAPIRepo::enumFiles | ( | $ | callback | ) |
$callback | Array|string |
MWException |
Reimplemented from FileRepo.
Definition at line 532 of file ForeignAPIRepo.php.
ForeignAPIRepo::fetchImageQuery | ( | $ | query | ) |
$query | array |
Definition at line 169 of file ForeignAPIRepo.php.
References $query, $wgMemc, array(), FormatJson\decode(), global, and httpGetCached().
Referenced by fileExistsBatch(), findBySha1(), getThumbError(), and getThumbUrl().
ForeignAPIRepo::fileExistsBatch | ( | array $ | files | ) |
$files | array |
Reimplemented from FileRepo.
Definition at line 110 of file ForeignAPIRepo.php.
References $f, $file, $key, $n, array(), as, fetchImageQuery(), FileBackend\isStoragePath(), and wfWarn().
ForeignAPIRepo::findBySha1 | ( | $ | hash | ) |
$hash | string |
Reimplemented from FileRepo.
Definition at line 211 of file ForeignAPIRepo.php.
References $hash, $ret, array(), as, fetchImageQuery(), ForeignAPIFile\getProps(), and Title\makeTitle().
Definition at line 87 of file ForeignAPIRepo.php.
Referenced by getInfo().
ForeignAPIRepo::getFileProps | ( | $ | virtualUrl | ) |
$virtualUrl | string |
Reimplemented from FileRepo.
Definition at line 161 of file ForeignAPIRepo.php.
ForeignAPIRepo::getImageInfo | ( | $ | data | ) |
$data | array |
Definition at line 196 of file ForeignAPIRepo.php.
References as.
Referenced by getThumbError(), and getThumbUrl().
Get information about the repo - overrides/extends the parent class's information.
Reimplemented from FileRepo.
Definition at line 434 of file ForeignAPIRepo.php.
References $query, array(), FormatJson\decode(), getApiUrl(), and httpGetCached().
ForeignAPIRepo::getThumbError | ( | $ | name, |
$ | width = -1 , |
||
$ | height = -1 , |
||
$ | otherParams = '' , |
||
$ | lang = null |
||
) |
$name | string |
$width | int |
$height | int |
$otherParams | string |
Definition at line 265 of file ForeignAPIRepo.php.
References $name, array(), fetchImageQuery(), FileRepo\getDisplayName(), getImageInfo(), and wfDebug().
ForeignAPIRepo::getThumbUrl | ( | $ | name, |
$ | width = -1 , |
||
$ | height = -1 , |
||
&$ | result = null , |
||
$ | otherParams = '' |
||
) |
$name | string |
$width | int |
$height | int |
$result | null |
$otherParams | string |
Definition at line 238 of file ForeignAPIRepo.php.
References $name, $result, 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 |
$width | ||
$height | ||
string | $params | Other rendering parameters (page number, etc) from handler's makeParamString. |
Definition at line 303 of file ForeignAPIRepo.php.
References FileRepo\$backend, $key, $name, $params, $result, $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 ForeignAPIRepo::getUserAgent | ( | ) | [static] |
The user agent the ForeignAPIRepo will use.
Definition at line 424 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.
$zone | string |
Reimplemented from FileRepo.
Definition at line 404 of file ForeignAPIRepo.php.
References array().
Referenced by getThumbUrlFromCache().
ForeignAPIRepo::getZoneUrl | ( | $ | zone, |
$ | ext = null |
||
) |
$zone | String | |
string | null | $ext | Optional file extension |
Reimplemented from FileRepo.
Definition at line 388 of file ForeignAPIRepo.php.
References $ext.
Referenced by getThumbUrlFromCache().
static ForeignAPIRepo::httpGet | ( | $ | url, |
$ | timeout = 'default' , |
||
$ | options = array() |
||
) | [static] |
Like a Http:get request, but with custom User-Agent.
$url | string |
$timeout | string |
$options | array |
Definition at line 466 of file ForeignAPIRepo.php.
References $options, FileRepo\$url, MWHttpRequest\factory(), getUserAgent(), wfDebug(), and wfExpandUrl().
Referenced by getThumbUrlFromCache(), and httpGetCached().
ForeignAPIRepo::httpGetCached | ( | $ | target, |
$ | query, | ||
$ | cacheTTL = 3600 |
||
) |
HTTP GET request to a mediawiki API (with caching)
$target | string Used in cache key creation, mostly |
$query | array The query parameters for the API request |
$cacheTTL | int Time to live for the memcached caching |
Definition at line 494 of file ForeignAPIRepo.php.
References $key, $query, FileRepo\$url, $wgMemc, array(), FileRepo\getLocalCacheKey(), global, httpGet(), FileRepo\makeUrl(), and wfAppendQuery().
Referenced by fetchImageQuery(), and getInfo().
ForeignAPIRepo::newFile | ( | $ | title, |
$ | time = false |
||
) |
ForeignAPIRepo::$apiThumbCacheExpiry = 86400 |
Definition at line 47 of file ForeignAPIRepo.php.
ForeignAPIRepo::$fileCacheExpiry = 2592000 |
Definition at line 49 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 45 of file ForeignAPIRepo.php.
ForeignAPIRepo::$mFileExists = array() [protected] |
Definition at line 52 of file ForeignAPIRepo.php.
ForeignAPIRepo::$mQueryCache = array() [protected] |
Definition at line 51 of file ForeignAPIRepo.php.
const ForeignAPIRepo::VERSION = "2.1" |
Definition at line 43 of file ForeignAPIRepo.php.
Referenced by getUserAgent().