MediaWiki REL1_37
RevDelArchivedFileItem.php
Go to the documentation of this file.
1<?php
24
33 protected $lockFile;
34
35 public function __construct( RevisionListBase $list, $row ) {
36 parent::__construct( $list, $row );
37 $this->lockFile = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
38 ->newFile( $row->fa_name );
39 }
40
41 protected static function initFile( $list, $row ) {
43 }
44
45 public function getIdField() {
46 return 'fa_id';
47 }
48
49 public function getTimestampField() {
50 return 'fa_timestamp';
51 }
52
53 public function getAuthorIdField() {
54 return 'fa_user';
55 }
56
57 public function getAuthorNameField() {
58 return 'fa_user_text';
59 }
60
61 public function getAuthorActorField() {
62 return 'fa_actor';
63 }
64
65 public function getId() {
66 return $this->row->fa_id;
67 }
68
69 public function setBits( $bits ) {
70 $dbw = wfGetDB( DB_PRIMARY );
71 $dbw->update( 'filearchive',
72 [ 'fa_deleted' => $bits ],
73 [
74 'fa_id' => $this->row->fa_id,
75 'fa_deleted' => $this->getBits(),
76 ],
77 __METHOD__
78 );
79
80 return (bool)$dbw->affectedRows();
81 }
82
83 protected function getLink() {
84 $date = $this->list->getLanguage()->userTimeAndDate(
85 $this->file->getTimestamp(), $this->list->getUser() );
86
87 # Hidden files...
88 if ( !$this->canViewContent() ) {
89 $link = htmlspecialchars( $date );
90 } else {
91 $undelete = SpecialPage::getTitleFor( 'Undelete' );
92 $key = $this->file->getKey();
93 $link = $this->getLinkRenderer()->makeLink( $undelete, $date, [],
94 [
95 'target' => $this->list->getPageName(),
96 'file' => $key,
97 'token' => $this->list->getUser()->getEditToken( $key )
98 ]
99 );
100 }
101 if ( $this->isDeleted() ) {
102 $link = '<span class="history-deleted">' . $link . '</span>';
103 }
104
105 return $link;
106 }
107
108 public function getApiData( ApiResult $result ) {
110 $user = $this->list->getUser();
111 $ret = [
112 'title' => $this->list->getPageName(),
113 'timestamp' => wfTimestamp( TS_ISO_8601, $file->getTimestamp() ),
114 'width' => $file->getWidth(),
115 'height' => $file->getHeight(),
116 'size' => $file->getSize(),
117 'userhidden' => (bool)$file->isDeleted( RevisionRecord::DELETED_USER ),
118 'commenthidden' => (bool)$file->isDeleted( RevisionRecord::DELETED_COMMENT ),
119 'contenthidden' => (bool)$this->isDeleted(),
120 ];
121 if ( $this->canViewContent() ) {
122 $ret += [
123 'url' => SpecialPage::getTitleFor( 'Revisiondelete' )->getLinkURL(
124 [
125 'target' => $this->list->getPageName(),
126 'file' => $file->getKey(),
127 'token' => $user->getEditToken( $file->getKey() )
128 ]
129 ),
130 ];
131 }
132 $uploader = $file->getUploader( ArchivedFile::FOR_THIS_USER, $user );
133 if ( $uploader ) {
134 $ret += [
135 'userid' => $uploader->getId(),
136 'user' => $uploader->getName(),
137 ];
138 }
140 if ( $comment ) {
141 $ret += [
142 'comment' => $comment,
143 ];
144 }
145
146 return $ret;
147 }
148
149 public function lock() {
150 return $this->lockFile->acquireFileLock();
151 }
152
153 public function unlock() {
154 return $this->lockFile->releaseFileLock();
155 }
156}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
This class represents the result of the API operations.
Definition ApiResult.php:35
const FOR_THIS_USER
static newFromRow( $row)
Loads a file object from the filearchive table.
getUser( $type='text')
Returns ID or name of user who uploaded the file STUB.
Definition File.php:614
Class to represent a local file in the wiki's own database.
Definition LocalFile.php:63
getWidth( $page=1)
Return the width of the image.
getUploader(int $audience=self::FOR_PUBLIC, Authority $performer=null)
getSize()
Returns the size of the image file, in bytes.
getDescription( $audience=self::FOR_PUBLIC, Authority $performer=null)
getHeight( $page=1)
Return the height of the image.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Page revision base class.
isDeleted( $field)
static initFile( $list, $row)
Create file object from $row sourced from $list.
getIdField()
Get the DB field name associated with the ID list.
getAuthorNameField()
Get the DB field name storing user names.
getApiData(ApiResult $result)
Get the return information about the revision for the API.
unlock()
Unlock the item against changes outside of the DB.
getTimestampField()
Get the DB field name storing timestamps.
setBits( $bits)
Set the visibility of the item.
__construct(RevisionListBase $list, $row)
getLink()
Get the link to the file.
lock()
Lock the item against changes outside of the DB.
getId()
Get the ID, as it would appear in the ids URL parameter.
getAuthorActorField()
Get the DB field name storing actor ids.
getAuthorIdField()
Get the DB field name storing user ids.
Item class for an oldimage table row.
RevDelFileList $list
canViewContent()
Returns true if the current user can view the item text/file.
OldLocalFile $file
stdClass $row
The database result row.
getLinkRenderer()
Returns an instance of LinkRenderer.
List for revision table items for a single page.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
const DB_PRIMARY
Definition defines.php:27