MediaWiki master
RevDelArchiveItem.php
Go to the documentation of this file.
1<?php
9
13
19 protected static function initRevisionRecord( $list, $row ) {
21 ->getRevisionFactory()
22 ->newRevisionFromArchiveRow(
23 $row,
24 IDBAccessObject::READ_NORMAL,
25 null,
26 [ 'page_id' => $list->getPage()->getId() ]
27 );
28
29 return $revRecord;
30 }
31
33 public function getIdField() {
34 return 'ar_timestamp';
35 }
36
38 public function getTimestampField() {
39 return 'ar_timestamp';
40 }
41
43 public function getAuthorIdField() {
44 return 'ar_user';
45 }
46
48 public function getAuthorNameField() {
49 return 'ar_user_text';
50 }
51
53 public function getAuthorActorField() {
54 return 'ar_actor';
55 }
56
58 public function getId() {
59 # Convert DB timestamp to MW timestamp
60 return $this->revisionRecord->getTimestamp();
61 }
62
64 public function setBits( $bits ) {
65 $dbw = MediaWikiServices::getInstance()->getConnectionProvider()->getPrimaryDatabase();
66 $dbw->newUpdateQueryBuilder()
67 ->update( 'archive' )
68 ->set( [ 'ar_deleted' => $bits ] )
69 ->where( [
70 'ar_namespace' => $this->list->getPage()->getNamespace(),
71 'ar_title' => $this->list->getPage()->getDBkey(),
72 // use timestamp for index
73 'ar_timestamp' => $this->row->ar_timestamp,
74 'ar_rev_id' => $this->row->ar_rev_id,
75 'ar_deleted' => $this->getBits()
76 ] )
77 ->caller( __METHOD__ )->execute();
78
79 return (bool)$dbw->affectedRows();
80 }
81
83 protected function getRevisionLink() {
84 $date = $this->list->getLanguage()->userTimeAndDate(
85 $this->revisionRecord->getTimestamp(), $this->list->getUser() );
86
87 if ( $this->isDeleted() && !$this->canViewContent() ) {
88 return htmlspecialchars( $date );
89 }
90
91 return $this->getLinkRenderer()->makeLink(
92 SpecialPage::getTitleFor( 'Undelete' ),
93 $date,
94 [],
95 [
96 'target' => $this->list->getPageName(),
97 'timestamp' => $this->revisionRecord->getTimestamp()
98 ]
99 );
100 }
101
103 protected function getDiffLink() {
104 if ( $this->isDeleted() && !$this->canViewContent() ) {
105 return $this->list->msg( 'diff' )->escaped();
106 }
107
108 return $this->getLinkRenderer()->makeLink(
109 SpecialPage::getTitleFor( 'Undelete' ),
110 $this->list->msg( 'diff' )->text(),
111 [],
112 [
113 'target' => $this->list->getPageName(),
114 'diff' => 'prev',
115 'timestamp' => $this->revisionRecord->getTimestamp()
116 ]
117 );
118 }
119}
120
122class_alias( RevDelArchiveItem::class, 'RevDelArchiveItem' );
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Item class for a archive table row.
getTimestampField()
Get the DB field name storing timestamps.Override this function. string|false
getIdField()
Get the DB field name associated with the ID list.Override this function. string|null
getId()
Get the ID, as it would appear in the ids URL parameter.int|string
getAuthorIdField()
Get the DB field name storing user ids.Override this function. string|false
getDiffLink()
Get the HTML link to the diff.Overridden by RevDelArchiveItem string
getRevisionLink()
Get the HTML link to the revision text.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...
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
getAuthorNameField()
Get the DB field name storing user names.Override this function. string|false
canViewContent()
Returns true if the current user can view the item text/file.bool
getLinkRenderer()
Returns an instance of LinkRenderer.
stdClass $row
The database result row.
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Interface for database access objects.