MediaWiki  REL1_19
RequestContext Class Reference

Group all the pieces relevant to the context of a request into one instance. More...

Inheritance diagram for RequestContext:
Collaboration diagram for RequestContext:

List of all members.

Public Member Functions

 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 getLang ()
 getLanguage ()
 Get the Language object.
 getOutput ()
 Get the OutputPage object.
 getRequest ()
 Get the WebRequest object.
 getSkin ()
 Get the Skin object.
 getTitle ()
 Get the Title object.
 getUser ()
 Get the User object.
 getWikiPage ()
 Get the WikiPage object.
 msg ()
 Helpful methods.
 setLang ($l)
 Set the Language object.
 setLanguage ($l)
 Set the Language object.
 setOutput (OutputPage $o)
 setRequest (WebRequest $r)
 Set the WebRequest object.
 setSkin (Skin $s)
 Set the Skin object.
 setTitle (Title $t)
 Set the Title object.
 setUser (User $u)
 Set the User object.
 setWikiPage (WikiPage $p)
 Set the WikiPage object.

Static Public Member Functions

static getMain ()
 Static methods.
static newExtraneousContext (Title $title, $request=array())
 Create a new extraneous context.
static sanitizeLangCode ($code)
 Accepts a language code and ensures it's sane.

Private Attributes

 $lang
 $output
 $request
 $skin
 $title
 $user
 $wikipage

Detailed Description

Group all the pieces relevant to the context of a request into one instance.

Definition at line 30 of file RequestContext.php.


Member Function Documentation

Check whether a WikiPage object can be get with getWikiPage().

Callers should expect that an exception is thrown from getWikiPage() if this method returns false.

Since:
1.19
Returns:
bool

Implements IContextSource.

Definition at line 119 of file RequestContext.php.

References $title, and getTitle().

Here is the call graph for this function:

Deprecated:
1.19 Use getLanguage instead
Returns:
Language

Implements IContextSource.

Definition at line 258 of file RequestContext.php.

References getLanguage(), and wfDeprecated().

Here is the call graph for this function:

Get the Language object.

Initialization of user or request objects can depend on this.

Returns:
Language
Since:
1.19

Implements IContextSource.

Definition at line 270 of file RequestContext.php.

References $request, $user, $wgContLang, $wgLanguageCode, Language\factory(), getRequest(), getUser(), sanitizeLangCode(), wfDebugLog(), and wfRunHooks().

Referenced by getLang(), UploadFromUrlTestSuite\setUp(), and ParserTest\setUp().

Here is the call graph for this function:

Here is the caller graph for this function:

static RequestContext::getMain ( ) [static]

Static methods.

Get the RequestContext object associated with the main request

Returns:
RequestContext object

Definition at line 378 of file RequestContext.php.

Referenced by MediaWiki\__construct(), LogFormatter\__construct(), StubUserLang\_newObject(), ContextSource\getContext(), SpecialPage\getContext(), Article\getContext(), User\getSkin(), ChangesList\newFromUser(), and LogEventsList\showLogExtract().

Here is the caller graph for this function:

Get the OutputPage object.

Returns:
OutputPage object

Implements IContextSource.

Definition at line 176 of file RequestContext.php.

Get the WebRequest object.

Returns:
WebRequest

Implements IContextSource.

Definition at line 81 of file RequestContext.php.

Referenced by getLanguage(), getSkin(), and getUser().

Here is the caller graph for this function:

Get the Skin object.

Returns:
Skin

Implements IContextSource.

Definition at line 320 of file RequestContext.php.

References $skin, $wgDefaultSkin, $wgHiddenPrefs, getRequest(), getUser(), Skin\newFromKey(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Here is the call graph for this function:

Get the Title object.

Returns:
Title

Implements IContextSource.

Definition at line 103 of file RequestContext.php.

References $wgTitle.

Referenced by canUseWikiPage(), and getWikiPage().

Here is the caller graph for this function:

Get the User object.

Returns:
User

Implements IContextSource.

Definition at line 197 of file RequestContext.php.

References getRequest(), and User\newFromSession().

Referenced by getLanguage(), and getSkin().

Here is the call graph for this function:

Here is the caller graph for this function:

Get the WikiPage object.

May throw an exception if there's no Title object set or the Title object belongs to a special namespace that doesn't have WikiPage, so use first canUseWikiPage() to check whether this method can be called safely.

Since:
1.19
Returns:
WikiPage

Implements IContextSource.

Definition at line 153 of file RequestContext.php.

References $title, WikiPage\factory(), and getTitle().

Here is the call graph for this function:

Helpful methods.

Get a Message object with context set Parameters are the same as wfMessage()

Returns:
Message object

Implements IContextSource.

Definition at line 366 of file RequestContext.php.

static RequestContext::newExtraneousContext ( Title title,
request = array() 
) [static]

Create a new extraneous context.

The context is filled with information external to the current session.

  • Title is specified by argument
  • Request is a FauxRequest, or a FauxRequest can be specified by argument
  • User is an anonymous user, for separation IPv4 localhost is used
  • Language will be based on the anonymous user and request, may be content language or a uselang param in the fauxrequest data may change the lang
  • Skin will be based on the anonymous user, should be the wiki's default skin
Parameters:
Title$titleTitle to use for the extraneous request
WebRequest | array$requestA WebRequest or data to use for a FauxRequest
Returns:
RequestContext

Definition at line 400 of file RequestContext.php.

References $request, and User\newFromName().

Referenced by LogPage\addEntry(), Title\moveToInternal(), and ManualLogEntry\publish().

Here is the call graph for this function:

Here is the caller graph for this function:

static RequestContext::sanitizeLangCode ( code) [static]

Accepts a language code and ensures it's sane.

Outputs a cleaned up language code and replaces with $wgLanguageCode if not sane.

Parameters:
$codestring
Returns:
string

Definition at line 210 of file RequestContext.php.

References $wgLanguageCode, Language\isValidCode(), and wfDebug().

Referenced by getLanguage(), DerivativeContext\setLanguage(), and setLanguage().

Here is the call graph for this function:

Here is the caller graph for this function:

Set the Language object.

Deprecated:
1.19 Use setLanguage instead
Parameters:
$lMixed Language instance or language code

Definition at line 231 of file RequestContext.php.

References setLanguage(), and wfDeprecated().

Here is the call graph for this function:

Set the Language object.

Parameters:
$lMixed Language instance or language code
Since:
1.19

Definition at line 242 of file RequestContext.php.

References Language\factory(), and sanitizeLangCode().

Referenced by setLang().

Here is the call graph for this function:

Here is the caller graph for this function:

Parameters:
$oOutputPage

Definition at line 167 of file RequestContext.php.

Set the WebRequest object.

Parameters:
$rWebRequest object

Definition at line 72 of file RequestContext.php.

Referenced by SpecialRecentchangesTest\assertConditions().

Here is the caller graph for this function:

Set the Skin object.

Parameters:
$sSkin

Definition at line 310 of file RequestContext.php.

References ContextSource\setContext().

Here is the call graph for this function:

Set the Title object.

Parameters:
$tTitle object

Definition at line 94 of file RequestContext.php.

References $t.

Referenced by Parser\braceSubstitution(), and RebuildFileCache\execute().

Here is the caller graph for this function:

Set the User object.

Parameters:
$uUser

Definition at line 188 of file RequestContext.php.

Referenced by SpecialSearchTest\testProfileAndNamespaceLoading().

Here is the caller graph for this function:

Set the WikiPage object.

Since:
1.19
Parameters:
$pWikiPage object

Definition at line 140 of file RequestContext.php.


Member Data Documentation

RequestContext::$lang [private]

Definition at line 60 of file RequestContext.php.

RequestContext::$output [private]

Definition at line 50 of file RequestContext.php.

RequestContext::$request [private]

Definition at line 35 of file RequestContext.php.

Referenced by getLanguage(), and newExtraneousContext().

RequestContext::$skin [private]

Definition at line 65 of file RequestContext.php.

Referenced by getSkin().

RequestContext::$title [private]

Definition at line 40 of file RequestContext.php.

Referenced by canUseWikiPage(), and getWikiPage().

RequestContext::$user [private]

Definition at line 55 of file RequestContext.php.

Referenced by getLanguage(), and ApiTestContext\newTestContext().

RequestContext::$wikipage [private]

Definition at line 45 of file RequestContext.php.


The documentation for this class was generated from the following file: