23use Wikimedia\ScopedCallback;
54 'dateformat' => [ __CLASS__,
'initDateFormat' ],
63 'numberheadings' =>
true,
65 'stubthreshold' =>
true,
122 if ( !array_key_exists( $name, $this->
options ) ) {
123 throw new InvalidArgumentException(
"Unknown parser option $name" );
126 if ( isset( self::$lazyOptions[$name] ) && $this->
options[$name] ===
null ) {
127 $this->
options[
$name] = call_user_func( self::$lazyOptions[$name], $this, $name );
129 if ( !empty( self::$inCacheKey[$name] ) ) {
144 if ( !array_key_exists( $name, $this->
options ) ) {
145 throw new InvalidArgumentException(
"Unknown parser option $name" );
161 if ( !array_key_exists( $name, $this->
options ) ) {
162 throw new InvalidArgumentException(
"Unknown parser option $name" );
176 return $this->
getOption(
'interwikiMagic' );
193 return $this->
getOption(
'allowExternalImages' );
213 return $this->
getOption(
'allowExternalImagesFrom' );
233 return $this->
getOption(
'enableImageWhitelist' );
250 return $this->
getOption(
'numberheadings' );
267 return $this->
getOption(
'allowSpecialInclusion' );
301 return $this->
getOption(
'interfaceMessage' );
318 return $this->
getOption(
'targetLanguage' );
327 return $this->
setOption(
'targetLanguage', $x );
335 return $this->
getOption(
'maxIncludeSize' );
352 return $this->
getOption(
'maxPPNodeCount' );
369 return $this->
getOption(
'maxGeneratedPPNodeCount' );
386 return $this->
getOption(
'maxPPExpandDepth' );
394 return $this->
getOption(
'maxTemplateDepth' );
412 return $this->
getOption(
'expensiveParserFunctionLimit' );
431 return $this->
getOption(
'removeComments' );
449 return $this->
getOption(
'enableLimitReport' );
467 return $this->
getOption(
'cleanSignatures' );
485 return $this->
getOption(
'externalLinkTarget' );
502 return $this->
getOption(
'disableContentConversion' );
519 return $this->
getOption(
'disableTitleConversion' );
553 return $this->
getOption(
'stubthreshold' );
587 return $this->
getOption(
'isSectionPreview' );
621 return $this->
getOption(
'preSaveTransform' );
645 return $popt->mUser->getDatePreference();
700 if ( is_string( $x ) ) {
701 $x = Language::factory( $x );
713 return $this->
getOption(
'magicISBNLinks' );
722 return $this->
getOption(
'magicPMIDLinks' );
730 return $this->
getOption(
'magicRFCLinks' );
748 return $this->
getOption(
'allowUnsafeRawHtml' );
780 if ( $className ===
true ) {
781 $className =
'mw-parser-output';
783 if ( $className ===
false ) {
786 return $this->
setOption(
'wrapclass', $className );
795 return $this->
getOption(
'currentRevisionCallback' );
813 return $this->
getOption(
'templateCallback' );
831 return $this->
getOption(
'speculativeRevIdCallback' );
851 if ( !isset( $this->mTimestamp ) ) {
854 return $this->mTimestamp;
863 return wfSetVar( $this->mTimestamp, $x );
898 $this->redirectTarget =
$title;
908 return $this->redirectTarget;
918 $this->mExtraKey .=
'!' . $key;
937 if ( $user ===
null ) {
945 if (
$lang ===
null ) {
1022 foreach ( self::getCanonicalOverrides() as $k => $v ) {
1023 $ret->setOption( $k, $v );
1045 if ( self::$defaults ===
null ) {
1048 'dateformat' =>
null,
1050 'interfaceMessage' =>
false,
1051 'targetLanguage' =>
null,
1052 'removeComments' =>
true,
1053 'enableLimitReport' =>
false,
1054 'preSaveTransform' =>
true,
1055 'isPreview' =>
false,
1056 'isSectionPreview' =>
false,
1057 'printable' =>
false,
1058 'allowUnsafeRawHtml' =>
true,
1059 'wrapclass' =>
'mw-parser-output',
1060 'currentRevisionCallback' => [ Parser::class,
'statelessFetchRevision' ],
1061 'templateCallback' => [ Parser::class,
'statelessFetchTemplate' ],
1062 'speculativeRevIdCallback' =>
null,
1065 Hooks::run(
'ParserOptionsRegister', [
1068 &self::$lazyOptions,
1071 ksort( self::$inCacheKey );
1075 return self::$defaults + [
1096 'stubthreshold' => 0,
1126 $this->
options = self::getDefaults();
1128 $this->mUser =
$user;
1129 $this->
options[
'numberheadings'] = $user->getOption(
'numberheadings' );
1130 $this->
options[
'thumbsize'] = $user->getOption(
'thumbsize' );
1131 $this->
options[
'stubthreshold'] = $user->getStubThreshold();
1146 foreach ( self::$lazyOptions as $name => $callback ) {
1147 if ( $this->
options[$name] ===
null ) {
1148 $this->
options[
$name] = call_user_func( $callback, $this, $name );
1150 if ( $other->options[$name] ===
null ) {
1151 $other->options[
$name] = call_user_func( $callback, $other, $name );
1158 'enableLimitReport',
1163 if ( $o1 !== $o2 ) {
1169 $fields = array_keys( get_class_vars( __CLASS__ ) );
1170 $fields = array_diff( $fields, [
1177 foreach ( $fields as $field ) {
1178 if ( !is_object( $this->$field ) && $this->$field !== $other->$field ) {
1192 $this->onAccessCallback = $callback;
1204 if ( $this->onAccessCallback ) {
1205 call_user_func( $this->onAccessCallback, $optionName );
1236 if ( self::$defaults ===
null ) {
1237 self::getDefaults();
1239 return array_keys( array_filter( self::$inCacheKey ) );
1250 } elseif (
$value ===
false ) {
1252 } elseif (
$value ===
null ) {
1255 return $value->getCode();
1256 } elseif ( is_array(
$value ) ) {
1257 return '[' . implode(
',', array_map( [ $this,
'optionToString' ],
$value ) ) .
']';
1279 $defaults = self::getCanonicalOverrides() + self::getDefaults();
1289 if ( $include && in_array( $option, $forOptions,
true ) ) {
1293 $values[] =
"$option=$v";
1298 $confstr = $values ? implode(
'!', $values ) :
'canonical';
1302 if ( !is_null( $title ) ) {
1303 $confstr .= $title->getPageLanguage()->getExtraHashOptions();
1311 if ( $this->mExtraKey !=
'' ) {
1312 $confstr .= $this->mExtraKey;
1317 Hooks::run(
'PageRenderingHash', [ &$confstr, $this->
getUser(), &$forOptions ] );
1320 $confstr = str_replace(
' ',
'_', $confstr );
1331 $defaults = self::getCanonicalOverrides() + self::getDefaults();
1333 if ( empty( self::$inCacheKey[$option] ) ) {
1357 $titleToCheck,
$parser =
false ) use ( $title, $content, $user, &$oldCallback
1359 if ( $titleToCheck->equals( $title ) ) {
1360 return new Revision( [
1361 'page' => $title->getArticleID(),
1362 'user_text' => $user->getName(),
1363 'user' => $user->getId(),
1364 'parent_id' => $title->getLatestRevID(),
1366 'content' => $content
1369 return call_user_func( $oldCallback, $titleToCheck, $parser );
1376 function ( $titleToCheck, &$exists ) use ( $title ) {
1377 if ( $titleToCheck->equals( $title ) ) {
1383 LinkCache::singleton()->clearBadLink( $title->getPrefixedDBkey() );
1384 return new ScopedCallback(
function () use ( $title, $key ) {
1386 unset(
$wgHooks[
'TitleExists'][$key] );
1387 LinkCache::singleton()->clearLink( $title );
$wgMaxTemplateDepth
Maximum recursion depth for templates within templates.
$wgMaxPPNodeCount
A complexity limit on template expansion: the maximum number of nodes visited by PPFrame::expand()
$wgMaxArticleSize
Maximum article size in kilobytes.
$wgMaxGeneratedPPNodeCount
A complexity limit on template expansion: the maximum number of elements generated by Preprocessor::p...
$wgEnableParserLimitReporting
Whether to include the NewPP limit report as a HTML comment.
$wgEnableImageWhitelist
If $wgAllowExternalImages is false, you can allow an on-wiki whitelist of regular expression fragment...
$wgCleanSignatures
If true, removes (by substituting) templates in signatures.
$wgRenderHashAppend
Append a configured value to the parser cache and the sitenotice key so that they can be kept separat...
$wgDisableLangConversion
Whether to enable language variant conversion.
$wgAllowSpecialInclusion
Allow special page inclusions such as {{Special:Allpages}}.
$wgAllowExternalImagesFrom
If the above is false, you can specify an exception here.
$wgInterwikiMagic
Treat language links as magic connectors, not inline links.
$wgAllowExternalImages
Whether to allow inline image pointing to other websites.
$wgEnableMagicLinks
Enable the magic links feature of automatically turning ISBN xxx, PMID xxx, RFC xxx into links.
$wgExternalLinkTarget
Set a default target for external links, e.g.
$wgExpensiveParserFunctionLimit
Maximum number of calls per parse to expensive parser functions such as PAGESINCATEGORY.
$wgDisableTitleConversion
Whether to enable language variant conversion for links.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Internationalisation code.
Set options of the Parser.
setAllowExternalImagesFrom( $x)
External images to allow.
disableTitleConversion( $x=true)
Whether title conversion should be disabled.
setIsSectionPreview( $x)
Parsing the page for a "preview" operation on a single section?
setIsPrintable( $x)
Parsing the printable version of the page?
getRedirectTarget()
Get the previously-set redirect target.
setAllowUnsafeRawHtml( $x)
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
static newCanonical(User $user=null, $lang=null)
Creates a "canonical" ParserOptions object.
getTidy()
Use tidy to cleanup output HTML?
setIsPreview( $x)
Parsing the page for a "preview" operation?
setDateFormat( $x)
Date format index.
static initDateFormat( $popt)
Lazy initializer for dateFormat.
getSpeculativeRevIdCallback()
Callback to generate a guess for {{REVISIONID}}.
enableLimitReport( $x=true)
Enable limit report in an HTML comment on output.
setTidy( $x)
Use tidy to cleanup output HTML?
optionToString( $value)
Convert an option to a string value.
callable null $onAccessCallback
Function to be called when an option is accessed.
getAllowExternalImages()
Allow all external images inline?
setNumberHeadings( $x)
Automatically number headings?
matches(ParserOptions $other)
Check if these options match that of another options set.
getMaxIncludeSize()
Maximum size of template expansions, in bytes.
setStubThreshold( $x)
Thumb size preferred by the user.
setTemplateCallback( $x)
Callback for template fetching; first argument to call_user_func().
setAllowExternalImages( $x)
Allow all external images inline?
getUserLangObj()
Get the user language used by the parser for this page and split the parser cache.
setMaxIncludeSize( $x)
Maximum size of template expansions, in bytes.
getEditSection()
Create "edit section" links?
static getCanonicalOverrides()
Get "canonical" non-default option values.
getEnableImageWhitelist()
Use the on-wiki external image whitelist?
getTargetLanguage()
Target language for the parse.
getAllowExternalImagesFrom()
External images to allow.
getCurrentRevisionCallback()
Callback for current revision fetching; first argument to call_user_func().
getIsSectionPreview()
Parsing the page for a "preview" operation on a single section?
getDisableContentConversion()
Whether content conversion should be disabled.
setInterfaceMessage( $x)
Parsing an interface message?
setTimestamp( $x)
Timestamp used for {{CURRENTDAY}} etc.
getMaxPPExpandDepth()
Maximum recursion depth in PPFrame::expand()
getExpensiveParserFunctionLimit()
Maximum number of calls per parse to expensive parser functions.
getAllowUnsafeRawHtml()
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
getNumberHeadings()
Automatically number headings?
setCurrentRevisionCallback( $x)
Callback for current revision fetching; first argument to call_user_func().
getIsPreview()
Parsing the page for a "preview" operation?
static getDefaults()
Get default option values.
setOptionLegacy( $name, $value)
Legacy implementation.
setMaxTemplateDepth( $x)
Maximum recursion depth for templates within templates.
setEnableImageWhitelist( $x)
Use the on-wiki external image whitelist?
getPreSaveTransform()
Transform wiki markup when saving the page?
setWrapOutputClass( $className)
CSS class to use to wrap output from Parser::parse()
User $mUser
Stored user object.
optionUsed( $optionName)
Called when an option is accessed.
setRedirectTarget( $title)
Set the redirect target.
getWrapOutputClass()
Class to use to wrap output from Parser::parse()
getIsPrintable()
Parsing the printable version of the page?
getStubThreshold()
Thumb size preferred by the user.
disableContentConversion( $x=true)
Whether content conversion should be disabled.
initialiseFromUser( $user, $lang)
Get user options.
getOption( $name)
Fetch an option, generically.
setThumbSize( $x)
Thumb size preferred by the user.
optionsHash( $forOptions, $title=null)
Generate a hash string with the values set on these ParserOptions for the keys given in the array.
$mExtraKey
Appended to the options hash.
setAllowSpecialInclusion( $x)
Allow inclusion of special pages?
setOption( $name, $value)
Set an option, generically.
getMaxTemplateDepth()
Maximum recursion depth for templates within templates.
getAllowSpecialInclusion()
Allow inclusion of special pages?
setTargetLanguage( $x)
Target language for the parse.
string null $mTimestamp
Timestamp used for {{CURRENTDAY}} etc.
getMagicRFCLinks()
Are magic RFC links enabled?
setupFakeRevision( $title, $content, $user)
Sets a hook to force that a page exists, and sets a current revision callback to return a revision wi...
getMagicPMIDLinks()
Are magic PMID links enabled?
static legacyOptions()
Returns the full array of options that would have been used by in 1.16.
static array $inCacheKey
Specify options that are included in the cache key.
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
static callback[] $lazyOptions
Lazy-loaded options.
registerWatcher( $callback)
Registers a callback for tracking which ParserOptions which are used.
getCleanSignatures()
Clean up signature texts?
addExtraKey( $key)
Extra key that should be present in the parser cache key.
setInterwikiMagic( $x)
Specify whether to extract interlanguage links.
static newFromAnon()
Get a ParserOptions object for an anonymous user.
setUserLang( $x)
Set the user language used by the parser for this page and split the parser cache.
static newFromUser( $user)
Get a ParserOptions object from a given user.
getUserLang()
Same as getUserLangObj() but returns a string instead.
getDateFormat()
Date format index.
setExternalLinkTarget( $x)
Target attribute for external links.
getMaxGeneratedPPNodeCount()
Maximum number of nodes generated by Preprocessor::preprocessToObj()
array $options
Current values for all options that are relevant for caching.
getRemoveComments()
Remove HTML comments.
setRemoveComments( $x)
Remove HTML comments.
Title null $redirectTarget
If the page being parsed is a redirect, this should hold the redirect target.
setMaxGeneratedPPNodeCount( $x)
Maximum number of nodes generated by Preprocessor::preprocessToObj()
getMaxPPNodeCount()
Maximum number of nodes touched by PPFrame::expand()
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
getEnableLimitReport()
Enable limit report in an HTML comment on output.
getExternalLinkTarget()
Target attribute for external links.
getMagicISBNLinks()
Are magic ISBN links enabled?
getThumbSize()
Thumb size preferred by the user.
getInterwikiMagic()
Whether to extract interlanguage links.
__construct( $user=null, $lang=null)
setEditSection( $x)
Create "edit section" links?
getTimestamp()
Timestamp used for {{CURRENTDAY}} etc.
getTemplateCallback()
Callback for template fetching; first argument to call_user_func().
setSpeculativeRevIdCallback( $x)
Callback to generate a guess for {{REVISIONID}}.
isSafeToCache()
Test whether these options are safe to cache.
getDisableTitleConversion()
Whether title conversion should be disabled.
getInterfaceMessage()
Parsing an interface message?
static allCacheVaryingOptions()
Return all option keys that vary the options hash.
setExpensiveParserFunctionLimit( $x)
Maximum number of calls per parse to expensive parser functions.
setPreSaveTransform( $x)
Transform wiki markup when saving the page?
setMaxPPNodeCount( $x)
Maximum number of nodes touched by PPFrame::expand()
static array null $defaults
Default values for all options that are relevant for caching.
setCleanSignatures( $x)
Clean up signature texts?
static isRealObject( $obj)
Returns a bool value whenever $obj is a stub object.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static getDefaultOption( $opt)
Get a given default option value.
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 and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
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 but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
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 and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
do that in ParserLimitReportFormat instead $parser
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
namespace and then decline to actually register it file or subcat img or subcat $title
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
$wgHooks['ArticleShow'][]
Allows to change the fields on the form that will be generated $name
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang