[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/filerepo/ -> FileRepo.php (summary)

(no description)

File Size: 1879 lines (56 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 2 classes

FileRepo:: (80 methods):
  __construct()
  getBackend()
  getReadOnlyReason()
  initZones()
  isVirtualUrl()
  getVirtualUrl()
  getZoneUrl()
  backendSupportsUnicodePaths()
  resolveVirtualUrl()
  getZoneLocation()
  getZonePath()
  newFile()
  findFile()
  findFiles()
  findFileFromKey()
  findBySha1()
  findBySha1s()
  findFilesByPrefix()
  getRootUrl()
  getThumbScriptUrl()
  canTransformVia404()
  getNameFromTitle()
  getRootDirectory()
  getHashPath()
  getTempHashPath()
  getHashPathForLevel()
  getHashLevels()
  getName()
  makeUrl()
  getDescriptionUrl()
  getDescriptionRenderUrl()
  getDescriptionStylesheetUrl()
  store()
  storeBatch()
  cleanupBatch()
  quickImport()
  quickPurge()
  quickCleanDir()
  quickImportBatch()
  quickPurgeBatch()
  storeTemp()
  freeTemp()
  concatenate()
  publish()
  publishBatch()
  initDirectory()
  cleanDir()
  fileExists()
  fileExistsBatch()
  delete()
  deleteBatch()
  cleanupDeletedBatch()
  getDeletedHashPath()
  resolveToStoragePath()
  getLocalCopy()
  getLocalReference()
  getFileProps()
  getFileTimestamp()
  getFileSize()
  getFileSha1()
  streamFile()
  enumFiles()
  enumFilesInStorage()
  validateFilename()
  getErrorCleanupFunction()
  paranoidClean()
  passThrough()
  newFatal()
  newGood()
  checkRedirect()
  invalidateImageRedirect()
  getDisplayName()
  nameForThumb()
  isLocal()
  getSharedCacheKey()
  getLocalCacheKey()
  getTempRepo()
  getUploadStash()
  assertWritableRepo()
  getInfo()

TempFileRepo:: (1 method):
  getTempRepo()


Class: FileRepo  - X-Ref

Base class for file repositories

__construct( array $info = null )   X-Ref

param: array|null $info

getBackend()   X-Ref
Get the file backend instance. Use this function wisely.

return: FileBackend

getReadOnlyReason()   X-Ref
Get an explanatory message if this repo is read-only.
This checks if an administrator disabled writes to the backend.

return: string|bool Returns false if the repo is not read-only

initZones( $doZones = array()   X-Ref
Check if a single zone or list of zones is defined for usage

param: array $doZones Only do a particular zones
return: Status

isVirtualUrl( $url )   X-Ref
Determine if a string is an mwrepo:// URL

param: string $url
return: bool

getVirtualUrl( $suffix = false )   X-Ref
Get a URL referring to this repository, with the private mwrepo protocol.
The suffix, if supplied, is considered to be unencoded, and will be
URL-encoded before being returned.

param: string|bool $suffix
return: string

getZoneUrl( $zone, $ext = null )   X-Ref
Get the URL corresponding to one of the four basic zones

param: string $zone One of: public, deleted, temp, thumb
param: string|null $ext Optional file extension
return: string|bool

backendSupportsUnicodePaths()   X-Ref

return: bool Whether non-ASCII path characters are allowed

resolveVirtualUrl( $url )   X-Ref
Get the backend storage path corresponding to a virtual URL.
Use this function wisely.

param: string $url
return: string

getZoneLocation( $zone )   X-Ref
The the storage container and base path of a zone

param: string $zone
return: array (container, base path) or (null, null)

getZonePath( $zone )   X-Ref
Get the storage path corresponding to one of the zones

param: string $zone
return: string|null Returns null if the zone is not defined

newFile( $title, $time = false )   X-Ref
Create a new File object from the local repository

param: Title|string $title Title object or string
param: bool|string $time Time at which the image was uploaded. If this
return: File|null A File, or null if passed an invalid Title

findFile( $title, $options = array()   X-Ref
Find an instance of the named file created at the specified time
Returns false if the file does not exist. Repositories not supporting
version control should return false if the time is specified.

param: Title|string $title Title object or string
param: array $options Associative array of options:
return: File|bool False on failure

findFiles( array $items, $flags = 0 )   X-Ref
Find many files at once.

param: array $items An array of titles, or an array of findFile() options with
param: int $flags Supports:
return: array Map of (file name => File objects) for matches

findFileFromKey( $sha1, $options = array()   X-Ref
Find an instance of the file with this key, created at the specified time
Returns false if the file does not exist. Repositories not supporting
version control should return false if the time is specified.

param: string $sha1 Base 36 SHA-1 hash
param: array $options Option array, same as findFile().
return: File|bool False on failure

findBySha1( $hash )   X-Ref
Get an array or iterator of file objects for files that have a given
SHA-1 content hash.

STUB
param: string $hash SHA-1 hash
return: File[]

findBySha1s( array $hashes )   X-Ref
Get an array of arrays or iterators of file objects for files that
have the given SHA-1 content hashes.

param: array $hashes An array of hashes
return: array An Array of arrays or iterators of file objects and the hash as key

findFilesByPrefix( $prefix, $limit )   X-Ref
Return an array of files where the name starts with $prefix.

STUB
param: string $prefix The prefix to search for
param: int $limit The maximum amount of files to return
return: array

getRootUrl()   X-Ref
Get the public root URL of the repository

return: string

getThumbScriptUrl()   X-Ref
Get the URL of thumb.php

return: string

canTransformVia404()   X-Ref
Returns true if the repository can transform files via a 404 handler

return: bool

getNameFromTitle( Title $title )   X-Ref
Get the name of a file from its title object

param: Title $title
return: string

getRootDirectory()   X-Ref
Get the public zone root storage directory of the repository

return: string

getHashPath( $name )   X-Ref
Get a relative path including trailing slash, e.g. f/fa/
If the repo is not hashed, returns an empty string

param: string $name Name of file
return: string

getTempHashPath( $suffix )   X-Ref
Get a relative path including trailing slash, e.g. f/fa/
If the repo is not hashed, returns an empty string

param: string $suffix Basename of file from FileRepo::storeTemp()
return: string

getHashPathForLevel( $name, $levels )   X-Ref

param: string $name
param: int $levels
return: string

getHashLevels()   X-Ref
Get the number of hash directory levels

return: int

getName()   X-Ref
Get the name of this repository, as specified by $info['name]' to the constructor

return: string

makeUrl( $query = '', $entry = 'index' )   X-Ref
Make an url to this repo

param: string $query Query string to append
param: string $entry Entry point; defaults to index
return: string|bool False on failure

getDescriptionUrl( $name )   X-Ref
Get the URL of an image description page. May return false if it is
unknown or not applicable. In general this should only be called by the
File class, since it may return invalid results for certain kinds of
repositories. Use File::getDescriptionUrl() in user code.

In particular, it uses the article paths as specified to the repository
constructor, whereas local repositories use the local Title functions.

param: string $name
return: string

getDescriptionRenderUrl( $name, $lang = null )   X-Ref
Get the URL of the content-only fragment of the description page. For
MediaWiki this means action=render. This should only be called by the
repository's file class, since it may return invalid results. User code
should use File::getDescriptionText().

param: string $name Name of image to fetch
param: string $lang Language to fetch it in, if any.
return: string

getDescriptionStylesheetUrl()   X-Ref
Get the URL of the stylesheet to apply to description pages

return: string|bool False on failure

store( $srcPath, $dstZone, $dstRel, $flags = 0 )   X-Ref
Store a file to a given destination.

param: string $srcPath Source file system path, storage path, or virtual URL
param: string $dstZone Destination zone
param: string $dstRel Destination relative path
param: int $flags Bitwise combination of the following flags:
return: FileRepoStatus

storeBatch( array $triplets, $flags = 0 )   X-Ref
Store a batch of files

param: array $triplets (src, dest zone, dest rel) triplets as per store()
param: int $flags Bitwise combination of the following flags:
return: FileRepoStatus

cleanupBatch( array $files, $flags = 0 )   X-Ref
Deletes a batch of files.
Each file can be a (zone, rel) pair, virtual url, storage path.
It will try to delete each file, but ignores any errors that may occur.

param: array $files List of files to delete
param: int $flags Bitwise combination of the following flags:
return: FileRepoStatus

quickImport( $src, $dst, $options = null )   X-Ref
Import a file from the local file system into the repo.
This does no locking nor journaling and overrides existing files.
This function can be used to write to otherwise read-only foreign repos.
This is intended for copying generated thumbnails into the repo.

param: string $src Source file system path, storage path, or virtual URL
param: string $dst Virtual URL or storage path
param: array|string|null $options An array consisting of a key named headers
return: FileRepoStatus

quickPurge( $path )   X-Ref
Purge a file from the repo. This does no locking nor journaling.
This function can be used to write to otherwise read-only foreign repos.
This is intended for purging thumbnails.

param: string $path Virtual URL or storage path
return: FileRepoStatus

quickCleanDir( $dir )   X-Ref
Deletes a directory if empty.
This function can be used to write to otherwise read-only foreign repos.

param: string $dir Virtual URL (or storage path) of directory to clean
return: Status

quickImportBatch( array $triples )   X-Ref
Import a batch of files from the local file system into the repo.
This does no locking nor journaling and overrides existing files.
This function can be used to write to otherwise read-only foreign repos.
This is intended for copying generated thumbnails into the repo.

All path parameters may be a file system path, storage path, or virtual URL.
When "headers" are given they are used as HTTP headers if supported.

param: array $triples List of (source path, destination path, disposition)
return: FileRepoStatus

quickPurgeBatch( array $paths )   X-Ref
Purge a batch of files from the repo.
This function can be used to write to otherwise read-only foreign repos.
This does no locking nor journaling and is intended for purging thumbnails.

param: array $paths List of virtual URLs or storage paths
return: FileRepoStatus

storeTemp( $originalName, $srcPath )   X-Ref
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().

param: string $originalName The base name of the file as specified
param: string $srcPath The current location of the file.
return: FileRepoStatus Object with the URL in the value.

freeTemp( $virtualUrl )   X-Ref
Remove a temporary file or mark it for garbage collection

param: string $virtualUrl The virtual URL returned by FileRepo::storeTemp()
return: bool True on success, false on failure

concatenate( array $srcPaths, $dstPath, $flags = 0 )   X-Ref
Concatenate a list of temporary files into a target file location.

param: array $srcPaths Ordered list of source virtual URLs/storage paths
param: string $dstPath Target file system path
param: int $flags Bitwise combination of the following flags:
return: FileRepoStatus

publish($srcPath, $dstRel, $archiveRel, $flags = 0, array $options = array()   X-Ref
Copy or move a file either from a storage path, virtual URL,
or file system path, into this repository at the specified destination location.

Returns a FileRepoStatus object. On success, the value contains "new" or
"archived", to indicate whether the file was new with that name.

Options to $options include:
- headers : name/value map of HTTP headers to use in response to GET/HEAD requests

param: string $srcPath The source file system path, storage path, or URL
param: string $dstRel The destination relative path
param: string $archiveRel The relative path where the existing file is to
param: int $flags Bitfield, may be FileRepo::DELETE_SOURCE to indicate
param: array $options Optional additional parameters
return: FileRepoStatus

publishBatch( array $ntuples, $flags = 0 )   X-Ref
Publish a batch of files

param: array $ntuples (source, dest, archive) triplets or
param: int $flags Bitfield, may be FileRepo::DELETE_SOURCE to indicate
return: FileRepoStatus

initDirectory( $dir )   X-Ref
Creates a directory with the appropriate zone permissions.
Callers are responsible for doing read-only and "writable repo" checks.

param: string $dir Virtual URL (or storage path) of directory to clean
return: Status

cleanDir( $dir )   X-Ref
Deletes a directory if empty.

param: string $dir Virtual URL (or storage path) of directory to clean
return: Status

fileExists( $file )   X-Ref
Checks existence of a a file

param: string $file Virtual URL (or storage path) of file to check
return: bool

fileExistsBatch( array $files )   X-Ref
Checks existence of an array of files.

param: array $files Virtual URLs (or storage paths) of files to check
return: array Map of files and existence flags, or false

delete( $srcRel, $archiveRel )   X-Ref
Move a file to the deletion archive.
If no valid deletion archive exists, this may either delete the file
or throw an exception, depending on the preference of the repository

param: mixed $srcRel Relative path for the file to be deleted
param: mixed $archiveRel Relative path for the archive location.
return: FileRepoStatus

deleteBatch( array $sourceDestPairs )   X-Ref
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.

param: array $sourceDestPairs Array of source/destination pairs. Each element
return: FileRepoStatus

cleanupDeletedBatch( array $storageKeys )   X-Ref
Delete files in the deleted directory if they are not referenced in the filearchive table

STUB
param: array $storageKeys

getDeletedHashPath( $key )   X-Ref
Get a relative path for a deletion archive key,
e.g. s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg

param: string $key
return: string

resolveToStoragePath( $path )   X-Ref
If a path is a virtual URL, resolve it to a storage path.
Otherwise, just return the path as it is.

param: string $path
return: string

getLocalCopy( $virtualUrl )   X-Ref
Get a local FS copy of a file with a given virtual URL/storage path.
Temporary files may be purged when the file object falls out of scope.

param: string $virtualUrl
return: TempFSFile|null Returns null on failure

getLocalReference( $virtualUrl )   X-Ref
Get a local FS file with a given virtual URL/storage path.
The file is either an original or a copy. It should not be changed.
Temporary files may be purged when the file object falls out of scope.

param: string $virtualUrl
return: FSFile|null Returns null on failure.

getFileProps( $virtualUrl )   X-Ref
Get properties of a file with a given virtual URL/storage path.
Properties should ultimately be obtained via FSFile::getProps().

param: string $virtualUrl
return: array

getFileTimestamp( $virtualUrl )   X-Ref
Get the timestamp of a file with a given virtual URL/storage path

param: string $virtualUrl
return: string|bool False on failure

getFileSize( $virtualUrl )   X-Ref
Get the size of a file with a given virtual URL/storage path

param: string $virtualUrl
return: int|bool False on failure

getFileSha1( $virtualUrl )   X-Ref
Get the sha1 (base 36) of a file with a given virtual URL/storage path

param: string $virtualUrl
return: string|bool

streamFile( $virtualUrl, $headers = array()   X-Ref
Attempt to stream a file with the given virtual URL/storage path

param: string $virtualUrl
param: array $headers Additional HTTP headers to send on success
return: bool Success

enumFiles( $callback )   X-Ref
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.

param: callable $callback
return: void

enumFilesInStorage( $callback )   X-Ref
Call a callback function for every public file in the repository.
May use either the database or the filesystem.

param: callable $callback
return: void

validateFilename( $filename )   X-Ref
Determine if a relative path is valid, i.e. not blank or involving directory traveral

param: string $filename
return: bool

getErrorCleanupFunction()   X-Ref
Get a callback function to use for cleaning error message parameters

return: array

paranoidClean( $param )   X-Ref
Path disclosure protection function

param: string $param
return: string

passThrough( $param )   X-Ref
Path disclosure protection function

param: string $param
return: string

newFatal( $message )   X-Ref
Create a new fatal error

param: string $message
return: FileRepoStatus

newGood( $value = null )   X-Ref
Create a new good result

param: null|string $value
return: FileRepoStatus

checkRedirect( Title $title )   X-Ref
Checks if there is a redirect named as $title. If there is, return the
title object. If not, return false.
STUB

param: Title $title Title of image
return: bool

invalidateImageRedirect( Title $title )   X-Ref
Invalidates image redirect cache related to that image
Doesn't do anything for repositories that don't support image redirects.

STUB
param: Title $title Title of image

getDisplayName()   X-Ref
Get the human-readable name of the repo

return: string

nameForThumb( $name )   X-Ref
Get the portion of the file that contains the origin file name.
If that name is too long, then the name "thumbnail.<ext>" will be given.

param: string $name
return: string

isLocal()   X-Ref
Returns true if this the local file repository.

return: bool

getSharedCacheKey( )   X-Ref
Get a key on the primary cache for this repository.
Returns false if the repository's cache is not accessible at this site.
The parameters are the parts of the key, as for wfMemcKey().

STUB
return: bool

getLocalCacheKey( )   X-Ref
Get a key for this repo in the local cache domain. These cache keys are
not shared with remote instances of the repo.
The parameters are the parts of the key, as for wfMemcKey().

return: string

getTempRepo()   X-Ref
Get an temporary FileRepo associated with this repo.
Files will be created in the temp zone of this repo and
thumbnails in a /temp subdirectory in thumb zone of this repo.
It will have the same backend as this repo.

return: TempFileRepo

getUploadStash( User $user = null )   X-Ref
Get an UploadStash associated with this repo.

param: User $user
return: UploadStash

assertWritableRepo()   X-Ref
Throw an exception if this repo is read-only by design.
This does not and should not check getReadOnlyReason().

return: void

getInfo()   X-Ref
Return information about the repository.

return: array

Class: TempFileRepo  - X-Ref

FileRepo for temporary files created via FileRepo::getTempRepo()

getTempRepo()   X-Ref
No description



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1