FileRepo Class Reference
[FileRepo]

Base class for file repositories Do not instantiate, use a derived class. More...

Inherited by ForeignAPIRepo, FSRepo, and NullRepo.

List of all members.

Public Member Functions

 __construct ($info)
 newFile ($title, $time=false)
 Create a new File object from the local repository.
 findFile ($title, $time=false, $flags=0)
 Find an instance of the named file created at the specified time Returns false if the file does not exist.
 findFiles ($titles)
 newFileFromKey ($sha1, $time=false)
 Create a new File object from the local repository.
 findFileFromKey ($sha1, $time=false, $flags=0)
 Find an instance of the file with this key, created at the specified time Returns false if the file does not exist.
 getThumbScriptUrl ()
 Get the URL of thumb.php.
 canTransformVia404 ()
 Returns true if the repository can transform files via a 404 handler.
 getNameFromTitle ($title)
 Get the name of an image from its title object.
 getHashPath ($name)
 Get a relative path including trailing slash, e.g.
 getName ()
 Get the name of this repository, as specified by $info['name]' to the constructor.
 getDescriptionUrl ($name)
 Get the URL of an image description page.
 getDescriptionRenderUrl ($name, $lang=null)
 Get the URL of the content-only fragment of the description page.
 store ($srcPath, $dstZone, $dstRel, $flags=0)
 Store a file to a given destination.
 storeBatch ($triplets, $flags=0)
 Store a batch of files.
 storeTemp ($originalName, $srcPath)
 Pick a random name in the temp zone and store a file to it.
 freeTemp ($virtualUrl)
 Remove a temporary file or mark it for garbage collection.
 publish ($srcPath, $dstRel, $archiveRel, $flags=0)
 Copy or move a file either from the local filesystem or from an mwrepo:// virtual URL, into this repository at the specified destination location.
 publishBatch ($triplets, $flags=0)
 Publish a batch of files.
 deleteBatch ($sourceDestPairs)
 Move a group of files to the deletion archive.
 delete ($srcRel, $archiveRel)
 Move a file to the deletion archive.
 getFileProps ($virtualUrl)
 Get properties of a file with a given virtual URL The virtual URL must refer to this repo Properties should ultimately be obtained via File::getPropsFromPath().
 enumFiles ($callback)
 Call a callback function for every file in the repository May use either the database or the filesystem STUB.
 validateFilename ($filename)
 Determine if a relative path is valid, i.e.
 paranoidClean ($param)
 #@+ Path disclosure protection functions
 passThrough ($param)
 getErrorCleanupFunction ()
 Get a callback function to use for cleaning error message parameters.
 newFatal ($message)
 #@-
 newGood ($value=null)
 Create a new good result.
 cleanupDeletedBatch ($storageKeys)
 Delete files in the deleted directory if they are not referenced in the filearchive table STUB.
 checkRedirect ($title)
 Checks if there is a redirect named as $title.
 invalidateImageRedirect ($title)
 Invalidates image redirect cache related to that image.
 findBySha1 ($hash)
 getDisplayName ()
 Get the human-readable name of the repo.
 getSlaveDB ()
 getMasterDB ()
 getMemcKey ($key)

Static Public Member Functions

static isVirtualUrl ($url)
 Determine if a string is an mwrepo:// URL.
static getHashPathForLevel ($name, $levels)

Public Attributes

const DELETE_SOURCE = 1
const FIND_PRIVATE = 1
const FIND_IGNORE_REDIRECT = 2
const OVERWRITE = 2
const OVERWRITE_SAME = 4
 $thumbScriptUrl
 $transformVia404
 $descBaseUrl
 $scriptDirUrl
 $articleUrl
 $fetchDescription
 $initialCapital
 $pathDisclosureProtection = 'paranoid'
 $descriptionCacheExpiry
 $apiThumbCacheExpiry
 $hashLevels
 $fileFactory = false
 Factory functions for creating new files Override these in the base class.
 $oldFileFactory = false
 $fileFactoryKey = false
 $oldFileFactoryKey = false


Detailed Description

Base class for file repositories Do not instantiate, use a derived class.

Definition at line 8 of file FileRepo.php.


Constructor & Destructor Documentation

FileRepo::__construct ( info  ) 

Reimplemented in ForeignAPIRepo, ForeignDBRepo, ForeignDBViaLBRepo, FSRepo, and NullRepo.

Definition at line 27 of file FileRepo.php.


Member Function Documentation

FileRepo::canTransformVia404 (  ) 

Returns true if the repository can transform files via a 404 handler.

Definition at line 208 of file FileRepo.php.

FileRepo::checkRedirect ( title  ) 

Checks if there is a redirect named as $title.

If there is, return the title object. If not, return false. STUB

Parameters:
Title $title Title of image

Reimplemented in LocalRepo.

Definition at line 526 of file FileRepo.php.

Referenced by findFile().

FileRepo::cleanupDeletedBatch ( storageKeys  ) 

Delete files in the deleted directory if they are not referenced in the filearchive table STUB.

Reimplemented in LocalRepo.

Definition at line 517 of file FileRepo.php.

FileRepo::delete ( srcRel,
archiveRel 
)

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

Parameters:
mixed $srcRel Relative path for the file to be deleted
mixed $archiveRel Relative path for the archive location. Relative to a private archive directory.
Returns:
WikiError object (wikitext-formatted), or true for success

Definition at line 430 of file FileRepo.php.

References deleteBatch().

FileRepo::deleteBatch ( sourceDestPairs  )  [abstract]

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 FSRepo 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:
array $sourceDestPairs Array 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 in ForeignAPIRepo, ForeignDBRepo, ForeignDBViaLBRepo, FSRepo, and NullRepo.

Referenced by delete().

FileRepo::enumFiles ( callback  ) 

Call a callback function for every file in the repository May use either the database or the filesystem STUB.

Reimplemented in FSRepo.

Definition at line 446 of file FileRepo.php.

FileRepo::findBySha1 ( hash  ) 

Reimplemented in ForeignAPIRepo, and LocalRepo.

Definition at line 541 of file FileRepo.php.

FileRepo::findFile ( title,
time = false,
flags = 0 
)

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.

Parameters:
mixed $title Title object or string
mixed $time 14-character timestamp, or false for the current version

Definition at line 86 of file FileRepo.php.

References $flags, $title, checkRedirect(), File::DELETED_FILE, FIND_IGNORE_REDIRECT, FIND_PRIVATE, Title::makeTitleSafe(), and newFile().

Referenced by findFiles().

FileRepo::findFileFromKey ( sha1,
time = false,
flags = 0 
)

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.

Parameters:
string $sha1 string
mixed $time 14-character timestamp, or false for the current version

Definition at line 175 of file FileRepo.php.

References $flags, File::DELETED_FILE, FIND_PRIVATE, and newFileFromKey().

FileRepo::findFiles ( titles  ) 

Reimplemented in LocalRepo.

Definition at line 136 of file FileRepo.php.

References $file, $result, $title, and findFile().

FileRepo::freeTemp ( virtualUrl  ) 

Remove a temporary file or mark it for garbage collection.

Parameters:
string $virtualUrl The virtual URL returned by storeTemp
Returns:
boolean True on success, false on failure STUB

Reimplemented in FSRepo.

Definition at line 364 of file FileRepo.php.

FileRepo::getDescriptionRenderUrl ( name,
lang = null 
)

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

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

Definition at line 300 of file FileRepo.php.

References $name, getDescriptionUrl(), wfAppendQuery(), and wfUrlencode().

FileRepo::getDescriptionUrl ( name  ) 

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.

Definition at line 266 of file FileRepo.php.

References $name, and wfUrlencode().

Referenced by getDescriptionRenderUrl().

FileRepo::getDisplayName (  ) 

Get the human-readable name of the repo.

Returns:
string

Definition at line 549 of file FileRepo.php.

References wfEmptyMsg(), and wfMsg().

FileRepo::getErrorCleanupFunction (  ) 

Get a callback function to use for cleaning error message parameters.

Reimplemented in FSRepo.

Definition at line 485 of file FileRepo.php.

FileRepo::getFileProps ( virtualUrl  )  [abstract]

Get properties of a file with a given virtual URL The virtual URL must refer to this repo Properties should ultimately be obtained via File::getPropsFromPath().

Reimplemented in ForeignAPIRepo, FSRepo, and NullRepo.

FileRepo::getHashPath ( name  ) 

Get a relative path including trailing slash, e.g.

f/fa/ If the repo is not hashed, returns an empty string

Definition at line 246 of file FileRepo.php.

References $name, and getHashPathForLevel().

Referenced by ForeignAPIRepo::getThumbUrlFromCache(), and FSRepo::storeTemp().

static FileRepo::getHashPathForLevel ( name,
levels 
) [static]

Definition at line 229 of file FileRepo.php.

References $i, $name, and $path.

Referenced by getHashPath().

FileRepo::getMasterDB (  ) 

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 565 of file FileRepo.php.

References wfGetDB().

Referenced by LocalRepo::cleanupDeletedBatch().

FileRepo::getMemcKey ( key  ) 

Definition at line 569 of file FileRepo.php.

References getSlaveDB(), and wfWikiID().

Referenced by LocalRepo::checkRedirect(), and invalidateImageRedirect().

FileRepo::getName (  ) 

Get the name of this repository, as specified by $info['name]' to the constructor.

Definition at line 253 of file FileRepo.php.

FileRepo::getNameFromTitle ( title  ) 

Get the name of an image from its title object.

Definition at line 215 of file FileRepo.php.

References $name, $title, $wgCapitalLinks, and $wgContLang.

FileRepo::getSlaveDB (  ) 

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 561 of file FileRepo.php.

References wfGetDB().

Referenced by getMemcKey().

FileRepo::getThumbScriptUrl (  ) 

Get the URL of thumb.php.

Definition at line 201 of file FileRepo.php.

FileRepo::invalidateImageRedirect ( title  ) 

Invalidates image redirect cache related to that image.

Parameters:
Title $title Title of image

Definition at line 535 of file FileRepo.php.

References $title, $wgMemc, and getMemcKey().

static FileRepo::isVirtualUrl ( url  )  [static]

Determine if a string is an mwrepo:// URL.

Definition at line 47 of file FileRepo.php.

References $url.

Referenced by RepoGroup::getFileProps().

FileRepo::newFatal ( message  ) 

#@-

Create a new fatal error

Definition at line 500 of file FileRepo.php.

Referenced by FSRepo::publishBatch(), and FSRepo::storeBatch().

FileRepo::newFile ( title,
time = false 
)

Create a new File object from the local repository.

Parameters:
mixed $title Title object or string
mixed $time Time at which the image was uploaded. If this is specified, the returned object will be an instance of the repository's old file class instead of a current file. Repositories not supporting version control should return false if this parameter is set.

Reimplemented in ForeignAPIRepo, and NullRepo.

Definition at line 60 of file FileRepo.php.

References $title, and Title::makeTitleSafe().

Referenced by findFile().

FileRepo::newFileFromKey ( sha1,
time = false 
)

Create a new File object from the local repository.

Parameters:
mixed $sha1 SHA-1 key
mixed $time Time at which the image was uploaded. If this is specified, the returned object will be an instance of the repository's old file class instead of a current file. Repositories not supporting version control should return false if this parameter is set.

Definition at line 155 of file FileRepo.php.

Referenced by findFileFromKey().

FileRepo::newGood ( value = null  ) 

Create a new good result.

Definition at line 509 of file FileRepo.php.

Referenced by LocalRepo::cleanupDeletedBatch(), FSRepo::deleteBatch(), FSRepo::publishBatch(), and FSRepo::storeBatch().

FileRepo::paranoidClean ( param  ) 

#@+ Path disclosure protection functions

Definition at line 479 of file FileRepo.php.

FileRepo::passThrough ( param  ) 

Definition at line 480 of file FileRepo.php.

FileRepo::publish ( srcPath,
dstRel,
archiveRel,
flags = 0 
)

Copy or move a file either from the local filesystem or from an mwrepo:// virtual URL, 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.

Parameters:
string $srcPath The source path or URL
string $dstRel The destination relative path
string $archiveRel The relative path where the existing file is to be archived, if there is one. Relative to the public zone root.
integer $flags Bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source file should be deleted if possible

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 382 of file FileRepo.php.

References $flags, $status, and publishBatch().

FileRepo::publishBatch ( triplets,
flags = 0 
) [abstract]

Publish a batch of files.

Parameters:
array $triplets (source,dest,archive) triplets as per publish()
integer $flags Bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible

Reimplemented in ForeignAPIRepo, FSRepo, and NullRepo.

Referenced by publish().

FileRepo::store ( srcPath,
dstZone,
dstRel,
flags = 0 
)

Store a file to a given destination.

Parameters:
string $srcPath Source path or virtual URL
string $dstZone Destination zone
string $dstRel Destination relative path
integer $flags Bitwise combination of the following flags: self::DELETE_SOURCE Delete the source file after upload self::OVERWRITE Overwrite an existing destination file instead of failing self::OVERWRITE_SAME Overwrite the file if the destination exists and has the same contents as the source
Returns:
FileRepoStatus

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 332 of file FileRepo.php.

References $flags, $status, and storeBatch().

Referenced by FSRepo::storeTemp().

FileRepo::storeBatch ( triplets,
flags = 0 
) [abstract]

Store a batch of files.

Parameters:
array $triplets (src,zone,dest) triplets as per store()
integer $flags Flags as per store

Reimplemented in ForeignAPIRepo, FSRepo, and NullRepo.

Referenced by store().

FileRepo::storeTemp ( originalName,
srcPath 
) [abstract]

Pick a random name in the temp zone and store a file to it.

Returns a FileRepoStatus object with the URL in the value.

Parameters:
string $originalName The base name of the file as specified by the user. The file extension will be maintained.
string $srcPath The current location of the file.

Reimplemented in ForeignAPIRepo, FSRepo, and NullRepo.

FileRepo::validateFilename ( filename  ) 

Determine if a relative path is valid, i.e.

not blank or involving directory traveral

Definition at line 453 of file FileRepo.php.

References $filename, and wfIsWindows().

Referenced by FSRepo::deleteBatch(), FSRepo::publishBatch(), and FSRepo::storeBatch().


Member Data Documentation

FileRepo::$apiThumbCacheExpiry

Reimplemented in ForeignAPIRepo.

Definition at line 18 of file FileRepo.php.

FileRepo::$articleUrl

Definition at line 16 of file FileRepo.php.

FileRepo::$descBaseUrl

Definition at line 16 of file FileRepo.php.

FileRepo::$descriptionCacheExpiry

Definition at line 18 of file FileRepo.php.

FileRepo::$fetchDescription

Definition at line 16 of file FileRepo.php.

FileRepo::$fileFactory = false

Factory functions for creating new files Override these in the base class.

Reimplemented in ForeignAPIRepo, ForeignDBRepo, ForeignDBViaLBRepo, FSRepo, and LocalRepo.

Definition at line 24 of file FileRepo.php.

FileRepo::$fileFactoryKey = false

Definition at line 25 of file FileRepo.php.

FileRepo::$hashLevels

Definition at line 18 of file FileRepo.php.

FileRepo::$initialCapital

Definition at line 16 of file FileRepo.php.

FileRepo::$oldFileFactory = false

Reimplemented in FSRepo, and LocalRepo.

Definition at line 24 of file FileRepo.php.

FileRepo::$oldFileFactoryKey = false

Definition at line 25 of file FileRepo.php.

FileRepo::$pathDisclosureProtection = 'paranoid'

Reimplemented in FSRepo.

Definition at line 17 of file FileRepo.php.

FileRepo::$scriptDirUrl

Definition at line 16 of file FileRepo.php.

FileRepo::$thumbScriptUrl

Definition at line 15 of file FileRepo.php.

FileRepo::$transformVia404

Definition at line 15 of file FileRepo.php.

Definition at line 9 of file FileRepo.php.

Referenced by LocalFileMoveBatch::execute(), and LocalFile::publish().

Definition at line 11 of file FileRepo.php.

Referenced by ApiDelete::deleteFile(), and findFile().

Definition at line 10 of file FileRepo.php.

Referenced by findFile(), and findFileFromKey().

Definition at line 12 of file FileRepo.php.

Definition at line 13 of file FileRepo.php.

Referenced by LocalFileRestoreBatch::execute().


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

Generated on Sat Sep 5 02:08:37 2009 for MediaWiki by  doxygen 1.5.9