MediaWiki  REL1_24
ParserOptions Class Reference

Set options of the Parser. More...

Collaboration diagram for ParserOptions:

List of all members.

Public Member Functions

 __construct ($user=null, $lang=null)
 Constructor.
 addExtraKey ($key)
 Extra key that should be present in the parser cache key.
 disableContentConversion ($x=true)
 disableTitleConversion ($x=true)
 enableLimitReport ($x=true)
 getAllowExternalImages ()
 getAllowExternalImagesFrom ()
 getAllowSpecialInclusion ()
 getCleanSignatures ()
 getDateFormat ()
 getDisableContentConversion ()
 getDisableTitleConversion ()
 getEditSection ()
 getEnableImageWhitelist ()
 getEnableLimitReport ()
 getExpensiveParserFunctionLimit ()
 getExternalLinkTarget ()
 getInterfaceMessage ()
 getInterwikiMagic ()
 getIsPreview ()
 getIsPrintable ()
 getIsSectionPreview ()
 getMaxGeneratedPPNodeCount ()
 getMaxIncludeSize ()
 getMaxPPExpandDepth ()
 getMaxPPNodeCount ()
 getMaxTemplateDepth ()
 getNumberHeadings ()
 getPreSaveTransform ()
 getRedirectTarget ()
 Get the previously-set redirect target.
 getRemoveComments ()
 getStubThreshold ()
 getTargetLanguage ()
 getTemplateCallback ()
 getThumbSize ()
 getTidy ()
 getTimestamp ()
 getUser ()
 getUserLang ()
 Same as getUserLangObj() but returns a string instead.
 getUserLangObj ()
 Get the user language used by the parser for this page.
 optionsHash ($forOptions, $title=null)
 Generate a hash string with the values set on these ParserOptions for the keys given in the array.
 optionUsed ($optionName)
 Called when an option is accessed.
 registerWatcher ($callback)
 Registers a callback for tracking which ParserOptions which are used.
 setAllowExternalImages ($x)
 setAllowExternalImagesFrom ($x)
 setAllowSpecialInclusion ($x)
 setCleanSignatures ($x)
 setDateFormat ($x)
 setEditSection ($x)
 setEnableImageWhitelist ($x)
 setExpensiveParserFunctionLimit ($x)
 setExternalLinkTarget ($x)
 setInterfaceMessage ($x)
 setInterwikiMagic ($x)
 setIsPreview ($x)
 setIsPrintable ($x)
 setIsSectionPreview ($x)
 setMaxGeneratedPPNodeCount ($x)
 setMaxIncludeSize ($x)
 setMaxPPNodeCount ($x)
 setMaxTemplateDepth ($x)
 setNumberHeadings ($x)
 setPreSaveTransform ($x)
 setRedirectTarget ($title)
 Set the redirect target.
 setRemoveComments ($x)
 setStubThreshold ($x)
 setTargetLanguage ($x)
 setTemplateCallback ($x)
 setThumbSize ($x)
 setTidy ($x)
 setTimestamp ($x)
 setUserLang ($x)

Static Public Member Functions

static legacyOptions ()
 Returns the full array of options that would have been used by in 1.16.
static newFromContext (IContextSource $context)
 Get a ParserOptions object from a IContextSource object.
static newFromUser ($user)
 Get a ParserOptions object from a given user.
static newFromUserAndLang (User $user, Language $lang)
 Get a ParserOptions object from a given user and language.

Public Attributes

 $mAllowExternalImages
 Allow external images inline?
 $mAllowExternalImagesFrom
 If not, any exception?
 $mAllowSpecialInclusion
 Allow inclusion of special pages?
 $mCleanSignatures
 Clean up signature texts?
 $mDateFormat = null
 Date format index.
 $mDisableContentConversion
 Whether content conversion should be disabled.
 $mDisableTitleConversion
 Whether title conversion should be disabled.
 $mEditSection = true
 Create "edit section" links?
 $mEnableImageWhitelist
 If not or it doesn't match, should we check an on-wiki whitelist?
 $mEnableLimitReport = false
 Enable limit report in an HTML comment on output.
 $mExpensiveParserFunctionLimit
 Maximum number of calls per parse to expensive parser functions.
 $mExternalLinkTarget
 Target attribute for external links.
 $mExtraKey = ''
 Extra key that should be present in the caching key.
 $mInterfaceMessage = false
 Which lang to call for PLURAL and GRAMMAR.
 $mInterwikiMagic
 Interlanguage links are removed and returned in an array.
 $mIsPreview = false
 Parsing the page for a "preview" operation?
 $mIsPrintable = false
 Parsing the printable version of the page?
 $mIsSectionPreview = false
 Parsing the page for a "preview" operation on a single section?
 $mMaxGeneratedPPNodeCount
 Maximum number of nodes generated by Preprocessor::preprocessToObj()
 $mMaxIncludeSize
 Maximum size of template expansions, in bytes.
 $mMaxPPExpandDepth
 Maximum recursion depth in PPFrame::expand()
 $mMaxPPNodeCount
 Maximum number of nodes touched by PPFrame::expand()
 $mMaxTemplateDepth
 Maximum recursion depth for templates within templates.
 $mNumberHeadings
 Automatically number headings?
 $mPreSaveTransform = true
 Transform wiki markup when saving the page?
 $mRemoveComments = true
 Remove HTML comments.
 $mTargetLanguage = null
 Overrides $mInterfaceMessage with arbitrary language.
 $mTemplateCallback
 Callback for template fetching.
 $mThumbSize
 Thumb size preferred by the user.
 $mTidy = false
 Use tidy to cleanup output HTML?
 $mTimestamp
 Timestamp used for {{CURRENTDAY}} etc.
User $mUser
 Stored user object.
 $mUserLang
 Language object of the User language.

Protected Attributes

 $onAccessCallback = null
 Function to be called when an option is accessed.

Private Member Functions

 initialiseFromUser ($user, $lang)
 Get user options.

Private Attributes

 $mStubThreshold
 Maximum article size of an article to be marked as "stub".
Title null $redirectTarget = null
 If the page being parsed is a redirect, this should hold the redirect target.

Detailed Description

Set options of the Parser.

All member variables are supposed to be private in theory, although in practise this is not the case.

Definition at line 32 of file ParserOptions.php.


Constructor & Destructor Documentation

ParserOptions::__construct ( user = null,
lang = null 
)

Constructor.

Parameters:
User$user
Language$lang

Definition at line 560 of file ParserOptions.php.


Member Function Documentation

Extra key that should be present in the parser cache key.

Parameters:
string$key

Definition at line 551 of file ParserOptions.php.

Definition at line 483 of file ParserOptions.php.

Definition at line 487 of file ParserOptions.php.

Definition at line 467 of file ParserOptions.php.

Definition at line 298 of file ParserOptions.php.

Definition at line 348 of file ParserOptions.php.

Definition at line 235 of file ParserOptions.php.

Definition at line 253 of file ParserOptions.php.

Definition at line 219 of file ParserOptions.php.

Definition at line 326 of file ParserOptions.php.

Definition at line 334 of file ParserOptions.php.

Definition at line 330 of file ParserOptions.php.

Definition at line 261 of file ParserOptions.php.

Definition at line 273 of file ParserOptions.php.

Definition at line 265 of file ParserOptions.php.

Definition at line 277 of file ParserOptions.php.

Definition at line 239 of file ParserOptions.php.

Definition at line 344 of file ParserOptions.php.

Get the previously-set redirect target.

Since:
1.24
Returns:
Title|null

Definition at line 543 of file ParserOptions.php.

Definition at line 286 of file ParserOptions.php.

Definition at line 320 of file ParserOptions.php.

Definition at line 257 of file ParserOptions.php.

Definition at line 290 of file ParserOptions.php.

Definition at line 314 of file ParserOptions.php.

Definition at line 249 of file ParserOptions.php.

Definition at line 356 of file ParserOptions.php.

Definition at line 340 of file ParserOptions.php.

Same as getUserLangObj() but returns a string instead.

Returns:
string Language code
Since:
1.17

Definition at line 390 of file ParserOptions.php.

Get the user language used by the parser for this page.

You shouldn't use this. Really. $parser->getFunctionLang() is all you need.

To avoid side-effects where the page will be rendered based on the language of the user who last saved, this function will triger a cache fragmentation. Usage of this method is discouraged for that reason.

When saving, this will return the default language instead of the user's.

{{int: }} uses this which used to produce inconsistent link tables (bug 14404).

Returns:
Language
Since:
1.19

Definition at line 379 of file ParserOptions.php.

ParserOptions::initialiseFromUser ( user,
lang 
) [private]

Get user options.

Parameters:
User$user
Language$lang

Definition at line 617 of file ParserOptions.php.

static ParserOptions::legacyOptions ( ) [static]

Returns the full array of options that would have been used by in 1.16.

Used to get the old parser cache entries when available.

Returns:
array

Definition at line 676 of file ParserOptions.php.

static ParserOptions::newFromContext ( IContextSource context) [static]

Get a ParserOptions object from a IContextSource object.

Parameters:
IContextSource$context
Returns:
ParserOptions

Definition at line 607 of file ParserOptions.php.

Referenced by ApiExpandTemplates\execute(), and Preferences\profilePreferences().

static ParserOptions::newFromUser ( user) [static]

Get a ParserOptions object from a given user.

Language will be taken from $wgLang.

Parameters:
User$user
Returns:
ParserOptions

Definition at line 586 of file ParserOptions.php.

Referenced by CompareParsers\checkOptions(), PPFuzzTest\execute(), DumpRenderer\handleRevision(), and ParserMethodsTest\testPreSaveTransform().

ParserOptions::optionsHash ( forOptions,
title = null 
)

Generate a hash string with the values set on these ParserOptions for the keys given in the array.

This will be used as part of the hash key for the parser cache, so users sharing the options with vary for the same page share the same cached data safely.

Extensions which require it should install 'PageRenderingHash' hook, which will give them a chance to modify this key based on their own settings.

Since:
1.17
Parameters:
array$forOptions
Title$titleUsed to get the content language of the page (since r97636)
Returns:
string Page rendering hash

Definition at line 703 of file ParserOptions.php.

ParserOptions::optionUsed ( optionName)

Called when an option is accessed.

Parameters:
string$optionNameName of the option

Definition at line 664 of file ParserOptions.php.

Registers a callback for tracking which ParserOptions which are used.

This is a private API with the parser.

Parameters:
callable$callback

Definition at line 656 of file ParserOptions.php.

Definition at line 398 of file ParserOptions.php.

Definition at line 402 of file ParserOptions.php.

Definition at line 422 of file ParserOptions.php.

Definition at line 475 of file ParserOptions.php.

Definition at line 410 of file ParserOptions.php.

Definition at line 414 of file ParserOptions.php.

Definition at line 406 of file ParserOptions.php.

Definition at line 455 of file ParserOptions.php.

References wfSetVar().

Definition at line 479 of file ParserOptions.php.

Definition at line 430 of file ParserOptions.php.

Definition at line 394 of file ParserOptions.php.

Definition at line 511 of file ParserOptions.php.

Definition at line 519 of file ParserOptions.php.

Definition at line 515 of file ParserOptions.php.

Definition at line 446 of file ParserOptions.php.

Definition at line 438 of file ParserOptions.php.

Definition at line 442 of file ParserOptions.php.

Definition at line 450 of file ParserOptions.php.

Definition at line 418 of file ParserOptions.php.

Definition at line 507 of file ParserOptions.php.

Set the redirect target.

Note that setting or changing this does not *make* the page a redirect or change its target, it merely records the information for reference during the parse.

Since:
1.24
Parameters:
Title | null$title

Definition at line 533 of file ParserOptions.php.

Definition at line 459 of file ParserOptions.php.

Definition at line 503 of file ParserOptions.php.

Definition at line 434 of file ParserOptions.php.

Definition at line 463 of file ParserOptions.php.

Definition at line 499 of file ParserOptions.php.

Definition at line 426 of file ParserOptions.php.

Definition at line 471 of file ParserOptions.php.

Definition at line 491 of file ParserOptions.php.


Member Data Documentation

ParserOptions::$mAllowExternalImages

Allow external images inline?

Definition at line 42 of file ParserOptions.php.

ParserOptions::$mAllowExternalImagesFrom

If not, any exception?

Definition at line 47 of file ParserOptions.php.

ParserOptions::$mAllowSpecialInclusion

Allow inclusion of special pages?

Definition at line 67 of file ParserOptions.php.

ParserOptions::$mCleanSignatures

Clean up signature texts?

1) Strip ~~~, ~~~~ and ~~~~~ out of signatures 2) Substitute all transclusions

Definition at line 146 of file ParserOptions.php.

ParserOptions::$mDateFormat = null

Date format index.

Definition at line 57 of file ParserOptions.php.

ParserOptions::$mDisableContentConversion

Whether content conversion should be disabled.

Definition at line 156 of file ParserOptions.php.

ParserOptions::$mDisableTitleConversion

Whether title conversion should be disabled.

Definition at line 161 of file ParserOptions.php.

ParserOptions::$mEditSection = true

Create "edit section" links?

Definition at line 62 of file ParserOptions.php.

ParserOptions::$mEnableImageWhitelist

If not or it doesn't match, should we check an on-wiki whitelist?

Definition at line 52 of file ParserOptions.php.

ParserOptions::$mEnableLimitReport = false

Enable limit report in an HTML comment on output.

Definition at line 128 of file ParserOptions.php.

ParserOptions::$mExpensiveParserFunctionLimit

Maximum number of calls per parse to expensive parser functions.

Definition at line 112 of file ParserOptions.php.

ParserOptions::$mExternalLinkTarget

Target attribute for external links.

Definition at line 138 of file ParserOptions.php.

ParserOptions::$mExtraKey = ''

Extra key that should be present in the caching key.

Definition at line 206 of file ParserOptions.php.

ParserOptions::$mInterfaceMessage = false

Which lang to call for PLURAL and GRAMMAR.

Definition at line 77 of file ParserOptions.php.

ParserOptions::$mInterwikiMagic

Interlanguage links are removed and returned in an array.

Definition at line 37 of file ParserOptions.php.

ParserOptions::$mIsPreview = false

Parsing the page for a "preview" operation?

Definition at line 191 of file ParserOptions.php.

ParserOptions::$mIsPrintable = false

Parsing the printable version of the page?

Definition at line 201 of file ParserOptions.php.

ParserOptions::$mIsSectionPreview = false

Parsing the page for a "preview" operation on a single section?

Definition at line 196 of file ParserOptions.php.

ParserOptions::$mMaxGeneratedPPNodeCount

Maximum number of nodes generated by Preprocessor::preprocessToObj()

Definition at line 97 of file ParserOptions.php.

ParserOptions::$mMaxIncludeSize

Maximum size of template expansions, in bytes.

Definition at line 87 of file ParserOptions.php.

ParserOptions::$mMaxPPExpandDepth

Maximum recursion depth in PPFrame::expand()

Definition at line 102 of file ParserOptions.php.

ParserOptions::$mMaxPPNodeCount

Maximum number of nodes touched by PPFrame::expand()

Definition at line 92 of file ParserOptions.php.

ParserOptions::$mMaxTemplateDepth

Maximum recursion depth for templates within templates.

Definition at line 107 of file ParserOptions.php.

ParserOptions::$mNumberHeadings

Automatically number headings?

Definition at line 166 of file ParserOptions.php.

ParserOptions::$mPreSaveTransform = true

Transform wiki markup when saving the page?

Definition at line 151 of file ParserOptions.php.

ParserOptions::$mRemoveComments = true

Remove HTML comments.

ONLY APPLIES TO PREPROCESS OPERATIONS

Definition at line 117 of file ParserOptions.php.

ParserOptions::$mStubThreshold [private]

Maximum article size of an article to be marked as "stub".

Definition at line 176 of file ParserOptions.php.

ParserOptions::$mTargetLanguage = null

Overrides $mInterfaceMessage with arbitrary language.

Definition at line 82 of file ParserOptions.php.

ParserOptions::$mTemplateCallback
Initial value:
        array( 'Parser', 'statelessFetchTemplate' )

Callback for template fetching.

Used as first argument to call_user_func().

Definition at line 122 of file ParserOptions.php.

ParserOptions::$mThumbSize

Thumb size preferred by the user.

Definition at line 171 of file ParserOptions.php.

ParserOptions::$mTidy = false

Use tidy to cleanup output HTML?

Definition at line 72 of file ParserOptions.php.

ParserOptions::$mTimestamp

Timestamp used for {{CURRENTDAY}} etc.

Definition at line 133 of file ParserOptions.php.

User ParserOptions::$mUser

Stored user object.

Definition at line 186 of file ParserOptions.php.

ParserOptions::$mUserLang

Language object of the User language.

Definition at line 181 of file ParserOptions.php.

ParserOptions::$onAccessCallback = null [protected]

Function to be called when an option is accessed.

Definition at line 211 of file ParserOptions.php.

Title null ParserOptions::$redirectTarget = null [private]

If the page being parsed is a redirect, this should hold the redirect target.

Definition at line 217 of file ParserOptions.php.


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