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->update( 'archive',
70  [ 'ar_deleted' => $bits ],
71  [
72  'ar_namespace' => $this->list->getPage()->getNamespace(),
73  'ar_title' => $this->list->getPage()->getDBkey(),
74  // use timestamp for index
75  'ar_timestamp' => $this->row->ar_timestamp,
76  'ar_rev_id' => $this->row->ar_rev_id,
77  'ar_deleted' => $this->getBits()
78  ],
79  __METHOD__ );
80 
81  return (bool)$dbw->affectedRows();
82  }
83 
84  protected function getRevisionLink() {
85  $date = $this->list->getLanguage()->userTimeAndDate(
86  $this->revisionRecord->getTimestamp(), $this->list->getUser() );
87 
88  if ( $this->isDeleted() && !$this->canViewContent() ) {
89  return htmlspecialchars( $date );
90  }
91 
92  return $this->getLinkRenderer()->makeLink(
93  SpecialPage::getTitleFor( 'Undelete' ),
94  $date,
95  [],
96  [
97  'target' => $this->list->getPageName(),
98  'timestamp' => $this->revisionRecord->getTimestamp()
99  ]
100  );
101  }
102 
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 }
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