MediaWiki  master
RevDelArchiveItem.php
Go to the documentation of this file.
1 <?php
24 
29  protected static function initRevisionRecord( $list, $row ) {
30  $revRecord = MediaWikiServices::getInstance()
31  ->getRevisionFactory()
32  ->newRevisionFromArchiveRow(
33  $row,
34  RevisionFactory::READ_NORMAL,
35  null,
36  [ 'page_id' => $list->getPage()->getId() ]
37  );
38 
39  return $revRecord;
40  }
41 
42  public function getIdField() {
43  return 'ar_timestamp';
44  }
45 
46  public function getTimestampField() {
47  return 'ar_timestamp';
48  }
49 
50  public function getAuthorIdField() {
51  return 'ar_user';
52  }
53 
54  public function getAuthorNameField() {
55  return 'ar_user_text';
56  }
57 
58  public function getAuthorActorField() {
59  return 'ar_actor';
60  }
61 
62  public function getId() {
63  # Convert DB timestamp to MW timestamp
64  return $this->revisionRecord->getTimestamp();
65  }
66 
67  public function setBits( $bits ) {
68  $dbw = wfGetDB( DB_PRIMARY );
69  $dbw->newUpdateQueryBuilder()
70  ->update( 'archive' )
71  ->set( [ 'ar_deleted' => $bits ] )
72  ->where( [
73  'ar_namespace' => $this->list->getPage()->getNamespace(),
74  'ar_title' => $this->list->getPage()->getDBkey(),
75  // use timestamp for index
76  'ar_timestamp' => $this->row->ar_timestamp,
77  'ar_rev_id' => $this->row->ar_rev_id,
78  'ar_deleted' => $this->getBits()
79  ] )
80  ->caller( __METHOD__ )->execute();
81 
82  return (bool)$dbw->affectedRows();
83  }
84 
85  protected function getRevisionLink() {
86  $date = $this->list->getLanguage()->userTimeAndDate(
87  $this->revisionRecord->getTimestamp(), $this->list->getUser() );
88 
89  if ( $this->isDeleted() && !$this->canViewContent() ) {
90  return htmlspecialchars( $date );
91  }
92 
93  return $this->getLinkRenderer()->makeLink(
94  SpecialPage::getTitleFor( 'Undelete' ),
95  $date,
96  [],
97  [
98  'target' => $this->list->getPageName(),
99  'timestamp' => $this->revisionRecord->getTimestamp()
100  ]
101  );
102  }
103 
104  protected function getDiffLink() {
105  if ( $this->isDeleted() && !$this->canViewContent() ) {
106  return $this->list->msg( 'diff' )->escaped();
107  }
108 
109  return $this->getLinkRenderer()->makeLink(
110  SpecialPage::getTitleFor( 'Undelete' ),
111  $this->list->msg( 'diff' )->text(),
112  [],
113  [
114  'target' => $this->list->getPageName(),
115  'diff' => 'prev',
116  'timestamp' => $this->revisionRecord->getTimestamp()
117  ]
118  );
119  }
120 }
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Service locator for MediaWiki core services.
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.
stdClass $row
The database result row.
RevisionListBase $list
The parent.
getLinkRenderer()
Returns an instance of LinkRenderer.
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,...
Service for constructing RevisionRecord objects.
const DB_PRIMARY
Definition: defines.php:28