MediaWiki  REL1_20
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)
 getFileProps ($virtualUrl)
 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.

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


Member Function Documentation

Exceptions:
MWException

Reimplemented from FileRepo.

Definition at line 423 of file ForeignAPIRepo.php.

Are we locally caching the thumbnails?

Returns:
bool

Definition at line 370 of file ForeignAPIRepo.php.

Referenced by __construct(), and getThumbUrlFromCache().

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

Reimplemented from FileRepo.

Definition at line 416 of file ForeignAPIRepo.php.

Parameters:
$queryarray
Returns:
string

Definition at line 145 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 ( array $  files)
Parameters:
$filesarray
Returns:
array

Reimplemented from FileRepo.

Definition at line 102 of file ForeignAPIRepo.php.

References $f, $file, fetchImageQuery(), FileBackend\isStoragePath(), and wfWarn().

Parameters:
$hashstring
Returns:
array

Reimplemented from FileRepo.

Definition at line 199 of file ForeignAPIRepo.php.

References fetchImageQuery(), ForeignAPIFile\getProps(), and Title\makeTitle().

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

Reimplemented from FileRepo.

Definition at line 137 of file ForeignAPIRepo.php.

Parameters:
$dataarray
Returns:
bool|array

Definition at line 184 of file ForeignAPIRepo.php.

Referenced by getThumbUrl().

ForeignAPIRepo::getThumbUrl ( name,
width = -1,
height = -1,
&$  result = null,
otherParams = '' 
)
Parameters:
$namestring
$widthint
$heightint
$resultnull
$otherParamsstring
Returns:
bool

Definition at line 225 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.

Parameters:
$nameString is 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 256 of file ForeignAPIRepo.php.

References FileRepo\$backend, $params, $result, $wgMemc, canCacheThumbs(), FileBackend\fileExists(), FileRepo\getBackend(), FileBackend\getFileTimestamp(), FileRepo\getHashPath(), FileRepo\getLocalCacheKey(), getThumbUrl(), getZonePath(), getZoneUrl(), 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 378 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 358 of file ForeignAPIRepo.php.

Referenced by getThumbUrlFromCache().

See also:
FileRepo::getZoneUrl()
Parameters:
$zoneString
Returns:
String

Reimplemented from FileRepo.

Definition at line 342 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.

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

Definition at line 390 of file ForeignAPIRepo.php.

References $options, FileRepo\$url, MWHttpRequest\factory(), getUserAgent(), wfDebug(), and wfExpandUrl().

Referenced by fetchImageQuery(), and getThumbUrlFromCache().

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 91 of file ForeignAPIRepo.php.

References $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: