3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
19 * @ingroup RevisionDelete
22 use MediaWiki\Storage\RevisionRecord
;
25 * Item class for a filearchive table row
27 * @property ArchivedFile $file
28 * @property RevDelArchivedFileList $list
30 class RevDelArchivedFileItem
extends RevDelFileItem
{
34 public function __construct( $list, $row ) {
35 parent
::__construct( $list, $row );
36 $this->lockFile
= RepoGroup
::singleton()->getLocalRepo()->newFile( $row->fa_name
);
39 protected static function initFile( $list, $row ) {
40 return ArchivedFile
::newFromRow( $row );
43 public function getIdField() {
47 public function getTimestampField() {
48 return 'fa_timestamp';
51 public function getAuthorIdField() {
55 public function getAuthorNameField() {
56 return 'fa_user_text';
59 public function getAuthorActorField() {
63 public function getId() {
64 return $this->row
->fa_id
;
67 public function setBits( $bits ) {
68 $dbw = wfGetDB( DB_MASTER
);
69 $dbw->update( 'filearchive',
70 [ 'fa_deleted' => $bits ],
72 'fa_id' => $this->row
->fa_id
,
73 'fa_deleted' => $this->getBits(),
78 return (bool)$dbw->affectedRows();
81 protected function getLink() {
82 $date = $this->list->getLanguage()->userTimeAndDate(
83 $this->file
->getTimestamp(), $this->list->getUser() );
86 if ( !$this->canViewContent() ) {
87 $link = htmlspecialchars( $date );
89 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
90 $key = $this->file
->getKey();
91 $link = $this->getLinkRenderer()->makeLink( $undelete, $date, [],
93 'target' => $this->list->title
->getPrefixedText(),
95 'token' => $this->list->getUser()->getEditToken( $key )
99 if ( $this->isDeleted() ) {
100 $link = '<span class="history-deleted">' . $link . '</span>';
106 public function getApiData( ApiResult
$result ) {
108 $user = $this->list->getUser();
110 'title' => $this->list->title
->getPrefixedText(),
111 'timestamp' => wfTimestamp( TS_ISO_8601
, $file->getTimestamp() ),
112 'width' => $file->getWidth(),
113 'height' => $file->getHeight(),
114 'size' => $file->getSize(),
115 'userhidden' => (bool)$file->isDeleted( RevisionRecord
::DELETED_USER
),
116 'commenthidden' => (bool)$file->isDeleted( RevisionRecord
::DELETED_COMMENT
),
117 'contenthidden' => (bool)$this->isDeleted(),
119 if ( $this->canViewContent() ) {
121 'url' => SpecialPage
::getTitleFor( 'Revisiondelete' )->getLinkURL(
123 'target' => $this->list->title
->getPrefixedText(),
124 'file' => $file->getKey(),
125 'token' => $user->getEditToken( $file->getKey() )
130 if ( $file->userCan( RevisionRecord
::DELETED_USER
, $user ) ) {
132 'userid' => $file->getUser( 'id' ),
133 'user' => $file->getUser( 'text' ),
136 if ( $file->userCan( RevisionRecord
::DELETED_COMMENT
, $user ) ) {
138 'comment' => $file->getRawDescription(),
145 public function lock() {
146 return $this->lockFile
->acquireFileLock();
149 public function unlock() {
150 return $this->lockFile
->releaseFileLock();