MediaWiki fundraising/REL1_35
|
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() | |
canAnimateThumbIfAppropriate () | |
Will the thumbnail be animated if one would expect it to be. | |
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, $user=null) | |
Delete all versions of the file. | |
deleteFile ( $reason, User $user, $suppress=false) | |
Delete all versions of the file. | |
exists () | |
Returns true if file exists in the repository. | |
formatMetadata ( $context=false) | |
generateAndSaveThumb ( $tmpFile, $transformParams, $flags) | |
Generates a thumbnail according to the given parameters and saves it to storage. | |
generateThumbName ( $name, $params) | |
Generate a thumbnail file name from a name and specified parameters Stable to override. | |
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 Stable to override. | |
getArchiveThumbPath ( $archiveName, $suffix=false) | |
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified. | |
getArchiveThumbUrl ( $archiveName, $suffix=false) | |
Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified Stable to override. | |
getArchiveUrl ( $suffix=false) | |
Get the URL of the archive directory, or a particular file if $suffix is specified Stable to override. | |
getArchiveVirtualUrl ( $suffix=false) | |
Get the public zone virtual URL for an archived version source file Stable to override. | |
getAvailableLanguages () | |
Gives a (possibly empty) list of languages to render the file in. | |
getBitDepth () | |
Return the bit depth of the file Overridden by LocalFile STUB Stable to override. | |
getCanonicalUrl () | |
Stable to override. | |
getCommonMetaArray () | |
Like getMetadata but returns a handler independent array of common values. | |
getContentHeaders () | |
getDefaultRenderLanguage () | |
In files that support multiple language, what is the default language to use if none specified. | |
getDescription ( $audience=self::FOR_PUBLIC, User $user=null) | |
Get description of file revision STUB. | |
getDescriptionShortUrl () | |
Get short description URL for a files based on the page ID Stable to override. | |
getDescriptionText (Language $lang=null) | |
Get the HTML text of the description page, if available Stable to override. | |
getDescriptionTouched () | |
Returns the timestamp (in TS_MW format) of the last change of the description page. | |
getDescriptionUrl () | |
Get the URL of the image description page. | |
getDimensionsString () | |
getDisplayWidthHeight ( $maxWidth, $maxHeight, $page=1) | |
Get the width and height to display image at. | |
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. | |
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 () | |
getMatchedLanguage ( $userPreferredLanguage) | |
Get the language code from the available languages for this file that matches the language requested by the user. | |
getMediaType () | |
Return the type of the media in the file. | |
getMetadata () | |
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB Stable to override. | |
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 () | |
getRel () | |
Get the path of the file relative to the public zone root. | |
getRepo () | |
Returns the repository Stable to override. | |
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 Stable to override. | |
getStorageKey () | |
Get the deletion archive key, "<sha1>.<ext>". | |
getThumbDisposition ( $thumbName, $dispositionType='inline') | |
getThumbnailBucket ( $desiredWidth, $page=1) | |
Return the smallest bucket from $wgThumbnailBuckets which is at least $wgThumbnailMinimumBucketDistance larger than $desiredWidth. | |
getThumbnailSource ( $params) | |
Returns the most appropriate source image for the thumbnail, given a target thumbnail size. | |
getThumbPath ( $suffix=false) | |
Get the path of the thumbnail directory, or a particular file if $suffix is specified Stable to override. | |
getThumbRel ( $suffix=false) | |
Get the path, relative to the thumbnail zone root, of the thumbnail directory or a particular file if $suffix is specified Stable to override. | |
getThumbUrl ( $suffix=false) | |
Get the URL of the thumbnail directory, or a particular file if $suffix is specified Stable to override. | |
getThumbVirtualUrl ( $suffix=false) | |
Get the virtual URL for a thumbnail file or directory Stable to override. | |
getTimestamp () | |
Get the 14-character timestamp of the file upload. | |
getTitle () | |
Return the associated title object. | |
getTranscodedPath ( $suffix=false) | |
Get the path of the transcoded directory, or a particular file if $suffix is specified. | |
getTranscodedUrl ( $suffix=false) | |
Get the URL of the transcoded directory, or a particular file if $suffix is specified. | |
getUnscaledThumb ( $handlerParams=[]) | |
Get a ThumbnailImage which is the same size as the source. | |
getUrl () | |
Return the URL of the file Stable to override. | |
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 Stable to override. | |
getVisibility () | |
Return the deletion bitfield STUB Stable to override. | |
getWidth ( $page=1) | |
Return the width of the image. | |
iconThumb () | |
Get a ThumbnailImage representing a file type icon. | |
isCacheable () | |
Check if this file object is small and can be cached Stable to override. | |
isDeleted ( $field) | |
Is this file a "deleted" file in a private archive? STUB. | |
isExpensiveToThumbnail () | |
True if creating thumbnails from the file is large or otherwise resource-intensive. | |
isLocal () | |
Returns true if the file comes from the local file repository. | |
isMissing () | |
Stable to override. | |
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. | |
isTransformedLocally () | |
Whether the thumbnails created on the same server as this code is running. | |
isVectorized () | |
Return true if the file is vectorized. | |
isVisible () | |
Returns true if file exists in the repository and can be included in a page. | |
load ( $flags=0) | |
Load any lazy-loaded file object fields from source. | |
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 ( $src, $flags=0, array $options=[]) | |
Move or copy a file to its public location. | |
purgeCache ( $options=[]) | |
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile Stable to override. | |
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. | |
recordUpload ( $oldver, $desc, $license='', $copyStatus='', $source='', $watch=false, $timestamp=false, User $user=null) | |
Record a file upload in the upload log and the image table Stable to override STUB Overridden by LocalFile. | |
redirectedFrom ( $from) | |
resetHistory () | |
Reset the history pointer to the first element of the history. | |
restore ( $versions=[], $unsuppress=false) | |
Restore all or specified deleted revisions to the given file. | |
thumbName ( $params, $flags=0) | |
Return the file name of a thumbnail with the specified parameters. | |
transform ( $params, $flags=0) | |
Transform a media file Stable to override. | |
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 | compare (File $a, File $b) |
Callback for usort() to do file sorts by name. | |
static | normalizeExtension ( $extension) |
Normalize a file extension to the common form, making it lowercase and checking some synonyms, 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 | 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 | |
FileRepo LocalRepo ForeignAPIRepo bool | $repo |
Some member variables can be lazy-initialised using __get(). | |
const | DELETE_SOURCE = 1 |
const | DELETED_COMMENT = 2 |
const | DELETED_FILE = 1 |
const | DELETED_RESTRICTED = 8 |
const | DELETED_USER = 4 |
const | FOR_PUBLIC = 1 |
const | FOR_THIS_USER = 2 |
const | RAW = 3 |
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. | |
const | THUMB_FULL_NAME = 1 |
Public Attributes inherited from IDBAccessObject | |
const | READ_LOCKING = self::READ_LATEST | 2 |
Constants for object loading bitfield flags (higher => higher QoS) | |
const | READ_NONE = -1 |
Protected Member Functions | |
assertRepoDefined () | |
Assert that $this->repo is set to a valid FileRepo instance. | |
assertTitleDefined () | |
Assert that $this->title is set to a Title. | |
generateBucketsIfNeeded ( $params, $flags=0) | |
Generates chained bucketed thumbnails if needed. | |
getBucketThumbName ( $bucket) | |
Returns the name of the thumb for a given bucket. | |
getBucketThumbPath ( $bucket) | |
Returns the repo path of the thumb for a given bucket. | |
getCanRender () | |
Accessor for __get() | |
getImageSize ( $filePath) | |
Get an image size array like that returned by getImageSize(), or false if it can't be determined. | |
getIsSafeFile () | |
Accessor for __get() | |
getIsSafeFileUncached () | |
Uncached accessor. | |
getRedirectedTitle () | |
getThumbnails () | |
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile Stable to override. | |
isHashed () | |
isTrustedFile () | |
Returns true if the file is flagged as trusted. | |
makeTransformTmpFile ( $thumbPath) | |
Creates a temp FS file with the same extension and the thumbnail. | |
migrateThumbFile ( $thumbName) | |
Hook into transform() to allow migration of thumbnail files STUB Stable to override. | |
readOnlyError () | |
transformErrorOutput ( $thumbPath, $thumbUrl, $params, $flags) | |
Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors) | |
Protected Attributes | |
bool | $canRender |
Whether the output of transform() for this file is likely to be valid. | |
string | $extension |
File extension. | |
FSFile bool | $fsFile |
False if undefined. | |
MediaHandler | $handler |
string | $hashPath |
Relative path including trailing slash. | |
bool | $isSafeFile |
Whether this media file is in a format that is unlikely to contain viruses or malicious content. | |
string | $lastError |
Text of last error. | |
string | $name |
The name of a file from its title object. | |
int false | $pageCount |
Number of pages of a multipage document, or false for documents which aren't multipage documents. | |
string | $path |
The storage path corresponding to one of the zones. | |
string | $redirected |
Main part of the title, with underscores (Title::getDBkey) | |
Title | $redirectedTitle |
Title | $redirectTitle |
string | $repoClass = FileRepo::class |
Required Repository class type. | |
Title string bool | $title |
array | $tmpBucketedThumbCache = [] |
Cache of tmp filepaths pointing to generated bucket thumbnails, keyed by width. | |
string | $transformScript |
URL of transformscript (for example thumb.php) | |
string | $url |
The URL corresponding to one of the four basic zones. | |
Private Member Functions | |
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. | |
getTransformScript () | |
getZoneUrl ( $zone, $suffix=false) | |
Get the URL of the zone directory, or a particular file if $suffix is specified. | |
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 );
Consider the services container below;
$services = MediaWikiServices::getInstance();
The convenience services $services->getRepoGroup()->getLocalRepo()->newFile() and $services->getRepoGroup()->findFile() should be sufficient in most cases.
@TODO: DI - Instead of using MediaWikiServices::getInstance(), a service should ideally accept a RepoGroup in its constructor and then, use $this->repoGroup->findFile() and $this->repoGroup->getLocalRepo()->newFile().
Stable to extend
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.
Stable to call
Reimplemented in LocalFile.
Definition at line 181 of file File.php.
References $title.
File::allowInlineDisplay | ( | ) |
Alias for canRender()
Definition at line 857 of file File.php.
References canRender().
Referenced by canAnimateThumbIfAppropriate(), and getIsSafeFileUncached().
|
protected |
Assert that $this->repo is set to a valid FileRepo instance.
MWException |
Definition at line 2421 of file File.php.
Referenced by LocalFile\__construct(), ForeignAPIFile\__construct(), UnregisteredLocalFile\__construct(), getArchivePath(), getArchiveThumbPath(), getArchiveThumbUrl(), getArchiveUrl(), getArchiveVirtualUrl(), getHashPath(), getLocalRefPath(), getName(), getPath(), getSha1(), UnregisteredLocalFile\getSize(), getThumbPath(), getThumbVirtualUrl(), getTimestamp(), getTranscodedPath(), getUrl(), getVirtualUrl(), getZoneUrl(), and isHashed().
|
protected |
Assert that $this->title is set to a Title.
MWException |
Definition at line 2431 of file File.php.
Referenced by LocalFile\__construct().
File::canAnimateThumbIfAppropriate | ( | ) |
Will the thumbnail be animated if one would expect it to be.
Currently used to add a warning to the image description page
Definition at line 697 of file File.php.
References allowInlineDisplay(), MediaHandler\canAnimateThumbnail(), getHandler(), and MediaHandler\isAnimatedImage().
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 821 of file File.php.
References canRender(), exists(), and getHandler().
Referenced by allowInlineDisplay(), canRender(), getCanRender(), getViewURL(), transform(), and ForeignAPIFile\transform().
|
static |
Checks if file extensions are compatible.
File | $old | Old file |
string | $new | New name |
Definition at line 264 of file File.php.
References getMimeType().
File::convertMetadataVersion | ( | $metadata, | |
$version ) |
get versioned metadata
array | string | $metadata | Array or string of (serialized) metadata |
int | $version | Version number. |
Definition at line 750 of file File.php.
References MediaHandler\convertMetadataVersion(), getHandler(), and unserialize().
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.
int | $width | Maximum width of the generated thumbnail |
int | $height | Maximum height of the image (optional) |
Definition at line 1084 of file File.php.
References transform().
Referenced by getViewURL().
File::delete | ( | $reason, | |
$suppress = false, | |||
$user = null ) |
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.
string | $reason | |
bool | $suppress | Hide content from sysops? |
User | null | $user |
Reimplemented in ForeignDBFile, and LocalFile.
Definition at line 2053 of file File.php.
References readOnlyError(), and wfDeprecated().
File::deleteFile | ( | $reason, | |
User | $user, | ||
$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.
string | $reason | |
User | $user | |
bool | $suppress | Hide content from sysops? |
Reimplemented in ForeignDBFile, and LocalFile.
Definition at line 2076 of file File.php.
References readOnlyError().
File::exists | ( | ) |
Returns true if file exists in the repository.
Overridden by LocalFile to avoid unnecessary stat calls.
Stable to override
Reimplemented in ForeignAPIFile, LocalFile, OldLocalFile, and UploadStashFile.
Definition at line 966 of file File.php.
References getPath().
Referenced by canRender(), isVisible(), and OutputPage\setFileVersion().
File::formatMetadata | ( | $context = false | ) |
bool | IContextSource | $context | Context to use (optional) |
Definition at line 1938 of file File.php.
References getHandler().
File::generateAndSaveThumb | ( | $tmpFile, | |
$transformParams, | |||
$flags ) |
Generates a thumbnail according to the given parameters and saves it to storage.
TempFSFile | $tmpFile | Temporary file where the rendered thumbnail will be saved |
array | $transformParams | |
int | $flags |
Definition at line 1211 of file File.php.
References $wgIgnoreImageErrors, MediaHandler\doTransform(), generateBucketsIfNeeded(), getHandler(), getThumbDisposition(), getThumbPath(), getThumbUrl(), MediaHandler\getTransform(), MediaHandler\normaliseParams(), MediaHandler\supportsBucketing(), thumbName(), and transformErrorOutput().
Referenced by generateBucketsIfNeeded(), and transform().
|
protected |
Generates chained bucketed thumbnails if needed.
array | $params | |
int | $flags |
Definition at line 1279 of file File.php.
References generateAndSaveThumb(), getBucketThumbPath(), getHandler(), getThumbnailBucket(), and makeTransformTmpFile().
Referenced by generateAndSaveThumb().
File::generateThumbName | ( | $name, | |
$params ) |
Generate a thumbnail file name from a name and specified parameters Stable to override.
string | $name | |
array | $params | Parameters which will be passed to MediaHandler::makeParamString |
Definition at line 1045 of file File.php.
References getExtension(), getHandler(), getMimeType(), and getSha1().
Referenced by thumbName(), and UploadStashFile\thumbName().
File::getArchivePath | ( | $suffix = false | ) |
Get the path of the archived file.
bool | string | $suffix | If not false, the name of an archived file. |
Definition at line 1691 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 Stable to override.
bool | string | $suffix | If not false, the name of an archived thumbnail file |
Definition at line 1629 of file File.php.
References $path, and getHashPath().
Referenced by getArchivePath(), getArchiveThumbRel(), OldLocalFile\getRel(), OldLocalFile\getUrlRel(), and OldLocalFile\uploadOld().
File::getArchiveThumbPath | ( | $archiveName, | |
$suffix = false ) |
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified.
string | $archiveName | The timestamped name of an archived image |
bool | string | $suffix | If not false, the name of a thumbnail file |
Definition at line 1704 of file File.php.
References assertRepoDefined(), and getArchiveThumbRel().
Referenced by LocalFile\getThumbnails().
|
private |
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.
string | $archiveName | The timestamped name of an archived image |
bool | string | $suffix | If not false, the name of a thumbnail file |
Definition at line 1676 of file File.php.
References $path, and getArchiveRel().
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 Stable to override.
string | $archiveName | The timestamped name of an archived image |
bool | string | $suffix | If not false, the name of a thumbnail file |
Definition at line 1764 of file File.php.
References $ext, $path, assertRepoDefined(), getExtension(), and getHashPath().
Referenced by LocalFile\purgeOldThumbnails().
File::getArchiveUrl | ( | $suffix = false | ) |
Get the URL of the archive directory, or a particular file if $suffix is specified Stable to override.
bool | string | $suffix | If not false, the name of an archived file |
Definition at line 1743 of file File.php.
References $ext, $path, assertRepoDefined(), getExtension(), and getHashPath().
File::getArchiveVirtualUrl | ( | $suffix = false | ) |
Get the public zone virtual URL for an archived version source file Stable to override.
bool | string | $suffix | If not false, the name of a thumbnail file |
Definition at line 1839 of file File.php.
References $path, assertRepoDefined(), and getHashPath().
File::getAvailableLanguages | ( | ) |
Gives a (possibly empty) list of languages to render the file in.
If the file doesn't have translations, or if the file format does not support that sort of thing, returns an empty array.
Definition at line 643 of file File.php.
References MediaHandler\getAvailableLanguages(), and getHandler().
File::getBitDepth | ( | ) |
Return the bit depth of the file Overridden by LocalFile STUB Stable to override.
Reimplemented in LocalFile, and UnregisteredLocalFile.
|
protected |
Returns the name of the thumb for a given bucket.
int | $bucket |
Definition at line 1414 of file File.php.
References thumbName().
Referenced by getBucketThumbPath().
|
protected |
Returns the repo path of the thumb for a given bucket.
int | $bucket |
Definition at line 1404 of file File.php.
References getBucketThumbName(), and getThumbPath().
Referenced by generateBucketsIfNeeded(), and getThumbnailSource().
File::getCanonicalUrl | ( | ) |
Stable to override.
Definition at line 405 of file File.php.
References getUrl(), PROTO_CANONICAL, and wfExpandUrl().
|
protected |
File::getCommonMetaArray | ( | ) |
Like getMetadata but returns a handler independent array of common values.
Definition at line 732 of file File.php.
References MediaHandler\getCommonMetaArray(), and getHandler().
File::getContentHeaders | ( | ) |
Definition at line 2315 of file File.php.
References MediaHandler\getContentHeaders(), getHandler(), and getMetadata().
File::getDefaultRenderLanguage | ( | ) |
In files that support multiple language, what is the default language to use if none specified.
Definition at line 678 of file File.php.
References MediaHandler\getDefaultRenderLanguage(), and getHandler().
File::getDescription | ( | $audience = self::FOR_PUBLIC, | |
User | $user = null ) |
Get description of file revision STUB.
Stable to override
int | $audience | One of: File::FOR_PUBLIC to be displayed to all users File::FOR_THIS_USER to be displayed to the given user File::RAW get the description regardless of permissions |
User | null | $user | User object to check for, only if FOR_THIS_USER is passed to the $audience parameter |
Reimplemented in ForeignAPIFile, and LocalFile.
File::getDescriptionShortUrl | ( | ) |
Get short description URL for a files based on the page ID Stable to override.
Reimplemented in ForeignAPIFile, ForeignDBFile, and LocalFile.
File::getDescriptionText | ( | Language | $lang = null | ) |
Get the HTML text of the description page, if available Stable to override.
Language | null | $lang | Optional language to fetch description in |
Reimplemented in ForeignDBFile, and LocalFile.
Definition at line 2188 of file File.php.
References $cache, $lang, $res, $wgLang, getName(), and wfDebug().
File::getDescriptionTouched | ( | ) |
Returns the timestamp (in TS_MW format) of the last change of the description page.
Returns false if the file does not have a description page, or retrieving the timestamp would be expensive.
Reimplemented in LocalFile.
File::getDescriptionUrl | ( | ) |
Get the URL of the image description page.
May return false if it is unknown or not applicable.
Stable to override
Reimplemented in ForeignAPIFile, ForeignDBFile, LocalFile, and UploadStashFile.
Definition at line 2173 of file File.php.
References getName().
Referenced by ForeignDBFile\getDescriptionUrl(), and transform().
File::getDimensionsString | ( | ) |
Definition at line 2361 of file File.php.
References MediaHandler\getDimensionsString(), and getHandler().
File::getDisplayWidthHeight | ( | $maxWidth, | |
$maxHeight, | |||
$page = 1 ) |
Get the width and height to display image at.
int | $maxWidth | Max width to display at |
int | $maxHeight | Max height to display at |
int | $page |
MWException |
Definition at line 561 of file File.php.
References getHeight(), and getWidth().
File::getExtension | ( | ) |
Get the file extension, e.g.
"svg"
Stable to override
Definition at line 330 of file File.php.
References getName().
Referenced by generateThumbName(), getArchiveThumbUrl(), getArchiveUrl(), ForeignAPIFile\getMimeType(), getStorageKey(), getThumbDisposition(), getUrl(), getZoneUrl(), 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. Stable to override
Reimplemented in UploadStashFile.
Definition at line 397 of file File.php.
References getUrl(), PROTO_RELATIVE, and wfExpandUrl().
File::getHandler | ( | ) |
Get a MediaHandler instance for this file.
Definition at line 1459 of file File.php.
References MediaHandler\getHandler(), and getMimeType().
Referenced by UnregisteredLocalFile\cachePageDimensions(), canAnimateThumbIfAppropriate(), canRender(), convertMetadataVersion(), formatMetadata(), generateAndSaveThumb(), generateBucketsIfNeeded(), generateThumbName(), getAvailableLanguages(), getCommonMetaArray(), getContentHeaders(), getDefaultRenderLanguage(), getDimensionsString(), LocalFile\getHeight(), UnregisteredLocalFile\getImageSize(), getImageSize(), getLength(), getLongDesc(), getMatchedLanguage(), UnregisteredLocalFile\getMetadata(), getShortDesc(), getThumbnailSource(), LocalFile\getWidth(), isExpensiveToThumbnail(), isMultipage(), isVectorized(), LocalFile\maybeUpgradeRow(), mustRender(), pageCount(), ForeignAPIFile\purgeThumbnails(), LocalFile\purgeThumbnails(), transform(), and transformErrorOutput().
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 1601 of file File.php.
References assertRepoDefined(), and getName().
Referenced by getArchiveRel(), getArchiveThumbUrl(), getArchiveUrl(), getArchiveVirtualUrl(), getRel(), ForeignAPIFile\getThumbPath(), 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
Stable to override
int | $page |
Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.
Definition at line 503 of file File.php.
Referenced by getDisplayWidthHeight(), and getThumbnailSource().
File::getHistory | ( | $limit = null, | |
$start = null, | |||
$end = null, | |||
$inc = true ) |
Return a fragment of the history of file.
STUB Stable to override
int | null | $limit | Limit of rows to return |
string | int | null | $start | Only revisions older than $start will be returned |
string | int | null | $end | Only revisions newer than $end will be returned |
bool | $inc | Include the endpoints of the time range |
Reimplemented in LocalFile.
|
protected |
Get an image size array like that returned by getImageSize(), or false if it can't be determined.
Loads the image size directly from the file ignoring caches.
Stable to override
string | $filePath | The path to the file (e.g. From getLocalRefPath() ) |
Reimplemented in UnregisteredLocalFile.
Definition at line 2158 of file File.php.
References getHandler().
|
protected |
|
protected |
Uncached accessor.
Definition at line 896 of file File.php.
References $mime, $type, $wgTrustedMediaFormats, allowInlineDisplay(), getMediaType(), getMimeType(), isTrustedFile(), and MEDIATYPE_UNKNOWN.
Referenced by isSafeFile().
File::getLastError | ( | ) |
File::getLength | ( | ) |
Get the duration of a media file in seconds.
Stable to override
Definition at line 609 of file File.php.
References getHandler(), and MediaHandler\getLength().
File::getLocalRefPath | ( | ) |
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 457 of file File.php.
References assertRepoDefined(), and getPath().
Referenced by UnregisteredLocalFile\getBitDepth(), UnregisteredLocalFile\getImageSize(), UnregisteredLocalFile\getMetadata(), UnregisteredLocalFile\getMimeType(), MediaHandler\getPageDimensions(), and getThumbnailSource().
File::getLongDesc | ( | ) |
Definition at line 2337 of file File.php.
References MediaHandler\getGeneralLongDesc(), getHandler(), and MediaHandler\getLongDesc().
File::getMatchedLanguage | ( | $userPreferredLanguage | ) |
Get the language code from the available languages for this file that matches the language requested by the user.
string | $userPreferredLanguage |
Definition at line 659 of file File.php.
References MediaHandler\getAvailableLanguages(), getHandler(), and MediaHandler\getMatchedLanguage().
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 Stable to override
Reimplemented in ForeignAPIFile, and LocalFile.
Definition at line 805 of file File.php.
References MEDIATYPE_UNKNOWN.
Referenced by getIsSafeFileUncached().
File::getMetadata | ( | ) |
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB Stable to override.
Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.
Definition at line 722 of file File.php.
Referenced by GIFHandler\getCommonMetaArray(), PNGHandler\getCommonMetaArray(), and getContentHeaders().
File::getMimeType | ( | ) |
Returns the MIME type of the file.
Overridden by LocalFile, UnregisteredLocalFile STUB
Stable to override
Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.
Definition at line 793 of file File.php.
Referenced by checkExtensionCompatibility(), generateThumbName(), getHandler(), getIsSafeFileUncached(), and getViewURL().
File::getName | ( | ) |
Return the name of this file.
Stable to override
Definition at line 315 of file File.php.
References assertRepoDefined().
Referenced by compare(), LocalFile\getCacheKey(), getDescriptionText(), ForeignDBFile\getDescriptionText(), getDescriptionUrl(), getExtension(), getHashPath(), getRel(), ForeignAPIFile\getThumbnails(), getThumbnailSource(), getTransformScript(), getUrlRel(), getViewURL(), ImageHistoryList\imageHistoryLine(), LocalFile\loadExtraFieldsWithTimestamp(), OldLocalFile\loadExtraFromDB(), LocalFile\loadFromDB(), OldLocalFile\loadFromDB(), ForeignAPIFile\purgeDescriptionPage(), LocalFile\purgeThumbList(), ForeignAPIFile\purgeThumbnails(), OldLocalFile\recordOldUpload(), thumbName(), ForeignAPIFile\transform(), LocalFile\upgradeRow(), and OldLocalFile\upgradeRow().
File::getOriginalTitle | ( | ) |
Return the title used to find this file.
Definition at line 354 of file File.php.
References $title, and 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.
Stable to override
Reimplemented in ForeignAPIFile.
Definition at line 441 of file File.php.
References $path, assertRepoDefined(), and getRel().
Referenced by exists(), getLocalRefPath(), getSha1(), and getTimestamp().
|
protected |
Definition at line 2380 of file File.php.
References NS_FILE.
Referenced by getOriginalTitle().
File::getRel | ( | ) |
Get the path of the file relative to the public zone root.
This function is overridden in OldLocalFile to be like getArchiveRel().
Stable to override
Reimplemented in OldLocalFile.
Definition at line 1617 of file File.php.
References getHashPath(), and getName().
Referenced by getPath(), and getThumbRel().
File::getRepo | ( | ) |
Returns the repository Stable to override.
Reimplemented in ForeignAPIFile, ForeignDBFile, and LocalFile.
File::getRepoName | ( | ) |
File::getSha1 | ( | ) |
Get the SHA-1 base 36 hash of the file.
Stable to override
Reimplemented in ForeignAPIFile, and LocalFile.
Definition at line 2273 of file File.php.
References assertRepoDefined(), and getPath().
Referenced by generateThumbName(), getStorageKey(), and ApiQueryDuplicateFiles\run().
File::getShortDesc | ( | ) |
Definition at line 2349 of file File.php.
References MediaHandler\getGeneralShortDesc(), getHandler(), and MediaHandler\getShortDesc().
File::getSize | ( | ) |
Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB Stable to override.
Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.
Definition at line 781 of file File.php.
Referenced by getThumbnailSource().
File::getStorageKey | ( | ) |
Get the deletion archive key, "<sha1>.<ext>".
Definition at line 2284 of file File.php.
References $ext, getExtension(), and getSha1().
File::getThumbDisposition | ( | $thumbName, | |
$dispositionType = 'inline' ) |
string | $thumbName | Thumbnail name |
string | $dispositionType | Type of disposition (either "attachment" or "inline") |
Definition at line 1434 of file File.php.
References FileBackend\extensionFromPath(), getExtension(), and FileBackend\makeContentDisposition().
Referenced by generateAndSaveThumb().
File::getThumbnailBucket | ( | $desiredWidth, | |
$page = 1 ) |
Return the smallest bucket from $wgThumbnailBuckets which is at least $wgThumbnailMinimumBucketDistance larger than $desiredWidth.
The returned bucket, if any, will always be bigger than $desiredWidth.
int | $desiredWidth | |
int | $page |
Definition at line 516 of file File.php.
References $wgThumbnailBuckets, $wgThumbnailMinimumBucketDistance, and getWidth().
Referenced by generateBucketsIfNeeded(), and getThumbnailSource().
|
protected |
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile Stable to override.
Reimplemented in ForeignAPIFile.
File::getThumbnailSource | ( | $params | ) |
Returns the most appropriate source image for the thumbnail, given a target thumbnail size.
array | $params |
Definition at line 1336 of file File.php.
References PoolCounterWork\execute(), getBucketThumbPath(), getHandler(), getHeight(), getLocalRefPath(), getName(), getSize(), getThumbnailBucket(), and getWidth().
File::getThumbPath | ( | $suffix = false | ) |
Get the path of the thumbnail directory, or a particular file if $suffix is specified Stable to override.
bool | string | $suffix | If not false, the name of a thumbnail file |
Reimplemented in ForeignAPIFile, and UploadStashFile.
Definition at line 1718 of file File.php.
References assertRepoDefined(), and getThumbRel().
Referenced by generateAndSaveThumb(), getBucketThumbPath(), LocalFile\getThumbnails(), and 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 Stable to override.
bool | string | $suffix | If not false, the name of a thumbnail file |
Definition at line 1648 of file File.php.
References $path, and getRel().
Referenced by getThumbPath(), and getTranscodedPath().
File::getThumbUrl | ( | $suffix = false | ) |
Get the URL of the thumbnail directory, or a particular file if $suffix is specified Stable to override.
bool | string | $suffix | If not false, the name of a thumbnail file |
Reimplemented in UploadStashFile.
Definition at line 1801 of file File.php.
References getZoneUrl().
Referenced by generateAndSaveThumb(), LocalFile\purgeThumbnails(), and transform().
File::getThumbVirtualUrl | ( | $suffix = false | ) |
Get the virtual URL for a thumbnail file or directory Stable to override.
bool | string | $suffix | If not false, the name of a thumbnail file |
Definition at line 1858 of file File.php.
References $path, assertRepoDefined(), and getUrlRel().
File::getTimestamp | ( | ) |
Get the 14-character timestamp of the file upload.
Stable to override
Reimplemented in ForeignAPIFile, and LocalFile.
Definition at line 2249 of file File.php.
References assertRepoDefined(), and getPath().
Referenced by getTimestamp().
File::getTitle | ( | ) |
Return the associated title object.
Definition at line 345 of file File.php.
References $title.
Referenced by FileDeleteForm\__construct(), and SpecialFileDuplicateSearch\doBatchLookups().
File::getTranscodedPath | ( | $suffix = false | ) |
Get the path of the transcoded directory, or a particular file if $suffix is specified.
bool | string | $suffix | If not false, the name of a media file |
Definition at line 1730 of file File.php.
References assertRepoDefined(), and getThumbRel().
File::getTranscodedUrl | ( | $suffix = false | ) |
Get the URL of the transcoded directory, or a particular file if $suffix is specified.
bool | string | $suffix | If not false, the name of a media file |
Definition at line 1811 of file File.php.
References getZoneUrl().
|
private |
Definition at line 984 of file File.php.
References getName(), and wfAppendQuery().
Referenced by transform().
File::getUnscaledThumb | ( | $handlerParams = [] | ) |
Get a ThumbnailImage which is the same size as the source.
array | $handlerParams |
Definition at line 1005 of file File.php.
References getWidth(), iconThumb(), and transform().
File::getUrl | ( | ) |
Return the URL of the file Stable to override.
Reimplemented in ForeignAPIFile, and UploadStashFile.
Definition at line 368 of file File.php.
References $ext, assertRepoDefined(), getExtension(), and getUrlRel().
Referenced by RevDelFileItem\getApiData(), getCanonicalUrl(), getFullUrl(), getViewURL(), and LocalFile\purgeCache().
File::getUrlRel | ( | ) |
Get urlencoded path of the file relative to the public zone root.
This function is overridden in OldLocalFile to be like getArchiveUrl(). Stable to override
Reimplemented in OldLocalFile.
Definition at line 1664 of file File.php.
References getHashPath(), and getName().
Referenced by getThumbVirtualUrl(), getUrl(), getVirtualUrl(), and getZoneUrl().
File::getUser | ( | $type = 'text' | ) |
Returns ID or name of user who uploaded the file STUB.
Stable to override
string | $type | 'text' or 'id' |
Reimplemented in ForeignAPIFile, and LocalFile.
Definition at line 599 of file File.php.
Referenced by SpecialFileDuplicateSearch\doBatchLookups().
File::getViewURL | ( | ) |
Definition at line 412 of file File.php.
References canRender(), createThumb(), getMimeType(), getName(), getUrl(), getWidth(), mustRender(), and wfDebug().
File::getVirtualUrl | ( | $suffix = false | ) |
Get the public zone virtual URL for a current version source file Stable to override.
bool | string | $suffix | If not false, the name of a thumbnail file |
Definition at line 1822 of file File.php.
References $path, assertRepoDefined(), and getUrlRel().
Referenced by LocalFile\isMissing(), and LocalFile\loadFromFile().
File::getVisibility | ( | ) |
File::getWidth | ( | $page = 1 | ) |
Return the width of the image.
Returns false if the width is unknown or undefined.
STUB Overridden by LocalFile, UnregisteredLocalFile
Stable to override
int | $page |
Reimplemented in ForeignAPIFile, LocalFile, and UnregisteredLocalFile.
Definition at line 488 of file File.php.
Referenced by getDisplayWidthHeight(), getThumbnailBucket(), getThumbnailSource(), getUnscaledThumb(), and getViewURL().
|
private |
Get the URL of the zone directory, or a particular file if $suffix is specified.
string | $zone | Name of requested zone |
bool | string | $suffix | If not false, the name of a file in zone |
Definition at line 1783 of file File.php.
References $ext, $path, assertRepoDefined(), getExtension(), and getUrlRel().
Referenced by getThumbUrl(), and getTranscodedUrl().
File::iconThumb | ( | ) |
Get a ThumbnailImage representing a file type icon.
Definition at line 1472 of file File.php.
References $IP, $wgResourceBasePath, and getExtension().
Referenced by getUnscaledThumb(), and transform().
File::isCacheable | ( | ) |
File::isDeleted | ( | $field | ) |
Is this file a "deleted" file in a private archive? STUB.
Stable to override
int | $field | One of DELETED_* bitfield constants |
Reimplemented in OldLocalFile.
File::isExpensiveToThumbnail | ( | ) |
True if creating thumbnails from the file is large or otherwise resource-intensive.
Definition at line 2441 of file File.php.
References getHandler(), and MediaHandler\isExpensiveToThumbnail().
|
protected |
File::isLocal | ( | ) |
Returns true if the file comes from the local file repository.
Definition at line 1951 of file File.php.
Referenced by SpecialFileDuplicateSearch\doBatchLookups(), and FileDeleteForm\haveDeletableFile().
File::isMissing | ( | ) |
File::isMultipage | ( | ) |
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.
Stable to override
Definition at line 2106 of file File.php.
References getHandler().
Referenced by LocalFile\getHeight(), and LocalFile\getWidth().
File::isOld | ( | ) |
Returns true if the image is an old version STUB.
Stable to override
Reimplemented in OldLocalFile.
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 874 of file File.php.
References getIsSafeFileUncached(), and isSafeFile().
Referenced by getIsSafeFile(), and isSafeFile().
File::isTransformedLocally | ( | ) |
Whether the thumbnails created on the same server as this code is running.
Reimplemented in ForeignAPIFile.
|
protected |
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 939 of file File.php.
Referenced by getIsSafeFileUncached().
File::isVectorized | ( | ) |
Return true if the file is vectorized.
Definition at line 623 of file File.php.
References getHandler(), and MediaHandler\isVectorized().
Referenced by LocalFile\prerenderThumbnails().
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
Stable to override
Reimplemented in OldLocalFile.
Definition at line 977 of file File.php.
References exists().
File::load | ( | $flags = 0 | ) |
|
protected |
Creates a temp FS file with the same extension and the thumbnail.
string | $thumbPath | Thumbnail path |
Definition at line 1423 of file File.php.
References FileBackend\extensionFromPath().
Referenced by generateBucketsIfNeeded(), and transform().
|
protected |
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
Stable to override
Title | $target | New file name |
Reimplemented in ForeignDBFile, and LocalFile.
Definition at line 2031 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.
Stable to override
Definition at line 848 of file File.php.
References getHandler().
Referenced by getViewURL().
File::nextHistoryLine | ( | ) |
|
static |
Normalize a file extension to the common form, making it lowercase and checking some synonyms, and ensure it's clean.
Extensions with non-alphanumeric characters will be discarded. Keep in sync with mw.Title.normalizeExtension() in JS.
string | $extension | File extension (without the leading dot) |
|
static |
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
Title | string | $title | |
string | bool | $exception | Use 'exception' to throw an error on bad titles |
MWException |
Definition at line 199 of file File.php.
References $title, NS_FILE, and NS_MEDIA.
Referenced by UnregisteredLocalFile\__construct().
File::pageCount | ( | ) |
Returns the number of pages of a multipage document, or false for documents which aren't multipage documents.
Stable to override
Definition at line 2117 of file File.php.
References getHandler(), and pageCount().
Referenced by pageCount().
File::publish | ( | $src, | |
$flags = 0, | |||
array | $options = [] ) |
Move or copy a file to its public location.
If a file exists at the destination, move it to an archive. Returns a Status object with the archive name in the "value" member on success.
The archive name should be passed through to recordUpload for database registration.
Options to $options include:
string | FSFile | $src | Local filesystem path to the source image |
int | $flags | A bitwise combination of: File::DELETE_SOURCE Delete the source file, i.e. move rather than copy |
array | $options | Optional additional parameters |
STUB Overridden by LocalFile Stable to override
Reimplemented in LocalFile, and ForeignDBFile.
Definition at line 1930 of file File.php.
References readOnlyError().
File::purgeCache | ( | $options = [] | ) |
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile Stable to override.
array | $options | Options, which include: 'forThumbRefresh' : The purging is only to refresh thumbnails |
Reimplemented in ForeignAPIFile, and LocalFile.
Definition at line 1517 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 1525 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 1538 of file File.php.
References $job, $title, getTitle(), HTMLCacheUpdateJob\newForBacklinks(), purgeCache(), and purgeDescription().
|
protected |
MWException |
Definition at line 1880 of file File.php.
Referenced by delete(), ForeignDBFile\delete(), deleteFile(), ForeignDBFile\deleteFile(), move(), ForeignDBFile\move(), publish(), ForeignDBFile\publish(), recordUpload(), ForeignDBFile\recordUpload(), restore(), and ForeignDBFile\restore().
File::recordUpload | ( | $oldver, | |
$desc, | |||
$license = '', | |||
$copyStatus = '', | |||
$source = '', | |||
$watch = false, | |||
$timestamp = false, | |||
User | $user = null ) |
Record a file upload in the upload log and the image table Stable to override STUB Overridden by LocalFile.
string | $oldver | |
string | $desc | |
string | $license | |
string | $copyStatus | |
string | $source | |
bool | $watch | |
string | bool | $timestamp | |
null | User | $user | User object or null to use $wgUser |
MWException |
Reimplemented in ForeignDBFile, and LocalFile.
Definition at line 1901 of file File.php.
References readOnlyError(), and wfDeprecated().
File::redirectedFrom | ( | $from | ) |
File::resetHistory | ( | ) |
File::restore | ( | $versions = [], | |
$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.
array | $versions | Set of record ids of deleted items to restore, or empty to restore all revisions. |
bool | $unsuppress | Remove restrictions on content upon restoration? |
Reimplemented in ForeignDBFile, and LocalFile.
Definition at line 2094 of file File.php.
References readOnlyError().
|
static |
|
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 290 of file File.php.
References $mime.
Referenced by OldLocalFile\upgradeRow().
File::thumbName | ( | $params, | |
$flags = 0 ) |
Return the file name of a thumbnail with the specified parameters.
Use File::THUMB_FULL_NAME to always get a name like "<params>-<source>". Otherwise, the format may be "<params>-<source>" or "<params>-thumbnail.<ext>". Stable to override
array | $params | Handler-specific parameters |
int | $flags | Bitfield that supports THUMB_* constants |
Reimplemented in UploadStashFile.
Definition at line 1029 of file File.php.
References generateThumbName(), and getName().
Referenced by generateAndSaveThumb(), getBucketThumbName(), and transform().
File::transform | ( | $params, | |
$flags = 0 ) |
Transform a media file Stable to override.
array | $params | An associative array of handler-specific parameters. Typical keys are width, height and page. |
int | $flags | A bitfield, may contain self::RENDER_NOW to force rendering |
Reimplemented in ForeignAPIFile.
Definition at line 1127 of file File.php.
References $wgThumbnailEpoch, canRender(), generateAndSaveThumb(), getDescriptionUrl(), getHandler(), MediaHandler\getScriptedTransform(), getThumbPath(), getThumbUrl(), MediaHandler\getTransform(), getTransformScript(), iconThumb(), makeTransformTmpFile(), MediaHandler\normaliseParams(), PROTO_CANONICAL, thumbName(), transformErrorOutput(), wfDebug(), and wfExpandUrl().
Referenced by createThumb(), SpecialFileDuplicateSearch\execute(), and getUnscaledThumb().
|
protected |
Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors)
string | $thumbPath | Thumbnail storage path |
string | $thumbUrl | Thumbnail URL |
array | $params | |
int | $flags |
Definition at line 1106 of file File.php.
References $wgIgnoreImageErrors, getHandler(), MediaHandler\getTransform(), and wfMessage().
Referenced by generateAndSaveThumb(), and transform().
File::upgradeRow | ( | ) |
Upgrade the database row if there is one Called by ImagePage STUB.
Stable to override
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 Stable to override
int | $field | |
User | null | $user | User object to check, or null to use $wgUser (deprecated since 1.35) |
Reimplemented in OldLocalFile.
Definition at line 2304 of file File.php.
References wfDeprecated().
File::wasDeleted | ( | ) |
Was this file ever deleted from the wiki?
Definition at line 2012 of file File.php.
References $title, and getTitle().
Referenced by UploadBase\checkLocalFileWasDeleted().
|
protected |
|
protected |
False if undefined.
Definition at line 125 of file File.php.
Referenced by UnregisteredLocalFile\setLocalReference().
|
protected |
Definition at line 128 of file File.php.
Referenced by LocalFile\getHeight(), LocalFile\getWidth(), LocalFile\maybeUpgradeRow(), ForeignAPIFile\purgeThumbnails(), LocalFile\purgeThumbnails(), and LocalFile\upload().
|
protected |
|
protected |
|
protected |
The name of a file from its title object.
Definition at line 137 of file File.php.
Referenced by UnregisteredLocalFile\__construct(), LocalFile\loadExtraFromDB(), OldLocalFile\loadExtraFromDB(), LocalFile\loadFromRow(), and LocalFile\unprefixRow().
|
protected |
|
protected |
The storage path corresponding to one of the zones.
Definition at line 140 of file File.php.
Referenced by ForeignAPIFile\getThumbPath().
|
protected |
FileRepo LocalRepo ForeignAPIRepo bool 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 110 of file File.php.
Referenced by UploadStashFile\__construct(), LocalFile\__construct(), ForeignAPIFile\__construct(), OldLocalFile\__construct(), UnregisteredLocalFile\__construct(), ForeignAPIFile\getRepo(), ForeignDBFile\getRepo(), OldLocalFile\newFromArchiveName(), LocalFile\newFromKey(), OldLocalFile\newFromKey(), LocalFile\newFromRow(), OldLocalFile\newFromRow(), UnregisteredLocalFile\newFromTitle(), OldLocalFile\newFromTitle(), LocalFile\newFromTitle(), and ForeignAPIFile\newFromTitle().
|
protected |
|
protected |
Definition at line 113 of file File.php.
Referenced by ForeignAPIFile\__construct(), OldLocalFile\__construct(), OldLocalFile\newFromArchiveName(), OldLocalFile\newFromRow(), OldLocalFile\newFromTitle(), and ForeignAPIFile\newFromTitle().
|
protected |
|
protected |
|
protected |
The URL corresponding to one of the four basic zones.
Definition at line 131 of file File.php.
Referenced by ForeignAPIFile\getDescriptionShortUrl(), ForeignDBFile\getDescriptionShortUrl(), LocalFile\getDescriptionShortUrl(), and ForeignAPIFile\purgeDescriptionPage().
const File::DELETE_SOURCE = 1 |
Definition at line 80 of file File.php.
Referenced by LocalFile\publishTo().
const File::DELETED_FILE = 1 |
Definition at line 67 of file File.php.
Referenced by OldLocalFile\isVisible().
const File::RENDER_FORCE = 2 |
const File::RENDER_NOW = 1 |