MediaWiki  REL1_19
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)
 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()

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


Constructor & Destructor Documentation

Definition at line 39 of file ForeignAPIRepo.php.

References $wgLocalFileRepo, and canCacheThumbs().

Here is the call graph for this function:


Member Function Documentation

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?

Returns:
bool

Definition at line 342 of file ForeignAPIRepo.php.

Referenced by __construct(), and getThumbUrlFromCache().

Here is the caller graph for this function:

ForeignAPIRepo::concatenate ( srcPaths,
dstPath,
flags = 0 
)

Concatenate a list of files into a target file location.

Parameters:
$srcPathsArray Ordered list of source virtual URLs/storage paths
$dstPathString Target file system path
$flagsInteger: bitwise combination of the following flags: self::DELETE_SOURCE Delete the source files
Returns:
FileRepoStatus

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.

Parameters:
$sourceDestPairsArray 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.
Returns:
FileRepoStatus

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.

Parameters:
$callbackArray|string
Returns:
void

Reimplemented from FileRepo.

Definition at line 379 of file ForeignAPIRepo.php.

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

Here is the call graph for this function:

Here is the caller graph for this function:

ForeignAPIRepo::fileExistsBatch ( files,
flags = 0 
)

Checks existence of an array of files.

Parameters:
$filesArray: Virtual URLs (or storage paths) of files to check
$flagsInteger: bitwise combination of the following flags: self::FILES_ONLY Mark file as existing only if it is a file (not directory)
Returns:
Either array of files and existence flags, or false

Reimplemented from FileRepo.

Definition at line 110 of file ForeignAPIRepo.php.

References $f, $file, $files, and fetchImageQuery().

Here is the call graph for this function:

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

Here is the call graph for this function:

ForeignAPIRepo::getFileProps ( virtualUrl)

Get properties of a file with a given virtual URL/storage path.

Properties should ultimately be obtained via FSFile::getProps().

Parameters:
$virtualUrlstring
Returns:
Array

Reimplemented from FileRepo.

Definition at line 137 of file ForeignAPIRepo.php.

Definition at line 176 of file ForeignAPIRepo.php.

Referenced by getThumbUrl().

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

See also:
FileRepo::getZoneUrl()

Reimplemented from FileRepo.

Definition at line 316 of file ForeignAPIRepo.php.

Referenced by getThumbUrlFromCache().

Here is the caller graph for this function:

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

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

See also:
Http:get

Definition at line 357 of file ForeignAPIRepo.php.

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

Referenced by fetchImageQuery(), and getThumbUrlFromCache().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Returns:
File

Reimplemented from FileRepo.

Definition at line 71 of file ForeignAPIRepo.php.

References $title.

ForeignAPIRepo::publishBatch ( triplets,
flags = 0 
)

Publish a batch of files.

Parameters:
$tripletsArray: (source, dest, archive) triplets as per publish()
$flagsInteger: bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible
Returns:
FileRepoStatus

Reimplemented from FileRepo.

Definition at line 102 of file ForeignAPIRepo.php.

ForeignAPIRepo::storeBatch ( triplets,
flags = 0 
)

No-ops.

Reimplemented from FileRepo.

Definition at line 82 of file ForeignAPIRepo.php.

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

Parameters:
$originalNameString: the base name of the file as specified by the user. The file extension will be maintained.
$srcPathString: the current location of the file.
Returns:
FileRepoStatus object with the URL in the value.

Reimplemented from FileRepo.

Definition at line 86 of file ForeignAPIRepo.php.


Member Data Documentation

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


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