File Class Reference
[FileRepo]

Implements some public methods and some protected utility functions which are required by multiple child classes. More...

Inherited by ForeignAPIFile, LocalFile, and UnregisteredLocalFile.

List of all members.

Public Member Functions

 __construct ($title, $repo)
 Call this constructor from child classes.
 __get ($name)
 upgradeRow ()
 Upgrade the database row if there is one Called by ImagePage STUB.
 getName ()
 Return the name of this file.
 getExtension ()
 Get the file extension, e.g.
 getTitle ()
 Return the associated title object.
 getOriginalTitle ()
 Return the title used to find this file.
 getUrl ()
 Return the URL of the file.
 getFullUrl ()
 Return a fully-qualified URL to the file.
 getViewURL ()
 getPath ()
 Return the full filesystem path to the file.
 getFullPath ()
 Alias for getPath().
 getWidth ($page=1)
 Return the width of the image.
 getHeight ($page=1)
 Return the height of the image.
 getUser ($type='text')
 Returns ID or name of user who uploaded the file STUB.
 getLength ()
 Get the duration of a media file in seconds.
 getMetadata ()
 Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
 getBitDepth ()
 Return the bit depth of the file Overridden by LocalFile STUB.
 getSize ()
 Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB.
 getMimeType ()
 Returns the mime type of the file.
 getMediaType ()
 Return the type of the media in the file.
 canRender ()
 Checks if the output of transform() for this file is likely to be valid.
 mustRender ()
 Return true if the file is of a type that can't be directly rendered by typical browsers and needs to be re-rasterized.
 allowInlineDisplay ()
 Alias for canRender().
 isSafeFile ()
 Determines if this media file is in a format that is unlikely to contain viruses or malicious content.
 isTrustedFile ()
 Returns true if the file is flagged as trusted.
 exists ()
 Returns true if file exists in the repository.
 isVisible ()
 Returns true if file exists in the repository and can be included in a page.
 getTransformScript ()
 getUnscaledThumb ($page=false)
 Get a ThumbnailImage which is the same size as the source.
 thumbName ($params)
 Return the file name of a thumbnail with the specified parameters.
 createThumb ($width, $height=-1)
 Create a thumbnail of the image having the specified width/height.
 getThumbnail ($width, $height=-1, $render=true)
 As createThumb, but returns a ThumbnailImage object.
 transform ($params, $flags=0)
 Transform a media file.
 migrateThumbFile ($thumbName)
 Hook into transform() to allow migration of thumbnail files STUB Overridden by LocalFile.
 getHandler ()
 Get a MediaHandler instance for this file.
 iconThumb ()
 Get a ThumbnailImage representing a file type icon.
 getLastError ()
 Get last thumbnailing error.
 getThumbnails ()
 Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.
 purgeCache ()
 Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
 purgeDescription ()
 Purge the file description page, but don't go after pages using the file.
 purgeEverything ()
 Purge metadata and all affected pages when the file is created, deleted, or majorly updated.
 getHistory ($limit=null, $start=null, $end=null, $inc=true)
 Return a fragment of the history of file.
 nextHistoryLine ()
 Return the history of this file, line by line.
 resetHistory ()
 Reset the history pointer to the first element of the history.
 getHashPath ()
 Get the filename hash component of the directory including trailing slash, e.g.
 getRel ()
 Get the path of the file relative to the public zone root.
 getUrlRel ()
 Get urlencoded relative path of the file.
 getArchiveRel ($suffix=false)
 Get the relative path for an archive file.
 getThumbRel ($suffix=false)
 Get relative path for a thumbnail file.
 getArchivePath ($suffix=false)
 Get the path of the archive directory, or a particular file if $suffix is specified.
 getThumbPath ($suffix=false)
 Get the path of the thumbnail directory, or a particular file if $suffix is specified.
 getArchiveUrl ($suffix=false)
 Get the URL of the archive directory, or a particular file if $suffix is specified.
 getThumbUrl ($suffix=false)
 Get the URL of the thumbnail directory, or a particular file if $suffix is specified.
 getArchiveVirtualUrl ($suffix=false)
 Get the virtual URL for an archive file or directory.
 getThumbVirtualUrl ($suffix=false)
 Get the virtual URL for a thumbnail file or directory.
 getVirtualUrl ($suffix=false)
 Get the virtual URL for the file itself.
 isHashed ()
 readOnlyError ()
 recordUpload ($oldver, $desc, $license= '', $copyStatus= '', $source= '', $watch=false)
 Record a file upload in the upload log and the image table STUB Overridden by LocalFile.
 publish ($srcPath, $flags=0)
 Move or copy a file to its public location.
 getLinksTo ($options=array())
 Get an array of Title objects which are articles which use this file Also adds their IDs to the link cache.
 formatMetadata ()
 isLocal ()
 Returns true if the file comes from the local file repository.
 getRepoName ()
 Returns the name of the repository.
 getRepo ()
 isOld ()
 Returns true if the image is an old version STUB.
 isDeleted ($field)
 Is this file a "deleted" file in a private archive? STUB.
 wasDeleted ()
 Was this file ever deleted from the wiki?
 move ($target)
 Move file to the new title.
 delete ($reason, $suppress=false)
 Delete all versions of the file.
 restore ($versions=array(), $unsuppress=false)
 Restore all or specified deleted revisions to the given file.
 isMultipage ()
 Returns 'true' if this image is a multipage document, e.g.
 pageCount ()
 Returns the number of pages of a multipage document, or NULL for documents which aren't multipage documents.
 getImageSize ($fileName)
 Get an image size array like that returned by getimagesize(), or false if it can't be determined.
 getDescriptionUrl ()
 Get the URL of the image description page.
 getDescriptionText ()
 Get the HTML text of the description page, if available.
 getDescription ()
 Get discription of file revision STUB.
 getTimestamp ()
 Get the 14-character timestamp of the file upload, or false if it doesn't exist.
 getSha1 ()
 Get the SHA-1 base 36 hash of the file.
 userCan ($field)
 Determine if the current user is allowed to view a particular field of this file, if it's marked as deleted.
 getLongDesc ()
 getShortDesc ()
 getDimensionsString ()
 getRedirected ()
 getRedirectedTitle ()
 redirectedFrom ($from)

Static Public Member Functions

static normalizeExtension ($ext)
 Normalize a file extension to the common form, and ensure it's clean.
static checkExtensionCompatibility (File $old, $new)
 Checks if file extensions are compatible.
static splitMime ($mime)
 Split an internet media type into its two components; if not a two-part name, set the minor type to 'unknown'.
static scaleHeight ($srcWidth, $srcHeight, $dstWidth)
 Calculate the height of a thumbnail using the source and destination width.
static getPropsFromPath ($path, $ext=true)
 Get an associative array containing information about a file in the local filesystem.
static sha1Base36 ($path)
 Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits.

Public Attributes

const DELETED_FILE = 1
const DELETED_COMMENT = 2
const DELETED_USER = 4
const DELETED_RESTRICTED = 8
const RENDER_NOW = 1
const DELETE_SOURCE = 1
 $repo
 Some member variables can be lazy-initialised using __get().
 $title
 $lastError
 $redirected
 $redirectedTitle

Protected Member Functions

 getCanRender ()
 Accessor for __get().
 getIsSafeFile ()
 Accessor for __get().
 _getIsSafeFile ()
 Uncached accessor.


Detailed Description

Implements some public methods and some protected utility functions which are required by multiple child classes.

Contains stub functionality for unimplemented public methods.

Stub functions which should be overridden are marked with STUB. Some more concrete functions are also typically overridden by child classes.

Note that only the repo object knows what its file class is called. You should never name a file class explictly outside of the repo class. Instead use the repo's factory functions to generate file objects, for example:

RepoGroup::singleton()->getLocalRepo()->newFile($title);

The convenience functions wfLocalFile() and wfFindFile() should be sufficient in most cases.

Definition at line 22 of file File.php.


Constructor & Destructor Documentation

File::__construct ( title,
repo 
)

Call this constructor from child classes.

Reimplemented in LocalFile.

Definition at line 54 of file File.php.

References $repo, and $title.


Member Function Documentation

File::__get ( name  ) 

Definition at line 59 of file File.php.

References $name.

File::_getIsSafeFile (  )  [protected]

Uncached accessor.

Definition at line 367 of file File.php.

References $type, $wgTrustedMediaFormats, allowInlineDisplay(), getMediaType(), getMimeType(), and isTrustedFile().

Referenced by isSafeFile().

File::allowInlineDisplay (  ) 

Alias for canRender().

Definition at line 339 of file File.php.

References canRender().

Referenced by _getIsSafeFile().

File::canRender (  ) 

Checks if the output of transform() for this file is likely to be valid.

If this is false, various user elements will display a placeholder instead.

Currently, this checks if the file is an image format that can be converted to a format supported by all browsers (namely GIF, PNG and JPEG), or if it is an SVG image and SVG conversion is enabled.

Definition at line 308 of file File.php.

References getHandler().

Referenced by allowInlineDisplay(), getCanRender(), getViewURL(), ForeignAPIFile::transform(), and transform().

static File::checkExtensionCompatibility ( File old,
new 
) [static]

Checks if file extensions are compatible.

Parameters:
$old File Old file
$new string New name

Definition at line 99 of file File.php.

References $n, getMimeType(), normalizeExtension(), and MimeMagic::singleton().

Referenced by Title::isValidMoveOperation().

File::createThumb ( width,
height = -1 
)

Create a thumbnail of the image having the specified width/height.

The thumbnail will not be created if the width is larger than the image's width. Let the browser do the scaling in this case. The thumbnail is stored on disk and is only computed if the thumbnail file does not exist OR if it is older than the image. Returns the URL.

Keeps aspect ratio of original image. If both width and height are specified, the generated image will be no bigger than width x height, and will also have correct aspect ratio.

Parameters:
integer $width maximum width of the generated thumbnail
integer $height maximum height of the image (optional)

Definition at line 490 of file File.php.

References transform().

Referenced by getViewURL().

File::delete ( reason,
suppress = false 
)

Delete all versions of the file.

Moves the files into an archive directory (or deletes them) and removes the database rows.

Cache purging is done; logging is caller's responsibility.

Parameters:
$reason 
$suppress,hide content from sysops?
Returns:
true on success, false on some kind of failure STUB Overridden by LocalFile

Reimplemented in ForeignDBFile, and LocalFile.

Definition at line 987 of file File.php.

References readOnlyError().

File::exists (  ) 

Returns true if file exists in the repository.

Overridden by LocalFile to avoid unnecessary stat calls.

Returns:
boolean Whether file exists in the repository.

Reimplemented in ForeignAPIFile, and LocalFile.

Definition at line 409 of file File.php.

References getPath().

Referenced by isVisible().

File::formatMetadata (  ) 

Definition at line 900 of file File.php.

References getHandler(), and getMetadata().

File::getArchivePath ( suffix = false  ) 

Get the path of the archive directory, or a particular file if $suffix is specified.

Definition at line 759 of file File.php.

References $suffix, and getArchiveRel().

File::getArchiveRel ( suffix = false  ) 

Get the relative path for an archive file.

Definition at line 739 of file File.php.

References $path, $suffix, and getHashPath().

Referenced by getArchivePath().

File::getArchiveUrl ( suffix = false  ) 

Get the URL of the archive directory, or a particular file if $suffix is specified.

Definition at line 769 of file File.php.

References $path, $suffix, and getHashPath().

File::getArchiveVirtualUrl ( suffix = false  ) 

Get the virtual URL for an archive file or directory.

Definition at line 789 of file File.php.

References $path, $suffix, and getHashPath().

File::getBitDepth (  ) 

Return the bit depth of the file Overridden by LocalFile STUB.

Reimplemented in LocalFile.

Definition at line 274 of file File.php.

File::getCanRender (  )  [protected]

Accessor for __get().

Definition at line 318 of file File.php.

References canRender().

File::getDescription (  ) 

Get discription of file revision STUB.

Reimplemented in ForeignAPIFile, and LocalFile.

Definition at line 1104 of file File.php.

File::getDescriptionText (  ) 

Get the HTML text of the description page, if available.

Reimplemented in ForeignDBFile, and LocalFile.

Definition at line 1071 of file File.php.

References $key, $obj, $res, $wgContLang, $wgMemc, Http::get(), getName(), wfDebug(), and wfMemcKey().

File::getDescriptionUrl (  ) 

Get the URL of the image description page.

May return false if it is unknown or not applicable.

Reimplemented in ForeignAPIFile, ForeignDBFile, and LocalFile.

Definition at line 1064 of file File.php.

References getName().

File::getDimensionsString (  ) 

Definition at line 1238 of file File.php.

References getHandler().

File::getExtension (  ) 

Get the file extension, e.g.

"svg"

Definition at line 143 of file File.php.

References $n, getName(), and normalizeExtension().

Referenced by ForeignAPIFile::getMimeType(), iconThumb(), and thumbName().

File::getFullPath (  ) 

Alias for getPath().

Definition at line 220 of file File.php.

References getPath().

File::getFullUrl (  ) 

Return a fully-qualified URL to the file.

Upload URL paths _may or may not_ be fully qualified, so we check. Local paths are assumed to belong on $wgServer.

Returns:
string

Definition at line 182 of file File.php.

References getUrl(), and wfExpandUrl().

File::getHandler (  ) 

File::getHashPath (  ) 

Get the filename hash component of the directory including trailing slash, e.g.

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

Definition at line 717 of file File.php.

References getName().

Referenced by getArchiveRel(), getArchiveUrl(), getArchiveVirtualUrl(), OldLocalFile::getRel(), getRel(), ForeignAPIFile::getThumbPath(), OldLocalFile::getUrlRel(), and getUrlRel().

File::getHeight ( page = 1  ) 

Return the height of the image.

Returns false if the height is unknown or undefined

STUB Overridden by LocalFile, UnregisteredLocalFile

Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.

Definition at line 240 of file File.php.

File::getHistory ( limit = null,
start = null,
end = null,
inc = true 
)

Return a fragment of the history of file.

STUB

Parameters:
$limit integer Limit of rows to return
$start timestamp Only revisions older than $start will be returned
$end timestamp Only revisions newer than $end will be returned
$inc bool Include the endpoints of the time range

Reimplemented in LocalFile.

Definition at line 688 of file File.php.

File::getImageSize ( fileName  ) 

Get an image size array like that returned by getimagesize(), or false if it can't be determined.

Parameters:
string $fileName The filename
Returns:
array

Reimplemented in UnregisteredLocalFile.

Definition at line 1053 of file File.php.

References getHandler().

File::getIsSafeFile (  )  [protected]

Accessor for __get().

Definition at line 362 of file File.php.

References isSafeFile().

File::getLastError (  ) 

Get last thumbnailing error.

Largely obsolete.

Definition at line 631 of file File.php.

File::getLength (  ) 

Get the duration of a media file in seconds.

Definition at line 253 of file File.php.

References getHandler().

File::getLinksTo ( options = array()  ) 

Get an array of Title objects which are articles which use this file Also adds their IDs to the link cache.

This is mostly copied from Title::getLinksTo()

Deprecated:
Use HTMLCacheUpdate, this function uses too much memory

Definition at line 868 of file File.php.

References $db, $options, $res, $row, getName(), Title::newFromRow(), LinkCache::singleton(), wfGetDB(), wfProfileIn(), and wfProfileOut().

File::getLongDesc (  ) 

Definition at line 1220 of file File.php.

References MediaHandler::getGeneralLongDesc(), and getHandler().

File::getMediaType (  ) 

Return the type of the media in the file.

Use the value returned by this function with the MEDIATYPE_xxx constants. Overridden by LocalFile, STUB

Reimplemented in ForeignAPIFile, and LocalFile.

Definition at line 296 of file File.php.

Referenced by _getIsSafeFile().

File::getMetadata (  ) 

Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.

Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.

Definition at line 267 of file File.php.

Referenced by formatMetadata().

File::getMimeType (  ) 

Returns the mime type of the file.

Overridden by LocalFile, UnregisteredLocalFile STUB

Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.

Definition at line 288 of file File.php.

Referenced by _getIsSafeFile(), checkExtensionCompatibility(), getHandler(), getViewURL(), and thumbName().

File::getName (  ) 

File::getOriginalTitle (  ) 

Return the title used to find this file.

Definition at line 160 of file File.php.

References getRedirectedTitle().

File::getPath (  ) 

Return the full filesystem path to the file.

Note that this does not mean that a file actually exists under that location.

This path depends on whether directory hashing is active or not, i.e. whether the files are all found in the same directory, or in hashed paths like /images/3/3c.

May return false if the file is not locally accessible.

Reimplemented in ForeignAPIFile.

Definition at line 210 of file File.php.

References getRel().

Referenced by exists(), getFullPath(), UnregisteredLocalFile::getImageSize(), UnregisteredLocalFile::getMetadata(), getSha1(), and getTimestamp().

static File::getPropsFromPath ( path,
ext = true 
) [static]

Get an associative array containing information about a file in the local filesystem.

Parameters:
string $path Absolute local filesystem path
mixed $ext The file extension, or true to extract it from the filename. Set it to false to ignore the extension.

Definition at line 1145 of file File.php.

References $ext, $path, getHandler(), sha1Base36(), MimeMagic::singleton(), splitMime(), wfDebug(), wfProfileIn(), and wfProfileOut().

Referenced by RepoGroup::getFileProps(), FSRepo::getFileProps(), and UploadForm::internalProcessUpload().

File::getRedirected (  ) 

Definition at line 1247 of file File.php.

File::getRedirectedTitle (  ) 

Definition at line 1251 of file File.php.

References Title::makeTitle().

Referenced by getOriginalTitle().

File::getRel (  ) 

Get the path of the file relative to the public zone root.

Reimplemented in OldLocalFile.

Definition at line 727 of file File.php.

References getHashPath(), and getName().

Referenced by getPath(), and getThumbRel().

File::getRepo (  ) 

Definition at line 927 of file File.php.

File::getRepoName (  ) 

Returns the name of the repository.

Returns:
string

Definition at line 921 of file File.php.

Referenced by isLocal().

File::getSha1 (  ) 

Get the SHA-1 base 36 hash of the file.

Reimplemented in ForeignAPIFile, and LocalFile.

Definition at line 1123 of file File.php.

References getPath(), and sha1Base36().

File::getShortDesc (  ) 

Definition at line 1229 of file File.php.

References MediaHandler::getGeneralShortDesc(), and getHandler().

File::getSize (  ) 

Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB.

Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.

Definition at line 281 of file File.php.

File::getThumbnail ( width,
height = -1,
render = true 
)

As createThumb, but returns a ThumbnailImage object.

This can provide access to the actual file, the real size of the thumb, and can produce a convenient tag for you.

For non-image formats, this may return a filetype-specific icon.

Parameters:
integer $width maximum width of the generated thumbnail
integer $height maximum height of the image (optional)
boolean $render Deprecated
Returns:
ThumbnailImage or null on failure
Deprecated:
use transform()

Definition at line 515 of file File.php.

References transform().

File::getThumbnails (  ) 

Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.

Reimplemented in ForeignAPIFile, and LocalFile.

Definition at line 640 of file File.php.

File::getThumbPath ( suffix = false  ) 

Get the path of the thumbnail directory, or a particular file if $suffix is specified.

Reimplemented in ForeignAPIFile.

Definition at line 764 of file File.php.

References $suffix, and getThumbRel().

Referenced by transform().

File::getThumbRel ( suffix = false  ) 

Get relative path for a thumbnail file.

Definition at line 750 of file File.php.

References $path, $suffix, and getRel().

Referenced by getThumbPath().

File::getThumbUrl ( suffix = false  ) 

Get the URL of the thumbnail directory, or a particular file if $suffix is specified.

Definition at line 780 of file File.php.

References $path, $suffix, and getUrlRel().

Referenced by transform().

File::getThumbVirtualUrl ( suffix = false  ) 

Get the virtual URL for a thumbnail file or directory.

Definition at line 800 of file File.php.

References $path, $suffix, and getUrlRel().

File::getTimestamp (  ) 

Get the 14-character timestamp of the file upload, or false if it doesn't exist.

Reimplemented in ForeignAPIFile, and LocalFile.

Definition at line 1112 of file File.php.

References $path, getPath(), and wfTimestamp().

File::getTitle (  ) 

Return the associated title object.

Definition at line 155 of file File.php.

Referenced by purgeDescription(), purgeEverything(), and wasDeleted().

File::getTransformScript (  ) 

Definition at line 424 of file File.php.

References $script, and getName().

Referenced by transform().

File::getUnscaledThumb ( page = false  ) 

Get a ThumbnailImage which is the same size as the source.

Definition at line 440 of file File.php.

References $page, getWidth(), iconThumb(), and transform().

File::getUrl (  ) 

Return the URL of the file.

Reimplemented in ForeignAPIFile.

Definition at line 169 of file File.php.

References getUrlRel().

Referenced by getFullUrl().

File::getUrlRel (  ) 

Get urlencoded relative path of the file.

Reimplemented in OldLocalFile.

Definition at line 734 of file File.php.

References getHashPath(), and getName().

Referenced by getThumbUrl(), getThumbVirtualUrl(), getUrl(), and getVirtualUrl().

File::getUser ( type = 'text'  ) 

Returns ID or name of user who uploaded the file STUB.

Parameters:
$type string 'text' or 'id'

Reimplemented in ForeignAPIFile, and LocalFile.

Definition at line 248 of file File.php.

File::getViewURL (  ) 

Definition at line 186 of file File.php.

References canRender(), createThumb(), getMimeType(), getWidth(), mustRender(), and wfDebug().

File::getVirtualUrl ( suffix = false  ) 

Get the virtual URL for the file itself.

Definition at line 809 of file File.php.

References $path, $suffix, and getUrlRel().

File::getWidth ( page = 1  ) 

Return the width of the image.

Returns false if the width is unknown or undefined.

STUB Overridden by LocalFile, UnregisteredLocalFile

Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.

Definition at line 231 of file File.php.

Referenced by getUnscaledThumb(), and getViewURL().

File::iconThumb (  ) 

Get a ThumbnailImage representing a file type icon.

Returns:
ThumbnailImage

Definition at line 613 of file File.php.

References $path, $wgStyleDirectory, $wgStylePath, and getExtension().

Referenced by getUnscaledThumb(), and transform().

File::isDeleted ( field  ) 

Is this file a "deleted" file in a private archive? STUB.

Reimplemented in OldLocalFile.

Definition at line 943 of file File.php.

File::isHashed (  ) 

Returns:
bool

Definition at line 820 of file File.php.

File::isLocal (  ) 

Returns true if the file comes from the local file repository.

Returns:
bool

Definition at line 912 of file File.php.

References getRepoName().

File::isMultipage (  ) 

Returns 'true' if this image is a multipage document, e.g.

a DJVU document.

Returns:
Bool

Definition at line 1015 of file File.php.

References getHandler().

File::isOld (  ) 

Returns true if the image is an old version STUB.

Reimplemented in OldLocalFile.

Definition at line 935 of file File.php.

File::isSafeFile (  ) 

Determines if this media file is in a format that is unlikely to contain viruses or malicious content.

It uses the global $wgTrustedMediaFormats list to determine if the file is safe.

This is used to show a warning on the description page of non-safe files. It may also be used to disallow direct [[media:...]] links to such files.

Note that this function will always return true if allowInlineDisplay() or isTrustedFile() is true for this file.

Definition at line 354 of file File.php.

References _getIsSafeFile().

Referenced by getIsSafeFile().

File::isTrustedFile (  ) 

Returns true if the file is flagged as trusted.

Files flagged that way can be linked to directly, even if that is not allowed for this type of file normally.

This is a dummy function right now and always returns false. It could be implemented to extract a flag from the database. The trusted flag could be set on upload, if the user has sufficient privileges, to bypass script- and html-filters. It may even be coupled with cryptographics signatures or such.

Definition at line 396 of file File.php.

Referenced by _getIsSafeFile().

File::isVisible (  ) 

Returns true if file exists in the repository and can be included in a page.

It would be unsafe to include private images, making public thumbnails inadvertently

Returns:
boolean Whether file exists in the repository and is includable.
Access:
public

Reimplemented in OldLocalFile.

Definition at line 420 of file File.php.

References exists().

File::migrateThumbFile ( thumbName  ) 

Hook into transform() to allow migration of thumbnail files STUB Overridden by LocalFile.

Reimplemented in LocalFile.

Definition at line 597 of file File.php.

Referenced by transform().

File::move ( target  ) 

Move file to the new title.

Move current, old version and all thumbnails to the new filename. Old file is deleted.

Cache purging is done; checks for validity and logging are caller's responsibility

Parameters:
$target Title New file name
Returns:
FileRepoStatus object.

Reimplemented in ForeignDBFile, and LocalFile.

Definition at line 969 of file File.php.

References readOnlyError().

File::mustRender (  ) 

Return true if the file is of a type that can't be directly rendered by typical browsers and needs to be re-rasterized.

This returns true for everything but the bitmap types supported by all browsers, i.e. JPEG; GIF and PNG. It will also return true for any non-image formats.

Returns:
bool

Definition at line 332 of file File.php.

References getHandler().

Referenced by getViewURL().

File::nextHistoryLine (  ) 

Return the history of this file, line by line.

Starts with current version, then old versions. Should return an object similar to an image/oldimage database row.

STUB Overridden in LocalFile

Reimplemented in LocalFile.

Definition at line 700 of file File.php.

static File::normalizeExtension ( ext  )  [static]

Normalize a file extension to the common form, and ensure it's clean.

Extensions with non-alphanumeric characters will be discarded.

Parameters:
$ext string (without the .)
Returns:
string

Definition at line 76 of file File.php.

References $ext.

Referenced by checkExtensionCompatibility(), LocalRepo::cleanupDeletedBatch(), and getExtension().

File::pageCount (  ) 

Returns the number of pages of a multipage document, or NULL for documents which aren't multipage documents.

Definition at line 1023 of file File.php.

References getHandler().

File::publish ( srcPath,
flags = 0 
)

Move or copy a file to its public location.

If a file exists at the destination, move it to an archive. Returns the archive name on success or an empty string if it was a new file, and a wikitext-formatted WikiError object on failure.

The archive name should be passed through to recordUpload for database registration.

Parameters:
string $sourcePath Local filesystem path to the source image
integer $flags A bitwise combination of: File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
Returns:
The archive name on success or an empty string if it was a new file, and a wikitext-formatted WikiError object on failure.
STUB Overridden by LocalFile

Reimplemented in ForeignDBFile, and LocalFile.

Definition at line 856 of file File.php.

References readOnlyError().

File::purgeCache (  ) 

Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.

Reimplemented in ForeignAPIFile, and LocalFile.

Definition at line 647 of file File.php.

Referenced by purgeEverything().

File::purgeDescription (  ) 

Purge the file description page, but don't go after pages using the file.

Use when modifying file history but not the current data.

Definition at line 654 of file File.php.

References $title, and getTitle().

Referenced by purgeEverything().

File::purgeEverything (  ) 

Purge metadata and all affected pages when the file is created, deleted, or majorly updated.

Definition at line 666 of file File.php.

References $title, getTitle(), purgeCache(), and purgeDescription().

File::readOnlyError (  ) 

File::recordUpload ( oldver,
desc,
license = '',
copyStatus = '',
source = '',
watch = false 
)

Record a file upload in the upload log and the image table STUB Overridden by LocalFile.

Definition at line 833 of file File.php.

References readOnlyError().

File::redirectedFrom ( from  ) 

Definition at line 1259 of file File.php.

File::resetHistory (  ) 

Reset the history pointer to the first element of the history.

Always call this function after using nextHistoryLine() to free db resources STUB Overridden in LocalFile.

Reimplemented in LocalFile.

Definition at line 710 of file File.php.

File::restore ( versions = array(),
unsuppress = false 
)

Restore all or specified deleted revisions to the given file.

Permissions and logging are left to the caller.

May throw database exceptions on error.

Parameters:
$versions set of record ids of deleted items to restore, or empty to restore all revisions.
$unsuppress,remove restrictions on content upon restoration?
Returns:
the number of file revisions restored if successful, or false on failure STUB Overridden by LocalFile

Reimplemented in ForeignDBFile, and LocalFile.

Definition at line 1005 of file File.php.

References readOnlyError().

static File::scaleHeight ( srcWidth,
srcHeight,
dstWidth 
) [static]

Calculate the height of a thumbnail using the source and destination width.

Definition at line 1037 of file File.php.

Referenced by SvgHandler::normaliseParams(), ImageHandler::normaliseParams(), and ImageHandler::validateThumbParams().

static File::sha1Base36 ( path  )  [static]

Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits.

160 log 2 / log 36 = 30.95, so the 160-bit hash fills 31 digits in base 36 fairly neatly.

Returns false on failure

Definition at line 1209 of file File.php.

References $path, wfBaseConvert(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by UploadForm::getDupeWarning(), getPropsFromPath(), LocalFile::getSha1(), and getSha1().

static File::splitMime ( mime  )  [static]

Split an internet media type into its two components; if not a two-part name, set the minor type to 'unknown'.

Parameters:
$mime "text/html" etc
Returns:
array ("text", "html") etc

Definition at line 122 of file File.php.

Referenced by getPropsFromPath(), and OldLocalFile::upgradeRow().

File::thumbName ( params  ) 

Return the file name of a thumbnail with the specified parameters.

Parameters:
array $params Handler-specific parameters
Access:
private -ish

Definition at line 462 of file File.php.

References getExtension(), getHandler(), getMimeType(), and getName().

Referenced by transform().

File::transform ( params,
flags = 0 
)

Transform a media file.

Parameters:
array $params An associative array of handler-specific parameters. Typical keys are width, height and page.
integer $flags A bitfield, may contain self::RENDER_NOW to force rendering
Returns:
MediaTransformOutput

Reimplemented in ForeignAPIFile.

Definition at line 531 of file File.php.

References $flags, $script, $wgIgnoreImageErrors, $wgUseSquid, canRender(), getThumbPath(), getThumbUrl(), getTransformScript(), iconThumb(), migrateThumbFile(), SquidUpdate::purge(), thumbName(), wfDebug(), wfProfileIn(), and wfProfileOut().

Referenced by createThumb(), getThumbnail(), and getUnscaledThumb().

File::upgradeRow (  ) 

Upgrade the database row if there is one Called by ImagePage STUB.

Reimplemented in LocalFile, and OldLocalFile.

Definition at line 113 of file File.php.

File::userCan ( field  ) 

Determine if the current user is allowed to view a particular field of this file, if it's marked as deleted.

STUB

Parameters:
int $field
Returns:
bool

Reimplemented in OldLocalFile.

Definition at line 1134 of file File.php.

File::wasDeleted (  ) 

Was this file ever deleted from the wiki?

Returns:
bool

Definition at line 952 of file File.php.

References $title, and getTitle().


Member Data Documentation

File::$lastError

Definition at line 49 of file File.php.

File::$redirected

Definition at line 49 of file File.php.

File::$redirectedTitle

Definition at line 49 of file File.php.

File::$repo

Some member variables can be lazy-initialised using __get().

The initialisation function for these variables is always a function named like getVar(), where Var is the variable name with upper-case first letter.

The following variables are initialised in this way in this base class: name, extension, handler, path, canRender, isSafeFile, transformScript, hashPath, pageCount, url

Code within this class should generally use the accessor function directly, since __get() isn't re-entrant and therefore causes bugs that depend on initialisation order. The following member variables are not lazy-initialised

Definition at line 49 of file File.php.

Referenced by UnregisteredLocalFile::__construct(), OldLocalFile::__construct(), Image::__construct(), ForeignAPIFile::__construct(), __construct(), OldLocalFile::newFromArchiveName(), OldLocalFile::newFromKey(), OldLocalFile::newFromRow(), ForeignDBFile::newFromRow(), UnregisteredLocalFile::newFromTitle(), OldLocalFile::newFromTitle(), ForeignDBFile::newFromTitle(), and ForeignAPIFile::newFromTitle().

File::$title

const File::DELETED_FILE = 1

const File::DELETED_USER = 4

const File::RENDER_NOW = 1

Definition at line 27 of file File.php.

Referenced by wfThumbMain().


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