Inherits File.
Inherited by ForeignDBFile, Image, and OldLocalFile.
Public Member Functions | |
__construct ($title, $repo) | |
Constructor. | |
getCacheKey () | |
Get the memcached key for the main data for this file, or false if there is no access to the shared cache. | |
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 file metadata from a DB result row. | |
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. | |
isMissing () | |
splitMime inherited | |
getWidth ($page=1) | |
Return the width of the image. | |
getHeight ($page=1) | |
Return the height of the image. | |
getUser ($type= 'text') | |
Returns ID or name of user who uploaded the file. | |
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 | |
$missing | |
$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 250 of file LocalFile.php.
References $name, 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 1033 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 file store failure |
Definition at line 1072 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 506 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 466 of file LocalFile.php.
LocalFile::getCacheFields | ( | $ | prefix = 'img_' |
) |
LocalFile::getCacheKey | ( | ) |
Get the memcached key for the main data for this file, or false if there is no access to the shared cache.
Reimplemented in OldLocalFile.
Definition at line 138 of file LocalFile.php.
LocalFile::getDescription | ( | ) |
Get discription of file revision STUB.
Reimplemented from File.
Definition at line 1142 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 1132 of file LocalFile.php.
References $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 1123 of file LocalFile.php.
LocalFile::getHeight | ( | $ | page = 1 |
) |
Return the height of the image.
Returns false on error
Reimplemented from File.
Definition at line 430 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 637 of file LocalFile.php.
References $dbr, $res, 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 491 of file LocalFile.php.
LocalFile::getMetadata | ( | ) |
Get handler-specific metadata.
Reimplemented from File.
Definition at line 461 of file LocalFile.php.
LocalFile::getMimeType | ( | ) |
Returns the mime type of the file.
Reimplemented from File.
Definition at line 482 of file LocalFile.php.
LocalFile::getSha1 | ( | ) |
Get the SHA-1 base 36 hash of the file.
Reimplemented from File.
Definition at line 1152 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 474 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 553 of file LocalFile.php.
References $files.
LocalFile::getTimestamp | ( | ) |
Get the 14-character timestamp of the file upload, or false if it doesn't exist.
Reimplemented from File.
Definition at line 1147 of file LocalFile.php.
LocalFile::getUpgraded | ( | ) |
Definition at line 322 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 449 of file LocalFile.php.
LocalFile::getWidth | ( | $ | page = 1 |
) |
Return the width of the image.
Returns false on error
Reimplemented from File.
Definition at line 411 of file LocalFile.php.
References $page.
LocalFile::isMissing | ( | ) |
splitMime inherited
getName inherited getTitle inherited getURL inherited getViewURL inherited getPath inherited isVisible inhereted
Reimplemented from File.
Definition at line 398 of file LocalFile.php.
References FileRepo::FILES_ONLY.
LocalFile::load | ( | ) |
Load file metadata from cache or DB, unless already loaded.
Definition at line 291 of file LocalFile.php.
Referenced by OldLocalFile::getArchiveName(), OldLocalFile::getVisibility(), OldLocalFile::isDeleted(), and OldLocalFile::userCan().
LocalFile::loadFromCache | ( | ) |
Try to load file metadata from memcached.
Returns true on success.
Definition at line 146 of file LocalFile.php.
LocalFile::loadFromDB | ( | ) |
Load file metadata from the DB.
Reimplemented in OldLocalFile.
Definition at line 225 of file LocalFile.php.
References loadFromRow().
LocalFile::loadFromFile | ( | ) |
Load metadata from the file itself.
Definition at line 201 of file LocalFile.php.
Referenced by OldLocalFile::upgradeRow().
LocalFile::loadFromRow | ( | $ | row, | |
$ | prefix = 'img_' | |||
) |
Load file metadata from a DB result row.
Definition at line 278 of file LocalFile.php.
References $name.
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 1175 of file LocalFile.php.
References $dbw.
LocalFile::maybeUpgradeRow | ( | ) |
Upgrade a row if it needs it.
Definition at line 304 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 521 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 996 of file LocalFile.php.
References 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 680 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 963 of file LocalFile.php.
References 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 598 of file LocalFile.php.
References SquidUpdate::purge().
LocalFile::purgeHistory | ( | ) |
Purge the shared history (OldLocalFile) cache.
Definition at line 586 of file LocalFile.php.
References $wgMemc.
LocalFile::purgeMetadataCache | ( | ) |
Refresh metadata in memcached, but don't touch thumbnails or squid.
Definition at line 577 of file LocalFile.php.
LocalFile::purgeThumbnails | ( | ) |
Delete cached transformed files.
Definition at line 612 of file LocalFile.php.
References $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 770 of file LocalFile.php.
References $wgUser, and SpecialUpload::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 788 of file LocalFile.php.
References $action, $dbw, $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 718 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 1096 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 LocalRepo::findBySha1(), and 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 373 of file LocalFile.php.
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 1188 of file LocalFile.php.
References $dbw.
LocalFile::unlockAndRollback | ( | ) |
Roll back the DB transaction and mark the image unlocked.
Definition at line 1201 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 329 of file LocalFile.php.
References $dbw, 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 754 of file LocalFile.php.
LocalFile::$attr |
Definition at line 31 of file LocalFile.php.
LocalFile::$bits |
Definition at line 31 of file LocalFile.php.
LocalFile::$dataLoaded |
Definition at line 31 of file LocalFile.php.
LocalFile::$deleted |
Definition at line 31 of file LocalFile.php.
LocalFile::$description |
Definition at line 31 of file LocalFile.php.
LocalFile::$fileExists |
LocalFile::$historyLine |
Definition at line 31 of file LocalFile.php.
LocalFile::$historyRes |
Definition at line 31 of file LocalFile.php.
LocalFile::$locked |
Definition at line 31 of file LocalFile.php.
LocalFile::$major_mime |
Definition at line 31 of file LocalFile.php.
LocalFile::$media_type |
Definition at line 31 of file LocalFile.php.
LocalFile::$metadata |
Definition at line 31 of file LocalFile.php.
LocalFile::$mime |
Definition at line 31 of file LocalFile.php.
LocalFile::$minor_mime |
Definition at line 31 of file LocalFile.php.
LocalFile::$missing |
Definition at line 31 of file LocalFile.php.
LocalFile::$sha1 |
LocalFile::$size |
Definition at line 31 of file LocalFile.php.
LocalFile::$timestamp |
LocalFile::$upgraded |
Definition at line 31 of file LocalFile.php.
LocalFile::$user |
Definition at line 31 of file LocalFile.php.
LocalFile::$user_text |
Definition at line 31 of file LocalFile.php.
LocalFile::$width |
Definition at line 31 of file LocalFile.php.