MediaWiki master
RevDelArchiveItem.php
Go to the documentation of this file.
1<?php
25
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() ]
38 );
39
40 return $revRecord;
41 }
42
43 public function getIdField() {
44 return 'ar_timestamp';
45 }
46
47 public function getTimestampField() {
48 return 'ar_timestamp';
49 }
50
51 public function getAuthorIdField() {
52 return 'ar_user';
53 }
54
55 public function getAuthorNameField() {
56 return 'ar_user_text';
57 }
58
59 public function getAuthorActorField() {
60 return 'ar_actor';
61 }
62
63 public function getId() {
64 # Convert DB timestamp to MW timestamp
65 return $this->revisionRecord->getTimestamp();
66 }
67
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();
82
83 return (bool)$dbw->affectedRows();
84 }
85
86 protected function getRevisionLink() {
87 $date = $this->list->getLanguage()->userTimeAndDate(
88 $this->revisionRecord->getTimestamp(), $this->list->getUser() );
89
90 if ( $this->isDeleted() && !$this->canViewContent() ) {
91 return htmlspecialchars( $date );
92 }
93
94 return $this->getLinkRenderer()->makeLink(
95 SpecialPage::getTitleFor( 'Undelete' ),
96 $date,
97 [],
98 [
99 'target' => $this->list->getPageName(),
100 'timestamp' => $this->revisionRecord->getTimestamp()
101 ]
102 );
103 }
104
105 protected function getDiffLink() {
106 if ( $this->isDeleted() && !$this->canViewContent() ) {
107 return $this->list->msg( 'diff' )->escaped();
108 }
109
110 return $this->getLinkRenderer()->makeLink(
111 SpecialPage::getTitleFor( 'Undelete' ),
112 $this->list->msg( 'diff' )->text(),
113 [],
114 [
115 'target' => $this->list->getPageName(),
116 'diff' => 'prev',
117 'timestamp' => $this->revisionRecord->getTimestamp()
118 ]
119 );
120 }
121}
Service locator for MediaWiki core services.
getLinkRenderer()
Returns an instance of LinkRenderer.
stdClass $row
The database result row.
Parent class for all special pages.
Item class for a archive table row.
getAuthorNameField()
Get the DB field name storing user names.
getRevisionLink()
Get the HTML link to the revision text.
getId()
Get the ID, as it would appear in the ids URL parameter.
getIdField()
Get the DB field name associated with the ID list.
getDiffLink()
Get the HTML link to the diff.
setBits( $bits)
Set the visibility of the item.
getAuthorIdField()
Get the DB field name storing user ids.
getTimestampField()
Get the DB field name storing timestamps.
static initRevisionRecord( $list, $row)
Create RevisionRecord object from $row sourced from $list.
getAuthorActorField()
Get the DB field name storing actor ids.
canViewContent()
Returns true if the current user can view the item text/file.
Interface for database access objects.