MediaWiki  REL1_22
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

 $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()

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:
$infoarray|null

Definition at line 57 of file ForeignAPIRepo.php.

References canCacheThumbs(), and global.


Member Function Documentation

Exceptions:
MWException

Reimplemented from FileRepo.

Definition at line 539 of file ForeignAPIRepo.php.

Are we locally caching the thumbnails?

Returns:
bool

Definition at line 416 of file ForeignAPIRepo.php.

Referenced by __construct(), and getThumbUrlFromCache().

ForeignAPIRepo::enumFiles ( callback)
Parameters:
$callbackArray|string
Exceptions:
MWException

Reimplemented from FileRepo.

Definition at line 532 of file ForeignAPIRepo.php.

Parameters:
$queryarray
Returns:
string

Definition at line 169 of file ForeignAPIRepo.php.

References $query, $wgMemc, array(), FormatJson\decode(), global, and httpGetCached().

Referenced by fileExistsBatch(), findBySha1(), getThumbError(), and getThumbUrl().

Parameters:
$filesarray
Returns:
array

Reimplemented from FileRepo.

Definition at line 110 of file ForeignAPIRepo.php.

References $f, $file, $key, $n, array(), as, fetchImageQuery(), FileBackend\isStoragePath(), and wfWarn().

Parameters:
$hashstring
Returns:
array

Reimplemented from FileRepo.

Definition at line 211 of file ForeignAPIRepo.php.

References $hash, $ret, array(), as, fetchImageQuery(), ForeignAPIFile\getProps(), and Title\makeTitle().

Returns:
string
Since:
1.22

Definition at line 87 of file ForeignAPIRepo.php.

Referenced by getInfo().

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

Reimplemented from FileRepo.

Definition at line 161 of file ForeignAPIRepo.php.

Parameters:
$dataarray
Returns:
bool|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.

Returns:
array
Since:
1.22

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 
)
Parameters:
$namestring
$widthint
$heightint
$otherParamsstring
Returns:
bool|MediaTransformError
Since:
1.22

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 = '' 
)
Parameters:
$namestring
$widthint
$heightint
$resultnull
$otherParamsstring
Returns:
bool

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.

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

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.

Returns:
string

Definition at line 424 of file ForeignAPIRepo.php.

References Http\userAgent(), and VERSION.

Referenced by httpGet().

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

Parameters:
$zonestring
Returns:
bool|null|string

Reimplemented from FileRepo.

Definition at line 404 of file ForeignAPIRepo.php.

References array().

Referenced by getThumbUrlFromCache().

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

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.

See also:
Http:get
Parameters:
$urlstring
$timeoutstring
$optionsarray
Returns:
bool|String

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)

Parameters:
$targetstring Used in cache key creation, mostly
$queryarray The query parameters for the API request
$cacheTTLint 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 
)

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

Well, we don't.

Parameters:
$titleTitle
$timestring|bool
Returns:
File

Reimplemented from FileRepo.

Definition at line 99 of file ForeignAPIRepo.php.

References $time, and $title.


Member Data Documentation

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().


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