MediaWiki
REL1_19
|
Implements some public methods and some protected utility functions which are required by multiple child classes. More...
Public Member Functions | |
__construct ($title, $repo) | |
Call this constructor from child classes. | |
__get ($name) | |
allowInlineDisplay () | |
Alias for canRender() | |
canRender () | |
Checks if the output of transform() for this file is likely to be valid. | |
convertMetadataVersion ($metadata, $version) | |
get versioned metadata | |
createThumb ($width, $height=-1) | |
Create a thumbnail of the image having the specified width/height. | |
delete ($reason, $suppress=false) | |
Delete all versions of the file. | |
exists () | |
Returns true if file exists in the repository. | |
formatMetadata () | |
generateThumbName ($name, $params) | |
Generate a thumbnail file name from a name and specified parameters. | |
getArchivePath ($suffix=false) | |
Get the path of the archived file. | |
getArchiveRel ($suffix=false) | |
Get the path of an archived file relative to the public zone root. | |
getArchiveThumbPath ($archiveName, $suffix=false) | |
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified. | |
getArchiveThumbRel ($archiveName, $suffix=false) | |
Get the path, relative to the thumbnail zone root, for an archived file's thumbs directory or a specific thumb if the $suffix is given. | |
getArchiveThumbUrl ($archiveName, $suffix=false) | |
Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified. | |
getArchiveUrl ($suffix=false) | |
Get the URL of the archive directory, or a particular file if $suffix is specified. | |
getArchiveVirtualUrl ($suffix=false) | |
Get the public zone virtual URL for an archived version source file. | |
getBitDepth () | |
Return the bit depth of the file Overridden by LocalFile STUB. | |
getCanonicalUrl () | |
getDescription () | |
Get discription of file revision STUB. | |
getDescriptionText () | |
Get the HTML text of the description page, if available. | |
getDescriptionUrl () | |
Get the URL of the image description page. | |
getDimensionsString () | |
getExtension () | |
Get the file extension, e.g. | |
getFullUrl () | |
Return a fully-qualified URL to the file. | |
getHandler () | |
Get a MediaHandler instance for this file. | |
getHashPath () | |
Get the filename hash component of the directory including trailing slash, e.g. | |
getHeight ($page=1) | |
Return the height of the image. | |
getHistory ($limit=null, $start=null, $end=null, $inc=true) | |
Return a fragment of the history of file. | |
getImageSize ($fileName) | |
Get an image size array like that returned by getImageSize(), or false if it can't be determined. | |
getLastError () | |
Get last thumbnailing error. | |
getLength () | |
Get the duration of a media file in seconds. | |
getLocalRefPath () | |
Get an FS copy or original of this file and return the path. | |
getLongDesc () | |
getMediaType () | |
Return the type of the media in the file. | |
getMetadata () | |
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB. | |
getMimeType () | |
Returns the mime type of the file. | |
getName () | |
Return the name of this file. | |
getOriginalTitle () | |
Return the title used to find this file. | |
getPath () | |
Return the storage path to the file. | |
getRedirected () | |
getRedirectedTitle () | |
getRel () | |
Get the path of the file relative to the public zone root. | |
getRepo () | |
Returns the repository. | |
getRepoName () | |
Returns the name of the repository. | |
getSha1 () | |
Get the SHA-1 base 36 hash of the file. | |
getShortDesc () | |
getSize () | |
Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB. | |
getStorageKey () | |
Get the deletion archive key, <sha1>. | |
getThumbnails () | |
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile. | |
getThumbPath ($suffix=false) | |
Get the path of the thumbnail directory, or a particular file if $suffix is specified. | |
getThumbRel ($suffix=false) | |
Get the path, relative to the thumbnail zone root, of the thumbnail 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. | |
getThumbVirtualUrl ($suffix=false) | |
Get the virtual URL for a thumbnail file or directory. | |
getTimestamp () | |
Get the 14-character timestamp of the file upload. | |
getTitle () | |
Return the associated title object. | |
getTransformScript () | |
getUnscaledThumb ($handlerParams=array()) | |
Get a ThumbnailImage which is the same size as the source. | |
getUrl () | |
Return the URL of the file. | |
getUrlRel () | |
Get urlencoded path of the file relative to the public zone root. | |
getUser ($type= 'text') | |
Returns ID or name of user who uploaded the file STUB. | |
getViewURL () | |
getVirtualUrl ($suffix=false) | |
Get the public zone virtual URL for a current version source file. | |
getVisibility () | |
Return the deletion bitfield STUB. | |
getWidth ($page=1) | |
Return the width of the image. | |
iconThumb () | |
Get a ThumbnailImage representing a file type icon. | |
isDeleted ($field) | |
Is this file a "deleted" file in a private archive? STUB. | |
isHashed () | |
isLocal () | |
Returns true if the file comes from the local file repository. | |
isMissing () | |
isMultipage () | |
Returns 'true' if this file is a type which supports multiple pages, e.g. | |
isOld () | |
Returns true if the image is an old version STUB. | |
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. | |
isVectorized () | |
Return true if the file is vectorized. | |
isVisible () | |
Returns true if file exists in the repository and can be included in a page. | |
migrateThumbFile ($thumbName) | |
Hook into transform() to allow migration of thumbnail files STUB Overridden by LocalFile. | |
move ($target) | |
Move file to the new title. | |
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. | |
nextHistoryLine () | |
Return the history of this file, line by line. | |
pageCount () | |
Returns the number of pages of a multipage document, or false for documents which aren't multipage documents. | |
publish ($srcPath, $flags=0) | |
Move or copy a file to its public location. | |
purgeCache ($options=array()) | |
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. | |
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. | |
redirectedFrom ($from) | |
resetHistory () | |
Reset the history pointer to the first element of the history. | |
restore ($versions=array(), $unsuppress=false) | |
Restore all or specified deleted revisions to the given file. | |
thumbName ($params) | |
Return the file name of a thumbnail with the specified parameters. | |
transform ($params, $flags=0) | |
Transform a media file. | |
upgradeRow () | |
Upgrade the database row if there is one Called by ImagePage STUB. | |
userCan ($field, User $user=null) | |
Determine if the current user is allowed to view a particular field of this file, if it's marked as deleted. | |
wasDeleted () | |
Was this file ever deleted from the wiki? | |
Static Public Member Functions | |
static | checkExtensionCompatibility (File $old, $new) |
Checks if file extensions are compatible. | |
static | getPropsFromPath ($path, $ext=true) |
Get an associative array containing information about a file in the local filesystem. | |
static | normalizeExtension ($ext) |
Normalize a file extension to the common form, and ensure it's clean. | |
static | normalizeTitle ($title, $exception=false) |
Given a string or Title object return either a valid Title object with namespace NS_FILE or null. | |
static | scaleHeight ($srcWidth, $srcHeight, $dstWidth) |
Calculate the height of a thumbnail using the source and destination width. | |
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. | |
static | splitMime ($mime) |
Split an internet media type into its two components; if not a two-part name, set the minor type to 'unknown'. | |
Public Attributes | |
$extension | |
$hashPath | |
$isSafeFile | |
$lastError | |
$name | |
$pageCount | |
$path | |
$redirected | |
$redirectedTitle | |
$repo | |
$title | |
$transformScript | |
const | DELETE_SOURCE = 1 |
const | DELETED_COMMENT = 2 |
const | DELETED_FILE = 1 |
const | DELETED_RESTRICTED = 8 |
const | DELETED_USER = 4 |
const | RENDER_FORCE = 2 |
Force rendering even if thumbnail already exist and using RENDER_NOW I.e. | |
const | RENDER_NOW = 1 |
Force rendering in the current process. | |
Protected Member Functions | |
_getIsSafeFile () | |
Uncached accessor. | |
assertRepoDefined () | |
Assert that $this->repo is set to a valid FileRepo instance. | |
assertTitleDefined () | |
Assert that $this->title is set to a Title. | |
getCanRender () | |
Accessor for __get() | |
getIsSafeFile () | |
Accessor for __get() | |
transformErrorOutput ($thumbPath, $thumbUrl, $params, $flags) | |
Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors) | |
Protected Attributes | |
$canRender | |
$fsFile | |
$handler | |
$repoClass = 'FileRepo' | |
$url |
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.
File::__construct | ( | $ | title, |
$ | repo | ||
) |
Call this constructor from child classes.
Both $title and $repo are optional, though some functions may return false or throw exceptions if they are not set. Most subclasses will want to call assertRepoDefined() here.
$title | Title|string|false |
$repo | FileRepo|false |
Reimplemented in LocalFile.
Definition at line 117 of file File.php.
References $repo, $title, and normalizeTitle().
File::__get | ( | $ | name | ) |
File::_getIsSafeFile | ( | ) | [protected] |
Uncached accessor.
Definition at line 583 of file File.php.
References $mime, $wgTrustedMediaFormats, allowInlineDisplay(), getMediaType(), getMimeType(), and isTrustedFile().
Referenced by isSafeFile().
Alias for canRender()
Definition at line 545 of file File.php.
References canRender().
Referenced by _getIsSafeFile().
File::assertRepoDefined | ( | ) | [protected] |
Assert that $this->repo is set to a valid FileRepo instance.
MWException |
Definition at line 1704 of file File.php.
Referenced by ForeignAPIFile\__construct(), UnregisteredLocalFile\__construct(), getArchivePath(), getArchiveThumbPath(), getArchiveThumbUrl(), getArchiveUrl(), getArchiveVirtualUrl(), getHashPath(), getLocalRefPath(), getName(), getPath(), getSha1(), UnregisteredLocalFile\getSize(), getThumbPath(), getThumbUrl(), getThumbVirtualUrl(), getTimestamp(), getUrl(), getVirtualUrl(), and isHashed().
File::assertTitleDefined | ( | ) | [protected] |
Assert that $this->title is set to a Title.
MWException |
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 512 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 195 of file File.php.
References $n, getMimeType(), normalizeExtension(), and MimeMagic\singleton().
Referenced by Title\validateFileMoveOperation().
File::convertMetadataVersion | ( | $ | metadata, |
$ | version | ||
) |
get versioned metadata
$metadata | Mixed Array or String of (serialized) metadata |
$version | integer version number. |
Definition at line 448 of file File.php.
References $handler, $version, and getHandler().
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.
$width | Integer: maximum width of the generated thumbnail |
$height | Integer: maximum height of the image (optional) |
Definition at line 739 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 | String |
$suppress | Boolean: hide content from sysops? |
Reimplemented in LocalFile, and ForeignDBFile.
Definition at line 1408 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 UploadStashFile, LocalFile, and ForeignAPIFile.
Definition at line 640 of file File.php.
References getPath().
Referenced by isVisible().
Definition at line 1304 of file File.php.
References getHandler(), and getMetadata().
File::generateThumbName | ( | $ | name, |
$ | params | ||
) |
Generate a thumbnail file name from a name and specified parameters.
string | $name | |
array | $params | Parameters which will be passed to MediaHandler::makeParamString |
Definition at line 708 of file File.php.
References $extension, $name, getExtension(), getHandler(), and getMimeType().
Referenced by UploadStashFile\thumbName(), and thumbName().
File::getArchivePath | ( | $ | suffix = false | ) |
Get the path of the archived file.
$suffix | bool|string if not false, the name of an archived file. |
Definition at line 1114 of file File.php.
References assertRepoDefined(), and getArchiveRel().
File::getArchiveRel | ( | $ | suffix = false | ) |
Get the path of an archived file relative to the public zone root.
$suffix | bool|string if not false, the name of an archived thumbnail file |
Definition at line 1052 of file File.php.
References $path, and getHashPath().
Referenced by getArchivePath().
File::getArchiveThumbPath | ( | $ | archiveName, |
$ | suffix = false |
||
) |
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified.
$archiveName | string the timestamped name of an archived image |
$suffix | bool|string if not false, the name of a thumbnail file |
Definition at line 1127 of file File.php.
References assertRepoDefined(), and getArchiveThumbRel().
File::getArchiveThumbRel | ( | $ | archiveName, |
$ | suffix = false |
||
) |
Get the path, relative to the thumbnail zone root, for an archived file's thumbs directory or a specific thumb if the $suffix is given.
$archiveName | string the timestamped name of an archived image |
$suffix | bool|string if not false, the name of a thumbnail file |
Definition at line 1097 of file File.php.
References $path, and getHashPath().
Referenced by getArchiveThumbPath().
File::getArchiveThumbUrl | ( | $ | archiveName, |
$ | suffix = false |
||
) |
Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified.
$archiveName | string the timestamped name of an archived image |
$suffix | bool|string if not false, the name of a thumbnail file |
Definition at line 1171 of file File.php.
References $path, assertRepoDefined(), and getHashPath().
File::getArchiveUrl | ( | $ | suffix = false | ) |
Get the URL of the archive directory, or a particular file if $suffix is specified.
$suffix | bool|string if not false, the name of an archived file |
Definition at line 1152 of file File.php.
References $path, assertRepoDefined(), and getHashPath().
File::getArchiveVirtualUrl | ( | $ | suffix = false | ) |
Get the public zone virtual URL for an archived version source file.
$suffix | bool|string if not false, the name of a thumbnail file |
Definition at line 1222 of file File.php.
References $path, assertRepoDefined(), and getHashPath().
Definition at line 300 of file File.php.
References getUrl(), and wfExpandUrl().
File::getCanRender | ( | ) | [protected] |
Accessor for __get()
Definition at line 522 of file File.php.
References canRender().
Get discription of file revision STUB.
Reimplemented in LocalFile, and ForeignAPIFile.
Get the HTML text of the description page, if available.
Reimplemented in LocalFile, and ForeignDBFile.
Definition at line 1509 of file File.php.
References $res, $wgLang, $wgMemc, Http\get(), getName(), and wfDebug().
Get the URL of the image description page.
May return false if it is unknown or not applicable.
Reimplemented in LocalFile, UploadStashFile, ForeignAPIFile, and ForeignDBFile.
Definition at line 1496 of file File.php.
References getName().
Referenced by transform().
Definition at line 1657 of file File.php.
References $handler, and getHandler().
Get the file extension, e.g.
"svg"
Definition at line 243 of file File.php.
References $n, getName(), and normalizeExtension().
Referenced by generateThumbName(), ForeignAPIFile\getMimeType(), getStorageKey(), and iconThumb().
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.
Reimplemented in UploadStashFile.
Definition at line 293 of file File.php.
References getUrl(), and wfExpandUrl().
File::getHandler | ( | ) |
Get a MediaHandler instance for this file.
Definition at line 903 of file File.php.
References getMimeType().
Referenced by UnregisteredLocalFile\cachePageDimensions(), canRender(), convertMetadataVersion(), formatMetadata(), generateThumbName(), getDimensionsString(), UnregisteredLocalFile\getImageSize(), getImageSize(), getLength(), getLongDesc(), UnregisteredLocalFile\getMetadata(), getShortDesc(), isMultipage(), isVectorized(), mustRender(), pageCount(), and ForeignAPIFile\purgeThumbnails().
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 1027 of file File.php.
References assertRepoDefined(), and getName().
Referenced by getArchiveRel(), getArchiveThumbRel(), getArchiveThumbUrl(), getArchiveUrl(), getArchiveVirtualUrl(), OldLocalFile\getRel(), getRel(), ForeignAPIFile\getThumbPath(), OldLocalFile\getUrlRel(), getUrlRel(), and OldLocalFile\uploadOld().
File::getHeight | ( | $ | page = 1 | ) |
Return the height of the image.
Returns false if the height is unknown or undefined
STUB Overridden by LocalFile, UnregisteredLocalFile
$page | int |
Reimplemented in LocalFile, FakeDimensionFile, ForeignAPIFile, 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.
$fileName | String: The filename |
Reimplemented in UnregisteredLocalFile.
Definition at line 1483 of file File.php.
References getHandler().
File::getIsSafeFile | ( | ) | [protected] |
Accessor for __get()
Definition at line 574 of file File.php.
References isSafeFile().
File::getLength | ( | ) |
Get the duration of a media file in seconds.
Definition at line 409 of file File.php.
References $handler, and getHandler().
Get an FS copy or original of this file and return the path.
Returns false on failure. Callers must not alter the file. Temporary files are cleared automatically.
Definition at line 349 of file File.php.
References assertRepoDefined(), and getPath().
Referenced by UnregisteredLocalFile\getImageSize(), UnregisteredLocalFile\getMetadata(), and UnregisteredLocalFile\getMimeType().
Definition at line 1633 of file File.php.
References $handler, MediaHandler\getGeneralLongDesc(), and getHandler().
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 LocalFile, and ForeignAPIFile.
Definition at line 496 of file File.php.
Referenced by _getIsSafeFile().
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
Reimplemented in LocalFile, UnregisteredLocalFile, and ForeignAPIFile.
Definition at line 437 of file File.php.
Referenced by formatMetadata().
Returns the mime type of the file.
Overridden by LocalFile, UnregisteredLocalFile STUB
Reimplemented in LocalFile, ForeignAPIFile, and UnregisteredLocalFile.
Definition at line 486 of file File.php.
Referenced by _getIsSafeFile(), checkExtensionCompatibility(), generateThumbName(), getHandler(), and getViewURL().
File::getName | ( | ) |
Return the name of this file.
Definition at line 230 of file File.php.
References assertRepoDefined().
Referenced by getDescriptionText(), getDescriptionUrl(), getExtension(), getHashPath(), getRel(), ForeignAPIFile\getThumbnails(), ForeignAPIFile\getThumbPath(), getTransformScript(), getUrlRel(), OldLocalFile\loadFromDB(), ForeignAPIFile\purgeDescriptionPage(), PurgeDeletedFiles\purgeFromArchiveTable(), ForeignAPIFile\purgeThumbnails(), OldLocalFile\recordOldUpload(), thumbName(), ForeignAPIFile\transform(), and OldLocalFile\upgradeRow().
Return the title used to find this file.
Definition at line 266 of file File.php.
References getRedirectedTitle().
File::getPath | ( | ) |
Return the storage 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.
Most callers don't check the return value, but ForeignAPIFile::getPath returns false.
Reimplemented in FakeDimensionFile, and ForeignAPIFile.
Definition at line 334 of file File.php.
References assertRepoDefined(), and getRel().
Referenced by exists(), getLocalRefPath(), getSha1(), getTimestamp(), and SpecialUploadStash\outputLocalFile().
static File::getPropsFromPath | ( | $ | path, |
$ | ext = true |
||
) | [static] |
Get an associative array containing information about a file in the local filesystem.
$path | String: absolute local filesystem path |
$ext | Mixed: the file extension, or true to extract it from the filename. Set it to false to ignore the extension. |
Definition at line 1604 of file File.php.
References $fsFile, $path, wfDebug(), and wfDeprecated().
Definition at line 1676 of file File.php.
References Title\makeTitle().
Referenced by getOriginalTitle().
File::getRel | ( | ) |
Get the path of the file relative to the public zone root.
This function is overriden in OldLocalFile to be like getArchiveRel().
Reimplemented in OldLocalFile.
Definition at line 1041 of file File.php.
References getHashPath(), and getName().
Referenced by getPath(), and getThumbRel().
File::getRepo | ( | ) |
Returns the repository.
Definition at line 1334 of file File.php.
Referenced by SpecialUploadStash\outputLocalFile(), and PurgeDeletedFiles\purgeFromArchiveTable().
File::getSha1 | ( | ) |
Get the SHA-1 base 36 hash of the file.
Reimplemented in LocalFile, and ForeignAPIFile.
Definition at line 1563 of file File.php.
References assertRepoDefined(), and getPath().
Referenced by getStorageKey().
Definition at line 1645 of file File.php.
References $handler, MediaHandler\getGeneralShortDesc(), and getHandler().
File::getSize | ( | ) |
Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB.
Reimplemented in LocalFile, UnregisteredLocalFile, and ForeignAPIFile.
Definition at line 475 of file File.php.
Referenced by SpecialUploadStash\outputLocalFile().
Get the deletion archive key, <sha1>.
<ext>
Definition at line 1573 of file File.php.
References $ext, getExtension(), and getSha1().
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.
Reimplemented in ForeignAPIFile.
File::getThumbPath | ( | $ | suffix = false | ) |
Get the path of the thumbnail directory, or a particular file if $suffix is specified.
$suffix | bool|string if not false, the name of a thumbnail file |
Reimplemented in UploadStashFile, and ForeignAPIFile.
Definition at line 1140 of file File.php.
References assertRepoDefined(), and getThumbRel().
Referenced by transform().
File::getThumbRel | ( | $ | suffix = false | ) |
Get the path, relative to the thumbnail zone root, of the thumbnail directory or a particular file if $suffix is specified.
$suffix | bool|string if not false, the name of a thumbnail file |
Definition at line 1070 of file File.php.
References $path, and getRel().
Referenced by getThumbPath().
File::getThumbUrl | ( | $ | suffix = false | ) |
Get the URL of the thumbnail directory, or a particular file if $suffix is specified.
$suffix | bool|string if not false, the name of a thumbnail file |
Reimplemented in UploadStashFile.
Definition at line 1190 of file File.php.
References $path, assertRepoDefined(), and getUrlRel().
Referenced by transform().
File::getThumbVirtualUrl | ( | $ | suffix = false | ) |
Get the virtual URL for a thumbnail file or directory.
$suffix | bool|string if not false, the name of a thumbnail file |
Definition at line 1240 of file File.php.
References $path, assertRepoDefined(), and getUrlRel().
Get the 14-character timestamp of the file upload.
Reimplemented in LocalFile, and ForeignAPIFile.
Definition at line 1553 of file File.php.
References assertRepoDefined(), and getPath().
File::getTitle | ( | ) |
Return the associated title object.
Definition at line 257 of file File.php.
Referenced by purgeDescription(), purgeEverything(), and wasDeleted().
Definition at line 657 of file File.php.
References getName().
Referenced by transform().
File::getUnscaledThumb | ( | $ | handlerParams = array() | ) |
Get a ThumbnailImage which is the same size as the source.
$handlerParams | array |
Definition at line 677 of file File.php.
References $page, getWidth(), iconThumb(), and transform().
File::getUrl | ( | ) |
Return the URL of the file.
Reimplemented in UploadStashFile, and ForeignAPIFile.
Definition at line 278 of file File.php.
References assertRepoDefined(), and getUrlRel().
Referenced by getCanonicalUrl(), and getFullUrl().
File::getUrlRel | ( | ) |
Get urlencoded path of the file relative to the public zone root.
This function is overriden in OldLocalFile to be like getArchiveUrl().
Reimplemented in OldLocalFile.
Definition at line 1084 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 LocalFile, and ForeignAPIFile.
File::getViewURL | ( | ) |
Definition at line 307 of file File.php.
References canRender(), createThumb(), getMimeType(), getWidth(), mustRender(), and wfDebug().
File::getVirtualUrl | ( | $ | suffix = false | ) |
Get the public zone virtual URL for a current version source file.
$suffix | bool|string if not false, the name of a thumbnail file |
Definition at line 1206 of file File.php.
References $path, assertRepoDefined(), and getUrlRel().
Return the deletion bitfield STUB.
Reimplemented in OldLocalFile.
File::getWidth | ( | $ | page = 1 | ) |
Return the width of the image.
Returns false if the width is unknown or undefined.
STUB Overridden by LocalFile, UnregisteredLocalFile
$page | int |
Reimplemented in LocalFile, FakeDimensionFile, ForeignAPIFile, and UnregisteredLocalFile.
Definition at line 373 of file File.php.
Referenced by getUnscaledThumb(), and getViewURL().
File::iconThumb | ( | ) |
Get a ThumbnailImage representing a file type icon.
Definition at line 915 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.
$field |
Reimplemented in OldLocalFile.
File::isHashed | ( | ) |
Definition at line 1252 of file File.php.
References assertRepoDefined().
File::isLocal | ( | ) |
File::isMissing | ( | ) |
Returns 'true' if this file is a type which supports multiple pages, e.g.
DJVU or PDF. Note that this may be true even if the file in question only has a single page.
Definition at line 1437 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 562 of file File.php.
References _getIsSafeFile().
Referenced by getIsSafeFile().
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 627 of file File.php.
Referenced by _getIsSafeFile().
Return true if the file is vectorized.
Definition at line 423 of file File.php.
References $handler, and getHandler().
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 650 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 896 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 LocalFile, and ForeignDBFile.
Definition at line 1390 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.
Reimplemented in FakeDimensionFile.
Definition at line 536 of file File.php.
References getHandler().
Referenced by getViewURL().
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 170 of file File.php.
References $ext.
Referenced by checkExtensionCompatibility(), getExtension(), UploadStash\getExtensionForPath(), and LocalRepo\hiddenFileHasKey().
static File::normalizeTitle | ( | $ | title, |
$ | exception = false |
||
) | [static] |
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
$title | Title|string |
$exception | string|false Use 'exception' to throw an error on bad titles |
Definition at line 133 of file File.php.
References $title, and Title\makeTitleSafe().
Referenced by ArchivedFile\__construct(), UnregisteredLocalFile\__construct(), __construct(), LocalRepo\checkRedirect(), RepoGroup\findFile(), FileRepo\findFile(), RepoGroup\findFiles(), and FileRepo\newFile().
File::pageCount | ( | ) |
Returns the number of pages of a multipage document, or false for documents which aren't multipage documents.
Definition at line 1447 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 a FileRepoStatus object with the archive name in the "value" member on success.
The archive name should be passed through to recordUpload for database registration.
$srcPath | String: local filesystem path to the source image |
$flags | Integer: a bitwise combination of: File::DELETE_SOURCE Delete the source file, i.e. move rather than copy |
STUB Overridden by LocalFile
Reimplemented in LocalFile, and ForeignDBFile.
Definition at line 1297 of file File.php.
References readOnlyError().
File::purgeCache | ( | $ | options = array() | ) |
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
$options | Array Options, which include: 'forThumbRefresh' : The purging is only to refresh thumbnails |
Reimplemented in LocalFile, and ForeignAPIFile.
Definition at line 953 of file File.php.
Referenced by purgeEverything().
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 960 of file File.php.
References $title, and getTitle().
Referenced by purgeEverything().
Purge metadata and all affected pages when the file is created, deleted, or majorly updated.
Definition at line 972 of file File.php.
References $title, getTitle(), purgeCache(), and purgeDescription().
MWException |
Definition at line 1260 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.
$oldver | |
$desc | |
$license | string |
$copyStatus | string |
$source | string |
$watch | bool |
Definition at line 1275 of file File.php.
References readOnlyError().
File::redirectedFrom | ( | $ | from | ) |
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 | array set of record ids of deleted items to restore, or empty to restore all revisions. |
$unsuppress | bool remove restrictions on content upon restoration? |
Reimplemented in LocalFile, and ForeignDBFile.
Definition at line 1426 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.
$srcWidth | |
$srcHeight | |
$dstWidth |
Definition at line 1467 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.
$path | string |
Definition at line 1623 of file File.php.
References $fsFile, $path, and wfDeprecated().
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'.
string | $mime | "text/html" etc |
Definition at line 217 of file File.php.
References $mime.
Referenced by MIMEsearchPage\execute(), RefreshImageMetadata\getConditions(), FSFile\getProps(), ApiQueryAllimages\run(), and OldLocalFile\upgradeRow().
File::thumbName | ( | $ | params | ) |
Return the file name of a thumbnail with the specified parameters.
$params | Array: handler-specific parameters |
Reimplemented in UploadStashFile.
Definition at line 696 of file File.php.
References generateThumbName(), and getName().
Referenced by transform().
File::transform | ( | $ | params, |
$ | flags = 0 |
||
) |
Transform a media file.
$params | Array: an associative array of handler-specific parameters. Typical keys are width, height and page. |
$flags | Integer: a bitfield, may contain self::RENDER_NOW to force rendering |
Reimplemented in ForeignAPIFile.
Definition at line 779 of file File.php.
References $wgIgnoreImageErrors, $wgThumbnailEpoch, $wgUseSquid, canRender(), FileBackend\extensionFromPath(), TempFSFile\factory(), getDescriptionUrl(), getThumbPath(), getThumbUrl(), getTransformScript(), iconThumb(), migrateThumbFile(), SquidUpdate\purge(), RENDER_FORCE, RENDER_NOW, thumbName(), transformErrorOutput(), wfDebug(), wfExpandUrl(), wfProfileIn(), and wfProfileOut().
Referenced by createThumb(), and getUnscaledThumb().
File::transformErrorOutput | ( | $ | thumbPath, |
$ | thumbUrl, | ||
$ | params, | ||
$ | flags | ||
) | [protected] |
Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors)
$thumbPath | string Thumbnail storage path |
$thumbUrl | string Thumbnail URL |
$params | Array |
$flags | integer |
Definition at line 760 of file File.php.
References $wgIgnoreImageErrors, and wfMsg().
Referenced by transform().
File::upgradeRow | ( | ) |
Upgrade the database row if there is one Called by ImagePage STUB.
Reimplemented in LocalFile, and OldLocalFile.
File::userCan | ( | $ | field, |
User $ | user = null |
||
) |
Determine if the current user is allowed to view a particular field of this file, if it's marked as deleted.
STUB
$field | Integer |
$user | User object to check, or null to use $wgUser |
Reimplemented in OldLocalFile.
File::wasDeleted | ( | ) |
Was this file ever deleted from the wiki?
Definition at line 1373 of file File.php.
References $title, and getTitle().
File::$extension |
Definition at line 95 of file File.php.
Referenced by generateThumbName().
File::$fsFile [protected] |
Definition at line 85 of file File.php.
Referenced by getPropsFromPath(), and sha1Base36().
File::$handler [protected] |
Reimplemented in UnregisteredLocalFile.
Definition at line 90 of file File.php.
Referenced by convertMetadataVersion(), getDimensionsString(), getLength(), getLongDesc(), getShortDesc(), isVectorized(), and ForeignAPIFile\purgeThumbnails().
File::$isSafeFile |
File::$name |
Definition at line 95 of file File.php.
Referenced by __get(), and generateThumbName().
File::$path |
Reimplemented in UnregisteredLocalFile.
Definition at line 95 of file File.php.
Referenced by getArchiveRel(), getArchiveThumbRel(), getArchiveThumbUrl(), getArchiveUrl(), getArchiveVirtualUrl(), getPropsFromPath(), ForeignAPIFile\getThumbPath(), getThumbRel(), getThumbUrl(), getThumbVirtualUrl(), getVirtualUrl(), iconThumb(), and sha1Base36().
File::$repo |
Definition at line 73 of file File.php.
Referenced by ForeignAPIFile\__construct(), UnregisteredLocalFile\__construct(), OldLocalFile\__construct(), __construct(), UploadStashFile\__construct(), OldLocalFile\newFromArchiveName(), OldLocalFile\newFromKey(), OldLocalFile\newFromRow(), ForeignDBFile\newFromRow(), OldLocalFile\newFromTitle(), ForeignDBFile\newFromTitle(), ForeignAPIFile\newFromTitle(), and UnregisteredLocalFile\newFromTitle().
File::$repoClass = 'FileRepo' [protected] |
Reimplemented in LocalFile, and ForeignAPIFile.
File::$title |
Reimplemented in UnregisteredLocalFile.
Definition at line 78 of file File.php.
Referenced by ForeignAPIFile\__construct(), OldLocalFile\__construct(), __construct(), OldLocalFile\newFromArchiveName(), OldLocalFile\newFromRow(), ForeignDBFile\newFromRow(), OldLocalFile\newFromTitle(), ForeignDBFile\newFromTitle(), ForeignAPIFile\newFromTitle(), normalizeTitle(), purgeDescription(), purgeEverything(), and wasDeleted().
File::$url [protected] |
Reimplemented in UploadStashFile.
Definition at line 95 of file File.php.
Referenced by ForeignAPIFile\purgeDescriptionPage().
const File::DELETE_SOURCE = 1 |
Definition at line 49 of file File.php.
Referenced by WikiRevision\importUpload(), UploadBase\performUpload(), LocalFile\publishTo(), and OldLocalFile\uploadOld().
const File::DELETED_COMMENT = 2 |
Definition at line 37 of file File.php.
Referenced by ApiQueryFilearchive\execute(), RevDel_FileItem\getComment(), ArchivedFile\getDescription(), SpecialUndelete\getFileComment(), ApiQueryImageInfo\getInfo(), and ImageHistoryList\imageHistoryLine().
const File::DELETED_FILE = 1 |
Definition at line 36 of file File.php.
Referenced by LocalFileMoveBatch\addOlds(), RevDel_FileItem\canViewContent(), DeleteArchivedFilesImplementation\doDelete(), ApiQueryFilearchive\execute(), SpecialUndelete\execute(), LocalFileDeleteBatch\execute(), LocalFileRestoreBatch\execute(), FileRepo\findFile(), FileRepo\findFileFromKey(), SpecialUndelete\getFileLink(), ApiQueryImageInfo\getInfo(), ImageHistoryList\getThumbForLine(), LocalRepo\hiddenFileHasKey(), ImageHistoryList\imageHistoryLine(), RevDel_FileItem\isDeleted(), OldLocalFile\isVisible(), RevDel_FileItem\setBits(), and SpecialRevisionDelete\tryShowFile().
const File::DELETED_RESTRICTED = 8 |
Definition at line 39 of file File.php.
Referenced by RevDel_FileItem\canView(), ApiQueryFilearchive\execute(), SpecialUndelete\execute(), SpecialUndelete\formatFileRow(), RevDel_FileList\getSuppressBit(), ImageHistoryList\imageHistoryLine(), and SpecialRevisionDelete\tryShowFile().
const File::DELETED_USER = 4 |
Definition at line 38 of file File.php.
Referenced by ApiQueryFilearchive\execute(), SpecialUndelete\getFileUser(), ApiQueryImageInfo\getInfo(), ArchivedFile\getUser(), ArchivedFile\getUserText(), and ImageHistoryList\imageHistoryLine().
const File::RENDER_FORCE = 2 |
Force rendering even if thumbnail already exist and using RENDER_NOW I.e.
you have to pass both flags: File::RENDER_NOW | File::RENDER_FORCE
Definition at line 47 of file File.php.
Referenced by ExifRotationTest\testRotationRendering(), ExifRotationTest\testRotationRenderingNoAutoRotate(), and transform().
const File::RENDER_NOW = 1 |
Force rendering in the current process.
Definition at line 42 of file File.php.
Referenced by SpecialUploadStash\outputLocallyScaledThumb(), ExifRotationTest\testRotationRendering(), ExifRotationTest\testRotationRenderingNoAutoRotate(), transform(), and wfStreamThumb().