MediaWiki master
RevisionItemBase.php
Go to the documentation of this file.
1<?php
24
27use stdClass;
28
32abstract class RevisionItemBase {
34 protected $list;
35
37 protected $row;
38
43 public function __construct( RevisionListBase $list, $row ) {
44 $this->list = $list;
45 $this->row = $row;
46 }
47
53 public function getIdField() {
54 return null;
55 }
56
62 public function getTimestampField() {
63 return false;
64 }
65
71 public function getAuthorIdField() {
72 return false;
73 }
74
80 public function getAuthorNameField() {
81 return false;
82 }
83
90 public function getAuthorActorField() {
91 return false;
92 }
93
98 public function getId() {
99 $field = $this->getIdField();
100 return intval( $this->row->$field );
101 }
102
107 public function formatDate() {
108 return $this->list->getLanguage()->userDate( $this->getTimestamp(),
109 $this->list->getUser() );
110 }
111
116 public function formatTime() {
117 return $this->list->getLanguage()->userTime( $this->getTimestamp(),
118 $this->list->getUser() );
119 }
120
125 public function getTimestamp() {
126 $field = $this->getTimestampField();
127 return wfTimestamp( TS_MW, $this->row->$field );
128 }
129
134 public function getAuthorId() {
135 $field = $this->getAuthorIdField();
136 return intval( $this->row->$field );
137 }
138
143 public function getAuthorName() {
144 $field = $this->getAuthorNameField();
145 return strval( $this->row->$field );
146 }
147
153 public function getAuthorActor() {
154 $field = $this->getAuthorActorField();
155 return strval( $this->row->$field );
156 }
157
162 abstract public function canView();
163
168 abstract public function canViewContent();
169
175 abstract public function getHTML();
176
181 protected function getLinkRenderer() {
182 return MediaWikiServices::getInstance()->getLinkRenderer();
183 }
184}
186class_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.