MediaWiki master
RevDelArchiveItem.php
Go to the documentation of this file.
1<?php
11
17 protected static function initRevisionRecord( $list, $row ) {
18 $revRecord = MediaWikiServices::getInstance()
19 ->getRevisionFactory()
20 ->newRevisionFromArchiveRow(
21 $row,
22 IDBAccessObject::READ_NORMAL,
23 null,
24 [ 'page_id' => $list->getPage()->getId() ]
25 );
26
27 return $revRecord;
28 }
29
31 public function getIdField() {
32 return 'ar_timestamp';
33 }
34
36 public function getTimestampField() {
37 return 'ar_timestamp';
38 }
39
41 public function getAuthorIdField() {
42 return 'ar_user';
43 }
44
46 public function getAuthorNameField() {
47 return 'ar_user_text';
48 }
49
51 public function getAuthorActorField() {
52 return 'ar_actor';
53 }
54
56 public function getId() {
57 # Convert DB timestamp to MW timestamp
58 return $this->revisionRecord->getTimestamp();
59 }
60
62 public function setBits( $bits ) {
63 $dbw = MediaWikiServices::getInstance()->getConnectionProvider()->getPrimaryDatabase();
64 $dbw->newUpdateQueryBuilder()
65 ->update( 'archive' )
66 ->set( [ 'ar_deleted' => $bits ] )
67 ->where( [
68 'ar_namespace' => $this->list->getPage()->getNamespace(),
69 'ar_title' => $this->list->getPage()->getDBkey(),
70 // use timestamp for index
71 'ar_timestamp' => $this->row->ar_timestamp,
72 'ar_rev_id' => $this->row->ar_rev_id,
73 'ar_deleted' => $this->getBits()
74 ] )
75 ->caller( __METHOD__ )->execute();
76
77 return (bool)$dbw->affectedRows();
78 }
79
81 protected function getRevisionLink() {
82 $date = $this->list->getLanguage()->userTimeAndDate(
83 $this->revisionRecord->getTimestamp(), $this->list->getUser() );
84
85 if ( $this->isDeleted() && !$this->canViewContent() ) {
86 return htmlspecialchars( $date );
87 }
88
89 return $this->getLinkRenderer()->makeLink(
90 SpecialPage::getTitleFor( 'Undelete' ),
91 $date,
92 [],
93 [
94 'target' => $this->list->getPageName(),
95 'timestamp' => $this->revisionRecord->getTimestamp()
96 ]
97 );
98 }
99
101 protected function getDiffLink() {
102 if ( $this->isDeleted() && !$this->canViewContent() ) {
103 return $this->list->msg( 'diff' )->escaped();
104 }
105
106 return $this->getLinkRenderer()->makeLink(
107 SpecialPage::getTitleFor( 'Undelete' ),
108 $this->list->msg( 'diff' )->text(),
109 [],
110 [
111 'target' => $this->list->getPageName(),
112 'diff' => 'prev',
113 'timestamp' => $this->revisionRecord->getTimestamp()
114 ]
115 );
116 }
117}
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.Override this function. string|false
getRevisionLink()
Get the HTML link to the revision text.Overridden by RevDelArchiveItem. string
getId()
Get the ID, as it would appear in the ids URL parameter.int|string
getIdField()
Get the DB field name associated with the ID list.Override this function. string|null
getDiffLink()
Get the HTML link to the diff.Overridden by RevDelArchiveItem string
setBits( $bits)
Set the visibility of the item.This should do any necessary DB queries.The DB update query should hav...
getAuthorIdField()
Get the DB field name storing user ids.Override this function. string|false
getTimestampField()
Get the DB field name storing timestamps.Override this function. string|false
static initRevisionRecord( $list, $row)
Create RevisionRecord object from $row sourced from $list.RevisionRecord
getAuthorActorField()
Get the DB field name storing actor ids.Override this function. 1.31 string|false
canViewContent()
Returns true if the current user can view the item text/file.bool
Interface for database access objects.