MediaWiki  REL1_24
ForeignAPIRepo Class Reference

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

Inheritance diagram for ForeignAPIRepo:
Collaboration diagram for ForeignAPIRepo:

List of all members.

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

const VERSION = "2.1"

Protected Member Functions

 assertWritableRepo ()

Static Protected Member Functions

static getIIProps ()

Protected Attributes

int $apiThumbCacheExpiry = 86400
 Check back with Commons after a day (24*60*60) *.
int $fileCacheExpiry = 2592000
 Redownload thumbnail files after a month (86400*30) *.
 $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' )
 Factory functions for creating new files Override these in the base class.
array $mFileExists = array()
 *

Static Protected Attributes

static $imageInfoProps
 List of iiprop values for the thumbnail fetch queries.

Private Attributes

array $mQueryCache = array()
 *

Detailed Description

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.


Constructor & Destructor Documentation

Parameters:
array | null$info

Definition at line 67 of file ForeignAPIRepo.php.

References canCacheThumbs(), and global.


Member Function Documentation

Exceptions:
MWException

Reimplemented from FileRepo.

Definition at line 584 of file ForeignAPIRepo.php.

Are we locally caching the thumbnails?

Returns:
bool

Definition at line 448 of file ForeignAPIRepo.php.

Referenced by __construct().

ForeignAPIRepo::enumFiles ( callback)
Parameters:
callable$callback
Exceptions:
MWException

Reimplemented from FileRepo.

Definition at line 577 of file ForeignAPIRepo.php.

Parameters:
array$query
Returns:
string

Definition at line 184 of file ForeignAPIRepo.php.

Parameters:
array$files
Returns:
array

Reimplemented from FileRepo.

Definition at line 121 of file ForeignAPIRepo.php.

Parameters:
string$hash
Returns:
array

Reimplemented from FileRepo.

Definition at line 227 of file ForeignAPIRepo.php.

Returns:
string
Since:
1.22

Definition at line 97 of file ForeignAPIRepo.php.

ForeignAPIRepo::getFileProps ( virtualUrl)
Parameters:
string$virtualUrl
Returns:
bool

Reimplemented from FileRepo.

Definition at line 176 of file ForeignAPIRepo.php.

static ForeignAPIRepo::getIIProps ( ) [static, protected]
Returns:
string
Since:
1.23

Definition at line 528 of file ForeignAPIRepo.php.

Parameters:
array$data
Returns:
bool|array

Definition at line 211 of file ForeignAPIRepo.php.

Get information about the repo - overrides/extends the parent class's information.

Returns:
array
Since:
1.22

Reimplemented from FileRepo.

Definition at line 466 of file ForeignAPIRepo.php.

ForeignAPIRepo::getThumbError ( name,
width = -1,
height = -1,
otherParams = '',
lang = null 
)
Parameters:
string$name
int$width
int$height
string$otherParams
string$langLanguage code for language of error
Returns:
bool|MediaTransformError
Since:
1.22

Definition at line 285 of file ForeignAPIRepo.php.

ForeignAPIRepo::getThumbUrl ( name,
width = -1,
height = -1,
&$  result = null,
otherParams = '' 
)
Parameters:
string$name
int$width
int$height
array$resultOut parameter that will be changed by the function.
string$otherParams
Returns:
bool

Definition at line 256 of file ForeignAPIRepo.php.

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.

Parameters:
string$nameIs a dbkey form of a title
int$width
int$height
string$paramsOther rendering parameters (page number, etc) from handler's makeParamString.
Returns:
bool|string

Definition at line 325 of file ForeignAPIRepo.php.

static ForeignAPIRepo::getUserAgent ( ) [static]

The user agent the ForeignAPIRepo will use.

Returns:
string

Definition at line 456 of file ForeignAPIRepo.php.

Get the local directory corresponding to one of the basic zones.

Parameters:
string$zone
Returns:
bool|null|string

Reimplemented from FileRepo.

Definition at line 435 of file ForeignAPIRepo.php.

ForeignAPIRepo::getZoneUrl ( zone,
ext = null 
)
See also:
FileRepo::getZoneUrl()
Parameters:
string$zone
string | null$extOptional file extension
Returns:
string

Reimplemented from FileRepo.

Definition at line 419 of file ForeignAPIRepo.php.

static ForeignAPIRepo::httpGet ( url,
timeout = 'default',
options = array() 
) [static]

Like a Http:get request, but with custom User-Agent.

See also:
Http:get
Parameters:
string$url
string$timeout
array$options
Returns:
bool|string

Definition at line 502 of file ForeignAPIRepo.php.

ForeignAPIRepo::httpGetCached ( target,
query,
cacheTTL = 3600 
)

HTTP GET request to a mediawiki API (with caching)

Parameters:
string$targetUsed in cache key creation, mostly
array$queryThe query parameters for the API request
int$cacheTTLTime to live for the memcached caching
Returns:
null

Definition at line 539 of file ForeignAPIRepo.php.

ForeignAPIRepo::newFile ( title,
time = false 
)

Per docs in FileRepo, this needs to return false if we don't support versioned files.

Well, we don't.

Parameters:
Title$title
string | bool$time
Returns:
File

Reimplemented from FileRepo.

Definition at line 109 of file ForeignAPIRepo.php.


Member Data Documentation

int ForeignAPIRepo::$apiThumbCacheExpiry = 86400 [protected]

Check back with Commons after a day (24*60*60) *.

Definition at line 56 of file ForeignAPIRepo.php.

int ForeignAPIRepo::$fileCacheExpiry = 2592000 [protected]

Redownload thumbnail files after a month (86400*30) *.

Definition at line 58 of file ForeignAPIRepo.php.

ForeignAPIRepo::$fileFactory = array( 'ForeignAPIFile', 'newFromTitle' ) [protected]

Factory functions for creating new files Override these in the base class.

Reimplemented from FileRepo.

Definition at line 55 of file ForeignAPIRepo.php.

ForeignAPIRepo::$imageInfoProps [static, protected]
Initial value:
 array(
        'url',
        'thumbnail',
        'timestamp',
    )

List of iiprop values for the thumbnail fetch queries.

Since:
1.23

Definition at line 49 of file ForeignAPIRepo.php.

array ForeignAPIRepo::$mFileExists = array() [protected]

*

Definition at line 60 of file ForeignAPIRepo.php.

array ForeignAPIRepo::$mQueryCache = array() [private]

*

Definition at line 62 of file ForeignAPIRepo.php.

const ForeignAPIRepo::VERSION = "2.1"

Definition at line 43 of file ForeignAPIRepo.php.


The documentation for this class was generated from the following file: