Inherits File.
Inherited by ForeignDBFile, Image, and OldLocalFile.
Public Member Functions | |
__construct ($title, $repo) | |
Constructor. | |
getCacheKey () | |
Get the memcached key. | |
loadFromCache () | |
Try to load file metadata from memcached. | |
saveToCache () | |
Save the file metadata to memcached. | |
loadFromFile () | |
Load metadata from the file itself. | |
getCacheFields ($prefix= 'img_') | |
loadFromDB () | |
Load file metadata from the DB. | |
decodeRow ($row, $prefix= 'img_') | |
Decode a row from the database (either object or array) to an array with timestamps and MIME types decoded, and the field prefix removed. | |
loadFromRow ($row, $prefix= 'img_') | |
load () | |
Load file metadata from cache or DB, unless already loaded. | |
maybeUpgradeRow () | |
Upgrade a row if it needs it. | |
getUpgraded () | |
upgradeRow () | |
Fix assorted version-related problems with the image row by reloading it from the file. | |
setProps ($info) | |
Set properties in this object to be equal to those given in the associative array $info. | |
getWidth ($page=1) | |
splitMime inherited | |
getHeight ($page=1) | |
Return the height of the image. | |
getUser ($type='text') | |
Returns ID or name of user who uploaded the file. | |
getMetadata () | |
Get handler-specific metadata. | |
getBitDepth () | |
Return the bit depth of the file Overridden by LocalFile STUB. | |
getSize () | |
Return the size of the image file, in bytes. | |
getMimeType () | |
Returns the mime type of the file. | |
getMediaType () | |
Return the type of the media in the file. | |
exists () | |
canRender inherited | |
migrateThumbFile ($thumbName) | |
getTransformScript inherited | |
getThumbnails () | |
getHandler inherited | |
purgeMetadataCache () | |
Refresh metadata in memcached, but don't touch thumbnails or squid. | |
purgeHistory () | |
Purge the shared history (OldLocalFile) cache. | |
purgeCache () | |
Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid. | |
purgeThumbnails () | |
Delete cached transformed files. | |
getHistory ($limit=null, $start=null, $end=null, $inc=true) | |
purgeDescription inherited | |
nextHistoryLine () | |
Return the history of this file, line by line. | |
resetHistory () | |
Reset the history pointer to the first element of the history. | |
upload ($srcPath, $comment, $pageText, $flags=0, $props=false, $timestamp=false, $user=null) | |
getFullPath inherited | |
recordUpload ($oldver, $desc, $license= '', $copyStatus= '', $source= '', $watch=false, $timestamp=false) | |
Record a file upload in the upload log and the image table. | |
recordUpload2 ($oldver, $comment, $pageText, $props=false, $timestamp=false, $user=null) | |
Record a file upload in the upload log and the image table. | |
publish ($srcPath, $flags=0) | |
Move or copy a file to its public location. | |
move ($target) | |
getLinksTo inherited | |
delete ($reason, $suppress=false) | |
Delete all versions of the file. | |
deleteOld ($archiveName, $reason, $suppress=false) | |
Delete an old version of the file. | |
restore ($versions=array(), $unsuppress=false) | |
Restore all or specified deleted revisions to the given file. | |
getDescriptionUrl () | |
isMultipage inherited | |
getDescriptionText () | |
Get the HTML text of the description page This is not used by ImagePage for local files, since (among other things) it skips the parser cache. | |
getDescription () | |
Get discription of file revision STUB. | |
getTimestamp () | |
Get the 14-character timestamp of the file upload, or false if it doesn't exist. | |
getSha1 () | |
Get the SHA-1 base 36 hash of the file. | |
lock () | |
Start a transaction and lock the image for update Increments a reference counter if the lock is already held. | |
unlock () | |
Decrement the lock reference count. | |
unlockAndRollback () | |
Roll back the DB transaction and mark the image unlocked. | |
Static Public Member Functions | |
static | newFromTitle ($title, $repo, $unused=null) |
#@- | |
static | newFromRow ($row, $repo) |
Create a LocalFile from a title Do not call this except from inside a repo class. | |
static | newFromKey ($sha1, $repo, $timestamp=false) |
Create a LocalFile from a SHA-1 key Do not call this except from inside a repo class. | |
static | selectFields () |
Fields in the image table. | |
Public Attributes | |
$fileExists | |
#@+ | |
$historyLine | |
$historyRes | |
$width | |
$bits | |
$attr | |
$media_type | |
$mime | |
$major_mime | |
$minor_mime | |
$size | |
$metadata | |
$timestamp | |
$sha1 | |
$user | |
$user_text | |
$description | |
$dataLoaded | |
$upgraded | |
$locked | |
$deleted |
Provides methods to retrieve paths (physical, logical, URL), to generate image thumbnails or for uploading.
Note that only the repo object knows what its file class is called. You should never name a file class explictly outside of the repo class. Instead use the repo's factory functions to generate file objects, for example:
RepoGroup::singleton()->getLocalRepo()->newFile($title);
The convenience functions wfLocalFile() and wfFindFile() should be sufficient in most cases.
Definition at line 27 of file LocalFile.php.
LocalFile::__construct | ( | $ | title, | |
$ | repo | |||
) |
Constructor.
Do not call this except from inside a repo class.
Reimplemented from File.
Definition at line 123 of file LocalFile.php.
LocalFile::decodeRow | ( | $ | row, | |
$ | prefix = 'img_' | |||
) |
Decode a row from the database (either object or array) to an array with timestamps and MIME types decoded, and the field prefix removed.
Definition at line 248 of file LocalFile.php.
References $name, $prefix, $row, and wfTimestamp().
LocalFile::delete | ( | $ | reason, | |
$ | suppress = false | |||
) |
Delete all versions of the file.
Moves the files into an archive directory (or deletes them) and removes the database rows.
Cache purging is done; logging is caller's responsibility.
$reason | ||
$suppress |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1026 of file LocalFile.php.
LocalFile::deleteOld | ( | $ | archiveName, | |
$ | reason, | |||
$ | suppress = false | |||
) |
Delete an old version of the file.
Moves the file into an archive directory (or deletes it) and removes the database row.
Cache purging is done; logging is caller's responsibility.
$reason | ||
$suppress |
MWException | or FSException on database or filestore failure |
Definition at line 1065 of file LocalFile.php.
LocalFile::exists | ( | ) |
canRender inherited
mustRender inherited allowInlineDisplay inherited isSafeFile inherited isTrustedFile inherited Returns true if the file file exists on disk.
Reimplemented from File.
Definition at line 498 of file LocalFile.php.
Referenced by OldLocalFile::isVisible().
LocalFile::getBitDepth | ( | ) |
Return the bit depth of the file Overridden by LocalFile STUB.
Reimplemented from File.
Definition at line 456 of file LocalFile.php.
LocalFile::getCacheFields | ( | $ | prefix = 'img_' |
) |
LocalFile::getCacheKey | ( | ) |
Get the memcached key.
Reimplemented in ForeignDBFile, and OldLocalFile.
Definition at line 137 of file LocalFile.php.
LocalFile::getDescription | ( | ) |
Get discription of file revision STUB.
Reimplemented from File.
Definition at line 1135 of file LocalFile.php.
LocalFile::getDescriptionText | ( | ) |
Get the HTML text of the description page This is not used by ImagePage for local files, since (among other things) it skips the parser cache.
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1125 of file LocalFile.php.
References $revision, $text, $wgParser, and Revision::newFromTitle().
LocalFile::getDescriptionUrl | ( | ) |
isMultipage inherited
pageCount inherited scaleHeight inherited getImageSize inherited Get the URL of the file description page.
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1116 of file LocalFile.php.
LocalFile::getHeight | ( | $ | page = 1 |
) |
Return the height of the image.
Returns false on error
Reimplemented from File.
Definition at line 420 of file LocalFile.php.
References $page.
LocalFile::getHistory | ( | $ | limit = null , |
|
$ | start = null , |
|||
$ | end = null , |
|||
$ | inc = true | |||
) |
purgeDescription inherited
purgeEverything inherited
Reimplemented from File.
Definition at line 627 of file LocalFile.php.
References $conds, $dbr, $end, $fields, $res, $row, $start, OldLocalFile::newFromRow(), OldLocalFile::selectFields(), and wfRunHooks().
LocalFile::getMediaType | ( | ) |
Return the type of the media in the file.
Use the value returned by this function with the MEDIATYPE_xxx constants.
Reimplemented from File.
Definition at line 482 of file LocalFile.php.
LocalFile::getMetadata | ( | ) |
Get handler-specific metadata.
Reimplemented from File.
Definition at line 451 of file LocalFile.php.
LocalFile::getMimeType | ( | ) |
Returns the mime type of the file.
Reimplemented from File.
Definition at line 473 of file LocalFile.php.
LocalFile::getSha1 | ( | ) |
Get the SHA-1 base 36 hash of the file.
Reimplemented from File.
Definition at line 1145 of file LocalFile.php.
References $dbw, File::sha1Base36(), and wfReadOnly().
LocalFile::getSize | ( | ) |
Return the size of the image file, in bytes.
Reimplemented from File.
Definition at line 465 of file LocalFile.php.
LocalFile::getThumbnails | ( | ) |
getHandler inherited
iconThumb inherited getLastError inherited Get all thumbnail names previously generated for this file
Reimplemented from File.
Definition at line 545 of file LocalFile.php.
LocalFile::getTimestamp | ( | ) |
Get the 14-character timestamp of the file upload, or false if it doesn't exist.
Reimplemented from File.
Definition at line 1140 of file LocalFile.php.
LocalFile::getUpgraded | ( | ) |
Definition at line 320 of file LocalFile.php.
LocalFile::getUser | ( | $ | type = 'text' |
) |
Returns ID or name of user who uploaded the file.
$type | string 'text' or 'id' |
Reimplemented from File.
Definition at line 439 of file LocalFile.php.
References $type.
LocalFile::getWidth | ( | $ | page = 1 |
) |
splitMime inherited
getName inherited getTitle inherited getURL inherited getViewURL inherited getPath inherited isVisible inhereted Return the width of the image Returns false on error
Reimplemented from File.
Definition at line 400 of file LocalFile.php.
References $page.
LocalFile::load | ( | ) |
Load file metadata from cache or DB, unless already loaded.
Definition at line 289 of file LocalFile.php.
Referenced by OldLocalFile::getArchiveName().
LocalFile::loadFromCache | ( | ) |
Try to load file metadata from memcached.
Returns true on success.
Definition at line 145 of file LocalFile.php.
LocalFile::loadFromDB | ( | ) |
Load file metadata from the DB.
Reimplemented in OldLocalFile.
Definition at line 223 of file LocalFile.php.
References $row, and loadFromRow().
LocalFile::loadFromFile | ( | ) |
Load metadata from the file itself.
Definition at line 199 of file LocalFile.php.
Referenced by OldLocalFile::upgradeRow().
LocalFile::loadFromRow | ( | $ | row, | |
$ | prefix = 'img_' | |||
) |
Definition at line 276 of file LocalFile.php.
References $name, $prefix, and $row.
Referenced by OldLocalFile::loadFromDB(), and loadFromDB().
LocalFile::lock | ( | ) |
Start a transaction and lock the image for update Increments a reference counter if the lock is already held.
Definition at line 1168 of file LocalFile.php.
References $dbw.
LocalFile::maybeUpgradeRow | ( | ) |
Upgrade a row if it needs it.
Definition at line 302 of file LocalFile.php.
References wfReadOnly().
LocalFile::migrateThumbFile | ( | $ | thumbName | ) |
getTransformScript inherited
getUnscaledThumb inherited thumbName inherited createThumb inherited getThumbnail inherited transform inherited Fix thumbnail files from 1.4 or before, with extreme prejudice
Reimplemented from File.
Definition at line 513 of file LocalFile.php.
References $i.
LocalFile::move | ( | $ | target | ) |
getLinksTo inherited
getExifData inherited isLocal inherited wasDeleted inherited 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 from File.
Reimplemented in ForeignDBFile.
Definition at line 989 of file LocalFile.php.
References $batch, $status, and wfDebugLog().
static LocalFile::newFromKey | ( | $ | sha1, | |
$ | repo, | |||
$ | timestamp = false | |||
) | [static] |
Create a LocalFile from a SHA-1 key Do not call this except from inside a repo class.
Reimplemented in OldLocalFile.
Definition at line 81 of file LocalFile.php.
static LocalFile::newFromRow | ( | $ | row, | |
$ | repo | |||
) | [static] |
Create a LocalFile from a title Do not call this except from inside a repo class.
Reimplemented in ForeignDBFile, and OldLocalFile.
Definition at line 70 of file LocalFile.php.
static LocalFile::newFromTitle | ( | $ | title, | |
$ | repo, | |||
$ | unused = null | |||
) | [static] |
#@-
Create a LocalFile from a title Do not call this except from inside a repo class.
Note: $unused param is only here to avoid an E_STRICT
Reimplemented in ForeignDBFile, and OldLocalFile.
Definition at line 62 of file LocalFile.php.
LocalFile::nextHistoryLine | ( | ) |
Return the history of this file, line by line.
starts with current version, then old versions. uses $this->historyLine to check which line to return: 0 return line for current version 1 query for old versions, return first one 2, ... return next old version from above query
Reimplemented from File.
Definition at line 672 of file LocalFile.php.
LocalFile::publish | ( | $ | srcPath, | |
$ | flags = 0 | |||
) |
Move or copy a file to its public location.
If a file exists at the destination, move it to an archive. Returns the archive name on success or an empty string if it was a new file, and a wikitext-formatted WikiError object on failure.
The archive name should be passed through to recordUpload for database registration.
string | $sourcePath Local filesystem path to the source image | |
integer | $flags A bitwise combination of: File::DELETE_SOURCE Delete the source file, i.e. move rather than copy |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 956 of file LocalFile.php.
References $flags, $status, FileRepo::DELETE_SOURCE, and File::DELETE_SOURCE.
LocalFile::purgeCache | ( | ) |
Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid.
Reimplemented from File.
Definition at line 588 of file LocalFile.php.
References SquidUpdate::purge().
LocalFile::purgeHistory | ( | ) |
Purge the shared history (OldLocalFile) cache.
Definition at line 578 of file LocalFile.php.
References $wgMemc, and wfMemcKey().
LocalFile::purgeMetadataCache | ( | ) |
Refresh metadata in memcached, but don't touch thumbnails or squid.
Definition at line 569 of file LocalFile.php.
LocalFile::purgeThumbnails | ( | ) |
Delete cached transformed files.
Definition at line 602 of file LocalFile.php.
References $file, $files, $url, $urls, $wgUseSquid, and SquidUpdate::purge().
LocalFile::recordUpload | ( | $ | oldver, | |
$ | desc, | |||
$ | license = '' , |
|||
$ | copyStatus = '' , |
|||
$ | source = '' , |
|||
$ | watch = false , |
|||
$ | timestamp = false | |||
) |
Record a file upload in the upload log and the image table.
Reimplemented in ForeignDBFile.
Definition at line 763 of file LocalFile.php.
References $source, $wgUser, and UploadForm::getInitialPageText().
LocalFile::recordUpload2 | ( | $ | oldver, | |
$ | comment, | |||
$ | pageText, | |||
$ | props = false , |
|||
$ | timestamp = false , |
|||
$ | user = null | |||
) |
Record a file upload in the upload log and the image table.
Definition at line 781 of file LocalFile.php.
References $action, $dbw, $user, $wgUser, Revision::newNullRevision(), SquidUpdate::purge(), wfDebug(), wfRunHooks(), and wfTimestamp().
LocalFile::resetHistory | ( | ) |
Reset the history pointer to the first element of the history.
Reimplemented from File.
Definition at line 711 of file LocalFile.php.
LocalFile::restore | ( | $ | versions = array() , |
|
$ | unsuppress = false | |||
) |
Restore all or specified deleted revisions to the given file.
Permissions and logging are left to the caller.
May throw database exceptions on error.
$versions | set of record ids of deleted items to restore, or empty to restore all revisions. | |
$unuppress |
Reimplemented from File.
Reimplemented in ForeignDBFile.
Definition at line 1089 of file LocalFile.php.
LocalFile::saveToCache | ( | ) |
static LocalFile::selectFields | ( | ) | [static] |
Fields in the image table.
Reimplemented in OldLocalFile.
Definition at line 100 of file LocalFile.php.
Referenced by ApiQueryAllimages::run().
LocalFile::setProps | ( | $ | info | ) |
Set properties in this object to be equal to those given in the associative array $info.
Only cacheable fields can be set.
If 'mime' is given, it will be split into major_mime/minor_mime. If major_mime/minor_mime are given, $this->mime will also be set.
Definition at line 369 of file LocalFile.php.
References $fields.
LocalFile::unlock | ( | ) |
Decrement the lock reference count.
If the reference count is reduced to zero, commits the transaction and thereby releases the image lock.
Definition at line 1181 of file LocalFile.php.
References $dbw.
LocalFile::unlockAndRollback | ( | ) |
Roll back the DB transaction and mark the image unlocked.
Definition at line 1194 of file LocalFile.php.
References $dbw.
LocalFile::upgradeRow | ( | ) |
Fix assorted version-related problems with the image row by reloading it from the file.
Reimplemented from File.
Reimplemented in OldLocalFile.
Definition at line 327 of file LocalFile.php.
References $dbw, $minor, wfDebug(), wfProfileIn(), wfProfileOut(), and wfReadOnly().
LocalFile::upload | ( | $ | srcPath, | |
$ | comment, | |||
$ | pageText, | |||
$ | flags = 0 , |
|||
$ | props = false , |
|||
$ | timestamp = false , |
|||
$ | user = null | |||
) |
getFullPath inherited
getHashPath inherited getRel inherited getUrlRel inherited getArchiveRel inherited getThumbRel inherited getArchivePath inherited getThumbPath inherited getArchiveUrl inherited getThumbUrl inherited getArchiveVirtualUrl inherited getThumbVirtualUrl inherited isHashed inherited Upload a file and record it in the DB
string | $srcPath Source path or virtual URL | |
string | $comment Upload description | |
string | $pageText Text to use for the new description page, if a new description page is created | |
integer | $flags Flags for publish() | |
array | $props File properties, if known. This can be used to reduce the upload time when uploading virtual URLs for which the file info is already known | |
string | $timestamp Timestamp for img_timestamp, or false to use the current time |
Definition at line 747 of file LocalFile.php.
LocalFile::$attr |
Definition at line 32 of file LocalFile.php.
LocalFile::$bits |
Definition at line 32 of file LocalFile.php.
LocalFile::$dataLoaded |
Definition at line 32 of file LocalFile.php.
LocalFile::$deleted |
Definition at line 32 of file LocalFile.php.
LocalFile::$description |
Definition at line 32 of file LocalFile.php.
LocalFile::$fileExists |
LocalFile::$historyLine |
Definition at line 32 of file LocalFile.php.
LocalFile::$historyRes |
Definition at line 32 of file LocalFile.php.
LocalFile::$locked |
Definition at line 32 of file LocalFile.php.
LocalFile::$major_mime |
Definition at line 32 of file LocalFile.php.
LocalFile::$media_type |
Definition at line 32 of file LocalFile.php.
LocalFile::$metadata |
Definition at line 32 of file LocalFile.php.
LocalFile::$mime |
Definition at line 32 of file LocalFile.php.
LocalFile::$minor_mime |
Definition at line 32 of file LocalFile.php.
LocalFile::$sha1 |
LocalFile::$size |
Definition at line 32 of file LocalFile.php.
LocalFile::$timestamp |
LocalFile::$upgraded |
Definition at line 32 of file LocalFile.php.
LocalFile::$user |
Definition at line 32 of file LocalFile.php.
LocalFile::$user_text |
Definition at line 32 of file LocalFile.php.
LocalFile::$width |
Definition at line 32 of file LocalFile.php.