BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
ForeignAPIRepo Class Reference
Inheritance diagram for ForeignAPIRepo:
Collaboration diagram for ForeignAPIRepo:

Public Member Functions

 __construct ($info)
 
 getApiUrl ()
 
 newFile ($title, $time=false)
 
 fileExistsBatch (array $files)
 
 getFileProps ($virtualUrl)
 
 fetchImageQuery ($query)
 
 getImageInfo ($data)
 
 findBySha1 ($hash)
 
 getThumbUrl ($name, $width=-1, $height=-1, &$result=null, $otherParams= '')
 
 getThumbError ($name, $width=-1, $height=-1, $otherParams= '', $lang=null)
 
 getThumbUrlFromCache ($name, $width, $height, $params="")
 
 getZoneUrl ($zone, $ext=null)
 
 getZonePath ($zone)
 
 canCacheThumbs ()
 
 getInfo ()
 
 httpGetCached ($target, $query, $cacheTTL=3600)
 
 enumFiles ($callback)
 
- Public Member Functions inherited from FileRepo
 __construct (array $info=null)
 
 getBackend ()
 
 getReadOnlyReason ()
 
 getVirtualUrl ($suffix=false)
 
 getZoneUrl ($zone, $ext=null)
 
 backendSupportsUnicodePaths ()
 
 resolveVirtualUrl ($url)
 
 getZonePath ($zone)
 
 newFile ($title, $time=false)
 
 findFile ($title, $options=[])
 
 findFiles (array $items, $flags=0)
 
 findFileFromKey ($sha1, $options=[])
 
 findBySha1 ($hash)
 
 findBySha1s (array $hashes)
 
 findFilesByPrefix ($prefix, $limit)
 
 getThumbScriptUrl ()
 
 getThumbProxyUrl ()
 
 getThumbProxySecret ()
 
 canTransformVia404 ()
 
 getNameFromTitle (Title $title)
 
 getRootDirectory ()
 
 getHashPath ($name)
 
 getTempHashPath ($suffix)
 
 getHashLevels ()
 
 getName ()
 
 makeUrl ($query= '', $entry= 'index')
 
 getDescriptionUrl ($name)
 
 getDescriptionRenderUrl ($name, $lang=null)
 
 getDescriptionStylesheetUrl ()
 
 store ($srcPath, $dstZone, $dstRel, $flags=0)
 
 storeBatch (array $triplets, $flags=0)
 
 cleanupBatch (array $files, $flags=0)
 
 quickImport ($src, $dst, $options=null)
 
 quickPurge ($path)
 
 quickCleanDir ($dir)
 
 quickImportBatch (array $triples)
 
 quickPurgeBatch (array $paths)
 
 storeTemp ($originalName, $srcPath)
 
 freeTemp ($virtualUrl)
 
 concatenate (array $srcPaths, $dstPath, $flags=0)
 
 publish ($src, $dstRel, $archiveRel, $flags=0, array $options=[])
 
 publishBatch (array $ntuples, $flags=0)
 
 cleanDir ($dir)
 
 fileExists ($file)
 
 fileExistsBatch (array $files)
 
 delete ($srcRel, $archiveRel)
 
 deleteBatch (array $sourceDestPairs)
 
 cleanupDeletedBatch (array $storageKeys)
 
 getDeletedHashPath ($key)
 
 getLocalCopy ($virtualUrl)
 
 getLocalReference ($virtualUrl)
 
 getFileProps ($virtualUrl)
 
 getFileTimestamp ($virtualUrl)
 
 getFileSize ($virtualUrl)
 
 getFileSha1 ($virtualUrl)
 
 streamFileWithStatus ($virtualUrl, $headers=[], $optHeaders=[])
 
 streamFile ($virtualUrl, $headers=[])
 
 enumFiles ($callback)
 
 validateFilename ($filename)
 
 getErrorCleanupFunction ()
 
 paranoidClean ($param)
 
 passThrough ($param)
 
 newFatal ($message)
 
 newGood ($value=null)
 
 checkRedirect (Title $title)
 
 invalidateImageRedirect (Title $title)
 
 getDisplayName ()
 
 nameForThumb ($name)
 
 isLocal ()
 
 getSharedCacheKey ()
 
 getLocalCacheKey ()
 
 getTempRepo ()
 
 getUploadStash (User $user=null)
 
 getInfo ()
 
 hasSha1Storage ()
 
 supportsSha1URLs ()
 

Static Public Member Functions

static getUserAgent ()
 
static httpGet ($url, $timeout= 'default', $options=[], &$mtime=false)
 
- Static Public Member Functions inherited from FileRepo
static isVirtualUrl ($url)
 

Public Attributes

const VERSION = "2.1"
 
- Public Attributes inherited from FileRepo
const DELETE_SOURCE = 1
 
const OVERWRITE = 2
 
const OVERWRITE_SAME = 4
 
const SKIP_LOCKING = 8
 
const NAME_AND_TIME_ONLY = 1
 
 $fetchDescription
 
 $descriptionCacheExpiry
 

Protected Member Functions

 assertWritableRepo ()
 
- Protected Member Functions inherited from FileRepo
 initZones ($doZones=[])
 
 getZoneLocation ($zone)
 
 initDirectory ($dir)
 
 resolveToStoragePath ($path)
 
 enumFilesInStorage ($callback)
 
 assertWritableRepo ()
 

Static Protected Member Functions

static getIIProps ()
 
- Static Protected Member Functions inherited from FileRepo
static getHashPathForLevel ($name, $levels)
 

Protected Attributes

 $fileFactory = [ ForeignAPIFile::class, 'newFromTitle' ]
 
 $apiThumbCacheExpiry = 86400
 
 $fileCacheExpiry = 2592000
 
 $mFileExists = []
 
- Protected Attributes inherited from FileRepo
 $hasSha1Storage = false
 
 $supportsSha1URLs = false
 
 $backend
 
 $zones = []
 
 $thumbScriptUrl
 
 $transformVia404
 
 $descBaseUrl
 
 $scriptDirUrl
 
 $articleUrl
 
 $initialCapital
 
 $pathDisclosureProtection = 'simple'
 
 $url
 
 $thumbUrl
 
 $hashLevels
 
 $deletedHashLevels
 
 $abbrvThreshold
 
 $favicon
 
 $isPrivate
 
 $fileFactory = [ UnregisteredLocalFile::class, 'newFromTitle' ]
 
 $oldFileFactory = false
 
 $fileFactoryKey = false
 
 $oldFileFactoryKey = false
 
 $thumbProxyUrl
 
 $thumbProxySecret
 

Static Protected Attributes

static $imageInfoProps
 

Detailed Description

A foreign repository with a remote MediaWiki with an API thingy

Example config:

$wgForeignFileRepos[] = [ 'class' => ForeignAPIRepo::class, 'name' => 'shared', 'apibase' => 'https://en.wikipedia.org/w/api.php', 'fetchDescription' => true, // Optional 'descriptionCacheExpiry' => 3600, ];

Constructor & Destructor Documentation

ForeignAPIRepo::__construct (   $info)
Parameters
array | null$info

Member Function Documentation

ForeignAPIRepo::assertWritableRepo ( )
protected
Exceptions
MWException
ForeignAPIRepo::canCacheThumbs ( )

Are we locally caching the thumbnails?

Returns
bool
ForeignAPIRepo::enumFiles (   $callback)
Parameters
callable$callback
Exceptions
MWException
ForeignAPIRepo::fetchImageQuery (   $query)
Parameters
array$query
Returns
string
ForeignAPIRepo::fileExistsBatch ( array  $files)
Parameters
string[]$files
Returns
array
ForeignAPIRepo::findBySha1 (   $hash)
Parameters
string$hash
Returns
ForeignAPIFile[]
ForeignAPIRepo::getApiUrl ( )
Returns
string
Since
1.22
ForeignAPIRepo::getFileProps (   $virtualUrl)
Parameters
string$virtualUrl
Returns
false
static ForeignAPIRepo::getIIProps ( )
staticprotected
Returns
string
Since
1.23
ForeignAPIRepo::getImageInfo (   $data)
Parameters
array$data
Returns
bool|array
ForeignAPIRepo::getInfo ( )

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

Returns
array
Since
1.22
ForeignAPIRepo::getThumbError (   $name,
  $width = -1,
  $height = -1,
  $otherParams = '',
  $lang = null 
)
Parameters
string$name
int$width
int$height
string$otherParams
string | null$langLanguage code for language of error
Returns
bool|MediaTransformError
Since
1.22
ForeignAPIRepo::getThumbUrl (   $name,
  $width = -1,
  $height = -1,
$result = null,
  $otherParams = '' 
)
Parameters
string$name
int$width
int$height
array | null&$resultOutput-only parameter, guaranteed to become an array
string$otherParams
Returns
string|false
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
static ForeignAPIRepo::getUserAgent ( )
static

The user agent the ForeignAPIRepo will use.

Returns
string
ForeignAPIRepo::getZonePath (   $zone)

Get the local directory corresponding to one of the basic zones

Parameters
string$zone
Returns
bool|null|string
ForeignAPIRepo::getZoneUrl (   $zone,
  $ext = null 
)
See Also
FileRepo::getZoneUrl()
Parameters
string$zone
string | null$extOptional file extension
Returns
string
static ForeignAPIRepo::httpGet (   $url,
  $timeout = 'default',
  $options = [],
$mtime = false 
)
static

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

See Also
Http::get
Parameters
string$url
string$timeout
array$options
int | bool&$mtimeResulting Last-Modified UNIX timestamp if received
Returns
bool|string
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
string|null
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|false

Member Data Documentation

ForeignAPIRepo::$imageInfoProps
staticprotected
Initial value:
= [
'url',
'timestamp',
]

List of iiprop values for the thumbnail fetch queries.

Since
1.23

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