MediaWiki  1.33.1
RevisionItemBase.php
Go to the documentation of this file.
1 <?php
24 
28 abstract class RevisionItemBase {
30  protected $list;
31 
33  protected $row;
34 
39  public function __construct( $list, $row ) {
40  $this->list = $list;
41  $this->row = $row;
42  }
43 
49  public function getIdField() {
50  return null;
51  }
52 
58  public function getTimestampField() {
59  return false;
60  }
61 
67  public function getAuthorIdField() {
68  return false;
69  }
70 
76  public function getAuthorNameField() {
77  return false;
78  }
79 
86  public function getAuthorActorField() {
87  return false;
88  }
89 
94  public function getId() {
95  $field = $this->getIdField();
96  return $this->row->$field;
97  }
98 
103  public function formatDate() {
104  return $this->list->getLanguage()->userDate( $this->getTimestamp(),
105  $this->list->getUser() );
106  }
107 
112  public function formatTime() {
113  return $this->list->getLanguage()->userTime( $this->getTimestamp(),
114  $this->list->getUser() );
115  }
116 
121  public function getTimestamp() {
122  $field = $this->getTimestampField();
123  return wfTimestamp( TS_MW, $this->row->$field );
124  }
125 
130  public function getAuthorId() {
131  $field = $this->getAuthorIdField();
132  return intval( $this->row->$field );
133  }
134 
139  public function getAuthorName() {
140  $field = $this->getAuthorNameField();
141  return strval( $this->row->$field );
142  }
143 
149  public function getAuthorActor() {
150  $field = $this->getAuthorActorField();
151  return strval( $this->row->$field );
152  }
153 
157  abstract public function canView();
158 
162  abstract public function canViewContent();
163 
168  abstract public function getHTML();
169 
174  protected function getLinkRenderer() {
175  return MediaWikiServices::getInstance()->getLinkRenderer();
176  }
177 }
RevisionItemBase\getHTML
getHTML()
Get the HTML of the list item.
RevisionListBase
List for revision table items for a single page.
Definition: RevisionListBase.php:29
RevisionItemBase
Abstract base class for revision items.
Definition: RevisionItemBase.php:28
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1912
RevisionItemBase\__construct
__construct( $list, $row)
Definition: RevisionItemBase.php:39
RevisionItemBase\getAuthorId
getAuthorId()
Get the author user ID.
Definition: RevisionItemBase.php:130
RevisionItemBase\canView
canView()
Returns true if the current user can view the item.
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
RevisionItemBase\getAuthorNameField
getAuthorNameField()
Get the DB field name storing user names.
Definition: RevisionItemBase.php:76
RevisionItemBase\$list
RevisionListBase $list
The parent.
Definition: RevisionItemBase.php:30
RevisionItemBase\formatDate
formatDate()
Get the date, formatted in user's language.
Definition: RevisionItemBase.php:103
RevisionItemBase\getTimestampField
getTimestampField()
Get the DB field name storing timestamps.
Definition: RevisionItemBase.php:58
RevisionItemBase\getLinkRenderer
getLinkRenderer()
Returns an instance of LinkRenderer.
Definition: RevisionItemBase.php:174
RevisionItemBase\formatTime
formatTime()
Get the time, formatted in user's language.
Definition: RevisionItemBase.php:112
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
RevisionItemBase\getAuthorName
getAuthorName()
Get the author user name.
Definition: RevisionItemBase.php:139
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
RevisionItemBase\getId
getId()
Get the ID, as it would appear in the ids URL parameter.
Definition: RevisionItemBase.php:94
RevisionItemBase\canViewContent
canViewContent()
Returns true if the current user can view the item text/file.
RevisionItemBase\$row
$row
The database result row.
Definition: RevisionItemBase.php:33
RevisionItemBase\getTimestamp
getTimestamp()
Get the timestamp in MW 14-char form.
Definition: RevisionItemBase.php:121
RevisionItemBase\getAuthorActorField
getAuthorActorField()
Get the DB field name storing actor ids.
Definition: RevisionItemBase.php:86
RevisionItemBase\getAuthorActor
getAuthorActor()
Get the author actor ID.
Definition: RevisionItemBase.php:149
RevisionItemBase\getIdField
getIdField()
Get the DB field name associated with the ID list.
Definition: RevisionItemBase.php:49
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
RevisionItemBase\getAuthorIdField
getAuthorIdField()
Get the DB field name storing user ids.
Definition: RevisionItemBase.php:67