Use 'div' instead of 'section' and 'article'
[mediawiki.git] / includes / revisiondelete / RevDelArchivedFileItem.php
blob7c41c180b7b365cb8fb6a0210295fdcae81e625b
1 <?php
2 /**
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
18 * @file
19 * @ingroup RevisionDelete
22 /**
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() {
32 return 'fa_id';
35 public function getTimestampField() {
36 return 'fa_timestamp';
39 public function getAuthorIdField() {
40 return 'fa_user';
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 ),
55 array(
56 'fa_id' => $this->row->fa_id,
57 'fa_deleted' => $this->getBits(),
59 __METHOD__
62 return (bool)$dbw->affectedRows();
65 protected function getLink() {
66 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
67 $this->file->getTimestamp(), $this->list->getUser() ) );
69 # Hidden files...
70 if ( !$this->canViewContent() ) {
71 $link = $date;
72 } else {
73 $undelete = SpecialPage::getTitleFor( 'Undelete' );
74 $key = $this->file->getKey();
75 $link = Linker::link( $undelete, $date, array(),
76 array(
77 'target' => $this->list->title->getPrefixedText(),
78 'file' => $key,
79 'token' => $this->list->getUser()->getEditToken( $key )
83 if ( $this->isDeleted() ) {
84 $link = '<span class="history-deleted">' . $link . '</span>';
87 return $link;
90 public function getApiData( ApiResult $result ) {
91 $file = $this->file;
92 $user = $this->list->getUser();
93 $ret = array(
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() ) {
104 $ret += array(
105 'url' => SpecialPage::getTitleFor( 'Revisiondelete' )->getLinkURL(
106 array(
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 ) ) {
116 $ret += array(
117 'userid' => $file->getUser( 'id' ),
118 'user' => $file->getUser( 'text' ),
121 if ( $file->userCan( Revision::DELETED_COMMENT, $user ) ) {
122 $ret += array(
123 'comment' => $file->getRawDescription(),
127 return $ret;