MediaWiki  master
RevisionItemBase.php
Go to the documentation of this file.
1 <?php
25 
29 abstract 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 }
RevisionItemBase\getHTML
getHTML()
Get the HTML of the list item.
RevisionItemBase\__construct
__construct(RevisionListBase $list, $row)
Definition: RevisionItemBase.php:40
RevisionListBase
List for revision table items for a single page.
Definition: RevisionListBase.php:30
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:193
RevisionItemBase
Abstract base class for revision items.
Definition: RevisionItemBase.php:29
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:43
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1668
RevisionItemBase\getAuthorId
getAuthorId()
Get the author user ID.
Definition: RevisionItemBase.php:131
RevisionItemBase\canView
canView()
Returns true if the current user can view the item.
RevisionItemBase\getAuthorNameField
getAuthorNameField()
Get the DB field name storing user names.
Definition: RevisionItemBase.php:77
RevisionItemBase\$list
RevisionListBase $list
The parent.
Definition: RevisionItemBase.php:31
RevisionItemBase\formatDate
formatDate()
Get the date, formatted in user's language.
Definition: RevisionItemBase.php:104
RevisionItemBase\getTimestampField
getTimestampField()
Get the DB field name storing timestamps.
Definition: RevisionItemBase.php:59
RevisionItemBase\getLinkRenderer
getLinkRenderer()
Returns an instance of LinkRenderer.
Definition: RevisionItemBase.php:178
RevisionItemBase\formatTime
formatTime()
Get the time, formatted in user's language.
Definition: RevisionItemBase.php:113
RevisionItemBase\getAuthorName
getAuthorName()
Get the author user name.
Definition: RevisionItemBase.php:140
RevisionItemBase\getId
getId()
Get the ID, as it would appear in the ids URL parameter.
Definition: RevisionItemBase.php:95
RevisionItemBase\canViewContent
canViewContent()
Returns true if the current user can view the item text/file.
RevisionItemBase\getTimestamp
getTimestamp()
Get the timestamp in MW 14-char form.
Definition: RevisionItemBase.php:122
RevisionItemBase\getAuthorActorField
getAuthorActorField()
Get the DB field name storing actor ids.
Definition: RevisionItemBase.php:87
RevisionItemBase\getAuthorActor
getAuthorActor()
Get the author actor ID.
Definition: RevisionItemBase.php:150
RevisionItemBase\getIdField
getIdField()
Get the DB field name associated with the ID list.
Definition: RevisionItemBase.php:50
RevisionItemBase\$row
stdClass $row
The database result row.
Definition: RevisionItemBase.php:34
RevisionItemBase\getAuthorIdField
getAuthorIdField()
Get the DB field name storing user ids.
Definition: RevisionItemBase.php:68