219 '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#s';
230 public function __construct( $text =
'', $languageLinks = [], $categoryLinks = [],
231 $unused =
false, $titletext =
''
233 $this->mText = $text;
234 $this->mLanguageLinks = $languageLinks;
235 $this->mCategories = $categoryLinks;
236 $this->mTitleText = $titletext;
273 'enableSectionEditLinks' =>
true,
275 'deduplicateStyles' =>
true,
277 $text = $this->mText;
279 Hooks::runWithoutAbort(
'ParserOutputPostCacheTransform', [ $this, &$text, &
$options ] );
281 if (
$options[
'unwrap'] !==
false ) {
282 $start = Html::openElement(
'div', [
283 'class' =>
'mw-parser-output'
285 $startLen = strlen( $start );
286 $end = Html::closeElement(
'div' );
287 $endPos = strrpos( $text, $end );
288 $endLen = strlen( $end );
290 if ( substr( $text, 0, $startLen ) === $start && $endPos !==
false
292 && preg_match(
'/^(?>\s*<!--.*?-->)*\s*$/s', substr( $text, $endPos + $endLen ) )
294 $text = substr( $text, $startLen );
295 $text = substr( $text, 0, $endPos - $startLen )
296 . substr( $text, $endPos - $startLen + $endLen );
300 if (
$options[
'enableSectionEditLinks'] ) {
301 $text = preg_replace_callback(
302 self::EDITSECTION_REGEX,
305 $editsectionPage = Title::newFromText( htmlspecialchars_decode( $m[1] ) );
306 $editsectionSection = htmlspecialchars_decode( $m[2] );
307 $editsectionContent = isset( $m[4] ) ? Sanitizer::decodeCharReferences( $m[3] ) :
null;
309 if ( !is_object( $editsectionPage ) ) {
310 throw new MWException(
"Bad parser output text." );
313 $skin =
$wgOut->getSkin();
314 return call_user_func_array(
315 [ $skin,
'doEditSectionLink' ],
316 [ $editsectionPage, $editsectionSection,
317 $editsectionContent,
$wgLang->getCode() ]
323 $text = preg_replace( self::EDITSECTION_REGEX,
'', $text );
327 $text = str_replace( [ Parser::TOC_START, Parser::TOC_END ],
'', $text );
329 $text = preg_replace(
330 '#' . preg_quote( Parser::TOC_START,
'#' ) .
'.*?' . preg_quote( Parser::TOC_END,
'#' ) .
'#s',
336 if (
$options[
'deduplicateStyles'] ) {
338 $text = preg_replace_callback(
339 '#<style\s+([^>]*data-mw-deduplicate\s*=[^>]*)>.*?</style>#s',
340 function ( $m ) use ( &$seen ) {
341 $attr = Sanitizer::decodeTagAttributes( $m[1] );
342 if ( !isset( $attr[
'data-mw-deduplicate'] ) ) {
346 $key = $attr[
'data-mw-deduplicate'];
347 if ( !isset( $seen[$key] ) ) {
356 return Html::element(
'link', [
357 'rel' =>
'mw-deduplicated-inline-style',
373 $this->mSpeculativeRevId = $id;
381 return $this->mSpeculativeRevId;
385 return $this->mLanguageLinks;
389 return $this->mInterwikiLinks;
393 return array_keys( $this->mCategories );
397 return $this->mCategories;
405 return $this->mIndicators;
409 return $this->mTitleText;
413 return $this->mSections;
425 return $this->mLinks;
429 return $this->mTemplates;
433 return $this->mTemplateIds;
437 return $this->mImages;
441 return $this->mFileSearchOptions;
445 return $this->mExternalLinks;
449 return $this->mNoGallery;
453 return $this->mHeadItems;
457 return $this->mModules;
461 return $this->mModuleScripts;
465 return $this->mModuleStyles;
473 return $this->mJsConfigVars;
477 return (array)$this->mOutputHooks;
481 return array_keys( $this->mWarnings );
485 return $this->mIndexPolicy;
489 return $this->mTOCHTML;
496 return $this->mTimestamp;
500 return $this->mLimitReportData;
504 return $this->mLimitReportJSData;
516 return $this->mEnableOOUI;
520 return wfSetVar( $this->mText, $text );
524 return wfSetVar( $this->mLanguageLinks, $ll );
528 return wfSetVar( $this->mCategories, $cl );
536 return wfSetVar( $this->mSections, $toc );
548 return wfSetVar( $this->mIndexPolicy, $policy );
552 return wfSetVar( $this->mTOCHTML, $tochtml );
556 return wfSetVar( $this->mTimestamp, $timestamp );
568 $this->mCategories[$c] =
$sort;
577 $this->mIndicators[$id] = $content;
588 $this->mEnableOOUI = $enable;
592 $this->mLanguageLinks[] =
$t;
596 $this->mWarnings[
$s] = 1;
600 $this->mOutputHooks[] = [ $hook, $data ];
604 $this->mNewSection = (bool)
$value;
607 $this->mHideNewSection = (bool)
$value;
610 return (
bool)$this->mHideNewSection;
613 return (
bool)$this->mNewSection;
624 return (
bool)preg_match(
'/^' .
626 ( substr( $internal, 0, 2 ) ===
'//' ?
'(?:https?:)?' :
'' ) .
627 preg_quote( $internal,
'/' ) .
628 #
check for query/path/anchor or end of
link in each
case
635 # We don't register links pointing to our own server, unless... :-)
638 # Replace unnecessary URL escape codes with the referenced character
639 # This prevents spammers from hiding links from the filters
640 $url = Parser::normalizeLinkUrl( $url );
642 $registerExternalLink =
true;
644 $registerExternalLink = !self::isLinkInternal(
$wgServer, $url );
646 if ( $registerExternalLink ) {
647 $this->mExternalLinks[$url] = 1;
658 if ( $title->isExternal() ) {
663 $ns = $title->getNamespace();
664 $dbk = $title->getDBkey();
672 } elseif ( $dbk ===
'' ) {
676 if ( !isset( $this->mLinks[$ns] ) ) {
677 $this->mLinks[$ns] = [];
679 if ( is_null( $id ) ) {
680 $id = $title->getArticleID();
682 $this->mLinks[$ns][$dbk] = $id;
692 public function addImage( $name, $timestamp =
null, $sha1 =
null ) {
693 $this->mImages[
$name] = 1;
694 if ( $timestamp !==
null && $sha1 !==
null ) {
695 $this->mFileSearchOptions[
$name] = [
'time' => $timestamp,
'sha1' => $sha1 ];
707 $ns = $title->getNamespace();
708 $dbk = $title->getDBkey();
709 if ( !isset( $this->mTemplates[$ns] ) ) {
710 $this->mTemplates[$ns] = [];
712 $this->mTemplates[$ns][$dbk] = $page_id;
713 if ( !isset( $this->mTemplateIds[$ns] ) ) {
714 $this->mTemplateIds[$ns] = [];
716 $this->mTemplateIds[$ns][$dbk] = $rev_id;
724 if ( !$title->isExternal() ) {
725 throw new MWException(
'Non-interwiki link passed, internal parser error.' );
727 $prefix = $title->getInterwiki();
728 if ( !isset( $this->mInterwikiLinks[$prefix] ) ) {
729 $this->mInterwikiLinks[$prefix] = [];
731 $this->mInterwikiLinks[$prefix][$title->getDBkey()] = 1;
742 if ( $tag !==
false ) {
750 $this->mModules = array_merge( $this->mModules, (array)
$modules );
754 $this->mModuleScripts = array_merge( $this->mModuleScripts, (array)
$modules );
758 $this->mModuleStyles = array_merge( $this->mModuleStyles, (array)
$modules );
769 if ( is_array(
$keys ) ) {
771 $this->mJsConfigVars[$key] =
$value;
790 $this->mHeadItems = array_merge( $this->mHeadItems,
$out->getHeadItemsArray() );
791 $this->mPreventClickjacking = $this->mPreventClickjacking ||
$out->getPreventClickjacking();
811 if ( $title->isSpecialPage() ) {
812 wfDebug( __METHOD__ .
": Not adding tracking category $msg to special page!\n" );
819 ->inContentLanguage()
822 # Allow tracking categories to be disabled by setting them to "-"
823 if ( $cat ===
'-' ) {
827 $containerCategory = Title::makeTitleSafe(
NS_CATEGORY, $cat );
828 if ( $containerCategory ) {
829 $this->
addCategory( $containerCategory->getDBkey(), $this->getProperty(
'defaultsort' ) ?:
'' );
832 wfDebug( __METHOD__ .
": [[MediaWiki:$msg]] is not a valid title!\n" );
874 $this->mFlags[$flag] =
true;
878 return isset( $this->mFlags[$flag] );
955 return isset( $this->mProperties[$name] ) ? $this->mProperties[
$name] :
false;
959 unset( $this->mProperties[$name] );
963 if ( !isset( $this->mProperties ) ) {
964 $this->mProperties = [];
966 return $this->mProperties;
975 if ( !isset( $this->mAccessedOptions ) ) {
978 return array_keys( $this->mAccessedOptions );
994 $this->mAccessedOptions[$option] =
true;
1039 unset( $this->mExtensionData[$key] );
1041 $this->mExtensionData[$key] =
$value;
1057 if ( isset( $this->mExtensionData[$key] ) ) {
1058 return $this->mExtensionData[$key];
1066 if ( !$clock || $clock ===
'wall' ) {
1067 $ret[
'wall'] = microtime(
true );
1069 if ( !$clock || $clock ===
'cpu' ) {
1072 $ret[
'cpu'] = $ru[
'ru_utime.tv_sec'] + $ru[
'ru_utime.tv_usec'] / 1e6;
1073 $ret[
'cpu'] += $ru[
'ru_stime.tv_sec'] + $ru[
'ru_stime.tv_usec'] / 1e6;
1084 $this->mParseStartTime = self::getTimes();
1099 if ( !isset( $this->mParseStartTime[$clock] ) ) {
1103 $end = self::getTimes( $clock );
1104 return $end[$clock] - $this->mParseStartTime[$clock];
1127 $this->mLimitReportData[$key] =
$value;
1129 if ( is_array(
$value ) ) {
1130 if ( array_keys(
$value ) === [ 0, 1 ]
1131 && is_numeric(
$value[0] )
1132 && is_numeric(
$value[1] )
1134 $data = [
'value' =>
$value[0],
'limit' =>
$value[1] ];
1142 if ( strpos( $key,
'-' ) ) {
1143 list( $ns, $name ) = explode(
'-', $key, 2 );
1144 $this->mLimitReportJSData[$ns][
$name] = $data;
1146 $this->mLimitReportJSData[$key] = $data;
1174 return wfSetVar( $this->mPreventClickjacking, $flag );
1184 $this->mMaxAdaptiveExpiry = min( $ttl, $this->mMaxAdaptiveExpiry );
1194 if ( is_infinite( $this->mMaxAdaptiveExpiry ) ) {
1199 if ( is_float( $runtime ) ) {
1200 $slope = ( self::SLOW_AR_TTL - self::FAST_AR_TTL )
1201 / ( self::PARSE_SLOW_SEC - self::PARSE_FAST_SEC );
1203 $point = self::SLOW_AR_TTL - self::PARSE_SLOW_SEC * $slope;
1206 max( $slope * $runtime + $point, self::MIN_AR_TTL ),
1207 $this->mMaxAdaptiveExpiry
1215 array_keys( get_object_vars( $this ) ),
1216 [
'mParseStartTime' ]
Apache License January http
$wgRegisterInternalExternals
By default MediaWiki does not register links pointing to same server in externallinks dataset,...
$wgParserCacheExpireTime
The expiry time for the parser cache, in seconds.
$wgServer
URL of the server.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfGetRusage()
Get system resource usage of current request context.
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.
Parser cache specific expiry check.
updateCacheExpiry( $seconds)
Sets the number of seconds after which this object should expire.
getCacheExpiry()
Returns the number of seconds after which this object should expire.
This class should be covered by a general architecture document which does not exist as of January 20...
addOutputPageMetadata(OutputPage $out)
Copy items from the OutputPage object into this one.
static getTimes( $clock=null)
getSpeculativeRevIdUsed()
int null $mSpeculativeRevId
Assumed rev ID for {{REVISIONID}} if no revision is set.
addOutputHook( $hook, $data=false)
const SUPPORTS_UNWRAP_TRANSFORM
setDisplayTitle( $text)
Override the title to be used for display.
addJsConfigVars( $keys, $value=null)
Add one or more variables to be set in mw.config in JavaScript.
setIndicator( $id, $content)
addModuleScripts( $modules)
addInterwikiLink( $title)
setEditSectionTokens( $t)
setEnableOOUI( $enable=false)
Enables OOUI, if true, in any OutputPage instance this ParserOutput object is added to.
getDisplayTitle()
Get the title to be used for display.
addTrackingCategory( $msg, $title)
Add a tracking category, getting the title from a system message, or print a debug message if the tit...
finalizeAdaptiveCacheExpiry()
Call this when parsing is done to lower the TTL based on low parse times.
addTemplate( $title, $page_id, $rev_id)
Register a template dependency for this output.
addLink(Title $title, $id=null)
Record a local or interwiki inline link for saving in future link tables.
resetParseStartTime()
Resets the parse start timestamps for future calls to getTimeSinceStart()
preventClickjacking( $flag=null)
Get or set the prevent-clickjacking flag.
setProperty( $name, $value)
Set a property to be stored in the page_props database table.
recordOption( $option)
Tags a parser option for use in the cache key for this parser output.
addHeadItem( $section, $tag=false)
Add some text to the "<head>".
hasDynamicContent()
Check whether the cache TTL was lowered due to dynamic content.
getExtensionData( $key)
Gets extensions data previously attached to this ParserOutput using setExtensionData().
getText( $options=[])
Get the output HTML.
getTimeSinceStart( $clock)
Returns the time since resetParseStartTime() was last called.
getRawText()
Get the cacheable text with <mw:editsection> markers still in it.
addImage( $name, $timestamp=null, $sha1=null)
Register a file dependency for this output.
updateRuntimeAdaptiveExpiry( $ttl)
Lower the runtime adaptive TTL to at most this value.
getUsedOptions()
Returns the options from its ParserOptions which have been taken into account to produce this output ...
const SUPPORTS_STATELESS_TRANSFORMS
Feature flags to indicate to extensions that MediaWiki core supports and uses getText() stateless tra...
setLimitReportData( $key, $value)
Sets parser limit report data for a key.
setExtensionData( $key, $value)
Attaches arbitrary data to this ParserObject.
setTimestamp( $timestamp)
setSpeculativeRevIdUsed( $id)
__construct( $text='', $languageLinks=[], $categoryLinks=[], $unused=false, $titletext='')
static isLinkInternal( $internal, $url)
Checks, if a url is pointing to the own server.
array $mLimitReportJSData
Parser limit report data for JSON.
addModuleStyles( $modules)
setFlag( $flag)
Fairly generic flag setter thingy.
int $mMaxAdaptiveExpiry
Upper bound of expiry based on parse duration.
Represents a title within MediaWiki.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
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
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
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template to be included in the link
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Allows to change the fields on the form that will be generated $name
in this case you re responsible for computing and outputting the entire conflict i the difference between revisions and your text headers and sections and Diff or overridable Default is either copyrightwarning or copyrightwarning2 overridable Default is editpage tos summary such as anonymity and the real check
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
This document describes the XML format used to represent information about external sites known to a MediaWiki installation This information about external sites is used to allow inter wiki links
in the order they appear.