Inherited by ForeignAPIFile, LocalFile, and UnregisteredLocalFile.
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. |
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.
File::__construct | ( | $ | title, | |
$ | repo | |||
) |
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.
$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.
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.
$reason | ||
$suppress,hide | content from sysops? |
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.
Reimplemented in ForeignAPIFile, and LocalFile.
Definition at line 409 of file File.php.
References getPath().
Referenced by isVisible().
File::formatMetadata | ( | ) |
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 | ( | ) |
File::getCanRender | ( | ) | [protected] |
File::getDescription | ( | ) |
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 | ( | ) |
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 | ( | ) |
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.
Definition at line 182 of file File.php.
References getUrl(), and wfExpandUrl().
File::getHandler | ( | ) |
Get a MediaHandler instance for this file.
Definition at line 602 of file File.php.
References getMimeType().
Referenced by canRender(), formatMetadata(), getDimensionsString(), UnregisteredLocalFile::getImageSize(), getImageSize(), getLength(), getLongDesc(), UnregisteredLocalFile::getMetadata(), UnregisteredLocalFile::getPageDimensions(), getPropsFromPath(), getShortDesc(), isMultipage(), mustRender(), pageCount(), and thumbName().
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.
File::getHistory | ( | $ | limit = null , |
|
$ | start = null , |
|||
$ | end = null , |
|||
$ | inc = true | |||
) |
Return a fragment of the history of file.
STUB
$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.
File::getImageSize | ( | $ | fileName | ) |
Get an image size array like that returned by getimagesize(), or false if it can't be determined.
string | $fileName The filename |
Reimplemented in UnregisteredLocalFile.
Definition at line 1053 of file File.php.
References getHandler().
File::getIsSafeFile | ( | ) | [protected] |
File::getLastError | ( | ) |
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()
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 | ( | ) |
Return the name of this file.
Definition at line 133 of file File.php.
Referenced by getDescriptionText(), getDescriptionUrl(), getExtension(), getHashPath(), getLinksTo(), getRel(), ForeignAPIFile::getThumbnails(), ForeignAPIFile::getThumbPath(), getTransformScript(), getUrlRel(), OldLocalFile::loadFromDB(), ForeignAPIFile::purgeDescriptionPage(), ForeignAPIFile::purgeThumbnails(), thumbName(), ForeignAPIFile::transform(), and OldLocalFile::upgradeRow().
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.
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::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::getRepoName | ( | ) |
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.
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.
integer | $width maximum width of the generated thumbnail | |
integer | $height maximum height of the image (optional) | |
boolean | $render Deprecated |
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.
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 |
) |
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.
$type | string 'text' or 'id' |
Reimplemented in ForeignAPIFile, and LocalFile.
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.
Definition at line 613 of file File.php.
References $path, $wgStyleDirectory, $wgStylePath, and getExtension().
Referenced by getUnscaledThumb(), and transform().
File::isDeleted | ( | $ | field | ) |
File::isLocal | ( | ) |
Returns true if the file comes from the local file repository.
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.
Definition at line 1015 of file File.php.
References getHandler().
File::isOld | ( | ) |
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
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
$target | Title New file name |
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.
Definition at line 332 of file File.php.
References getHandler().
Referenced by getViewURL().
File::nextHistoryLine | ( | ) |
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.
$ext | string (without the .) |
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.
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 |
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 | ( | ) |
Definition at line 824 of file File.php.
Referenced by ForeignDBFile::delete(), delete(), ForeignDBFile::move(), move(), ForeignDBFile::publish(), publish(), ForeignDBFile::recordUpload(), recordUpload(), ForeignDBFile::restore(), and restore().
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::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.
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.
$versions | set of record ids of deleted items to restore, or empty to restore all revisions. | |
$unsuppress,remove | restrictions on content upon restoration? |
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'.
$mime | "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.
array | $params Handler-specific parameters |
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.
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 |
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.
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
int | $field |
Reimplemented in OldLocalFile.
File::wasDeleted | ( | ) |
Was this file ever deleted from the wiki?
Definition at line 952 of file File.php.
References $title, and getTitle().
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 |
Reimplemented in UnregisteredLocalFile.
Definition at line 49 of file File.php.
Referenced by OldLocalFile::__construct(), Image::__construct(), ForeignAPIFile::__construct(), __construct(), OldLocalFile::newFromArchiveName(), Image::newFromName(), OldLocalFile::newFromRow(), ForeignDBFile::newFromRow(), OldLocalFile::newFromTitle(), Image::newFromTitle(), ForeignDBFile::newFromTitle(), ForeignAPIFile::newFromTitle(), purgeDescription(), purgeEverything(), and wasDeleted().
const File::DELETE_SOURCE = 1 |
Definition at line 29 of file File.php.
Referenced by WikiRevision::importUpload(), UploadForm::internalProcessUpload(), and LocalFile::publish().
const File::DELETED_COMMENT = 2 |
Definition at line 24 of file File.php.
Referenced by SpecialRevisionDelete::fileComment(), ArchivedFile::getDescription(), UndeleteForm::getFileComment(), and ImageHistoryList::imageHistoryLine().
const File::DELETED_FILE = 1 |
Definition at line 23 of file File.php.
Referenced by LocalFileMoveBatch::addOlds(), SpecialRevisionDelete::archivedfileLine(), LocalRepo::cleanupDeletedBatch(), DeleteArchivedFiles(), UndeleteForm::execute(), SpecialRevisionDelete::execute(), LocalFileRestoreBatch::execute(), LocalFileDeleteBatch::execute(), SpecialRevisionDelete::fileLine(), FileRepo::findFile(), FileRepo::findFileFromKey(), UndeleteForm::getFileLink(), ImageHistoryList::imageHistoryLine(), OldLocalFile::isVisible(), RevisionDeleter::makeOldImagePublic(), SpecialRevisionDelete::secureOperation(), and RevisionDeleter::setOldImgVisibility().
const File::DELETED_RESTRICTED = 8 |
Definition at line 26 of file File.php.
Referenced by UndeleteForm::formatFileRow(), ImageHistoryList::imageHistoryLine(), RevisionDeleter::setArchFileVisibility(), RevisionDeleter::setOldImgVisibility(), SpecialRevisionDelete::showImages(), OldLocalFile::userCan(), and ArchivedFile::userCan().
const File::DELETED_USER = 4 |
Definition at line 25 of file File.php.
Referenced by UndeleteForm::getFileUser(), ArchivedFile::getUser(), ArchivedFile::getUserText(), and ImageHistoryList::imageHistoryLine().
const File::RENDER_NOW = 1 |