MediaWiki  REL1_19
Parser Class Reference

PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for making links), and provides a one-way transformation of that wiki markup it into XHTML output / markup (which in turn the browser understands, and can display). More...

Inheritance diagram for Parser:

List of all members.

Public Member Functions

 __construct ($conf=array())
 Constructor.
 __destruct ()
 Reduce memory usage to reduce the impact of circular references.
 addTrackingCategory ($msg)
 Add a tracking category, getting the title from a system message, or print a debug message if the title is invalid.
 areSubpagesAllowed ()
 Return true if subpage links should be expanded on this page.
 armorLinks ($text)
 Insert a NOPARSE hacky thing into any inline links in a chunk that's going to go through further parsing steps before inline URL expansion.
 attributeStripCallback (&$text, $frame=false)
 Callback from the Sanitizer for expanding items found in HTML attribute values, so they can be safely tested and escaped.
 cleanSig ($text, $parsing=false)
 Clean up signature text.
 clearState ()
 Clear Parser state.
 clearTagHooks ()
 Remove all tag hooks.
 disableCache ()
 Set a flag in the output object indicating that the content is dynamic and shouldn't be cached.
 doAllQuotes ($text)
 Replace single quotes with HTML markup.
 doDoubleUnderscore ($text)
 Strip double-underscore items like __NOGALLERY__ and __NOTOC__ Fills $this->mDoubleUnderscores, returns the modified text.
 doHeadings ($text)
 Parse headers and return html.
 doQuotes ($text)
 Helper function for doAllQuotes()
 doTableStuff ($text)
 parse the wiki syntax used to render tables
 extensionSubstitution ($params, $frame)
 Return the text to be used for a given extension tag.
 fetchFile ($title, $options=array())
 Fetch a file and its title and register a reference to it.
 fetchFileAndTitle ($title, $options=array())
 Fetch a file and its title and register a reference to it.
 fetchScaryTemplateMaybeFromCache ($url)
 fetchTemplate ($title)
 Fetch the unparsed text of a template and register a reference to it.
 fetchTemplateAndTitle ($title)
 Fetch the unparsed text of a template and register a reference to it.
 findColonNoLinks ($str, &$before, &$after)
 Split up a string on ':', ignoring any occurences inside tags to prevent illegal overlapping.
 firstCallInit ()
 Do various kinds of initialisation on the first call of the parser.
 formatHeadings ($text, $origText, $isMain=true)
 This function accomplishes several tasks: 1) Auto-number headings if that option is enabled 2) Add an [edit] link to sections for users who have enabled the option and can edit the page 3) Add a Table of contents on the top for users who have enabled the option 4) Auto-anchor headings.
 getConverterLanguage ()
 Get the language object for language conversion.
 getCustomDefaultSort ()
 Accessor for $mDefaultSort Unlike getDefaultSort(), will return false if none is set.
 getDefaultSort ()
 Accessor for $mDefaultSort Will use the empty string if none is set.
 getExternalLinkAttribs ($url=false)
 Get an associative array of additional HTML attributes appropriate for a particular external link.
 getFunctionHooks ()
 Get all registered function hook identifiers.
 getFunctionLang ()
 Get a language object for use in parser functions such as {{FORMATNUM:}}.
 getImageParams ($handler)
 getOptions ()
 Get the ParserOptions object.
 getOutput ()
 Get the ParserOutput object.
 getPreloadText ($text, Title $title, ParserOptions $options)
 Process the wikitext for the ?preload= feature.
 getPreprocessor ()
 Get a preprocessor object.
 getRevisionId ()
 Get the ID of the revision we are parsing.
 getRevisionTimestamp ()
 Get the timestamp associated with the current revision, adjusted for the default server-local timestamp.
 getRevisionUser ()
 Get the name of the user that edited the last revision.
 getSection ($text, $section, $deftext='')
 This function returns the text of a section, specified by a number ($section).
 getStripList ()
 Get a list of strippable XML-like elements.
 getTags ()
 Accessor.
 getTargetLanguage ()
 Get the target language for the content being parsed.
 getTemplateDom ($title)
 Get the semi-parsed DOM representation of a template with a given title, and its redirect destination title.
 getTitle ()
 Accessor for the Title object.
 getUser ()
 Get a User object either from $this->mUser, if set, or from the ParserOptions object otherwise.
 getUserSig (&$user, $nickname=false, $fancySig=null)
 Fetch the user's signature text, if any, and normalize to validated, ready-to-insert wikitext.
 guessLegacySectionNameFromWikiText ($text)
 Same as guessSectionNameFromWikiText(), but produces legacy anchors instead.
 guessSectionNameFromWikiText ($text)
 Try to guess the section anchor name based on a wikitext fragment presumably extracted from a heading, for example "Header" from "== Header ==".
 incrementExpensiveFunctionCount ()
 Increment the expensive function count.
 incrementIncludeSize ($type, $size)
 Increment an include size counter.
 insertStripItem ($text)
 Add an item to the strip state Returns the unique tag which must be inserted into the stripped text The tag will be replaced with the original text in unstrip()
 internalParse ($text, $isMain=true, $frame=false)
 Helper function for parse() that transforms wiki markup into HTML.
 interwikiTransclude ($title, $action)
 Transclude an interwiki link.
 isValidHalfParsedText ($data)
 Returns true if the given array, presumed to be generated by serializeHalfParsedText(), is compatible with the current version of the parser.
 killMarkers ($text)
 Remove any strip markers found in the given text.
 limitationWarn ($limitationType, $current=null, $max=null)
 Warn the user when a parser limitation is reached Will warn at most once the user per limitation type.
 magicLinkCallback ($m)
 makeFreeExternalLink ($url)
 Make a free external link, given a user-supplied URL.
 makeImage ($title, $options, $holders=false)
 Parse image options text and use it to make an image.
 makeKnownLinkHolder ($nt, $text= '', $query=array(), $trail= '', $prefix= '')
 Render a forced-blue link inline; protect against double expansion of URLs if we're in a mode that prepends full URL prefixes to internal links.
 markerSkipCallback ($s, $callback)
 Call a callback function on all regions of the given text that are not inside strip markers, and replace those regions with the return value of the callback.
 maybeMakeExternalImage ($url)
 make an image if it's allowed, either through the global option, through the exception, or through the on-wiki whitelist
 nextLinkID ()
 Options ($x=null)
 Accessor/mutator for the ParserOptions object.
 OutputType ($x=null)
 Accessor/mutator for the output type.
 parse ($text, Title $title, ParserOptions $options, $linestart=true, $clearState=true, $revid=null)
 Convert wikitext to HTML Do not call this function recursively.
 preprocess ($text, Title $title, ParserOptions $options, $revid=null)
 Expand templates and variables in the text, producing valid, static wikitext.
 preSaveTransform ($text, Title $title, User $user, ParserOptions $options, $clearState=true)
 Transform wiki markup when saving a page by doing
->
conversion, substitting signatures, {{subst:}} templates, etc.
 pstPass2 ($text, $user)
 Pre-save transform helper function.
 recursivePreprocess ($text, $frame=false)
 Recursive parser entry point that can be called from an extension tag hook.
 recursiveTagParse ($text, $frame=false)
 Recursive parser entry point that can be called from an extension tag hook.
 renderImageGallery ($text, $params)
 Renders an image gallery from a text with one line per image.
 replaceInternalLinks ($s)
 Process [[ ]] wikilinks.
 replaceInternalLinks2 (&$s)
 Process [[ ]] wikilinks (RIL)
 replaceLinkHolders (&$text, $options=0)
 replaceLinkHoldersText ($text)
 Replace link placeholders with plain text of links (not HTML-formatted).
 replaceSection ($oldtext, $section, $text)
 This function returns $oldtext after the content of the section specified by $section has been replaced with $text.
 replaceTransparentTags ($text)
 Replace transparent tags in $text with the values given by the callbacks.
 serializeHalfParsedText ($text)
 Save the parser state required to convert the given half-parsed text to HTML.
 setDefaultSort ($sort)
 Mutator for $mDefaultSort.
 setFunctionHook ($id, $callback, $flags=0)
 Create a function, e.g.
 setFunctionTagHook ($tag, $callback, $flags)
 Create a tag function, e.g.
 setHook ($tag, $callback)
 Create an HTML-style tag, e.g.
 setLinkID ($id)
 setOutputType ($ot)
 Set the output type.
 setTitle ($t)
 Set the context title.
 setTransparentTagHook ($tag, $callback)
 As setHook(), but letting the contents be parsed.
 setUser ($user)
 Set the current user.
 startExternalParse (Title $title=null, ParserOptions $options, $outputType, $clearState=true)
 Set up some variables which are usually set up in parse() so that an external function can call some class members with confidence.
 stripSectionName ($text)
 Strips a text string of wikitext for use in a section anchor.
 testPreprocess ($text, Title $title, ParserOptions $options)
 testPst ($text, Title $title, ParserOptions $options)
 testSrvus ($text, Title $title, ParserOptions $options, $outputType=self::OT_HTML)
 strip/replaceVariables/unstrip for preprocessor regression testing
 Title ($x=null)
 Accessor/mutator for the Title object.
 transformMsg ($text, $options, $title=null)
 Wrapper for preprocess()
 uniqPrefix ()
 Accessor for mUniqPrefix.
 unserializeHalfParsedText ($data)
 Load the parser state given in the $data array, which is assumed to have been generated by serializeHalfParsedText().
 validateSig ($text)
 Check that the user's signature contains no bad XML.

Static Public Member Functions

static cleanSigInSig ($text)
 Strip ~~~, ~~~~ and ~~~~~ out of signatures.
static createAssocArgs ($args)
 Clean up argument array - refactored in 1.9 so parserfunctions can use it, too.
static extractTagsAndParams ($elements, $text, &$matches, $uniq_prefix= '')
 Replaces all occurrences of HTML-style comments and the given tags in the text with a random marker and returns the next text.
static getRandomString ()
 Get a random string.
static replaceUnusualEscapes ($url)
 Replace unusual URL escape codes with their equivalent characters.
static splitWhitespace ($s)
 Return a three-element array: leading whitespace, string contents, trailing whitespace.
static statelessFetchTemplate ($title, $parser=false)
 Static function to get a template Can be overridden via ParserOptions::setTemplateCallback().

Public Attributes

 $mArgStack
 $mAutonumber
 $mConf
 $mDefaultSort
 $mDefaultStripList = array()
 $mDoubleUnderscores
 $mDTopen
 $mExpensiveFunctionCount
 $mExtLinkBracketedRegex
 $mFirstCall = true
 $mForceTocPosition
 $mFunctionHooks = array()
 $mFunctionSynonyms = array( 0 => array(), 1 => array() )
 $mFunctionTagHooks = array()
 $mHeadings
 $mImageParams = array()
 $mImageParamsMagicArray = array()
 $mIncludeCount
 $mIncludeSizes
 $mInPre
 $mLastSection
 $mLinkHolders
 $mLinkID
 $mMarkerIndex = 0
 $mOptions
 $mOutput
 $mOutputType
 $mPPNodeCount
 $mPreprocessor
 $mRevIdForTs
 $mRevisionId
 $mRevisionObject
 $mRevisionTimestamp
 $mRevisionUser
 $mShowToc
 $mStripList = array()
 $mStripState
 $mSubstWords
 $mTagHooks = array()
 $mTitle
 $mTplDomCache
 $mTplExpandCache
 $mTplRedirCache
 $mTransparentTagHooks = array()
 $mUniqPrefix
 $mUrlProtocols
 $mUser
 $mVarCache = array()
 $mVariables
 $ot
const COLON_STATE_CLOSETAG = 3
const COLON_STATE_COMMENT = 5
const COLON_STATE_COMMENTDASH = 6
const COLON_STATE_COMMENTDASHDASH = 7
const COLON_STATE_TAG = 1
const COLON_STATE_TAGSLASH = 4
const COLON_STATE_TAGSTART = 2
const COLON_STATE_TEXT = 0
const EXT_IMAGE_REGEX
const EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F\p{Zs}]'
const HALF_PARSED_VERSION = 2
 Update this version number when the output of serialiseHalfParsedText() changes in an incompatible way.
const MARKER_SUFFIX = "-QINU\x7f"
const OT_HTML = 1
const OT_MSG = 3
const OT_PLAIN = 4
const OT_PREPROCESS = 3
const OT_WIKI = 2
const PTD_FOR_INCLUSION = 1
const SFH_NO_HASH = 1
const SFH_OBJECT_ARGS = 2
const VERSION = '1.6.4'
 Update this version number when the ParserOutput format changes in an incompatible way, so the parser cache can automatically discard old data.

Protected Member Functions

 getRevisionObject ()
 Get the revision object for $this->mRevisionId.
 stripAltText ($caption, $holders)

Private Member Functions

 argSubstitution ($piece, $frame)
 Triple brace replacement -- used for template arguments.
 braceSubstitution ($piece, $frame)
 Return the text of a template, after recursively replacing any variables or templates within the template.
 closeList ($char)
 TODO: document.
 closeParagraph ()
 #@+ Used by doBlockLevels()
 doBlockLevels ($text, $linestart)
 #@-
 doMagicLinks ($text)
 Replace special strings like "ISBN xxx" and "RFC xxx" with magic external links.
 extractSections ($text, $section, $mode, $newText='')
 Break wikitext input into sections, and either pull or replace some particular section's text.
 getCommon ($st1, $st2)
 getCommon() returns the length of the longest common substring of both arguments, starting at the beginning of both.
 getVariableValue ($index, $frame=false)
 Return value of a magic variable (like PAGENAME)
 initialiseVariables ()
 initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers
 maybeDoSubpageLink ($target, &$text)
 Handle link to subpage if necessary.
 nextItem ($char)
 TODO: document.
 openList ($char)
 These next three functions open, continue, and close the list element appropriate to the prefix character passed into them.
 preprocessToDom ($text, $flags=0)
 Preprocess some wikitext and return the document tree.
 replaceExternalLinks ($text)
 Replace external links (REL)
 replaceVariables ($text, $frame=false, $argsOnly=false)
 Replace magic variables, templates, and template arguments with the appropriate text.
 startParse (Title $title=null, ParserOptions $options, $outputType, $clearState=true)

Static Private Member Functions

static replaceUnusualEscapesCallback ($matches)
 Callback function used in replaceUnusualEscapes().

Detailed Description

PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for making links), and provides a one-way transformation of that wiki markup it into XHTML output / markup (which in turn the browser understands, and can display).

 There are five main entry points into the Parser class:
 parse()
     produces HTML output
 preSaveTransform().
     produces altered wiki markup.
 preprocess()
     removes HTML comments and expands templates
 cleanSig() / cleanSigInSig()
     Cleans a signature before saving it to preferences
 getSection()
     Return the content of a section from an article for section editing
 replaceSection()
     Replaces a section by number inside an article
 getPreloadText()
     Removes <noinclude> sections, and <includeonly> tags.
 Globals used:
    object: $wgContLang
 NOT $wgUser or $wgTitle or $wgRequest or $wgLang. Keep them away!
 settings:
  $wgUseDynamicDates*, $wgInterwikiMagic*,
  $wgNamespacesWithSubpages, $wgAllowExternalImages*,
  $wgLocaltimezone, $wgAllowSpecialInclusion*,
  $wgMaxArticleSize*
  * only within ParserOptions
 

Definition at line 50 of file Parser.php.


Constructor & Destructor Documentation

Parser::__construct ( conf = array())

Constructor.

Parameters:
$confarray

Reimplemented in Parser_LinkHooks.

Definition at line 188 of file Parser.php.

References wfDebug(), and wfUrlProtocols().

Here is the call graph for this function:

Reduce memory usage to reduce the impact of circular references.

Definition at line 213 of file Parser.php.


Member Function Documentation

Add a tracking category, getting the title from a system message, or print a debug message if the title is invalid.

Parameters:
$msgString: message key
Returns:
Boolean: whether the addition was successful

Definition at line 3890 of file Parser.php.

References Title\makeTitleSafe(), wfDebug(), and wfMessage().

Here is the call graph for this function:

Return true if subpage links should be expanded on this page.

Returns:
Boolean

Definition at line 2067 of file Parser.php.

References MWNamespace\hasSubpages().

Referenced by replaceInternalLinks2(), and Parser_LinkHooks\replaceInternalLinksCallback().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::argSubstitution ( piece,
frame 
) [private]

Triple brace replacement -- used for template arguments.

Parameters:
$peicearray
$framePPFrame
Returns:
array

Definition at line 3663 of file Parser.php.

References wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

Parser::armorLinks ( text)

Insert a NOPARSE hacky thing into any inline links in a chunk that's going to go through further parsing steps before inline URL expansion.

Not needed quite as much as it used to be since free links are a bit more sensible these days. But bracketed links are still an issue.

Parameters:
$textString: more-or-less HTML
Returns:
String: less-or-more HTML with NOPARSE bits

Definition at line 2058 of file Parser.php.

References wfUrlProtocols().

Referenced by replaceInternalLinks2().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::attributeStripCallback ( &$  text,
frame = false 
)

Callback from the Sanitizer for expanding items found in HTML attribute values, so they can be safely tested and escaped.

Parameters:
$textString
$framePPFrame
Returns:
String

Definition at line 5185 of file Parser.php.

Parser::braceSubstitution ( piece,
frame 
) [private]

Return the text of a template, after recursively replacing any variables or templates within the template.

Parameters:
$pieceArray: the parts of the template $piece['title']: the title, i.e. the part before the | $piece['parts']: the parameter array $piece['lineStart']: whether the brace was at the start of a line
$framePPFrame The current frame, contains template arguments
Returns:
String: the text of the template

Definition at line 3058 of file Parser.php.

References $limit, $result, $title, $wgContLang, $wgNonincludableNamespaces, SpecialPageFactory\capturePath(), expand, MagicWord\get(), MagicWord\getCacheTTL(), Title\newFromText(), PPFrame\RECOVER_ORIG, RequestContext\setTitle(), PPFrame\STRIP_COMMENTS, wfDebug(), wfEscapeWikiText(), wfMsgForContent(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

Parser::cleanSig ( text,
parsing = false 
)

Clean up signature text.

1) Strip ~~~, ~~~~ and ~~~~~ out of signatures

See also:
cleanSigInSig 2) Substitute all transclusions
Parameters:
$textString
$parsingbool Whether we're cleaning (preferences save) or parsing
Returns:
String: signature text

Definition at line 4487 of file Parser.php.

References $wgTitle, and MagicWord\get().

Here is the call graph for this function:

static Parser::cleanSigInSig ( text) [static]

Strip ~~~, ~~~~ and ~~~~~ out of signatures.

Parameters:
$textString
Returns:
String: signature text with /~{3,5}/ removed

Definition at line 4523 of file Parser.php.

Referenced by Preferences\cleanSignature(), and ExtraParserTest\testCleanSigInSig().

Here is the caller graph for this function:

Clear Parser state.

Access:
private

Definition at line 246 of file Parser.php.

References firstCallInit(), getRandomString(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Here is the call graph for this function:

Remove all tag hooks.

Definition at line 4653 of file Parser.php.

Parser::closeList ( char) [private]

TODO: document.

Parameters:
$charString
Returns:
string

Definition at line 2186 of file Parser.php.

Parser::closeParagraph ( ) [private]

#@+ Used by doBlockLevels()

Returns:
string

Definition at line 2090 of file Parser.php.

References $result.

static Parser::createAssocArgs ( args) [static]

Clean up argument array - refactored in 1.9 so parserfunctions can use it, too.

Parameters:
$argsarray
Returns:
array

Definition at line 2999 of file Parser.php.

Set a flag in the output object indicating that the content is dynamic and shouldn't be cached.

Definition at line 5167 of file Parser.php.

References wfDebug().

Here is the call graph for this function:

Parser::doAllQuotes ( text)

Replace single quotes with HTML markup.

Access:
private
Parameters:
$textstring
Returns:
string the altered text

Definition at line 1298 of file Parser.php.

References $lines, doQuotes(), StringUtils\explode(), wfProfileIn(), and wfProfileOut().

Referenced by internalParse().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::doBlockLevels ( text,
linestart 
) [private]

#@-

Make lists from lines starting with ':', '*', '#', etc. (DBL)

Parameters:
$textString
$linestartBoolean: whether or not this is at the start of a line.
Returns:
string the lists rendered as HTML

Definition at line 2213 of file Parser.php.

References $output, $t, StringUtils\explode(), wfProfileIn(), and wfProfileOut().

Referenced by parse().

Here is the call graph for this function:

Here is the caller graph for this function:

Strip double-underscore items like __NOGALLERY__ and __NOTOC__ Fills $this->mDoubleUnderscores, returns the modified text.

Parameters:
$textstring
Returns:
string

Definition at line 3832 of file Parser.php.

References MagicWord\get(), MagicWord\getDoubleUnderscoreArray(), wfProfileIn(), and wfProfileOut().

Referenced by internalParse().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::doHeadings ( text)

Parse headers and return html.

Access:
private
Parameters:
$textstring
Returns:
string

Definition at line 1279 of file Parser.php.

References wfProfileIn(), and wfProfileOut().

Referenced by internalParse().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::doMagicLinks ( text) [private]

Replace special strings like "ISBN xxx" and "RFC xxx" with magic external links.

DML

Parameters:
$textstring
Returns:
string

Definition at line 1146 of file Parser.php.

References EXT_LINK_URL_CLASS, wfProfileIn(), wfProfileOut(), and wfUrlProtocolsWithoutProtRel().

Referenced by internalParse().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::doQuotes ( text)

Helper function for doAllQuotes()

Parameters:
$textstring
Returns:
string

Definition at line 1317 of file Parser.php.

References $output.

Referenced by doAllQuotes().

Here is the caller graph for this function:

Parser::doTableStuff ( text)

parse the wiki syntax used to render tables

Access:
private

Definition at line 873 of file Parser.php.

References $lines, $matches, $out, StringUtils\explode(), StringUtils\explodeMarkup(), Sanitizer\fixTagAttributes(), wfProfileIn(), and wfProfileOut().

Referenced by internalParse().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::extensionSubstitution ( params,
frame 
)

Return the text to be used for a given extension tag.

This is the ghost of strip().

Parameters:
$paramsAssociative array of parameters: name PPNode for the tag name attr PPNode for unparsed text where tag attributes are thought to be attributes Optional associative array of parsed attributes inner Contents of extension element noClose Original text did not have a close tag
$framePPFrame
Returns:
string

Definition at line 3718 of file Parser.php.

References $output, and Sanitizer\decodeTagAttributes().

Here is the call graph for this function:

Parser::extractSections ( text,
section,
mode,
newText = '' 
) [private]

Break wikitext input into sections, and either pull or replace some particular section's text.

External callers should use the getSection and replaceSection methods.

Parameters:
$textString: Page wikitext
$sectionString: a section identifier string of the form: <flag1> - <flag2> - ... - <section number>="">

Currently the only recognised flag is "T", which means the target section number was derived during a template inclusion parse, in other words this is a template section edit link. If no flags are given, it was an ordinary section edit link. This flag is required to avoid a section numbering mismatch when a section is enclosed by <includeonly> (bug 6563).

The section number 0 pulls the text before the first heading; other numbers will pull the given section along with its lower-level subsections. If the section is not found, $mode=get will return $newtext, and $mode=replace will return $text.

Section 0 is always considered to exist, even if it only contains the empty string. If $text is the empty string and section 0 is replaced, $newText is returned.

Parameters:
$modeString: one of "get" or "replace"
$newTextString: replacement text for section data.
Returns:
String: for "get", the extracted section text. for "replace", the whole page with the section replaced.

Definition at line 5258 of file Parser.php.

References $section, $wgTitle, and PPFrame\RECOVER_ORIG.

static Parser::extractTagsAndParams ( elements,
text,
&$  matches,
uniq_prefix = '' 
) [static]

Replaces all occurrences of HTML-style comments and the given tags in the text with a random marker and returns the next text.

The output parameter $matches will be an associative array filled with data in the form: 'UNIQ-xxxxx' => array( 'element', 'tag content', array( 'param' => 'x' ), '<element param="x">tag content</element>' ) )

Parameters:
$elementsarray list of element names. Comments are always extracted.
$textstring Source text string.
$matchesarray Out parameter, Array: extracted tags
$uniq_prefixstring
Returns:
String: stripped text

Definition at line 781 of file Parser.php.

References $matches, $n, Sanitizer\decodeTagAttributes(), and MARKER_SUFFIX.

Here is the call graph for this function:

Parser::fetchFile ( title,
options = array() 
)

Fetch a file and its title and register a reference to it.

If 'broken' is a key in $options then the file will appear as a broken thumbnail.

Parameters:
Title$title
Array$optionsArray of options to RepoGroup::findFile
Returns:
File|false

Definition at line 3566 of file Parser.php.

References $options, $res, and $title.

Parser::fetchFileAndTitle ( title,
options = array() 
)

Fetch a file and its title and register a reference to it.

If 'broken' is a key in $options then the file will appear as a broken thumbnail.

Parameters:
Title$title
Array$optionsArray of options to RepoGroup::findFile
Returns:
Array ( File or false, Title of file )

Definition at line 3578 of file Parser.php.

References $file, $options, $title, RepoGroup\singleton(), and wfFindFile().

Here is the call graph for this function:

Parameters:
$urlstring
Returns:
Mixed|String

Definition at line 3630 of file Parser.php.

References $dbr, $url, $wgTranscludeCacheExpiry, Http\get(), wfGetDB(), and wfMsgForContent().

Here is the call graph for this function:

Parser::fetchTemplate ( title)

Fetch the unparsed text of a template and register a reference to it.

Parameters:
Title$title
Returns:
mixed string or false

Definition at line 3475 of file Parser.php.

References $title.

Fetch the unparsed text of a template and register a reference to it.

Parameters:
Title$title
Returns:
Array ( string or false, Title )

Definition at line 3457 of file Parser.php.

References $title, and statelessFetchTemplate().

Here is the call graph for this function:

Parser::findColonNoLinks ( str,
&$  before,
&$  after 
)

Split up a string on ':', ignoring any occurences inside tags to prevent illegal overlapping.

Parameters:
$strString the string to split
&$beforeString set to everything before the ':'
&$afterString set to everything after the ':'
Returns:
String the position of the ':', or false if none found

Definition at line 2400 of file Parser.php.

References wfDebug(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

Do various kinds of initialisation on the first call of the parser.

Reimplemented in Parser_LinkHooks.

Definition at line 225 of file Parser.php.

References initialiseVariables(), CoreParserFunctions\register(), CoreTagHooks\register(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Referenced by clearState().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::formatHeadings ( text,
origText,
isMain = true 
)

This function accomplishes several tasks: 1) Auto-number headings if that option is enabled 2) Add an [edit] link to sections for users who have enabled the option and can edit the page 3) Add a Table of contents on the top for users who have enabled the option 4) Auto-anchor headings.

It loops through all headlines, collects the necessary data, then splits up the string and re-inserts the newly formatted headlines.

Parameters:
$textString
$origTextString: original, untouched wikitext
$isMainBoolean
Access:
private

Definition at line 3931 of file Parser.php.

References $matches, $wgExperimentalHtmlIds, $wgHtml5, $wgMaxTocLevel, Sanitizer\escapeId(), Linker\makeHeadline(), Sanitizer\normalizeSectionNameWhitespace(), PPFrame\RECOVER_ORIG, Linker\tocIndent(), Linker\tocLine(), Linker\tocLineEnd(), Linker\tocList(), Linker\tocUnindent(), and wfRunHooks().

Referenced by internalParse().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::getCommon ( st1,
st2 
) [private]

getCommon() returns the length of the longest common substring of both arguments, starting at the beginning of both.

Parameters:
$st1string
$st2string
Returns:
int

Definition at line 2110 of file Parser.php.

Get the language object for language conversion.

Definition at line 729 of file Parser.php.

References $wgBug34832TransitionalRollback, $wgContLang, and getTargetLanguage().

Referenced by makeFreeExternalLink(), parse(), replaceExternalLinks(), and replaceInternalLinks2().

Here is the call graph for this function:

Here is the caller graph for this function:

Accessor for $mDefaultSort Unlike getDefaultSort(), will return false if none is set.

Returns:
string or false

Definition at line 5503 of file Parser.php.

Accessor for $mDefaultSort Will use the empty string if none is set.

This value is treated as a prefix, so the empty string is equivalent to sorting by page name.

Returns:
string

Definition at line 5489 of file Parser.php.

Referenced by replaceInternalLinks2().

Here is the caller graph for this function:

Get an associative array of additional HTML attributes appropriate for a particular external link.

This currently may include rel => nofollow (depending on configuration, namespace, and the URL's domain) and/or a target attribute (depending on configuration).

Parameters:
$urlString|bool optional URL, to extract the domain from for rel => nofollow if appropriate
Returns:
Array associative array of HTML attributes

Definition at line 1566 of file Parser.php.

References $url, $wgNoFollowDomainExceptions, $wgNoFollowLinks, $wgNoFollowNsExceptions, and wfMatchesDomainList().

Referenced by makeFreeExternalLink(), and replaceExternalLinks().

Here is the call graph for this function:

Here is the caller graph for this function:

Get all registered function hook identifiers.

Returns:
Array

Definition at line 4738 of file Parser.php.

Get a language object for use in parser functions such as {{FORMATNUM:}}.

Returns:
Language

Definition at line 706 of file Parser.php.

References getTargetLanguage().

Here is the call graph for this function:

Parser::getImageParams ( handler)
Parameters:
$handler
Returns:
array

Definition at line 4885 of file Parser.php.

Get the ParserOptions object.

Returns:
ParserOptions object

Definition at line 674 of file Parser.php.

Get the ParserOutput object.

Returns:
ParserOutput object

Definition at line 665 of file Parser.php.

Parser::getPreloadText ( text,
Title title,
ParserOptions options 
)

Process the wikitext for the ?preload= feature.

(bug 5210)

<noinclude>, <includeonly> etc. are parsed as for template transclusion, comments, templates, arguments, tags hooks and parser functions are untouched.

Parameters:
$textString
$titleTitle
$optionsParserOptions
Returns:
String

Definition at line 548 of file Parser.php.

Get a preprocessor object.

Returns:
Preprocessor instance

Definition at line 756 of file Parser.php.

static Parser::getRandomString ( ) [static]

Get a random string.

Returns:
string

Definition at line 564 of file Parser.php.

Referenced by clearState(), and StripState\merge().

Here is the caller graph for this function:

Get the ID of the revision we are parsing.

Returns:
Mixed: integer or null

Definition at line 5402 of file Parser.php.

Parser::getRevisionObject ( ) [protected]

Get the revision object for $this->mRevisionId.

Returns:
Revision|null either a Revision object or null

Definition at line 5411 of file Parser.php.

References Revision\newFromId().

Here is the call graph for this function:

Get the timestamp associated with the current revision, adjusted for the default server-local timestamp.

Definition at line 5427 of file Parser.php.

References $wgContLang, wfProfileIn(), wfProfileOut(), and wfTimestampNow().

Here is the call graph for this function:

Get the name of the user that edited the last revision.

Returns:
String: user name

Definition at line 5454 of file Parser.php.

Parser::getSection ( text,
section,
deftext = '' 
)

This function returns the text of a section, specified by a number ($section).

A section is text under a heading like == Heading == or <h1>Heading</h1>, or the first section before any such heading (section 0).

If a section contains subsections, these are also returned.

Parameters:
$textString: text to look in
$sectionString: section identifier
$deftextString: default to return if section is not found
Returns:
string text of the requested section

Definition at line 5379 of file Parser.php.

References $section.

Get a list of strippable XML-like elements.

Returns:
array

Definition at line 848 of file Parser.php.

Accessor.

Returns:
array

Definition at line 5196 of file Parser.php.

Get the target language for the content being parsed.

This is usually the language that the content is in.

Definition at line 714 of file Parser.php.

Referenced by getConverterLanguage(), getFunctionLang(), replaceExternalLinks(), and replaceInternalLinks2().

Here is the caller graph for this function:

Parser::getTemplateDom ( title)

Get the semi-parsed DOM representation of a template with a given title, and its redirect destination title.

Cached.

Parameters:
$titleTitle
Returns:
array

Definition at line 3420 of file Parser.php.

References $title, and Title\makeTitle().

Here is the call graph for this function:

Accessor for the Title object.

Returns:
Title object

Definition at line 620 of file Parser.php.

Get a User object either from $this->mUser, if set, or from the ParserOptions object otherwise.

Returns:
User object

Definition at line 744 of file Parser.php.

Parser::getUserSig ( &$  user,
nickname = false,
fancySig = null 
)

Fetch the user's signature text, if any, and normalize to validated, ready-to-insert wikitext.

If you have pre-fetched the nickname or the fancySig option, you can specify them here to save a database query. Do not reuse this parser instance after calling getUserSig(), as it may have changed if it's the $wgParser.

Parameters:
$userUser
$nicknameString|bool nickname to use or false to use user's default nickname
$fancySigBoolean|null whether the nicknname is the complete signature or null to use default value
Returns:
string

Definition at line 4426 of file Parser.php.

References $user, $wgMaxSigChars, wfDebug(), wfEscapeWikiText(), and wfMessage().

Here is the call graph for this function:

Same as guessSectionNameFromWikiText(), but produces legacy anchors instead.

For use in redirects, since IE6 interprets Redirect: headers as something other than UTF-8 (apparently?), resulting in breakage.

Parameters:
$textString: The section name
Returns:
string An anchor

Definition at line 5531 of file Parser.php.

References Sanitizer\escapeId(), and Sanitizer\normalizeSectionNameWhitespace().

Here is the call graph for this function:

Try to guess the section anchor name based on a wikitext fragment presumably extracted from a heading, for example "Header" from "== Header ==".

Parameters:
$textstring
Returns:
string

Definition at line 5516 of file Parser.php.

References Sanitizer\escapeId(), and Sanitizer\normalizeSectionNameWhitespace().

Here is the call graph for this function:

Increment the expensive function count.

Returns:
Boolean: false if the limit has been exceeded

Definition at line 3815 of file Parser.php.

References $wgExpensiveParserFunctionLimit.

Parser::incrementIncludeSize ( type,
size 
)

Increment an include size counter.

Parameters:
$typeString: the type of expansion
$sizeInteger: the size of the text
Returns:
Boolean: false if this inclusion would take it over the maximum, true otherwise

Definition at line 3801 of file Parser.php.

References $size.

initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers

Definition at line 2892 of file Parser.php.

References MagicWord\getSubstIDs(), MagicWord\getVariableIDs(), wfProfileIn(), and wfProfileOut().

Referenced by Parser_LinkHooks\firstCallInit(), and firstCallInit().

Here is the call graph for this function:

Here is the caller graph for this function:

Add an item to the strip state Returns the unique tag which must be inserted into the stripped text The tag will be replaced with the original text in unstrip()

Parameters:
$textstring
Returns:
string

Definition at line 861 of file Parser.php.

References MARKER_SUFFIX.

Parser::internalParse ( text,
isMain = true,
frame = false 
)

Helper function for parse() that transforms wiki markup into HTML.

Only called for $mOutputType == self::OT_HTML.

Access:
private
Parameters:
$textstring
$isMainbool
$framebool
Returns:
string

Definition at line 1075 of file Parser.php.

References doAllQuotes(), doDoubleUnderscore(), doHeadings(), doMagicLinks(), doTableStuff(), formatHeadings(), DateFormatter\getInstance(), preprocessToDom(), PTD_FOR_INCLUSION, Sanitizer\removeHTMLtags(), replaceExternalLinks(), replaceInternalLinks(), replaceVariables(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Referenced by parse().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::interwikiTransclude ( title,
action 
)

Transclude an interwiki link.

Parameters:
$titleTitle
$action
Returns:
string

Definition at line 3611 of file Parser.php.

References $title, $url, $wgEnableScaryTranscluding, and wfMsgForContent().

Here is the call graph for this function:

Returns true if the given array, presumed to be generated by serializeHalfParsedText(), is compatible with the current version of the parser.

Parameters:
$dataArray
Returns:
bool

Definition at line 5727 of file Parser.php.

Parser::killMarkers ( text)

Remove any strip markers found in the given text.

Parameters:
$textInput string
Returns:
string

Definition at line 5656 of file Parser.php.

Parser::limitationWarn ( limitationType,
current = null,
max = null 
)

Warn the user when a parser limitation is reached Will warn at most once the user per limitation type.

Parameters:
$limitationTypeString: should be one of: 'expensive-parserfunction' (corresponding messages: 'expensive-parserfunction-warning', 'expensive-parserfunction-category') 'post-expand-template-argument' (corresponding messages: 'post-expand-template-argument-warning', 'post-expand-template-argument-category') 'post-expand-template-inclusion' (corresponding messages: 'post-expand-template-inclusion-warning', 'post-expand-template-inclusion-category')
$currentCurrent value
$maxMaximum allowed, when an explicit limit has been exceeded, provide the values (optional)

Definition at line 3039 of file Parser.php.

References wfMsgExt().

Here is the call graph for this function:

Exceptions:
MWException
Parameters:
$marray
Returns:
HTML|string

Definition at line 1171 of file Parser.php.

References $url, SpecialPage\getTitleFor(), Linker\makeExternalLink(), makeFreeExternalLink(), and wfMsgForContent().

Here is the call graph for this function:

Make a free external link, given a user-supplied URL.

Parameters:
$urlstring
Returns:
string HTML
Access:
private

Definition at line 1224 of file Parser.php.

References $url, Sanitizer\cleanUrl(), getConverterLanguage(), getExternalLinkAttribs(), Linker\makeExternalLink(), maybeMakeExternalImage(), replaceUnusualEscapes(), wfProfileIn(), and wfProfileOut().

Referenced by magicLinkCallback().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::makeImage ( title,
options,
holders = false 
)

Parse image options text and use it to make an image.

Parameters:
$titleTitle
$optionsString
$holdersLinkHolderArray|false
Returns:
string HTML

Definition at line 4933 of file Parser.php.

References $file, $options, $title, StringUtils\explode(), Linker\makeImageLink2(), Title\newFromText(), and wfRunHooks().

Referenced by replaceInternalLinks2().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::makeKnownLinkHolder ( nt,
text = '',
query = array(),
trail = '',
prefix = '' 
)

Render a forced-blue link inline; protect against double expansion of URLs if we're in a mode that prepends full URL prefixes to internal links.

Since this little disaster has to split off the trail text to avoid breaking URLs in the following text without breaking trails on the wiki links, it's been made into a horrible function.

Parameters:
$ntTitle
$textString
$queryArray or String
$trailString
$prefixString
Returns:
String: HTML-wikitext mix oh yuck

Definition at line 2033 of file Parser.php.

References Linker\linkKnown(), Linker\splitTrail(), and wfCgiToArray().

Here is the call graph for this function:

Parser::markerSkipCallback ( s,
callback 
)

Call a callback function on all regions of the given text that are not inside strip markers, and replace those regions with the return value of the callback.

For example, with input:

aaa<MARKER>bbb

This will call the callback function twice, with 'aaa' and 'bbb'. Those two strings will be replaced with the value returned by the callback in each case.

Parameters:
$sstring
$callback
Returns:
string

Definition at line 5626 of file Parser.php.

References $out.

Parser::maybeDoSubpageLink ( target,
&$  text 
) [private]

Handle link to subpage if necessary.

Parameters:
$targetString: the source of the link
&$textString: the link text, modified as necessary
Returns:
string the full name of the link

Definition at line 2080 of file Parser.php.

References Linker\normalizeSubpageLink().

Referenced by replaceInternalLinks2(), and Parser_LinkHooks\replaceInternalLinksCallback().

Here is the call graph for this function:

Here is the caller graph for this function:

make an image if it's allowed, either through the global option, through the exception, or through the on-wiki whitelist

Access:
private

$param $url string

Returns:
string

Definition at line 1627 of file Parser.php.

References $url, Linker\makeExternalImage(), and wfMsgForContent().

Referenced by makeFreeExternalLink(), and replaceExternalLinks().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::nextItem ( char) [private]

TODO: document.

Parameters:
$charString
Returns:
string

Definition at line 2160 of file Parser.php.

Returns:
int

Definition at line 691 of file Parser.php.

Parser::openList ( char) [private]

These next three functions open, continue, and close the list element appropriate to the prefix character passed into them.

Parameters:
$charchar
Returns:
string

Definition at line 2134 of file Parser.php.

References $result.

Parser::Options ( x = null)

Accessor/mutator for the ParserOptions object.

Parameters:
$xNew value or null to just get the current one
Returns:
Current ParserOptions object

Definition at line 684 of file Parser.php.

References wfSetVar().

Here is the call graph for this function:

Parser::OutputType ( x = null)

Accessor/mutator for the output type.

Parameters:
$xNew value or null to just get the current one
Returns:
Integer

Definition at line 656 of file Parser.php.

References wfSetVar().

Here is the call graph for this function:

Parser::parse ( text,
Title title,
ParserOptions options,
linestart = true,
clearState = true,
revid = null 
)

Convert wikitext to HTML Do not call this function recursively.

Parameters:
$textString: text we want to parse
$titleTitle object
$optionsParserOptions
$linestartboolean
$clearStateboolean
$revidInt: number to pass in {{REVISIONID}}
Returns:
ParserOutput a ParserOutput

Definition at line 318 of file Parser.php.

References $fname, $wgAlwaysUseTidy, $wgBug34832TransitionalRollback, $wgDisableLangConversion, $wgDisableTitleConversion, $wgUseTidy, doBlockLevels(), expand, false, getConverterLanguage(), internalParse(), Sanitizer\normalizeCharReferences(), replaceLinkHolders(), replaceTransparentTags(), startParse(), MWTidy\tidy(), wfGetCaller(), wfProfileIn(), and wfRunHooks().

Here is the call graph for this function:

Parser::preprocess ( text,
Title title,
ParserOptions options,
revid = null 
)

Expand templates and variables in the text, producing valid, static wikitext.

Also removes comments.

Definition at line 506 of file Parser.php.

Parser::preprocessToDom ( text,
flags = 0 
) [private]

Preprocess some wikitext and return the document tree.

This is the ghost of replace_variables().

Parameters:
$textString: The text to parse
$flagsInteger: bitwise combination of: self::PTD_FOR_INCLUSION Handle <noinclude>/<includeonly> as if the text is being included. Default is to assume a direct page view.

The generated DOM tree must depend only on the input text and the flags. The DOM tree must be the same in OT_HTML and OT_WIKI mode, to avoid a regression of bug 4899.

Any flag added to the $flags parameter here, or any other parameter liable to cause a change in the DOM tree for a given text, must be passed through the section identifier in the section edit link and thus back to extractSections().

The output of this function is currently only cached in process memory, but a persistent cache may be implemented at a later date which takes further advantage of these strict dependency requirements.

Returns:
PPNode

Definition at line 2926 of file Parser.php.

Referenced by internalParse().

Here is the caller graph for this function:

Parser::preSaveTransform ( text,
Title title,
User user,
ParserOptions options,
clearState = true 
)

Transform wiki markup when saving a page by doing
->
conversion, substitting signatures, {{subst:}} templates, etc.

Parameters:
$textString: the text to transform
$titleTitle: the Title object for the current article
$userUser: the User object describing the current user
$optionsParserOptions: parsing options
$clearStateBoolean: whether to clear the parser state first
Returns:
String: the altered wiki markup

Definition at line 4304 of file Parser.php.

References ParserOptions\getPreSaveTransform().

Here is the call graph for this function:

Parser::pstPass2 ( text,
user 
)

Pre-save transform helper function.

Access:
private
Parameters:
$textstring
$userUser
Returns:
string

Definition at line 4331 of file Parser.php.

References $t, $user, $wgContLang, $wgLegalTitleChars, $wgLocaltimezone, wfMessage(), and wfTimestamp().

Here is the call graph for this function:

Parser::recursivePreprocess ( text,
frame = false 
)

Recursive parser entry point that can be called from an extension tag hook.

Parameters:
$textString: text to be expanded
$framePPFrame: The frame to use for expanding any template variables
Returns:
String
Since:
1.19

Definition at line 529 of file Parser.php.

Parser::recursiveTagParse ( text,
frame = false 
)

Recursive parser entry point that can be called from an extension tag hook.

If $frame is not provided, then template variables (e.g., {{{1}}}) within $text are not expanded

Parameters:
$textString: text extension wants to have parsed
$framePPFrame: The frame to use for expanding any template variables
Returns:
string

Definition at line 493 of file Parser.php.

Parser::renderImageGallery ( text,
params 
)

Renders an image gallery from a text with one line per image.

text labels may be given by using |-style alternative text. E.g. Image:one.jpg|The number "1" Image:tree.jpg|A tree given as text will return the HTML of a gallery with two images, labeled 'The number "1"' and 'A tree'.

Parameters:
string$text
array$params
Returns:
string HTML

Definition at line 4799 of file Parser.php.

References $lines, $matches, $title, StringUtils\explode(), MagicWord\get(), Title\newFromText(), Sanitizer\validateTagAttributes(), and wfRunHooks().

Here is the call graph for this function:

Parser::replaceExternalLinks ( text) [private]

Replace external links (REL)

Note: this is all very hackish and the order of execution matters a lot. Make sure to run maintenance/parserTests.php if you change this code.

Parameters:
$textstring
Returns:
string

Definition at line 1485 of file Parser.php.

References $url, Sanitizer\cleanUrl(), getConverterLanguage(), getExternalLinkAttribs(), getTargetLanguage(), Linker\makeExternalLink(), maybeMakeExternalImage(), replaceUnusualEscapes(), Linker\splitTrail(), wfProfileIn(), and wfProfileOut().

Referenced by internalParse(), and replaceInternalLinks2().

Here is the call graph for this function:

Here is the caller graph for this function:

Process [[ ]] wikilinks.

Parameters:
$sstring
Returns:
String: processed text
Access:
private

Definition at line 1679 of file Parser.php.

References replaceInternalLinks2().

Referenced by internalParse().

Here is the call graph for this function:

Here is the caller graph for this function:

Process [[ ]] wikilinks (RIL)

Returns:
LinkHolderArray
Access:
private

Reimplemented in Parser_LinkHooks.

Definition at line 1690 of file Parser.php.

References areSubpagesAllowed(), armorLinks(), Sanitizer\decodeCharReferences(), StringUtils\explode(), getConverterLanguage(), getDefaultSort(), getTargetLanguage(), Title\legalChars(), makeImage(), maybeDoSubpageLink(), Title\newFromText(), replaceExternalLinks(), wfMsgForContent(), wfProfileIn(), wfProfileOut(), and wfUrlProtocols().

Referenced by replaceInternalLinks().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::replaceLinkHolders ( &$  text,
options = 0 
)
Todo:
FIXME: Update documentation.

makeLinkObj() is deprecated. Replace link placeholders with actual links, in the buffer Placeholders created in Skin::makeLinkObj()

Parameters:
$textstring
$optionsint
Returns:
array of link CSS classes, indexed by PDBK.

Definition at line 4771 of file Parser.php.

Referenced by parse().

Here is the caller graph for this function:

Replace link placeholders with plain text of links (not HTML-formatted).

Parameters:
$textString
Returns:
String

Definition at line 4782 of file Parser.php.

Parser::replaceSection ( oldtext,
section,
text 
)

This function returns $oldtext after the content of the section specified by $section has been replaced with $text.

If the target section does not exist, $oldtext is returned unchanged.

Parameters:
$oldtextString: former text of the article
$sectionNumeric: section identifier
$textString: replacing text
Returns:
String: modified text

Definition at line 5393 of file Parser.php.

References $section.

Replace transparent tags in $text with the values given by the callbacks.

Transparent tag hooks are like regular XML-style tag hooks, except they operate late in the transformation sequence, on HTML instead of wikitext.

Parameters:
$textstring
Returns:
string

Definition at line 5210 of file Parser.php.

References $matches, and $output.

Referenced by parse().

Here is the caller graph for this function:

static Parser::replaceUnusualEscapes ( url) [static]

Replace unusual URL escape codes with their equivalent characters.

Parameters:
$urlString
Returns:
String
Todo:
This can merge genuinely required bits in the path or query string, breaking legit URLs. A proper fix would treat the various parts of the URL differently; as a workaround, just use the output for statistical records, not for actual linking/output.

Definition at line 1592 of file Parser.php.

References $url.

Referenced by makeFreeExternalLink(), and replaceExternalLinks().

Here is the caller graph for this function:

static Parser::replaceUnusualEscapesCallback ( matches) [static, private]

Callback function used in replaceUnusualEscapes().

Replaces unusual URL escape codes with their equivalent character

Parameters:
$matchesarray
Returns:
string

Definition at line 1605 of file Parser.php.

References $matches.

Parser::replaceVariables ( text,
frame = false,
argsOnly = false 
) [private]

Replace magic variables, templates, and template arguments with the appropriate text.

Templates are substituted recursively, taking care to avoid infinite loops.

Note that the substitution depends on value of $mOutputType: self::OT_WIKI: only {{subst:}} templates self::OT_PREPROCESS: templates but not extension tags self::OT_HTML: all templates and extension tags

Parameters:
$textString the text to transform
$framePPFrame Object describing the arguments passed to the template. Arguments may also be provided as an associative array, as was the usual case before MW1.12. Providing arguments this way may be useful for extensions wishing to perform variable replacement explicitly.
$argsOnlyBoolean only do argument (triple-brace) expansion, not double-brace expansion
Returns:
string

Definition at line 2970 of file Parser.php.

References PPFrame\NO_TEMPLATES, wfDebug(), wfProfileIn(), and wfProfileOut().

Referenced by internalParse().

Here is the call graph for this function:

Here is the caller graph for this function:

Save the parser state required to convert the given half-parsed text to HTML.

"Half-parsed" in this context means the output of recursiveTagParse() or internalParse(). This output has strip markers from replaceVariables (extensionSubstitution() etc.), and link placeholders from replaceLinkHolders().

Returns an array which can be serialized and stored persistently. This array can later be loaded into another parser instance with unserializeHalfParsedText(). The text can then be safely incorporated into the return value of a parser hook.

Parameters:
$textstring
Returns:
array

Definition at line 5676 of file Parser.php.

References wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

Mutator for $mDefaultSort.

Parameters:
$sortNew value

Definition at line 5474 of file Parser.php.

Parser::setFunctionHook ( id,
callback,
flags = 0 
)

Create a function, e.g.

{{sum:1|2|3}} The callback function should have the form: function myParserFunction( &$parser, $arg1, $arg2, $arg3 ) { ... }

Or with SFH_OBJECT_ARGS: function myParserFunction( $parser, $frame, $args ) { ... }

The callback may either return the text result of the function, or an array with the text in element 0, and a number of flags in the other elements. The names of the flags are specified in the keys. Valid flags are: found The text returned is valid, stop processing the template. This is on by default. nowiki Wiki markup in the return value should be escaped isHTML The returned text is HTML, armour it against wikitext transformation

Parameters:
$idString: The magic word ID
$callbackMixed: the callback function (and object) to use
$flagsInteger: a combination of the following flags: SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{if:...}}

SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This allows for conditional expansion of the parse tree, allowing you to eliminate dead branches and thus speed up parsing. It is also possible to analyse the parse tree of the arguments, and to control the way they are expanded.

The $frame parameter is a PPFrame. This can be used to produce expanded text from the arguments, for instance: $text = isset( $args[0] ) ? $frame->expand( $args[0] ) : '';

For technical reasons, $args[0] is pre-expanded and will be a string. This may change in future versions. Please call $frame->expand() on it anyway so that your code keeps working if/when this is changed.

If you want whitespace to be trimmed from $args, you need to do it yourself, post- expansion.

Please read the documentation in includes/parser/Preprocessor.php for more information about the methods available in PPFrame and PPNode.

Returns:
The old callback function for this name, if any

Definition at line 4701 of file Parser.php.

References $wgContLang, and MagicWord\get().

Here is the call graph for this function:

Parser::setFunctionTagHook ( tag,
callback,
flags 
)

Create a tag function, e.g.

<test>some stuff</test>. Unlike tag hooks, tag functions are parsed at preprocessor level. Unlike parser functions, their content is not preprocessed.

Definition at line 4747 of file Parser.php.

Parser::setHook ( tag,
callback 
)

Create an HTML-style tag, e.g.

<yourtag>special text</yourtag> The callback should have the following form: function myParserHook( $text, $params, $parser, $frame ) { ... }

Transform and return $text. Use $parser for any required context, e.g. use $parser->getTitle() and $parser->getOptions() not $wgTitle or $wgOut->mParserOptions

Hooks may return extended information by returning an array, of which the first numbered element (index 0) must be the return string, and all other entries are extracted into local variables within an internal function in the Parser class.

This interface (introduced r61913) appears to be undocumented, but 'markerName' is used by some core tag hooks to override which strip array their results are placed in. **Use great caution if attempting this interface, as it is not documented and injudicious use could smash private variables.**

Parameters:
$tagMixed: the tag to use, e.g. 'hook' for <hook>
$callbackMixed: the callback function (and object) to use for the tag
Returns:
The old value of the mTagHooks array associated with the hook

Definition at line 4613 of file Parser.php.

Referenced by Parser_LinkHooks\firstCallInit().

Here is the caller graph for this function:

Parser::setLinkID ( id)
Parameters:
$idint

Definition at line 698 of file Parser.php.

Set the output type.

Parameters:
$otInteger: new value

Definition at line 639 of file Parser.php.

References $ot.

Parser::setTitle ( t)

Set the context title.

Parameters:
$tTitle

Definition at line 601 of file Parser.php.

References $t, and Title\newFromText().

Here is the call graph for this function:

Parser::setTransparentTagHook ( tag,
callback 
)

As setHook(), but letting the contents be parsed.

Transparent tag hooks are like regular XML-style tag hooks, except they operate late in the transformation sequence, on HTML instead of wikitext.

This is probably obsoleted by things dealing with parser frames? The only extension currently using it is geoserver.

Since:
1.10
Todo:
better document or deprecate this
Parameters:
$tagMixed: the tag to use, e.g. 'hook' for <hook>
$callbackMixed: the callback function (and object) to use for the tag
Returns:
The old value of the mTagHooks array associated with the hook

Definition at line 4641 of file Parser.php.

Parser::setUser ( user)

Set the current user.

Should only be used when doing pre-save transform.

Parameters:
$userMixed: User object or null (to reset)

Definition at line 574 of file Parser.php.

static Parser::splitWhitespace ( s) [static]

Return a three-element array: leading whitespace, string contents, trailing whitespace.

Parameters:
$sstring
Returns:
array

Definition at line 2938 of file Parser.php.

Parser::startExternalParse ( Title title = null,
ParserOptions options,
outputType,
clearState = true 
)

Set up some variables which are usually set up in parse() so that an external function can call some class members with confidence.

Parameters:
$titleTitle|null
$optionsParserOptions
$outputType
$clearStatebool

Definition at line 4537 of file Parser.php.

References $title.

Parser::startParse ( Title title = null,
ParserOptions options,
outputType,
clearState = true 
) [private]
Parameters:
$titleTitle|null
$optionsParserOptions
$outputType
$clearStatebool

Definition at line 4547 of file Parser.php.

References $options, and $title.

Referenced by parse().

Here is the caller graph for this function:

static Parser::statelessFetchTemplate ( title,
parser = false 
) [static]

Static function to get a template Can be overridden via ParserOptions::setTemplateCallback().

$title Title

Parameters:
$parserParser
Returns:
array

Definition at line 3489 of file Parser.php.

References $title, $wgContLang, Revision\newFromId(), Title\newFromRedirect(), Revision\newFromTitle(), LinkCache\singleton(), wfMessage(), and wfRunHooks().

Referenced by fetchTemplateAndTitle().

Here is the call graph for this function:

Here is the caller graph for this function:

Parser::stripAltText ( caption,
holders 
) [protected]
Parameters:
$caption
$holdersLinkHolderArray
Returns:
mixed|String

Definition at line 5144 of file Parser.php.

References Sanitizer\stripAllTags().

Here is the call graph for this function:

Strips a text string of wikitext for use in a section anchor.

Accepts a text string and then removes all wikitext from the string and leaves only the resultant text (i.e. the result of [[User:WikiSysop|Sysop]] would be "Sysop" and the result of [[User:WikiSysop]] would be "User:WikiSysop") - this is intended to create valid section anchors by mimicing the output of the parser when headings are parsed.

Parameters:
$textString: text string to be stripped of wikitext for use in a Section anchor
Returns:
Filtered text string

Definition at line 5552 of file Parser.php.

References StringUtils\delimiterReplace(), and wfUrlProtocols().

Here is the call graph for this function:

Parser::testPreprocess ( text,
Title title,
ParserOptions options 
)
Parameters:
$text
$titleTitle
$optionsParserOptions
Returns:
string

Definition at line 5606 of file Parser.php.

Parser::testPst ( text,
Title title,
ParserOptions options 
)
Parameters:
$textstring
$titleTitle
$optionsParserOptions
Returns:
string

Definition at line 5596 of file Parser.php.

References $options, and ParserOptions\getUser().

Here is the call graph for this function:

Parser::testSrvus ( text,
Title title,
ParserOptions options,
outputType = self::OT_HTML 
)

strip/replaceVariables/unstrip for preprocessor regression testing

Parameters:
$textstring
$titleTitle
$optionsParserOptions
$outputTypeint
Returns:
string

Definition at line 5581 of file Parser.php.

References Sanitizer\removeHTMLtags().

Here is the call graph for this function:

Parser::Title ( x = null)

Accessor/mutator for the Title object.

Parameters:
$xNew Title object or null to just get the current one
Returns:
Title object

Definition at line 630 of file Parser.php.

References wfSetVar().

Here is the call graph for this function:

Parser::transformMsg ( text,
options,
title = null 
)

Wrapper for preprocess()

Parameters:
$textString: the text to preprocess
$optionsParserOptions: options
$titleTitle object or null to use $wgTitle
Returns:
String

Definition at line 4564 of file Parser.php.

References $options, $title, $wgTitle, Title\newFromText(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

Accessor for mUniqPrefix.

Returns:
String

Definition at line 583 of file Parser.php.

Load the parser state given in the $data array, which is assumed to have been generated by serializeHalfParsedText().

The text contents is extracted from the array, and its markers are transformed into markers appropriate for the current Parser instance. This transformed text is returned, and can be safely included in the return value of a parser hook.

If the $data array has been stored persistently, the caller should first check whether it is still valid, by calling isValidHalfParsedText().

Parameters:
$dataSerialized data
Returns:
String

Definition at line 5702 of file Parser.php.

Parser::validateSig ( text)

Check that the user's signature contains no bad XML.

Parameters:
$textString
Returns:
mixed An expanded string, or false if invalid.

Definition at line 4473 of file Parser.php.

References Xml\isWellFormedXmlFragment().

Here is the call graph for this function:


Member Data Documentation

Parser::$mArgStack

Definition at line 140 of file Parser.php.

Parser::$mAutonumber

Definition at line 133 of file Parser.php.

Parser::$mConf

Definition at line 126 of file Parser.php.

Parser::$mDefaultSort

Definition at line 147 of file Parser.php.

Parser::$mDefaultStripList = array()

Definition at line 108 of file Parser.php.

Parser::$mDoubleUnderscores

Definition at line 149 of file Parser.php.

Parser::$mDTopen

Definition at line 133 of file Parser.php.

Parser::$mExpensiveFunctionCount

Definition at line 150 of file Parser.php.

Parser::$mExtLinkBracketedRegex

Definition at line 126 of file Parser.php.

Parser::$mFirstCall = true

Definition at line 113 of file Parser.php.

Parser::$mForceTocPosition

Definition at line 151 of file Parser.php.

Parser::$mFunctionHooks = array()

Definition at line 104 of file Parser.php.

Parser::$mFunctionSynonyms = array( 0 => array(), 1 => array() )

Definition at line 105 of file Parser.php.

Parser::$mFunctionTagHooks = array()

Definition at line 106 of file Parser.php.

Parser::$mHeadings

Definition at line 149 of file Parser.php.

Parser::$mImageParams = array()

Definition at line 110 of file Parser.php.

Parser::$mImageParamsMagicArray = array()

Definition at line 111 of file Parser.php.

Parser::$mIncludeCount

Definition at line 140 of file Parser.php.

Parser::$mIncludeSizes

Definition at line 147 of file Parser.php.

Parser::$mInPre

Definition at line 140 of file Parser.php.

Parser::$mLastSection

Definition at line 140 of file Parser.php.

Parser::$mLinkHolders

Definition at line 144 of file Parser.php.

Parser::$mLinkID

Definition at line 146 of file Parser.php.

Parser::$mMarkerIndex = 0

Definition at line 112 of file Parser.php.

Parser::$mOptions

Definition at line 164 of file Parser.php.

Parser::$mOutput

Definition at line 132 of file Parser.php.

Parser::$mOutputType

Definition at line 170 of file Parser.php.

Parser::$mPPNodeCount

Definition at line 147 of file Parser.php.

Parser::$mPreprocessor

Definition at line 126 of file Parser.php.

Parser::$mRevIdForTs

Definition at line 176 of file Parser.php.

Parser::$mRevisionId

Definition at line 173 of file Parser.php.

Parser::$mRevisionObject

Definition at line 172 of file Parser.php.

Parser::$mRevisionTimestamp

Definition at line 174 of file Parser.php.

Parser::$mRevisionUser

Definition at line 175 of file Parser.php.

Parser::$mShowToc

Definition at line 151 of file Parser.php.

Parser::$mStripList = array()

Definition at line 107 of file Parser.php.

Parser::$mStripState

Definition at line 138 of file Parser.php.

Parser::$mSubstWords

Definition at line 125 of file Parser.php.

Parser::$mTagHooks = array()

Definition at line 102 of file Parser.php.

Parser::$mTitle

Definition at line 169 of file Parser.php.

Parser::$mTplDomCache

Definition at line 149 of file Parser.php.

Parser::$mTplExpandCache

Definition at line 148 of file Parser.php.

Parser::$mTplRedirCache

Definition at line 149 of file Parser.php.

Parser::$mTransparentTagHooks = array()

Definition at line 103 of file Parser.php.

Parser::$mUniqPrefix

Definition at line 181 of file Parser.php.

Parser::$mUrlProtocols

Definition at line 126 of file Parser.php.

Parser::$mUser

Definition at line 156 of file Parser.php.

Parser::$mVarCache = array()

Definition at line 109 of file Parser.php.

Parser::$mVariables

Definition at line 120 of file Parser.php.

Parser::$ot

Definition at line 171 of file Parser.php.

Referenced by setOutputType().

Definition at line 81 of file Parser.php.

Definition at line 83 of file Parser.php.

Definition at line 84 of file Parser.php.

Definition at line 85 of file Parser.php.

Definition at line 79 of file Parser.php.

Definition at line 82 of file Parser.php.

Definition at line 80 of file Parser.php.

Definition at line 78 of file Parser.php.

Initial value:
 '/^(http:\/\/|https:\/\/)([^][<>"\\x00-\\x20\\x7F\p{Zs}]+)
                \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sxu'

Reimplemented in Parser_LinkHooks.

Definition at line 74 of file Parser.php.

const Parser::EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F\p{Zs}]'

Reimplemented in Parser_LinkHooks.

Definition at line 73 of file Parser.php.

Referenced by doMagicLinks().

Update this version number when the output of serialiseHalfParsedText() changes in an incompatible way.

Definition at line 62 of file Parser.php.

const Parser::OT_HTML = 1

Definition at line 92 of file Parser.php.

const Parser::OT_MSG = 3

Definition at line 95 of file Parser.php.

const Parser::OT_PLAIN = 4

Definition at line 96 of file Parser.php.

Definition at line 94 of file Parser.php.

const Parser::OT_WIKI = 2

Definition at line 93 of file Parser.php.

Definition at line 66 of file Parser.php.

Definition at line 67 of file Parser.php.

const Parser::VERSION = '1.6.4'

Update this version number when the ParserOutput format changes in an incompatible way, so the parser cache can automatically discard old data.

Reimplemented in Parser_LinkHooks.

Definition at line 56 of file Parser.php.

Referenced by CacheTime\expired().


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