MediaWiki  1.23.12
DerivativeContext.php
Go to the documentation of this file.
1 <?php
36  private $request;
37 
41  private $title;
42 
46  private $wikipage;
47 
51  private $output;
52 
56  private $user;
57 
61  private $lang;
62 
66  private $skin;
67 
71  private $config;
72 
77  public function __construct( IContextSource $context ) {
78  $this->setContext( $context );
79  }
80 
86  public function setConfig( Config $s ) {
87  $this->config = $s;
88  }
89 
95  public function getConfig() {
96  if ( !is_null( $this->config ) ) {
97  return $this->config;
98  } else {
99  return $this->getContext()->getConfig();
100  }
101  }
102 
108  public function setRequest( WebRequest $r ) {
109  $this->request = $r;
110  }
111 
117  public function getRequest() {
118  if ( !is_null( $this->request ) ) {
119  return $this->request;
120  } else {
121  return $this->getContext()->getRequest();
122  }
123  }
124 
131  public function setTitle( $t ) {
132  if ( $t !== null && !$t instanceof Title ) {
133  throw new MWException( __METHOD__ . " expects an instance of Title" );
134  }
135  $this->title = $t;
136  }
137 
143  public function getTitle() {
144  if ( !is_null( $this->title ) ) {
145  return $this->title;
146  } else {
147  return $this->getContext()->getTitle();
148  }
149  }
150 
159  public function canUseWikiPage() {
160  if ( $this->wikipage !== null ) {
161  return true;
162  } elseif ( $this->title !== null ) {
163  return $this->title->canExist();
164  } else {
165  return $this->getContext()->canUseWikiPage();
166  }
167  }
168 
175  public function setWikiPage( WikiPage $p ) {
176  $this->wikipage = $p;
177  }
178 
188  public function getWikiPage() {
189  if ( !is_null( $this->wikipage ) ) {
190  return $this->wikipage;
191  } else {
192  return $this->getContext()->getWikiPage();
193  }
194  }
195 
201  public function setOutput( OutputPage $o ) {
202  $this->output = $o;
203  }
204 
210  public function getOutput() {
211  if ( !is_null( $this->output ) ) {
212  return $this->output;
213  } else {
214  return $this->getContext()->getOutput();
215  }
216  }
217 
223  public function setUser( User $u ) {
224  $this->user = $u;
225  }
226 
232  public function getUser() {
233  if ( !is_null( $this->user ) ) {
234  return $this->user;
235  } else {
236  return $this->getContext()->getUser();
237  }
238  }
239 
246  public function setLang( $l ) {
247  wfDeprecated( __METHOD__, '1.19' );
248  $this->setLanguage( $l );
249  }
250 
258  public function setLanguage( $l ) {
259  if ( $l instanceof Language ) {
260  $this->lang = $l;
261  } elseif ( is_string( $l ) ) {
263  $obj = Language::factory( $l );
264  $this->lang = $obj;
265  } else {
266  throw new MWException( __METHOD__ . " was passed an invalid type of data." );
267  }
268  }
269 
274  public function getLang() {
275  wfDeprecated( __METHOD__, '1.19' );
276  $this->getLanguage();
277  }
278 
285  public function getLanguage() {
286  if ( !is_null( $this->lang ) ) {
287  return $this->lang;
288  } else {
289  return $this->getContext()->getLanguage();
290  }
291  }
292 
298  public function setSkin( Skin $s ) {
299  $this->skin = clone $s;
300  $this->skin->setContext( $this );
301  }
302 
308  public function getSkin() {
309  if ( !is_null( $this->skin ) ) {
310  return $this->skin;
311  } else {
312  return $this->getContext()->getSkin();
313  }
314  }
315 
327  public function msg() {
328  $args = func_get_args();
329 
330  return call_user_func_array( 'wfMessage', $args )->setContext( $this );
331  }
332 }
DerivativeContext\__construct
__construct(IContextSource $context)
Constructor.
Definition: DerivativeContext.php:69
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
ContextSource\getContext
getContext()
Get the RequestContext object.
Definition: ContextSource.php:40
RequestContext\sanitizeLangCode
static sanitizeLangCode( $code)
Accepts a language code and ensures it's sane.
Definition: RequestContext.php:248
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
DerivativeContext\$config
Config $config
Definition: DerivativeContext.php:63
DerivativeContext\setConfig
setConfig(Config $s)
Set the SiteConfiguration object.
Definition: DerivativeContext.php:78
DerivativeContext\$wikipage
WikiPage $wikipage
Definition: DerivativeContext.php:43
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:37
$s
$s
Definition: mergeMessageFileList.php:156
request
this hook is for auditing only etc 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:1644
DerivativeContext\getWikiPage
getWikiPage()
Get the WikiPage object.
Definition: DerivativeContext.php:180
DerivativeContext\getUser
getUser()
Get the User object.
Definition: DerivativeContext.php:224
DerivativeContext\getOutput
getOutput()
Get the OutputPage object.
Definition: DerivativeContext.php:202
DerivativeContext\msg
msg()
Get a message using the current context.
Definition: DerivativeContext.php:319
DerivativeContext\getTitle
getTitle()
Get the Title object.
Definition: DerivativeContext.php:135
DerivativeContext\$output
OutputPage $output
Definition: DerivativeContext.php:47
title
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Definition: All_system_messages.txt:2703
Config
Interface for configuration instances.
Definition: Config.php:28
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:32
MWException
MediaWiki exception.
Definition: MWException.php:26
DerivativeContext\$title
Title $title
Definition: DerivativeContext.php:39
DerivativeContext\$skin
Skin $skin
Definition: DerivativeContext.php:59
DerivativeContext\setSkin
setSkin(Skin $s)
Set the Skin object.
Definition: DerivativeContext.php:290
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1174
DerivativeContext\setTitle
setTitle( $t)
Set the Title object.
Definition: DerivativeContext.php:123
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:30
DerivativeContext\setLang
setLang( $l)
Set the Language object.
Definition: DerivativeContext.php:238
DerivativeContext\getRequest
getRequest()
Get the WebRequest object.
Definition: DerivativeContext.php:109
ContextSource\setContext
setContext(IContextSource $context)
Set the IContextSource object.
Definition: ContextSource.php:57
OutputPage
This class should be covered by a general architecture document which does not exist as of January 20...
Definition: OutputPage.php:38
DerivativeContext\canUseWikiPage
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
Definition: DerivativeContext.php:151
user
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
Definition: distributors.txt:9
skin
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)
DerivativeContext\getConfig
getConfig()
Get the Config object.
Definition: DerivativeContext.php:87
DerivativeContext\setWikiPage
setWikiPage(WikiPage $p)
Set the WikiPage object.
Definition: DerivativeContext.php:167
DerivativeContext\getSkin
getSkin()
Get the Skin object.
Definition: DerivativeContext.php:300
DerivativeContext\$user
User $user
Definition: DerivativeContext.php:51
IContextSource
Interface for objects which can provide a context on request.
Definition: IContextSource.php:29
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
Definition: WebRequest.php:38
$args
if( $line===false) $args
Definition: cdb.php:62
Title
Represents a title within MediaWiki.
Definition: Title.php:35
DerivativeContext\setUser
setUser(User $u)
Set the User object.
Definition: DerivativeContext.php:215
output
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
DerivativeContext\setRequest
setRequest(WebRequest $r)
Set the WebRequest object.
Definition: DerivativeContext.php:100
DerivativeContext\getLang
getLang()
Definition: DerivativeContext.php:266
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:184
$t
$t
Definition: testCompression.php:65
Skin
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:35
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59
DerivativeContext\setOutput
setOutput(OutputPage $o)
Set the OutputPage object.
Definition: DerivativeContext.php:193
Language
Internationalisation code.
Definition: Language.php:74
DerivativeContext\getLanguage
getLanguage()
Get the Language object.
Definition: DerivativeContext.php:277
DerivativeContext\$request
WebRequest $request
Definition: DerivativeContext.php:35
DerivativeContext\setLanguage
setLanguage( $l)
Set the Language object.
Definition: DerivativeContext.php:250
DerivativeContext\$lang
Language $lang
Definition: DerivativeContext.php:55