MediaWiki  1.28.0
DerivativeContext.php
Go to the documentation of this file.
1 <?php
23 
35  private $request;
36 
40  private $title;
41 
45  private $wikipage;
46 
50  private $output;
51 
55  private $user;
56 
60  private $lang;
61 
65  private $skin;
66 
70  private $config;
71 
75  private $timing;
76 
81  public function __construct( IContextSource $context ) {
82  $this->setContext( $context );
83  }
84 
90  public function setConfig( Config $s ) {
91  $this->config = $s;
92  }
93 
99  public function getConfig() {
100  if ( !is_null( $this->config ) ) {
101  return $this->config;
102  } else {
103  return $this->getContext()->getConfig();
104  }
105  }
106 
114  public function getStats() {
115  return MediaWikiServices::getInstance()->getStatsdDataFactory();
116  }
117 
123  public function getTiming() {
124  if ( !is_null( $this->timing ) ) {
125  return $this->timing;
126  } else {
127  return $this->getContext()->getTiming();
128  }
129  }
130 
136  public function setRequest( WebRequest $r ) {
137  $this->request = $r;
138  }
139 
145  public function getRequest() {
146  if ( !is_null( $this->request ) ) {
147  return $this->request;
148  } else {
149  return $this->getContext()->getRequest();
150  }
151  }
152 
158  public function setTitle( Title $t ) {
159  $this->title = $t;
160  }
161 
167  public function getTitle() {
168  if ( !is_null( $this->title ) ) {
169  return $this->title;
170  } else {
171  return $this->getContext()->getTitle();
172  }
173  }
174 
183  public function canUseWikiPage() {
184  if ( $this->wikipage !== null ) {
185  return true;
186  } elseif ( $this->title !== null ) {
187  return $this->title->canExist();
188  } else {
189  return $this->getContext()->canUseWikiPage();
190  }
191  }
192 
199  public function setWikiPage( WikiPage $p ) {
200  $this->wikipage = $p;
201  }
202 
212  public function getWikiPage() {
213  if ( !is_null( $this->wikipage ) ) {
214  return $this->wikipage;
215  } else {
216  return $this->getContext()->getWikiPage();
217  }
218  }
219 
225  public function setOutput( OutputPage $o ) {
226  $this->output = $o;
227  }
228 
234  public function getOutput() {
235  if ( !is_null( $this->output ) ) {
236  return $this->output;
237  } else {
238  return $this->getContext()->getOutput();
239  }
240  }
241 
247  public function setUser( User $u ) {
248  $this->user = $u;
249  }
250 
256  public function getUser() {
257  if ( !is_null( $this->user ) ) {
258  return $this->user;
259  } else {
260  return $this->getContext()->getUser();
261  }
262  }
263 
271  public function setLanguage( $l ) {
272  if ( $l instanceof Language ) {
273  $this->lang = $l;
274  } elseif ( is_string( $l ) ) {
276  $obj = Language::factory( $l );
277  $this->lang = $obj;
278  } else {
279  throw new MWException( __METHOD__ . " was passed an invalid type of data." );
280  }
281  }
282 
289  public function getLanguage() {
290  if ( !is_null( $this->lang ) ) {
291  return $this->lang;
292  } else {
293  return $this->getContext()->getLanguage();
294  }
295  }
296 
302  public function setSkin( Skin $s ) {
303  $this->skin = clone $s;
304  $this->skin->setContext( $this );
305  }
306 
312  public function getSkin() {
313  if ( !is_null( $this->skin ) ) {
314  return $this->skin;
315  } else {
316  return $this->getContext()->getSkin();
317  }
318  }
319 
330  public function msg() {
331  $args = func_get_args();
332 
333  return call_user_func_array( 'wfMessage', $args )->setContext( $this );
334  }
335 }
setRequest(WebRequest $r)
Set the WebRequest object.
setContext(IContextSource $context)
Set the IContextSource object.
Interface for objects which can provide a MediaWiki context on request.
setOutput(OutputPage $o)
Set the OutputPage object.
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:34
getUser()
Get the User object.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
getStats()
Get the stats object.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg()
Get a message using the current context.
__construct(IContextSource $context)
Constructor.
An IContextSource implementation which will inherit context from another source but allow individual ...
getOutput()
Get the OutputPage object.
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
getWikiPage()
Get the WikiPage object.
getTitle()
Get the Title object.
title
IContextSource $context
setConfig(Config $s)
Set the SiteConfiguration object.
static sanitizeLangCode($code)
Accepts a language code and ensures it's sane.
if($line===false) $args
Definition: cdb.php:64
setSkin(Skin $s)
Set the Skin object.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging a wrapping ErrorException instead of letting the login form give the generic error message that the account does not exist For when the account has been renamed or deleted or an array to pass a message key and parameters create2 Corresponds to logging log_action database field and which is displayed in the UI similar to $comment this hook should only be used to add variables that depend on the current page request
Definition: hooks.txt:2102
getRequest()
Get the WebRequest object.
setWikiPage(WikiPage $p)
Set the WikiPage object.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Wikitext formatted, in the key only.
Definition: distributors.txt:9
getContext()
Get the base IContextSource object.
getSkin()
Get the Skin object.
getTiming()
Get the timing object.
setTitle(Title $t)
Set the Title object.
This class should be covered by a general architecture document which does not exist as of January 20...
Definition: OutputPage.php:43
setLanguage($l)
Set the Language object.
Class representing a MediaWiki article and history.
Definition: WikiPage.php:32
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
setUser(User $u)
Set the User object.
getConfig()
Get the Config object.
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all.It could be easily changed to send incrementally if that becomes useful
getLanguage()
Get the Language object.
static factory($code)
Get a cached or new language object for a given language code.
Definition: Language.php:181
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a skin(according to that user's preference)