[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/parser/ -> Parser.php (summary)

PHP parser that converts wiki markup to HTML. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 6399 lines (202 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Parser:: (135 methods):
  __construct()
  __destruct()
  __clone()
  firstCallInit()
  clearState()
  parse()
  recursiveTagParse()
  preprocess()
  recursivePreprocess()
  getPreloadText()
  getRandomString()
  setUser()
  uniqPrefix()
  setTitle()
  getTitle()
  Title()
  setOutputType()
  OutputType()
  getOutput()
  getOptions()
  Options()
  nextLinkID()
  setLinkID()
  getFunctionLang()
  getTargetLanguage()
  getConverterLanguage()
  getUser()
  getPreprocessor()
  extractTagsAndParams()
  getStripList()
  insertStripItem()
  doTableStuff()
  internalParse()
  doMagicLinks()
  magicLinkCallback()
  makeFreeExternalLink()
  doHeadings()
  doAllQuotes()
  doQuotes()
  replaceExternalLinks()
  getExternalLinkRel()
  getExternalLinkAttribs()
  replaceUnusualEscapes()
  normalizeLinkUrl()
  normalizeUrlComponent()
  maybeMakeExternalImage()
  replaceInternalLinks()
  replaceInternalLinks2()
  makeKnownLinkHolder()
  armorLinks()
  areSubpagesAllowed()
  maybeDoSubpageLink()
  closeParagraph()
  getCommon()
  openList()
  nextItem()
  closeList()
  doBlockLevels()
  findColonNoLinks()
  getVariableValue()
  initialiseVariables()
  preprocessToDom()
  splitWhitespace()
  replaceVariables()
  createAssocArgs()
  limitationWarn()
  braceSubstitution()
  callParserFunction()
  getTemplateDom()
  fetchTemplateAndTitle()
  fetchTemplate()
  statelessFetchTemplate()
  fetchFile()
  fetchFileAndTitle()
  fetchFileNoRegister()
  interwikiTransclude()
  fetchScaryTemplateMaybeFromCache()
  argSubstitution()
  extensionSubstitution()
  incrementIncludeSize()
  incrementExpensiveFunctionCount()
  doDoubleUnderscore()
  addTrackingCategory()
  formatHeadings()
  preSaveTransform()
  pstPass2()
  getUserSig()
  validateSig()
  cleanSig()
  cleanSigInSig()
  startExternalParse()
  startParse()
  transformMsg()
  setHook()
  setTransparentTagHook()
  clearTagHooks()
  setFunctionHook()
  getFunctionHooks()
  setFunctionTagHook()
  replaceLinkHolders()
  replaceLinkHoldersText()
  renderImageGallery()
  getImageParams()
  makeImage()
  stripAltText()
  disableCache()
  attributeStripCallback()
  getTags()
  replaceTransparentTags()
  extractSections()
  getSection()
  replaceSection()
  getRevisionId()
  getRevisionObject()
  getRevisionTimestamp()
  getRevisionUser()
  getRevisionSize()
  setDefaultSort()
  getDefaultSort()
  getCustomDefaultSort()
  guessSectionNameFromWikiText()
  guessLegacySectionNameFromWikiText()
  stripSectionName()
  testSrvus()
  testPst()
  testPreprocess()
  markerSkipCallback()
  killMarkers()
  serializeHalfParsedText()
  unserializeHalfParsedText()
  isValidHalfParsedText()
  parseWidthParam()
  lock()
  stripOuterParagraph()
  getFreshParser()


Class: Parser  - X-Ref

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 (X)HTML output / markup
(which in turn the browser understands, and can display).

There are seven main entry points into the Parser class:

- Parser::parse()
produces HTML output
- Parser::preSaveTransform().
produces altered wiki markup.
- Parser::preprocess()
removes HTML comments and expands templates
- Parser::cleanSig() and Parser::cleanSigInSig()
Cleans a signature before saving it to preferences
- Parser::getSection()
Return the content of a section from an article for section editing
- Parser::replaceSection()
Replaces a section by number inside an article
- Parser::getPreloadText()
Removes <noinclude> sections, and <includeonly> tags.

Globals used:
object: $wgContLang

__construct( $conf = array()   X-Ref

param: array $conf

__destruct()   X-Ref
Reduce memory usage to reduce the impact of circular references


__clone()   X-Ref
Allow extensions to clean up when the parser is cloned


firstCallInit()   X-Ref
Do various kinds of initialisation on the first call of the parser


clearState()   X-Ref
Clear Parser state


parse( $text, Title $title, ParserOptions $options,$linestart = true, $clearState = true, $revid = null)   X-Ref
Convert wikitext to HTML
Do not call this function recursively.

param: string $text Text we want to parse
param: Title $title
param: ParserOptions $options
param: bool $linestart
param: bool $clearState
param: int $revid Number to pass in {{REVISIONID}}
return: ParserOutput A ParserOutput

recursiveTagParse( $text, $frame = false )   X-Ref
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

param: string $text Text extension wants to have parsed
param: bool|PPFrame $frame The frame to use for expanding any template variables
return: string

preprocess( $text, Title $title = null, ParserOptions $options, $revid = null, $frame = false )   X-Ref
Expand templates and variables in the text, producing valid, static wikitext.
Also removes comments.
Do not call this function recursively.

param: string $text
param: Title $title
param: ParserOptions $options
param: int|null $revid
param: bool|PPFrame $frame
return: mixed|string

recursivePreprocess( $text, $frame = false )   X-Ref
Recursive parser entry point that can be called from an extension tag
hook.

param: string $text Text to be expanded
param: bool|PPFrame $frame The frame to use for expanding any template variables
return: string

getPreloadText( $text, Title $title, ParserOptions $options, $params = array()   X-Ref
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.

param: string $text
param: Title $title
param: ParserOptions $options
param: array $params
return: string

getRandomString()   X-Ref
Get a random string

return: string

setUser( $user )   X-Ref
Set the current user.
Should only be used when doing pre-save transform.

param: User|null $user User object or null (to reset)

uniqPrefix()   X-Ref
Accessor for mUniqPrefix.

return: string

setTitle( $t )   X-Ref
Set the context title

param: Title $t

getTitle()   X-Ref
Accessor for the Title object

return: Title

Title( $x = null )   X-Ref
Accessor/mutator for the Title object

param: Title $x Title object or null to just get the current one
return: Title

setOutputType( $ot )   X-Ref
Set the output type

param: int $ot New value

OutputType( $x = null )   X-Ref
Accessor/mutator for the output type

param: int|null $x New value or null to just get the current one
return: int

getOutput()   X-Ref
Get the ParserOutput object

return: ParserOutput

getOptions()   X-Ref
Get the ParserOptions object

return: ParserOptions

Options( $x = null )   X-Ref
Accessor/mutator for the ParserOptions object

param: ParserOptions $x New value or null to just get the current one
return: ParserOptions Current ParserOptions object

nextLinkID()   X-Ref

return: int

setLinkID( $id )   X-Ref

param: int $id

getFunctionLang()   X-Ref
Get a language object for use in parser functions such as {{FORMATNUM:}}

return: Language

getTargetLanguage()   X-Ref
Get the target language for the content being parsed. This is usually the
language that the content is in.

return: Language

getConverterLanguage()   X-Ref
Get the language object for language conversion

return: Language|null

getUser()   X-Ref
Get a User object either from $this->mUser, if set, or from the
ParserOptions object otherwise

return: User

getPreprocessor()   X-Ref
Get a preprocessor object

return: Preprocessor

extractTagsAndParams( $elements, $text, &$matches, $uniq_prefix = '' )   X-Ref
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:

param: array $elements List of element names. Comments are always extracted.
param: string $text Source text string.
param: array $matches Out parameter, Array: extracted tags
param: string $uniq_prefix
return: string Stripped text

getStripList()   X-Ref
Get a list of strippable XML-like elements

return: array

insertStripItem( $text )   X-Ref
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()

param: string $text
return: string

doTableStuff( $text )   X-Ref
parse the wiki syntax used to render tables

param: string $text
return: string

internalParse( $text, $isMain = true, $frame = false )   X-Ref
Helper function for parse() that transforms wiki markup into
HTML. Only called for $mOutputType == self::OT_HTML.

param: string $text
param: bool $isMain
param: bool $frame
return: string

doMagicLinks( $text )   X-Ref
Replace special strings like "ISBN xxx" and "RFC xxx" with
magic external links.

DML
param: string $text
return: string

magicLinkCallback( $m )   X-Ref

param: array $m
return: HTML|string

makeFreeExternalLink( $url )   X-Ref
Make a free external link, given a user-supplied URL

param: string $url
return: string HTML

doHeadings( $text )   X-Ref
Parse headers and return html

param: string $text
return: string

doAllQuotes( $text )   X-Ref
Replace single quotes with HTML markup

param: string $text
return: string The altered text

doQuotes( $text )   X-Ref
Helper function for doAllQuotes()

param: string $text
return: string

replaceExternalLinks( $text )   X-Ref
Replace external links (REL)

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

param: string $text
return: string

getExternalLinkRel( $url = false, $title = null )   X-Ref
Get the rel attribute for a particular external link.

param: string|bool $url Optional URL, to extract the domain from for rel =>
param: Title $title Optional Title, for wgNoFollowNsExceptions lookups
return: string|null Rel attribute for $url

getExternalLinkAttribs( $url = false )   X-Ref
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).

param: string|bool $url Optional URL, to extract the domain from for rel =>
return: array Associative array of HTML attributes

replaceUnusualEscapes( $url )   X-Ref
Replace unusual escape codes in a URL with their equivalent characters

param: string $url
return: string

normalizeLinkUrl( $url )   X-Ref
Replace unusual escape codes in a URL with their equivalent characters

This generally follows the syntax defined in RFC 3986, with special
consideration for HTTP query strings.

param: string $url
return: string

normalizeUrlComponent( $component, $unsafe )   X-Ref
No description

maybeMakeExternalImage( $url )   X-Ref
make an image if it's allowed, either through the global
option, through the exception, or through the on-wiki whitelist

param: string $url
return: string

replaceInternalLinks( $s )   X-Ref
Process [[ ]] wikilinks

param: string $s
return: string Processed text

replaceInternalLinks2( &$s )   X-Ref
Process [[ ]] wikilinks (RIL)

param: string $s
return: LinkHolderArray

makeKnownLinkHolder( $nt, $text = '', $query = array()   X-Ref
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.

param: Title $nt
param: string $text
param: array|string $query
param: string $trail
param: string $prefix
return: string HTML-wikitext mix oh yuck

armorLinks( $text )   X-Ref
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.

param: string $text More-or-less HTML
return: string Less-or-more HTML with NOPARSE bits

areSubpagesAllowed()   X-Ref
Return true if subpage links should be expanded on this page.

return: bool

maybeDoSubpageLink( $target, &$text )   X-Ref
Handle link to subpage if necessary

param: string $target The source of the link
param: string &$text The link text, modified as necessary
return: string The full name of the link

closeParagraph()   X-Ref
No description

getCommon( $st1, $st2 )   X-Ref
getCommon() returns the length of the longest common substring
of both arguments, starting at the beginning of both.

param: string $st1
param: string $st2
return: int

openList( $char )   X-Ref
These next three functions open, continue, and close the list
element appropriate to the prefix character passed into them.

param: string $char
return: string

nextItem( $char )   X-Ref
TODO: document

param: string $char
return: string

closeList( $char )   X-Ref

param: string $char
return: string

doBlockLevels( $text, $linestart )   X-Ref
Make lists from lines starting with ':', '*', '#', etc. (DBL)

param: string $text
param: bool $linestart Whether or not this is at the start of a line.
return: string The lists rendered as HTML

findColonNoLinks( $str, &$before, &$after )   X-Ref
Split up a string on ':', ignoring any occurrences inside tags
to prevent illegal overlapping.

param: string $str The string to split
param: string &$before Set to everything before the ':'
param: string &$after Set to everything after the ':'
return: string The position of the ':', or false if none found

getVariableValue( $index, $frame = false )   X-Ref
Return value of a magic variable (like PAGENAME)

param: int $index
param: bool|PPFrame $frame
return: string

initialiseVariables()   X-Ref
initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers


preprocessToDom( $text, $flags = 0 )   X-Ref
Preprocess some wikitext and return the document tree.
This is the ghost of replace_variables().

param: string $text The text to parse
param: int $flags Bitwise combination of:
return: PPNode

splitWhitespace( $s )   X-Ref
Return a three-element array: leading whitespace, string contents, trailing whitespace

param: string $s
return: array

replaceVariables( $text, $frame = false, $argsOnly = false )   X-Ref
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

param: string $text The text to transform
param: bool|PPFrame $frame Object describing the arguments passed to the
param: bool $argsOnly Only do argument (triple-brace) expansion, not
return: string

createAssocArgs( $args )   X-Ref
Clean up argument array - refactored in 1.9 so parserfunctions can use it, too.

param: array $args
return: array

limitationWarn( $limitationType, $current = '', $max = '' )   X-Ref
Warn the user when a parser limitation is reached
Will warn at most once the user per limitation type

param: string $limitationType Should be one of:
param: string|int|null $current Current value
param: string|int|null $max Maximum allowed, when an explicit limit has been

braceSubstitution( $piece, $frame )   X-Ref
Return the text of a template, after recursively
replacing any variables or templates within the template.

param: array $piece The parts of the template
param: PPFrame $frame The current frame, contains template arguments
return: string The text of the template

callParserFunction( $frame, $function, array $args = array()   X-Ref
Call a parser function and return an array with text and flags.

The returned array will always contain a boolean 'found', indicating
whether the parser function was found or not. It may also contain the
following:
text: string|object, resulting wikitext or PP DOM object
isHTML: bool, $text is HTML, armour it against wikitext transformation
isChildObj: bool, $text is a DOM node needing expansion in a child frame
isLocalObj: bool, $text is a DOM node needing expansion in the current frame
nowiki: bool, wiki markup in $text should be escaped

param: PPFrame $frame The current frame, contains template arguments
param: string $function Function name
param: array $args Arguments to the function
return: array

getTemplateDom( $title )   X-Ref
Get the semi-parsed DOM representation of a template with a given title,
and its redirect destination title. Cached.

param: Title $title
return: array

fetchTemplateAndTitle( $title )   X-Ref
Fetch the unparsed text of a template and register a reference to it.

param: Title $title
return: array ( string or false, Title )

fetchTemplate( $title )   X-Ref
Fetch the unparsed text of a template and register a reference to it.

param: Title $title
return: string|bool

statelessFetchTemplate( $title, $parser = false )   X-Ref
Static function to get a template
Can be overridden via ParserOptions::setTemplateCallback().

param: Title $title
param: bool|Parser $parser
return: array

fetchFile( $title, $options = array()   X-Ref
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.

param: Title $title
param: array $options Array of options to RepoGroup::findFile
return: File|bool

fetchFileAndTitle( $title, $options = array()   X-Ref
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.

param: Title $title
param: array $options Array of options to RepoGroup::findFile
return: array ( File or false, Title of file )

fetchFileNoRegister( $title, $options = array()   X-Ref
Helper function for fetchFileAndTitle.

Also useful if you need to fetch a file but not use it yet,
for example to get the file's handler.

param: Title $title
param: array $options Array of options to RepoGroup::findFile
return: File|bool

interwikiTransclude( $title, $action )   X-Ref
Transclude an interwiki link.

param: Title $title
param: string $action
return: string

fetchScaryTemplateMaybeFromCache( $url )   X-Ref

param: string $url
return: mixed|string

argSubstitution( $piece, $frame )   X-Ref
Triple brace replacement -- used for template arguments

param: array $piece
param: PPFrame $frame
return: array

extensionSubstitution( $params, $frame )   X-Ref
Return the text to be used for a given extension tag.
This is the ghost of strip().

param: array $params Associative array of parameters:
param: PPFrame $frame
return: string

incrementIncludeSize( $type, $size )   X-Ref
Increment an include size counter

param: string $type The type of expansion
param: int $size The size of the text
return: bool False if this inclusion would take it over the maximum, true otherwise

incrementExpensiveFunctionCount()   X-Ref
Increment the expensive function count

return: bool False if the limit has been exceeded

doDoubleUnderscore( $text )   X-Ref
Strip double-underscore items like __NOGALLERY__ and __NOTOC__
Fills $this->mDoubleUnderscores, returns the modified text

param: string $text
return: string

addTrackingCategory( $msg )   X-Ref
Add a tracking category, getting the title from a system message,
or print a debug message if the title is invalid.

Please add any message that you use with this function to
$wgTrackingCategories. That way they will be listed on
Special:TrackingCategories.

param: string $msg Message key
return: bool Whether the addition was successful

formatHeadings( $text, $origText, $isMain = true )   X-Ref
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.

param: string $text
param: string $origText Original, untouched wikitext
param: bool $isMain
return: mixed|string

preSaveTransform( $text, Title $title, User $user,ParserOptions $options, $clearState = true)   X-Ref
Transform wiki markup when saving a page by doing "\r\n" -> "\n"
conversion, substitting signatures, {{subst:}} templates, etc.

param: string $text The text to transform
param: Title $title The Title object for the current article
param: User $user The User object describing the current user
param: ParserOptions $options Parsing options
param: bool $clearState Whether to clear the parser state first
return: string The altered wiki markup

pstPass2( $text, $user )   X-Ref
Pre-save transform helper function

param: string $text
param: User $user
return: string

getUserSig( &$user, $nickname = false, $fancySig = null )   X-Ref
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.

param: User $user
param: string|bool $nickname Nickname to use or false to use user's default nickname
param: bool|null $fancySig whether the nicknname is the complete signature
return: string

validateSig( $text )   X-Ref
Check that the user's signature contains no bad XML

param: string $text
return: string|bool An expanded string, or false if invalid.

cleanSig( $text, $parsing = false )   X-Ref
Clean up signature text

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

param: string $text
param: bool $parsing Whether we're cleaning (preferences save) or parsing
return: string Signature text

cleanSigInSig( $text )   X-Ref
Strip ~~~, ~~~~ and ~~~~~ out of signatures

param: string $text
return: string Signature text with /~{3,5}/ removed

startExternalParse( Title $title = null, ParserOptions $options,$outputType, $clearState = true)   X-Ref
Set up some variables which are usually set up in parse()
so that an external function can call some class members with confidence

param: Title|null $title
param: ParserOptions $options
param: int $outputType
param: bool $clearState

startParse( Title $title = null, ParserOptions $options,$outputType, $clearState = true)   X-Ref

param: Title|null $title
param: ParserOptions $options
param: int $outputType
param: bool $clearState

transformMsg( $text, $options, $title = null )   X-Ref
Wrapper for preprocess()

param: string $text The text to preprocess
param: ParserOptions $options Options
param: Title|null $title Title object or null to use $wgTitle
return: string

setHook( $tag, $callback )   X-Ref
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.**

param: string $tag The tag to use, e.g. 'hook' for "<hook>"
param: callable $callback The callback function (and object) to use for the tag
return: callable|null The old value of the mTagHooks array associated with the hook

setTransparentTagHook( $tag, $callback )   X-Ref
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.

param: string $tag The tag to use, e.g. 'hook' for "<hook>"
param: callable $callback The callback function (and object) to use for the tag
return: callable|null The old value of the mTagHooks array associated with the hook

clearTagHooks()   X-Ref
Remove all tag hooks


setFunctionHook( $id, $callback, $flags = 0 )   X-Ref
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

param: string $id The magic word ID
param: callable $callback The callback function (and object) to use
param: int $flags A combination of the following flags:
return: string|callable The old callback function for this name, if any

getFunctionHooks()   X-Ref
Get all registered function hook identifiers

return: array

setFunctionTagHook( $tag, $callback, $flags )   X-Ref
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.

param: string $tag
param: callable $callback
param: int $flags
return: null

replaceLinkHolders( &$text, $options = 0 )   X-Ref

param: string $text
param: int $options
return: array Array of link CSS classes, indexed by PDBK.

replaceLinkHoldersText( $text )   X-Ref
Replace "<!--LINK-->" link placeholders with plain text of links
(not HTML-formatted).

param: string $text
return: string

renderImageGallery( $text, $params )   X-Ref
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'.

param: string $text
param: array $params
return: string HTML

getImageParams( $handler )   X-Ref

param: string $handler
return: array

makeImage( $title, $options, $holders = false )   X-Ref
Parse image options text and use it to make an image

param: Title $title
param: string $options
param: LinkHolderArray|bool $holders
return: string HTML

stripAltText( $caption, $holders )   X-Ref

param: string $caption
param: LinkHolderArray|bool $holders
return: mixed|string

disableCache()   X-Ref
Set a flag in the output object indicating that the content is dynamic and
shouldn't be cached.


attributeStripCallback( &$text, $frame = false )   X-Ref
Callback from the Sanitizer for expanding items found in HTML attribute
values, so they can be safely tested and escaped.

param: string $text
param: bool|PPFrame $frame
return: string

getTags()   X-Ref
Accessor

return: array

replaceTransparentTags( $text )   X-Ref
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.

param: string $text
return: string

extractSections( $text, $sectionId, $mode, $newText = '' )   X-Ref
Break wikitext input into sections, and either pull or replace
some particular section's text.

External callers should use the getSection and replaceSection methods.

param: string $text Page wikitext
param: string|number $sectionId A section identifier string of the form:
param: string $mode One of "get" or "replace"
param: string $newText Replacement text for section data.
return: string For "get", the extracted section text.

getSection( $text, $sectionId, $defaultText = '' )   X-Ref
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.

param: string $text Text to look in
param: string|number $sectionId Section identifier as a number or string
param: string $defaultText Default to return if section is not found
return: string Text of the requested section

replaceSection( $oldText, $sectionId, $newText )   X-Ref
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.

param: string $oldText Former text of the article
param: string|number $sectionId Section identifier as a number or string
param: string $newText Replacing text
return: string Modified text

getRevisionId()   X-Ref
Get the ID of the revision we are parsing

return: int|null

getRevisionObject()   X-Ref
Get the revision object for $this->mRevisionId

return: Revision|null Either a Revision object or null

getRevisionTimestamp()   X-Ref
Get the timestamp associated with the current revision, adjusted for
the default server-local timestamp

return: string

getRevisionUser()   X-Ref
Get the name of the user that edited the last revision

return: string User name

getRevisionSize()   X-Ref
Get the size of the revision

return: int|null Revision size

setDefaultSort( $sort )   X-Ref
Mutator for $mDefaultSort

param: string $sort New value

getDefaultSort()   X-Ref
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.

return: string

getCustomDefaultSort()   X-Ref
Accessor for $mDefaultSort
Unlike getDefaultSort(), will return false if none is set

return: string|bool

guessSectionNameFromWikiText( $text )   X-Ref
Try to guess the section anchor name based on a wikitext fragment
presumably extracted from a heading, for example "Header" from
"== Header ==".

param: string $text
return: string

guessLegacySectionNameFromWikiText( $text )   X-Ref
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.

param: string $text The section name
return: string An anchor

stripSectionName( $text )   X-Ref
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.

param: string $text Text string to be stripped of wikitext
return: string Filtered text string

testSrvus( $text, Title $title, ParserOptions $options, $outputType = self::OT_HTML )   X-Ref
strip/replaceVariables/unstrip for preprocessor regression testing

param: string $text
param: Title $title
param: ParserOptions $options
param: int $outputType
return: string

testPst( $text, Title $title, ParserOptions $options )   X-Ref

param: string $text
param: Title $title
param: ParserOptions $options
return: string

testPreprocess( $text, Title $title, ParserOptions $options )   X-Ref

param: string $text
param: Title $title
param: ParserOptions $options
return: string

markerSkipCallback( $s, $callback )   X-Ref
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.

param: string $s
param: callable $callback
return: string

killMarkers( $text )   X-Ref
Remove any strip markers found in the given text.

param: string $text Input string
return: string

serializeHalfParsedText( $text )   X-Ref
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.

param: string $text
return: array

unserializeHalfParsedText( $data )   X-Ref
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().

param: array $data Serialized data
return: string

isValidHalfParsedText( $data )   X-Ref
Returns true if the given array, presumed to be generated by
serializeHalfParsedText(), is compatible with the current version of the
parser.

param: array $data
return: bool

parseWidthParam( $value )   X-Ref
Parsed a width param of imagelink like 300px or 200x300px

param: string $value
return: array

lock()   X-Ref
Lock the current instance of the parser.

This is meant to stop someone from calling the parser
recursively and messing up all the strip state.

return: ScopedCallback The lock will be released once the return value goes out of scope.

stripOuterParagraph( $html )   X-Ref
Strip outer <p></p> tag from the HTML source of a single paragraph.

Returns original HTML if the <p/> tag has any attributes, if there's no wrapping <p/> tag,
or if there is more than one <p/> tag in the input HTML.

param: string $html
return: string

getFreshParser()   X-Ref
Return this parser if it is not doing anything, otherwise
get a fresh parser. You can use this method by doing
$myParser = $wgParser->getFreshParser(), or more simply
$wgParser->getFreshParser()->parse( ... );
if you're unsure if $wgParser is safe to use.

return: Parser A parser object that is not parsing anything



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1