MediaWiki REL1_35
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_MASTER );
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->title->getPrefixedText(),
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->title->getPrefixedText(),
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->title->getPrefixedText(),
126 'file' => $file->getKey(),
127 'token' => $user->getEditToken( $file->getKey() )
128 ]
129 ),
130 ];
131 }
132 if ( $file->userCan( RevisionRecord::DELETED_USER, $user ) ) {
133 $ret += [
134 'userid' => $file->getUser( 'id' ),
135 'user' => $file->getUser( 'text' ),
136 ];
137 }
138 if ( $file->userCan( RevisionRecord::DELETED_COMMENT, $user ) ) {
139 $ret += [
140 'comment' => $file->getRawDescription(),
141 ];
142 }
143
144 return $ret;
145 }
146
147 public function lock() {
148 return $this->lockFile->acquireFileLock();
149 }
150
151 public function unlock() {
152 return $this->lockFile->releaseFileLock();
153 }
154}
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
static newFromRow( $row)
Loads a file object from the filearchive table Stable to override.
Class to represent a local file in the wiki's own database.
Definition LocalFile.php:59
getWidth( $page=1)
Return the width of the image Stable to override.
getUser( $type='text')
Returns user who uploaded the file Stable to override.
getSize()
Returns the size of the image file, in bytes Stable to override.
getHeight( $page=1)
Return the height of the image Stable to override.
getTimestamp()
Stable to override.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Page revision base class.
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this image file,...
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
$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_MASTER
Definition defines.php:29