MediaWiki REL1_39
RevisionItemBase.php
Go to the documentation of this file.
1<?php
25
29abstract class RevisionItemBase {
31 protected $list;
32
34 protected $row;
35
40 public function __construct( RevisionListBase $list, $row ) {
41 $this->list = $list;
42 $this->row = $row;
43 }
44
50 public function getIdField() {
51 return null;
52 }
53
59 public function getTimestampField() {
60 return false;
61 }
62
68 public function getAuthorIdField() {
69 return false;
70 }
71
77 public function getAuthorNameField() {
78 return false;
79 }
80
87 public function getAuthorActorField() {
88 return false;
89 }
90
95 public function getId() {
96 $field = $this->getIdField();
97 return intval( $this->row->$field );
98 }
99
104 public function formatDate() {
105 return $this->list->getLanguage()->userDate( $this->getTimestamp(),
106 $this->list->getUser() );
107 }
108
113 public function formatTime() {
114 return $this->list->getLanguage()->userTime( $this->getTimestamp(),
115 $this->list->getUser() );
116 }
117
122 public function getTimestamp() {
123 $field = $this->getTimestampField();
124 return wfTimestamp( TS_MW, $this->row->$field );
125 }
126
131 public function getAuthorId() {
132 $field = $this->getAuthorIdField();
133 return intval( $this->row->$field );
134 }
135
140 public function getAuthorName() {
141 $field = $this->getAuthorNameField();
142 return strval( $this->row->$field );
143 }
144
150 public function getAuthorActor() {
151 $field = $this->getAuthorActorField();
152 return strval( $this->row->$field );
153 }
154
159 abstract public function canView();
160
165 abstract public function canViewContent();
166
172 abstract public function getHTML();
173
178 protected function getLinkRenderer() {
179 return MediaWikiServices::getInstance()->getLinkRenderer();
180 }
181}
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Class that generates HTML anchor link elements for pages.
Service locator for MediaWiki core services.
Abstract base class for revision items.
formatTime()
Get the time, formatted in user's language.
getAuthorIdField()
Get the DB field name storing user ids.
stdClass $row
The database result row.
getTimestampField()
Get the DB field name storing timestamps.
canViewContent()
Returns true if the current user can view the item text/file.
getAuthorActorField()
Get the DB field name storing actor ids.
getAuthorActor()
Get the author actor ID.
getAuthorNameField()
Get the DB field name storing user names.
getHTML()
Get the HTML of the list item.
canView()
Returns true if the current user can view the item.
getAuthorId()
Get the author user ID.
getIdField()
Get the DB field name associated with the ID list.
__construct(RevisionListBase $list, $row)
getAuthorName()
Get the author user name.
getTimestamp()
Get the timestamp in MW 14-char form.
RevisionListBase $list
The parent.
formatDate()
Get the date, formatted in user's language.
getId()
Get the ID, as it would appear in the ids URL parameter.
getLinkRenderer()
Returns an instance of LinkRenderer.
List for revision table items for a single page.