Go to the documentation of this file.
109 $this->title =
false;
111 $this->group =
'deleted';
117 $this->metadata =
'';
118 $this->mime =
"unknown/unknown";
119 $this->media_type =
'';
120 $this->description =
'';
122 $this->timestamp =
null;
124 $this->dataLoaded =
false;
146 throw new MWException(
"No specifications provided to ArchivedFile constructor." );
156 if ( $this->dataLoaded ) {
161 if ( $this->
id > 0 ) {
168 if ( $this->title ) {
169 $conds[
'fa_name'] = $this->title->getDBkey();
175 if ( $conds === [] ) {
176 throw new MWException(
"No specific information for retrieving archived file" );
179 if ( !$this->title || $this->title->getNamespace() ==
NS_FILE ) {
180 $this->dataLoaded =
true;
183 $row =
$dbr->selectRow(
184 $fileQuery[
'tables'],
185 $fileQuery[
'fields'],
188 [
'ORDER BY' =>
'fa_timestamp DESC' ],
199 throw new MWException(
'This title does not correspond to an image page.' );
214 $file->loadFromRow( $row );
229 $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin(
'fa_description' );
232 'tables' => [
'filearchive' ] + $commentQuery[
'tables'] + $actorQuery[
'tables'],
249 'fa_deleted_timestamp',
251 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
252 'joins' => $commentQuery[
'joins'] + $actorQuery[
'joins'],
263 $this->
id = intval( $row->fa_id );
264 $this->name = $row->fa_name;
265 $this->archive_name = $row->fa_archive_name;
266 $this->group = $row->fa_storage_group;
267 $this->key = $row->fa_storage_key;
268 $this->size = $row->fa_size;
269 $this->bits = $row->fa_bits;
270 $this->width = $row->fa_width;
271 $this->height = $row->fa_height;
272 $this->metadata = $row->fa_metadata;
273 $this->mime =
"$row->fa_major_mime/$row->fa_minor_mime";
274 $this->media_type = $row->fa_media_type;
275 $this->description = MediaWikiServices::getInstance()->getCommentStore()
278 $this->user =
User::newFromAnyId( $row->fa_user, $row->fa_user_text, $row->fa_actor );
279 $this->timestamp = $row->fa_timestamp;
280 $this->deleted = $row->fa_deleted;
281 if ( isset( $row->fa_sha1 ) ) {
282 $this->sha1 = $row->fa_sha1;
287 if ( !$this->title ) {
298 if ( !$this->title ) {
310 if ( $this->name ===
false ) {
426 if ( !isset( $this->handler ) ) {
442 if ( $this->
getHandler() && $this->handler->isMultiPage( $this ) ) {
444 $this->
pageCount = $this->handler->pageCount( $this );
501 if (
$type ===
'object' ) {
503 } elseif (
$type ===
'text' ) {
504 return $this->user ? $this->user->
getName() :
'';
505 } elseif (
$type ===
'id' ) {
506 return $this->user ? $this->user->getId() : 0;
541 return $this->
getUser(
'text' );
574 return ( $this->deleted & $field ) == $field;
loadFromRow( $row)
Load ArchivedFile object fields from a DB row.
int $deleted
Bitfield akin to rev_deleted.
string $sha1
SHA-1 hash of file content.
getKey()
Return the FileStore key.
getTimestamp()
Return upload timestamp.
static userCanBitfield( $bitfield, $field, User $user=null, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision,...
string $metadata
Metadata string.
bool $dataLoaded
Whether or not all this has been loaded from the database (loadFromXxx)
string $group
FileStore storage group.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
isDeleted( $field)
for file or revision rows
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new archivedfile object.
string $key
FileStore SHA-1 key.
getStorageKey()
Return the FileStore key (overriding base File class)
static newMigration()
Static constructor.
static getHashFromKey( $key)
Gets the SHA1 hash from a storage key.
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
string $archive_name
Original base filename.
getMetadata()
Get handler-specific metadata.
getSize()
Return the size of the image file, in bytes.
load()
Loads a file object from the filearchive table.
getDBkey()
Get the main part with underscores.
getHandler()
Get a MediaHandler instance for this file.
int $id
Filearchive row ID.
getMimeType()
Returns the MIME type of the file.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getTitle()
Return the associated title object.
pageCount()
Returns the number of pages of a multipage document, or false for documents which aren't multipage do...
getVisibility()
Returns the deletion bitfield.
__construct( $title, $id=0, $key='', $sha1='')
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
int $size
File size in bytes.
static newFromAnyId( $userId, $userName, $actorId, $dbDomain=false)
Static factory method for creation from an ID, name, and/or actor ID.
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this FileStore image file,...
getDescription()
Return upload description.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Class representing a row of the 'filearchive' table.
int false $pageCount
Number of pages of a multipage document, or false for documents which aren't multipage documents.
getSha1()
Get the SHA-1 base 36 hash of the file.
getName()
Return the file name.
getGroup()
Return the FileStore storage group.
getWidth()
Return the width of the image.
getRawUserText()
Return the user name of the uploader.
getUser( $type='text')
Returns ID or name of user who uploaded the file.
string $timestamp
Time of upload.
Represents a title within MediaWiki.
getRawDescription()
Return upload description.
string $description
Upload description.
getHeight()
Return the height of the image.
getBits()
Return the bits of the image file, in bytes.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.
getRawUser()
Return the user ID of the uploader.
string $media_type
Media type.
static newFromRow( $row)
Loads a file object from the filearchive table.
getMediaType()
Return the type of the media in the file.