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
23 * Item class for a filearchive table row
25 class RevDelArchivedFileItem
extends RevDelFileItem
{
26 /** @var RevDelArchivedFileList */
28 /** @var ArchivedFile */
33 public function __construct( $list, $row ) {
34 RevDelItem
::__construct( $list, $row );
35 $this->file
= ArchivedFile
::newFromRow( $row );
36 $this->lockFile
= RepoGroup
::singleton()->getLocalRepo()->newFile( $row->fa_name
);
39 public function getIdField() {
43 public function getTimestampField() {
44 return 'fa_timestamp';
47 public function getAuthorIdField() {
51 public function getAuthorNameField() {
52 return 'fa_user_text';
55 public function getId() {
56 return $this->row
->fa_id
;
59 public function setBits( $bits ) {
60 $dbw = wfGetDB( DB_MASTER
);
61 $dbw->update( 'filearchive',
62 [ 'fa_deleted' => $bits ],
64 'fa_id' => $this->row
->fa_id
,
65 'fa_deleted' => $this->getBits(),
70 return (bool)$dbw->affectedRows();
73 protected function getLink() {
74 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
75 $this->file
->getTimestamp(), $this->list->getUser() ) );
78 if ( !$this->canViewContent() ) {
81 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
82 $key = $this->file
->getKey();
83 $link = Linker
::link( $undelete, $date, [],
85 'target' => $this->list->title
->getPrefixedText(),
87 'token' => $this->list->getUser()->getEditToken( $key )
91 if ( $this->isDeleted() ) {
92 $link = '<span class="history-deleted">' . $link . '</span>';
98 public function getApiData( ApiResult
$result ) {
100 $user = $this->list->getUser();
102 'title' => $this->list->title
->getPrefixedText(),
103 'timestamp' => wfTimestamp( TS_ISO_8601
, $file->getTimestamp() ),
104 'width' => $file->getWidth(),
105 'height' => $file->getHeight(),
106 'size' => $file->getSize(),
108 $ret +
= $file->isDeleted( Revision
::DELETED_USER
) ?
[ 'userhidden' => '' ] : [];
109 $ret +
= $file->isDeleted( Revision
::DELETED_COMMENT
) ?
[ 'commenthidden' => '' ] : [];
110 $ret +
= $this->isDeleted() ?
[ 'contenthidden' => '' ] : [];
111 if ( $this->canViewContent() ) {
113 'url' => SpecialPage
::getTitleFor( 'Revisiondelete' )->getLinkURL(
115 'target' => $this->list->title
->getPrefixedText(),
116 'file' => $file->getKey(),
117 'token' => $user->getEditToken( $file->getKey() )
122 if ( $file->userCan( Revision
::DELETED_USER
, $user ) ) {
124 'userid' => $file->getUser( 'id' ),
125 'user' => $file->getUser( 'text' ),
128 if ( $file->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
130 'comment' => $file->getRawDescription(),
137 public function lock() {
138 return $this->lockFile
->acquireFileLock();
141 public function unlock() {
142 return $this->lockFile
->releaseFileLock();