* @ingroup FileAbstraction
*/
class ArchivedFile {
- /**#@+
- * @private
- */
- var $id, # filearchive row ID
- $name, # image name
- $group, # FileStore storage group
- $key, # FileStore sha1 key
- $size, # file dimensions
- $bits, # size in bytes
- $width, # width
- $height, # height
- $metadata, # metadata string
- $mime, # mime type
- $media_type, # media type
- $description, # upload description
- $user, # user ID of uploader
- $user_text, # user name of uploader
- $timestamp, # time of upload
- $dataLoaded, # Whether or not all this has been loaded from the database (loadFromXxx)
- $deleted, # Bitfield akin to rev_deleted
- $sha1, # sha1 hash of file content
- $pageCount,
- $archive_name;
+ /** @var int filearchive row ID */
+ private $id;
- /**
- * @var MediaHandler
- */
- var $handler;
- /**
- * @var Title
+ /** @var string File name */
+ private $name;
+
+ /** @var string FileStore storage group */
+ private $group;
+
+ /** @var string FileStore SHA-1 key */
+ private $key;
+
+ /** @var int File size in bytes */
+ private $size;
+
+ /** @var int size in bytes */
+ private $bits;
+
+ /** @var int Width */
+ private $width;
+
+ /** @var int Height */
+ private $height;
+
+ /** @var string Metadata string */
+ private $metadata;
+
+ /** @var string MIME type */
+ private $mime;
+
+ /** @var string Media type */
+ private $media_type;
+
+ /** @var string Upload description */
+ private $description;
+
+ /** @var int User ID of uploader */
+ private $user;
+
+ /** @var string User name of uploader */
+ private $user_text;
+
+ /** @var string Time of upload */
+ private $timestamp;
+
+ /** @var bool Whether or not all this has been loaded from the database (loadFromXxx) */
+ private $dataLoaded;
+
+ /** @var int Bitfield akin to rev_deleted */
+ private $deleted;
+
+ /** @var string SHA-1 hash of file content */
+ private $sha1;
+
+ /** @var string Number of pages of a multipage document, or false for
+ * documents which aren't multipage documents
*/
- var $title; # image title
+ private $pageCount;
+
+ /** @var string Original base filename */
+ private $archive_name;
- /**#@-*/
+ /** @var MediaHandler */
+ protected $handler;
+
+ /** @var Title */
+ protected $title; # image title
/**
* @throws MWException
/**
* Loads a file object from the filearchive table
*
- * @param $row
- *
+ * @param stdClass $row
* @return ArchivedFile
*/
public static function newFromRow( $row ) {
$file = new ArchivedFile( Title::makeTitle( NS_FILE, $row->fa_name ) );
$file->loadFromRow( $row );
+
return $file;
}
/**
* Load ArchivedFile object fields from a DB row.
*
- * @param $row Object database row
+ * @param stdClass $row Object database row
* @since 1.21
*/
public function loadFromRow( $row ) {
*/
public function getID() {
$this->load();
+
return $this->id;
}
*/
public function exists() {
$this->load();
+
return $this->exists;
}
*/
public function getKey() {
$this->load();
+
return $this->key;
}
*/
public function getWidth() {
$this->load();
+
return $this->width;
}
*/
public function getHeight() {
$this->load();
+
return $this->height;
}
*/
public function getMetadata() {
$this->load();
+
return $this->metadata;
}
*/
public function getSize() {
$this->load();
+
return $this->size;
}
*/
public function getBits() {
$this->load();
+
return $this->bits;
}
*/
public function getMimeType() {
$this->load();
+
return $this->mime;
}
if ( !isset( $this->handler ) ) {
$this->handler = MediaHandler::getHandler( $this->getMimeType() );
}
+
return $this->handler;
}
$this->pageCount = false;
}
}
+
return $this->pageCount;
}
*/
public function getMediaType() {
$this->load();
+
return $this->media_type;
}
*/
public function getTimestamp() {
$this->load();
+
return wfTimestamp( TS_MW, $this->timestamp );
}
*/
function getSha1() {
$this->load();
+
return $this->sha1;
}
*/
public function getRawUser() {
$this->load();
+
return $this->user;
}
*/
public function getRawUserText() {
$this->load();
+
return $this->user_text;
}
*/
public function getRawDescription() {
$this->load();
+
return $this->description;
}
*/
public function getVisibility() {
$this->load();
+
return $this->deleted;
}
/**
* for file or revision rows
*
- * @param $field Integer: one of DELETED_* bitfield constants
+ * @param int $field One of DELETED_* bitfield constants
* @return bool
*/
public function isDeleted( $field ) {
$this->load();
+
return ( $this->deleted & $field ) == $field;
}
/**
* Determine if the current user is allowed to view a particular
* field of this FileStore image file, if it's marked as deleted.
- * @param $field Integer
- * @param $user User object to check, or null to use $wgUser
+ * @param int $field
+ * @param null|User $user User object to check, or null to use $wgUser
* @return bool
*/
public function userCan( $field, User $user = null ) {
$this->load();
+
return Revision::userCanBitfield( $this->deleted, $field, $user );
}
}