MediaWiki master
RevisionItemBase.php
Go to the documentation of this file.
1<?php
10
13use stdClass;
14use Wikimedia\Timestamp\TimestampFormat as TS;
15
19abstract class RevisionItemBase {
21 protected $list;
22
24 protected $row;
25
30 public function __construct( RevisionListBase $list, $row ) {
31 $this->list = $list;
32 $this->row = $row;
33 }
34
40 public function getIdField() {
41 return null;
42 }
43
49 public function getTimestampField() {
50 return false;
51 }
52
58 public function getAuthorIdField() {
59 return false;
60 }
61
67 public function getAuthorNameField() {
68 return false;
69 }
70
77 public function getAuthorActorField() {
78 return false;
79 }
80
85 public function getId() {
86 $field = $this->getIdField();
87 return intval( $this->row->$field );
88 }
89
94 public function formatDate() {
95 return $this->list->getLanguage()->userDate( $this->getTimestamp(),
96 $this->list->getUser() );
97 }
98
103 public function formatTime() {
104 return $this->list->getLanguage()->userTime( $this->getTimestamp(),
105 $this->list->getUser() );
106 }
107
112 public function getTimestamp() {
113 $field = $this->getTimestampField();
114 return wfTimestamp( TS::MW, $this->row->$field );
115 }
116
121 public function getAuthorId() {
122 $field = $this->getAuthorIdField();
123 return intval( $this->row->$field );
124 }
125
130 public function getAuthorName() {
131 $field = $this->getAuthorNameField();
132 return strval( $this->row->$field );
133 }
134
140 public function getAuthorActor() {
141 $field = $this->getAuthorActorField();
142 return strval( $this->row->$field );
143 }
144
149 abstract public function canView();
150
155 abstract public function canViewContent();
156
162 abstract public function getHTML();
163
168 protected function getLinkRenderer() {
169 return MediaWikiServices::getInstance()->getLinkRenderer();
170 }
171}
173class_alias( RevisionItemBase::class, 'RevisionItemBase' );
wfTimestamp( $outputtype=TS::UNIX, $ts=0)
Get a timestamp string in one of various formats.
Class that generates HTML for internal links.
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Abstract base class for revision items.
getAuthorActorField()
Get the DB field name storing actor ids.
canView()
Returns true if the current user can view the item.
getIdField()
Get the DB field name associated with the ID list.
formatTime()
Get the time, formatted in user's language.
__construct(RevisionListBase $list, $row)
getTimestamp()
Get the timestamp in MW 14-char form.
getLinkRenderer()
Returns an instance of LinkRenderer.
getId()
Get the ID, as it would appear in the ids URL parameter.
getHTML()
Get the HTML of the list item.
getAuthorNameField()
Get the DB field name storing user names.
getAuthorIdField()
Get the DB field name storing user ids.
canViewContent()
Returns true if the current user can view the item text/file.
stdClass $row
The database result row.
getTimestampField()
Get the DB field name storing timestamps.
formatDate()
Get the date, formatted in user's language.
List for revision table items for a single page.