Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / revisiondelete / RevDelArchiveItem.php
blobcb23fbf489cd5ca62ccd92375e85d209fb214581
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 use MediaWiki\MediaWikiServices;
23 use MediaWiki\SpecialPage\SpecialPage;
24 use Wikimedia\Rdbms\IDBAccessObject;
26 /**
27 * Item class for a archive table row
29 class RevDelArchiveItem extends RevDelRevisionItem {
30 protected static function initRevisionRecord( $list, $row ) {
31 $revRecord = MediaWikiServices::getInstance()
32 ->getRevisionFactory()
33 ->newRevisionFromArchiveRow(
34 $row,
35 IDBAccessObject::READ_NORMAL,
36 null,
37 [ 'page_id' => $list->getPage()->getId() ]
40 return $revRecord;
43 public function getIdField() {
44 return 'ar_timestamp';
47 public function getTimestampField() {
48 return 'ar_timestamp';
51 public function getAuthorIdField() {
52 return 'ar_user';
55 public function getAuthorNameField() {
56 return 'ar_user_text';
59 public function getAuthorActorField() {
60 return 'ar_actor';
63 public function getId() {
64 # Convert DB timestamp to MW timestamp
65 return $this->revisionRecord->getTimestamp();
68 public function setBits( $bits ) {
69 $dbw = MediaWikiServices::getInstance()->getConnectionProvider()->getPrimaryDatabase();
70 $dbw->newUpdateQueryBuilder()
71 ->update( 'archive' )
72 ->set( [ 'ar_deleted' => $bits ] )
73 ->where( [
74 'ar_namespace' => $this->list->getPage()->getNamespace(),
75 'ar_title' => $this->list->getPage()->getDBkey(),
76 // use timestamp for index
77 'ar_timestamp' => $this->row->ar_timestamp,
78 'ar_rev_id' => $this->row->ar_rev_id,
79 'ar_deleted' => $this->getBits()
80 ] )
81 ->caller( __METHOD__ )->execute();
83 return (bool)$dbw->affectedRows();
86 protected function getRevisionLink() {
87 $date = $this->list->getLanguage()->userTimeAndDate(
88 $this->revisionRecord->getTimestamp(), $this->list->getUser() );
90 if ( $this->isDeleted() && !$this->canViewContent() ) {
91 return htmlspecialchars( $date );
94 return $this->getLinkRenderer()->makeLink(
95 SpecialPage::getTitleFor( 'Undelete' ),
96 $date,
97 [],
99 'target' => $this->list->getPageName(),
100 'timestamp' => $this->revisionRecord->getTimestamp()
105 protected function getDiffLink() {
106 if ( $this->isDeleted() && !$this->canViewContent() ) {
107 return $this->list->msg( 'diff' )->escaped();
110 return $this->getLinkRenderer()->makeLink(
111 SpecialPage::getTitleFor( 'Undelete' ),
112 $this->list->msg( 'diff' )->text(),
115 'target' => $this->list->getPageName(),
116 'diff' => 'prev',
117 'timestamp' => $this->revisionRecord->getTimestamp()