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 public function __construct( $list, $row ) {
27 RevDelItem
::__construct( $list, $row );
28 $this->file
= ArchivedFile
::newFromRow( $row );
31 public function getIdField() {
35 public function getTimestampField() {
36 return 'fa_timestamp';
39 public function getAuthorIdField() {
43 public function getAuthorNameField() {
44 return 'fa_user_text';
47 public function getId() {
48 return $this->row
->fa_id
;
51 public function setBits( $bits ) {
52 $dbw = wfGetDB( DB_MASTER
);
53 $dbw->update( 'filearchive',
54 array( 'fa_deleted' => $bits ),
56 'fa_id' => $this->row
->fa_id
,
57 'fa_deleted' => $this->getBits(),
62 return (bool)$dbw->affectedRows();
65 protected function getLink() {
66 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
67 $this->file
->getTimestamp(), $this->list->getUser() ) );
70 if ( !$this->canViewContent() ) {
73 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
74 $key = $this->file
->getKey();
75 $link = Linker
::link( $undelete, $date, array(),
77 'target' => $this->list->title
->getPrefixedText(),
79 'token' => $this->list->getUser()->getEditToken( $key )
83 if ( $this->isDeleted() ) {
84 $link = '<span class="history-deleted">' . $link . '</span>';
90 public function getApiData( ApiResult
$result ) {
92 $user = $this->list->getUser();
94 'title' => $this->list->title
->getPrefixedText(),
95 'timestamp' => wfTimestamp( TS_ISO_8601
, $file->getTimestamp() ),
96 'width' => $file->getWidth(),
97 'height' => $file->getHeight(),
98 'size' => $file->getSize(),
100 $ret +
= $file->isDeleted( Revision
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
101 $ret +
= $file->isDeleted( Revision
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
102 $ret +
= $this->isDeleted() ?
array( 'contenthidden' => '' ) : array();
103 if ( $this->canViewContent() ) {
105 'url' => SpecialPage
::getTitleFor( 'Revisiondelete' )->getLinkURL(
107 'target' => $this->list->title
->getPrefixedText(),
108 'file' => $file->getKey(),
109 'token' => $user->getEditToken( $file->getKey() )
111 false, PROTO_RELATIVE
115 if ( $file->userCan( Revision
::DELETED_USER
, $user ) ) {
117 'userid' => $file->getUser( 'id' ),
118 'user' => $file->getUser( 'text' ),
121 if ( $file->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
123 'comment' => $file->getRawDescription(),