BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
OutputPage Class Reference
Inheritance diagram for OutputPage:
Collaboration diagram for OutputPage:

Public Member Functions

 __construct (IContextSource $context)
 
 redirect ($url, $responsecode= '302')
 
 getRedirect ()
 
 setCopyrightUrl ($url)
 
 setStatusCode ($statusCode)
 
 addMeta ($name, $val)
 
 getMetaTags ()
 
 addLink (array $linkarr)
 
 getLinkTags ()
 
 addMetadataLink (array $linkarr)
 
 setCanonicalUrl ($url)
 
 getCanonicalUrl ()
 
 getMetadataAttribute ()
 
 addScript ($script)
 
 addScriptFile ($file, $version=null)
 
 addInlineScript ($script)
 
 getModules ($filter=false, $position=null, $param= 'mModules', $type=ResourceLoaderModule::TYPE_COMBINED)
 
 addModules ($modules)
 
 getModuleScripts ($filter=false, $position=null)
 
 addModuleScripts ($modules)
 
 getModuleStyles ($filter=false, $position=null)
 
 addModuleStyles ($modules)
 
 getTarget ()
 
 setTarget ($target)
 
 addContentOverride (LinkTarget $target, Content $content)
 
 addContentOverrideCallback (callable $callback)
 
 getHeadItemsArray ()
 
 addHeadItem ($name, $value)
 
 addHeadItems ($values)
 
 hasHeadItem ($name)
 
 addBodyClasses ($classes)
 
 setArticleBodyOnly ($only)
 
 getArticleBodyOnly ()
 
 setProperty ($name, $value)
 
 getProperty ($name)
 
 checkLastModified ($timestamp)
 
 setLastModified ($timestamp)
 
 setRobotPolicy ($policy)
 
 setIndexPolicy ($policy)
 
 setFollowPolicy ($policy)
 
 setPageTitleActionText ($text)
 
 getPageTitleActionText ()
 
 setHTMLTitle ($name)
 
 getHTMLTitle ()
 
 setRedirectedFrom ($t)
 
 setPageTitle ($name)
 
 getPageTitle ()
 
 setTitle (Title $t)
 
 setSubtitle ($str)
 
 addSubtitle ($str)
 
 addBacklinkSubtitle (Title $title, $query=[])
 
 clearSubtitle ()
 
 getSubtitle ()
 
 setPrintable ()
 
 isPrintable ()
 
 disable ()
 
 isDisabled ()
 
 showNewSectionLink ()
 
 forceHideNewSectionLink ()
 
 setSyndicated ($show=true)
 
 setFeedAppendQuery ($val)
 
 addFeedLink ($format, $href)
 
 isSyndicated ()
 
 getSyndicationLinks ()
 
 getFeedAppendQuery ()
 
 setArticleFlag ($v)
 
 isArticle ()
 
 setArticleRelated ($v)
 
 isArticleRelated ()
 
 addLanguageLinks (array $newLinkArray)
 
 setLanguageLinks (array $newLinkArray)
 
 getLanguageLinks ()
 
 addCategoryLinks (array $categories)
 
 setCategoryLinks (array $categories)
 
 getCategoryLinks ()
 
 getCategories ($type= 'all')
 
 setIndicators (array $indicators)
 
 getIndicators ()
 
 addHelpLink ($to, $overrideBaseUrl=false)
 
 disallowUserJs ()
 
 getAllowedModules ($type)
 
 reduceAllowedModules ($type, $level)
 
 prependHTML ($text)
 
 addHTML ($text)
 
 addElement ($element, array $attribs=[], $contents= '')
 
 clearHTML ()
 
 getHTML ()
 
 parserOptions ($options=null)
 
 setRevisionId ($revid)
 
 getRevisionId ()
 
 setRevisionTimestamp ($timestamp)
 
 getRevisionTimestamp ()
 
 setFileVersion ($file)
 
 getFileVersion ()
 
 getTemplateIds ()
 
 getFileSearchOptions ()
 
 addWikiText ($text, $linestart=true, $interface=true)
 
 addWikiTextWithTitle ($text, &$title, $linestart=true)
 
 addWikiTextTitleTidy ($text, &$title, $linestart=true)
 
 addWikiTextTidy ($text, $linestart=true)
 
 addWikiTextTitle ($text, Title $title, $linestart, $tidy=false, $interface=false)
 
 addParserOutputMetadata ($parserOutput)
 
 addParserOutputContent ($parserOutput, $poOptions=[])
 
 addParserOutputText ($parserOutput, $poOptions=[])
 
 addParserOutput ($parserOutput, $poOptions=[])
 
 addTemplate (&$template)
 
 parse ($text, $linestart=true, $interface=false, $language=null)
 
 parseInline ($text, $linestart=true, $interface=false)
 
 setCdnMaxage ($maxage)
 
 lowerCdnMaxage ($maxage)
 
 adaptCdnTTL ($mtime, $minTTL=0, $maxTTL=0)
 
 enableClientCache ($state)
 
 getCacheVaryCookies ()
 
 haveCacheVaryCookies ()
 
 addVaryHeader ($header, array $option=null)
 
 getVaryHeader ()
 
 addLinkHeader ($header)
 
 getLinkHeader ()
 
 getKeyHeader ()
 
 addAcceptLanguage ()
 
 preventClickjacking ($enable=true)
 
 allowClickjacking ()
 
 getPreventClickjacking ()
 
 getFrameOptions ()
 
 sendCacheControl ()
 
 loadSkinModules ($sk)
 
 output ($return=false)
 
 prepareErrorPage ($pageTitle, $htmlTitle=false)
 
 showErrorPage ($title, $msg, $params=[])
 
 showPermissionsErrorPage (array $errors, $action=null)
 
 versionRequired ($version)
 
 formatPermissionsErrorMessage (array $errors, $action=null)
 
 showLagWarning ($lag)
 
 showFatalError ($message)
 
 showUnexpectedValueError ($name, $val)
 
 showFileCopyError ($old, $new)
 
 showFileRenameError ($old, $new)
 
 showFileDeleteError ($name)
 
 showFileNotFoundError ($name)
 
 addReturnTo ($title, array $query=[], $text=null, $options=[])
 
 returnToMain ($unused=null, $returnto=null, $returntoquery=null)
 
 getRlClient ()
 
 headElement (Skin $sk, $includeStyle=true)
 
 getResourceLoader ()
 
 makeResourceLoaderLink ($modules, $only, array $extraQuery=[])
 
 getBottomScripts ()
 
 getJsConfigVars ()
 
 addJsConfigVars ($keys, $value=null)
 
 getJSVars ()
 
 userCanPreview ()
 
 getHeadLinksArray ()
 
 addStyle ($style, $media= '', $condition= '', $dir= '')
 
 addInlineStyle ($style_css, $flip= 'noflip')
 
 buildCssLinksArray ()
 
 addWikiMsg ()
 
 addWikiMsgArray ($name, $args)
 
 wrapWikiMsg ($wrap)
 
 isTOCEnabled ()
 
 enableSectionEditLinks ($flag=true)
 
 sectionEditLinksEnabled ()
 
 enableOOUI ()
 
- Public Member Functions inherited from ContextSource
 getContext ()
 
 setContext (IContextSource $context)
 
 getConfig ()
 
 getRequest ()
 
 getTitle ()
 
 canUseWikiPage ()
 
 getWikiPage ()
 
 getOutput ()
 
 getUser ()
 
 getLanguage ()
 
 getSkin ()
 
 getTiming ()
 
 getStats ()
 
 msg ($key)
 
 exportSession ()
 

Static Public Member Functions

static buildBacklinkSubtitle (Title $title, $query=[])
 
static transformResourcePath (Config $config, $path)
 
static transformFilePath ($remotePathPrefix, $localPath, $file)
 
static transformCssMedia ($media)
 
static setupOOUI ($skinName= 'default', $dir= 'ltr')
 

Public Attributes

 $mPagetitle = ''
 
 $mBodytext = ''
 
 $mRedirect = ''
 
 $mPageLinkTitle = ''
 
 $mRedirectCode = ''
 
 $mNoGallery = false
 

Protected Member Functions

 filterModules (array $modules, $position=null, $type=ResourceLoaderModule::TYPE_COMBINED)
 
 addCategoryLinksToLBAndGetResult (array $categories)
 
 buildExemptModules ()
 
 styleLink ($style, array $options)
 
 addLogoPreloadLinkHeaders ()
 

Static Protected Member Functions

static combineWrappedStrings (array $chunks)
 

Protected Attributes

 $mMetatags = []
 
 $mLinktags = []
 
 $mCanonicalUrl = false
 
 $mStatusCode
 
 $mLastModified = ''
 
 $mCategoryLinks = []
 
 $mCategories
 
 $mIndicators = []
 
 $mInlineStyles = ''
 
 $mHeadItems = []
 
 $mAdditionalBodyClasses = []
 
 $mModules = []
 
 $mModuleScripts = []
 
 $mModuleStyles = []
 
 $mResourceLoader
 
 $mJsConfigVars = []
 
 $mTemplateIds = []
 
 $mImageTimeKeys = []
 
 $mFeedLinksAppendQuery = null
 
 $mAllowedModules
 
 $mDoNothing = false
 
 $mContainsNewMagic = 0
 
 $mParserOptions = null
 
 $mEnableClientCache = true
 
 $mNewSectionLink = false
 
 $mHideNewSectionLink = false
 
 $mCdnMaxage = 0
 
 $mCdnMaxageLimit = INF
 
 $mPreventClickjacking = true
 
 $mFileVersion = null
 
 $styles = []
 

Detailed Description

This class should be covered by a general architecture document which does not exist as of January 2011. This is one of the Core classes and should be read at least once by any new developers.

This class is used to prepare the final rendering. A skin is then applied to the output parameters (links, javascript, html, categories ...).

Todo:
FIXME: Another class handles sending the whole page to the client.

Some comments comes from a pairing session between Zak Greant and Antoine Musso in November 2010.

Todo:
document

Constructor & Destructor Documentation

OutputPage::__construct ( IContextSource  $context)

Constructor for OutputPage. This should not be called directly. Instead a new RequestContext should be created and it will implicitly create a OutputPage tied to that context.

Parameters
IContextSource$context

Member Function Documentation

OutputPage::adaptCdnTTL (   $mtime,
  $minTTL = 0,
  $maxTTL = 0 
)

Get TTL in [$minTTL,$maxTTL] in pass it to lowerCdnMaxage()

This sets and returns $minTTL if $mtime is false or null. Otherwise, the TTL is higher the older the $mtime timestamp is. Essentially, the TTL is 90% of the age of the object, subject to the min and max.

Parameters
string | int | float | bool | null$mtimeLast-Modified timestamp
int$minTTLMimimum TTL in seconds [default: 1 minute]
int$maxTTLMaximum TTL in seconds [default: $wgSquidMaxage]
Returns
int TTL in seconds
Since
1.28
OutputPage::addAcceptLanguage ( )

T23672: Add Accept-Language to Vary and Key headers if there's no 'variant' parameter existed in GET.

For example: /w/index.php?title=Main_page should always be served; but /w/index.php?title=Main_page&variant=zh-cn should never be served.

OutputPage::addBacklinkSubtitle ( Title  $title,
  $query = [] 
)

Add a subtitle containing a backlink to a page

Parameters
Title$titleTitle to link to
array$queryArray of additional parameters to include in the link
OutputPage::addBodyClasses (   $classes)

Add a class to the <body> element

Since
1.30
Parameters
string|string[]$classes One or more classes to add
OutputPage::addCategoryLinks ( array  $categories)

Add an array of categories, with names in the keys

Parameters
array$categoriesMapping category name => sort key
OutputPage::addCategoryLinksToLBAndGetResult ( array  $categories)
protected
Parameters
array$categories
Returns
bool|ResultWrapper
OutputPage::addContentOverride ( LinkTarget  $target,
Content  $content 
)

Add a mapping from a LinkTarget to a Content, for things like page preview.

See Also
self::addContentOverrideCallback()
Since
1.32
Parameters
LinkTarget$target
Content$content
OutputPage::addContentOverrideCallback ( callable  $callback)

Add a callback for mapping from a Title to a Content object, for things like page preview.

See Also
ResourceLoaderContext::getContentOverrideCallback()
Since
1.32
Parameters
callable$callback
OutputPage::addElement (   $element,
array  $attribs = [],
  $contents = '' 
)

Shortcut for adding an Html::element via addHTML.

Since
1.19
Parameters
string$element
array$attribs
string$contents
OutputPage::addFeedLink (   $format,
  $href 
)

Add a feed link to the page header

Parameters
string$formatFeed type, should be a key of $wgFeedClasses
string$hrefURL
OutputPage::addHeadItem (   $name,
  $value 
)

Add or replace a head item to the output

Whenever possible, use more specific options like ResourceLoader modules, OutputPage::addLink(), OutputPage::addMetaLink() and OutputPage::addFeedLink() Fallback options for those are: OutputPage::addStyle, OutputPage::addScript(), OutputPage::addInlineScript() and OutputPage::addInlineStyle() This would be your very LAST fallback.

Parameters
string$nameItem name
string$valueRaw HTML
OutputPage::addHeadItems (   $values)

Add one or more head items to the output

Since
1.28
Parameters
string|string[]$values Raw HTML
OutputPage::addHelpLink (   $to,
  $overrideBaseUrl = false 
)

Adds help link with an icon via page indicators. Link target can be overridden by a local message containing a wikilink: the message key is: lowercase action or special page name + '-helppage'.

Parameters
string$toTarget MediaWiki.org page title or encoded URL.
bool$overrideBaseUrlWhether $url is a full URL, to avoid MW.o.
Since
1.25
OutputPage::addHTML (   $text)

Append $text to the body HTML

Parameters
string$textHTML
OutputPage::addInlineScript (   $script)

Add a self-contained script tag with the given contents Internal use only. Use OutputPage::addModules() if possible.

Parameters
string$scriptJavaScript text, no script tags
OutputPage::addInlineStyle (   $style_css,
  $flip = 'noflip' 
)

Adds inline CSS styles Internal use only. Use OutputPage::addModuleStyles() if possible.

Parameters
mixed$style_cssInline CSS
string$flipSet to 'flip' to flip the CSS if needed
OutputPage::addJsConfigVars (   $keys,
  $value = null 
)

Add one or more variables to be set in mw.config in JavaScript

Parameters
string | array$keysKey or array of key/value pairs
mixed$value[optional] Value of the configuration variable
OutputPage::addLanguageLinks ( array  $newLinkArray)

Add new language links

Parameters
string[]$newLinkArray Array of interwiki-prefixed (non DB key) titles (e.g. 'fr:Test page')
OutputPage::addLink ( array  $linkarr)

Add a new <link> tag to the page header.

Note: use setCanonicalUrl() for rel=canonical.

Parameters
array$linkarrAssociative array of attributes.
OutputPage::addLinkHeader (   $header)

Add an HTTP Link: header

Parameters
string$headerHeader value
OutputPage::addLogoPreloadLinkHeaders ( )
protected

Add Link headers for preloading the wiki's logo.

Since
1.26
OutputPage::addMeta (   $name,
  $val 
)

Add a new "<meta>" tag To add an http-equiv meta tag, precede the name with "http:"

Parameters
string$nameName of the meta tag
string$valValue of the meta tag
OutputPage::addMetadataLink ( array  $linkarr)

Add a new <link> with "rel" attribute set to "meta"

Parameters
array$linkarrAssociative array mapping attribute names to their values, both keys and values will be escaped, and the "rel" attribute will be automatically added
OutputPage::addModules (   $modules)

Add one or more modules recognized by ResourceLoader. Modules added through this function will be loaded by ResourceLoader when the page loads.

Parameters
string | array$modulesModule name (string) or array of module names
OutputPage::addModuleScripts (   $modules)

Add only JS of one or more modules recognized by ResourceLoader. Module scripts added through this function will be loaded by ResourceLoader when the page loads.

Parameters
string | array$modulesModule name (string) or array of module names
OutputPage::addModuleStyles (   $modules)

Add only CSS of one or more modules recognized by ResourceLoader.

Module styles added through this function will be added using standard link CSS tags, rather than as a combined Javascript and CSS package. Thus, they will load when JavaScript is disabled (unless CSS also happens to be disabled).

Parameters
string | array$modulesModule name (string) or array of module names
OutputPage::addParserOutput (   $parserOutput,
  $poOptions = [] 
)

Add everything from a ParserOutput object.

Parameters
ParserOutput$parserOutput
array$poOptionsOptions to ParserOutput::getText()
OutputPage::addParserOutputContent (   $parserOutput,
  $poOptions = [] 
)

Add the HTML and enhancements for it (like ResourceLoader modules) associated with a ParserOutput object, without any other metadata.

Since
1.24
Parameters
ParserOutput$parserOutput
array$poOptionsOptions to ParserOutput::getText()
OutputPage::addParserOutputMetadata (   $parserOutput)

Add all metadata associated with a ParserOutput object, but without the actual HTML. This includes categories, language links, ResourceLoader modules, effects of certain magic words, and so on.

Since
1.24
Parameters
ParserOutput$parserOutput
OutputPage::addParserOutputText (   $parserOutput,
  $poOptions = [] 
)

Add the HTML associated with a ParserOutput object, without any metadata.

Since
1.24
Parameters
ParserOutput$parserOutput
array$poOptionsOptions to ParserOutput::getText()
OutputPage::addReturnTo (   $title,
array  $query = [],
  $text = null,
  $options = [] 
)

Add a "return to" link pointing to a specified title

Parameters
Title$titleTitle to link
array$queryQuery string parameters
string$textText of the link (input is not escaped)
array$optionsOptions array to pass to Linker
OutputPage::addScript (   $script)

Add raw HTML to the list of scripts (including <script> tag, etc.) Internal use only. Use OutputPage::addModules() or OutputPage::addJsConfigVars() if possible.

Parameters
string$scriptRaw HTML
OutputPage::addScriptFile (   $file,
  $version = null 
)

Add a JavaScript file out of skins/common, or a given relative path. Internal use only. Use OutputPage::addModules() if possible.

Parameters
string$fileFilename in skins/common or complete on-server path (/foo/bar.js)
string$versionStyle version of the file. Defaults to $wgStyleVersion
OutputPage::addStyle (   $style,
  $media = '',
  $condition = '',
  $dir = '' 
)

Add a local or specified stylesheet, with the given media options. Internal use only. Use OutputPage::addModuleStyles() if possible.

Parameters
string$styleURL to the file
string$mediaTo specify a media type, 'screen', 'printable', 'handheld' or any.
string$conditionFor IE conditional comments, specifying an IE version
string$dirSet to 'rtl' or 'ltr' for direction-specific sheets
OutputPage::addSubtitle (   $str)

Add $str to the subtitle

Parameters
string | Message$strString or Message to add to the subtitle. String should be safe HTML.
OutputPage::addTemplate ( $template)

Add the output of a QuickTemplate to the output buffer

Parameters
QuickTemplate&$template
OutputPage::addVaryHeader (   $header,
array  $option = null 
)

Add an HTTP header that will influence on the cache

Parameters
string$headerHeader name
string[]|null$option Options for the Key header. See https://datatracker.ietf.org/doc/draft-fielding-http-key/ for the list of valid options.
OutputPage::addWikiMsg ( )

Add a wikitext-formatted message to the output. This is equivalent to:

$wgOut->addWikiText( wfMessage( ... )->plain() )

OutputPage::addWikiMsgArray (   $name,
  $args 
)

Add a wikitext-formatted message to the output. Like addWikiMsg() except the parameters are taken as an array instead of a variable argument list.

Parameters
string$name
array$args
OutputPage::addWikiText (   $text,
  $linestart = true,
  $interface = true 
)

Convert wikitext to HTML and add it to the buffer Default assumes that the current page title will be used.

Parameters
string$text
bool$linestartIs this the start of a line?
bool$interfaceIs this text in the user interface language?
Exceptions
MWException
OutputPage::addWikiTextTidy (   $text,
  $linestart = true 
)

Add wikitext with tidy enabled

Parameters
string$textWikitext
bool$linestartIs this the start of a line?
OutputPage::addWikiTextTitle (   $text,
Title  $title,
  $linestart,
  $tidy = false,
  $interface = false 
)

Add wikitext with a custom Title object

Parameters
string$textWikitext
Title$title
bool$linestartIs this the start of a line?
bool$tidyWhether to use tidy
bool$interfaceWhether it is an interface message (for example disables conversion)
OutputPage::addWikiTextTitleTidy (   $text,
$title,
  $linestart = true 
)

Add wikitext with a custom Title object and tidy enabled.

Parameters
string$textWikitext
Title&$title
bool$linestartIs this the start of a line?
OutputPage::addWikiTextWithTitle (   $text,
$title,
  $linestart = true 
)

Add wikitext with a custom Title object

Parameters
string$textWikitext
Title&$title
bool$linestartIs this the start of a line?
OutputPage::allowClickjacking ( )

Turn off frame-breaking. Alias for $this->preventClickjacking(false). This can be called from pages which do not contain any CSRF-protected HTML form.

static OutputPage::buildBacklinkSubtitle ( Title  $title,
  $query = [] 
)
static

Build message object for a subtitle containing a backlink to a page

Parameters
Title$titleTitle to link to
array$queryArray of additional parameters to include in the link
Returns
Message
Since
1.25
OutputPage::buildCssLinksArray ( )
Returns
array
OutputPage::buildExemptModules ( )
protected

Build exempt modules and legacy non-ResourceLoader styles.

Returns
string|WrappedStringList HTML
OutputPage::checkLastModified (   $timestamp)

checkLastModified tells the client to use the client-cached page if possible. If successful, the OutputPage is disabled so that any future call to OutputPage->output() have no effect.

Side effect: sets mLastModified for Last-Modified header

Parameters
string$timestamp
Returns
bool True if cache-ok headers was sent.
OutputPage::clearHTML ( )

Clear the body HTML

OutputPage::clearSubtitle ( )

Clear the subtitles

static OutputPage::combineWrappedStrings ( array  $chunks)
staticprotected

Combine WrappedString chunks and filter out empty ones

Parameters
array$chunks
Returns
string|WrappedStringList HTML
OutputPage::disable ( )

Disable output completely, i.e. calling output() will have no effect

OutputPage::disallowUserJs ( )

Do not allow scripts which can be modified by wiki users to load on this page; only allow scripts bundled with, or generated by, the software. Site-wide styles are controlled by a config setting, since they can be used to create a custom skin/theme, but not user-specific ones.

Todo:
this should be given a more accurate name
OutputPage::enableClientCache (   $state)

Use enableClientCache(false) to force it to send nocache headers

Parameters
bool$state
Returns
bool
OutputPage::enableOOUI ( )

Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with MediaWiki and this OutputPage instance.

Since
1.25
OutputPage::enableSectionEditLinks (   $flag = true)

Enables/disables section edit links, doesn't override NOEDITSECTION

Parameters
bool$flag
Since
1.23
Deprecated:
since 1.31, use $poOptions to addParserOutput() instead.
OutputPage::filterModules ( array  $modules,
  $position = null,
  $type = ResourceLoaderModule::TYPE_COMBINED 
)
protected

Filter an array of modules to remove insufficiently trustworthy members, and modules which are no longer registered (eg a page is cached before an extension is disabled)

Parameters
array$modules
string | null$positionUnused
string$type
Returns
array
OutputPage::forceHideNewSectionLink ( )

Forcibly hide the new section link?

Returns
bool
OutputPage::formatPermissionsErrorMessage ( array  $errors,
  $action = null 
)

Format a list of error messages

Parameters
array$errorsArray of arrays returned by Title::getUserPermissionsErrors
string$actionAction that was denied or null if unknown
Returns
string The wikitext error-messages, formatted into a list.
OutputPage::getAllowedModules (   $type)

Show what level of JavaScript / CSS untrustworthiness is allowed on this page

See Also
ResourceLoaderModule::$origin
Parameters
string$typeResourceLoaderModule TYPE_ constant
Returns
int ResourceLoaderModule ORIGIN_ class constant
OutputPage::getArticleBodyOnly ( )

Return whether the output will contain only the body of the article

Returns
bool
OutputPage::getBottomScripts ( )

JS stuff to put at the bottom of the <body>. These are legacy scripts ($this->mScripts), and user JS.

Returns
string|WrappedStringList HTML
OutputPage::getCacheVaryCookies ( )

Get the list of cookies that will influence on the cache

Returns
array
OutputPage::getCanonicalUrl ( )

Returns the URL to be used for the <link rel="canonical"> if one is set.

Since
1.25
Returns
bool|string
OutputPage::getCategories (   $type = 'all')

Get the list of category names this page belongs to.

Parameters
string$typeThe type of categories which should be returned. Possible values:
  • all: all categories of all types
  • hidden: only the hidden categories
  • normal: all categories, except hidden categories
Returns
array Array of strings
OutputPage::getCategoryLinks ( )

Get the list of category links, in a 2-D array with the following format: $arr[$type][] = $link, where $type is either "normal" or "hidden" (for hidden categories) and $link a HTML fragment with a link to the category page

Returns
array
OutputPage::getFeedAppendQuery ( )

Will currently always return null

Returns
null
OutputPage::getFileSearchOptions ( )

Get the files used on this page

Returns
array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or ''))
Since
1.18
OutputPage::getFileVersion ( )

Get the displayed file version

Returns
array|null ('time' => MW timestamp, 'sha1' => sha1)
OutputPage::getFrameOptions ( )

Get the X-Frame-Options header value (without the name part), or false if there isn't one. This is used by Skin to determine whether to enable JavaScript frame-breaking, for clients that don't support X-Frame-Options.

Returns
string|false
OutputPage::getHeadItemsArray ( )

Get an array of head items

Returns
array
OutputPage::getHeadLinksArray ( )
Returns
array Array in format "link name or number => 'link html'".
OutputPage::getHTML ( )

Get the body HTML

Returns
string HTML
OutputPage::getHTMLTitle ( )

Return the "HTML title", i.e. the content of the "<title>" tag.

Returns
string
OutputPage::getIndicators ( )

Get the indicators associated with this page.

The array will be internally ordered by item keys.

Returns
array Keys: identifiers, values: HTML contents
Since
1.25
OutputPage::getJsConfigVars ( )

Get the javascript config vars to include on this page

Returns
array Array of javascript config vars
Since
1.23
OutputPage::getJSVars ( )

Get an array containing the variables to be set in mw.config in JavaScript.

Do not add things here which can be evaluated in ResourceLoaderStartUpModule

  • in other words, page-independent/site-wide variables (without state). You will only be adding bloat to the html page and causing page caches to have to be purged on configuration changes.
    Returns
    array
OutputPage::getKeyHeader ( )

Get a complete Key header

Returns
string
OutputPage::getLanguageLinks ( )

Get the list of language links

Returns
string[] Array of interwiki-prefixed (non DB key) titles (e.g. 'fr:Test page')
OutputPage::getLinkHeader ( )

Return a Link: header. Based on the values of $mLinkHeader.

Returns
string
OutputPage::getLinkTags ( )

Returns the current <link> tags

Since
1.25
Returns
array
OutputPage::getMetadataAttribute ( )

Get the value of the "rel" attribute for metadata links

Returns
string
OutputPage::getMetaTags ( )

Returns the current <meta> tags

Since
1.25
Returns
array
OutputPage::getModules (   $filter = false,
  $position = null,
  $param = 'mModules',
  $type = ResourceLoaderModule::TYPE_COMBINED 
)

Get the list of modules to include on this page

Parameters
bool$filterWhether to filter out insufficiently trustworthy modules
string | null$positionUnused
string$param
string$type
Returns
array Array of module names
OutputPage::getModuleScripts (   $filter = false,
  $position = null 
)

Get the list of module JS to include on this page

Parameters
bool$filter
string | null$positionUnused
Returns
array Array of module names
OutputPage::getModuleStyles (   $filter = false,
  $position = null 
)

Get the list of module CSS to include on this page

Parameters
bool$filter
string | null$positionUnused
Returns
array Array of module names
OutputPage::getPageTitle ( )

Return the "page title", i.e. the content of the <h1> tag.

Returns
string
OutputPage::getPageTitleActionText ( )

Get the value of the "action text"

Returns
string
OutputPage::getPreventClickjacking ( )

Get the prevent-clickjacking flag

Since
1.24
Returns
bool
OutputPage::getProperty (   $name)

Get an additional output property

Since
1.21
Parameters
string$name
Returns
mixed Property value or null if not found
OutputPage::getRedirect ( )

Get the URL to redirect to, or an empty string if not redirect URL set

Returns
string
OutputPage::getResourceLoader ( )

Get a ResourceLoader object associated with this OutputPage

Returns
ResourceLoader
OutputPage::getRevisionId ( )

Get the displayed revision ID

Returns
int
OutputPage::getRevisionTimestamp ( )

Get the timestamp of displayed revision. This will be null if not filled by setRevisionTimestamp().

Returns
string|null
OutputPage::getRlClient ( )

Call this to freeze the module queue and JS config and create a formatter.

Depending on the Skin, this may get lazy-initialised in either headElement() or getBottomScripts(). See SkinTemplate::prepareQuickTemplate(). Calling this too early may cause unexpected side-effects since disallowUserJs() may be called at any time to change the module filters retroactively. Skins and extension hooks may also add modules until very late in the request lifecycle.

Returns
ResourceLoaderClientHtml
OutputPage::getSubtitle ( )

Get the subtitle

Returns
string
OutputPage::getSyndicationLinks ( )

Return URLs for each supported syndication format for this page.

Returns
array Associating format keys with URLs
OutputPage::getTarget ( )
Returns
null|string ResourceLoader target
OutputPage::getTemplateIds ( )

Get the templates used on this page

Returns
array (namespace => dbKey => revId)
Since
1.18
OutputPage::getVaryHeader ( )

Return a Vary: header on which to vary caches. Based on the keys of $mVaryHeader, such as Accept-Encoding or Cookie

Returns
string
OutputPage::hasHeadItem (   $name)

Check if the header item $name is already set

Parameters
string$nameItem name
Returns
bool
OutputPage::haveCacheVaryCookies ( )

Check if the request has a cache-varying cookie header If it does, it's very important that we don't allow public caching

Returns
bool
OutputPage::headElement ( Skin  $sk,
  $includeStyle = true 
)
Parameters
Skin$skThe given Skin
bool$includeStyleUnused
Returns
string The doctype, opening "<html>", and head element.
OutputPage::isArticle ( )

Return whether the content displayed page is related to the source of the corresponding article on the wiki

Returns
bool
OutputPage::isArticleRelated ( )

Return whether this page is related an article on the wiki

Returns
bool
OutputPage::isDisabled ( )

Return whether the output will be completely disabled

Returns
bool
bool We have to set OutputPage::isPrintable ( )

Return whether the page is "printable"

Returns
bool

never be printed (ex: redirections).

OutputPage::isSyndicated ( )

Should we output feed links for this page?

Returns
bool
OutputPage::isTOCEnabled ( )

Whether the output has a table of contents

Returns
bool
Since
1.22
OutputPage::loadSkinModules (   $sk)

Transfer styles and JavaScript modules from skin.

Parameters
Skin$skto load modules for
OutputPage::lowerCdnMaxage (   $maxage)

Lower the value of the "s-maxage" part of the "Cache-control" HTTP header

Parameters
int$maxageMaximum cache time on the CDN, in seconds
Since
1.27
OutputPage::makeResourceLoaderLink (   $modules,
  $only,
array  $extraQuery = [] 
)

Explicily load or embed modules on a page.

Parameters
array | string$modulesOne or more module names
string$onlyResourceLoaderModule TYPE_ class constant
array$extraQuery[optional] Array with extra query parameters for the request
Returns
string|WrappedStringList HTML
OutputPage::output (   $return = false)

Finally, all the text has been munged and accumulated into the object, let's actually output it:

Parameters
bool$returnSet to true to get the result as a string rather than sending it
Returns
string|null
Exceptions
Exception
FatalError
MWException
OutputPage::parse (   $text,
  $linestart = true,
  $interface = false,
  $language = null 
)

Parse wikitext and return the HTML.

Parameters
string$text
bool$linestartIs this the start of a line?
bool$interfaceUse interface language ($wgLang instead of $wgContLang) while parsing language sensitive magic words like GRAMMAR and PLURAL. This also disables LanguageConverter.
Language$languageTarget language object, will override $interface
Exceptions
MWException
Returns
string HTML
OutputPage::parseInline (   $text,
  $linestart = true,
  $interface = false 
)

Parse wikitext, strip paragraphs, and return the HTML.

Parameters
string$text
bool$linestartIs this the start of a line?
bool$interfaceUse interface language ($wgLang instead of $wgContLang) while parsing language sensitive magic words like GRAMMAR and PLURAL
Returns
string HTML
OutputPage::parserOptions (   $options = null)

Get/set the ParserOptions object to use for wikitext parsing

Parameters
ParserOptions | null$optionsEither the ParserOption to use or null to only get the current ParserOption object. This parameter is deprecated since 1.31.
Returns
ParserOptions
OutputPage::prepareErrorPage (   $pageTitle,
  $htmlTitle = false 
)

Prepare this object to display an error page; disable caching and indexing, clear the current text and redirect, set the page's title and optionally an custom HTML title (content of the "<title>" tag).

Parameters
string | Message$pageTitleWill be passed directly to setPageTitle()
string | Message$htmlTitleWill be passed directly to setHTMLTitle(); optional, if not passed the "<title>" attribute will be based on $pageTitle
OutputPage::prependHTML (   $text)

Prepend $text to the body HTML

Parameters
string$textHTML
OutputPage::preventClickjacking (   $enable = true)

Set a flag which will cause an X-Frame-Options header appropriate for edit pages to be sent. The header value is controlled by $wgEditPageFrameOptions.

This is the default for special pages. If you display a CSRF-protected form on an ordinary view page, then you need to call this function.

Parameters
bool$enable
OutputPage::redirect (   $url,
  $responsecode = '302' 
)

Redirect to $url rather than displaying the normal page

Parameters
string$url
string$responsecodeHTTP status code
OutputPage::reduceAllowedModules (   $type,
  $level 
)

Limit the highest level of CSS/JS untrustworthiness allowed.

If passed the same or a higher level than the current level of untrustworthiness set, the level will remain unchanged.

Parameters
string$type
int$levelResourceLoaderModule class constant
OutputPage::returnToMain (   $unused = null,
  $returnto = null,
  $returntoquery = null 
)

Add a "return to" link pointing to a specified title, or the title indicated in the request, or else the main page

Parameters
mixed$unused
Title | string$returntoTitle or String to return to
string$returntoqueryQuery string for the return to link
OutputPage::sectionEditLinksEnabled ( )
Returns
bool
Since
1.23
Deprecated:
since 1.31, use $poOptions to addParserOutput() instead.
OutputPage::sendCacheControl ( )

Send cache control HTTP headers

OutputPage::setArticleBodyOnly (   $only)

Set whether the output should only contain the body of the article, without any skin, sidebar, etc. Used e.g. when calling with "action=render".

Parameters
bool$onlyWhether to output only the body of the article
OutputPage::setArticleFlag (   $v)

Set whether the displayed content is related to the source of the corresponding article on the wiki Setting true will cause the change "article related" toggle to true

Parameters
bool$v
OutputPage::setArticleRelated (   $v)

Set whether this page is related an article on the wiki Setting false will cause the change of "article flag" toggle to false

Parameters
bool$v
OutputPage::setCanonicalUrl (   $url)

Set the URL to be used for the <link rel="canonical">. This should be used in preference to addLink(), to avoid duplicate link tags.

Parameters
string$url
OutputPage::setCategoryLinks ( array  $categories)

Reset the category links (but not the category list) and add $categories

Parameters
array$categoriesMapping category name => sort key
OutputPage::setCdnMaxage (   $maxage)

Set the value of the "s-maxage" part of the "Cache-control" HTTP header

Parameters
int$maxageMaximum cache time on the CDN, in seconds.
OutputPage::setCopyrightUrl (   $url)

Set the copyright URL to send with the output. Empty string to omit, null to reset.

Since
1.26
Parameters
string | null$url
OutputPage::setFeedAppendQuery (   $val)

Add default feeds to the page header This is mainly kept for backward compatibility, see OutputPage::addFeedLink() for the new version

See Also
addFeedLink()
Parameters
string$valQuery to append to feed links or false to output default links
OutputPage::setFileVersion (   $file)

Set the displayed file version

Parameters
File | bool$file
Returns
mixed Previous value
OutputPage::setFollowPolicy (   $policy)

Set the follow policy for the page, but leave the index policy un- touched.

Parameters
string$policyEither 'follow' or 'nofollow'.
Returns
null
OutputPage::setHTMLTitle (   $name)

"HTML title" means the contents of "<title>". It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file.

Parameters
string | Message$name
OutputPage::setIndexPolicy (   $policy)

Set the index policy for the page, but leave the follow policy un- touched.

Parameters
string$policyEither 'index' or 'noindex'.
Returns
null
OutputPage::setIndicators ( array  $indicators)

Add an array of indicators, with their identifiers as array keys and HTML contents as values.

In case of duplicate keys, existing values are overwritten.

Parameters
array$indicators
Since
1.25
OutputPage::setLanguageLinks ( array  $newLinkArray)

Reset the language links and add new language links

Parameters
string[]$newLinkArray Array of interwiki-prefixed (non DB key) titles (e.g. 'fr:Test page')
OutputPage::setLastModified (   $timestamp)

Override the last modified timestamp

Parameters
string$timestampNew timestamp, in a format readable by wfTimestamp()
OutputPage::setPageTitle (   $name)

"Page title" means the contents of <h1>. It is stored as a valid HTML fragment. This function allows good tags like <sup> in the <h1> tag, but not bad tags like <script>. This function automatically sets <title> to the same content as <h1> but with all tags removed. Bad tags that were escaped in <h1> will still be escaped in <title>, and good tags like <i> will be dropped entirely.

Parameters
string | Message$name
OutputPage::setPageTitleActionText (   $text)

Set the new value of the "action text", this will be added to the "HTML title", separated from it with " - ".

Parameters
string$textNew value of the "action text"
OutputPage::setPrintable ( )

Set the page as printable, i.e. it'll be displayed with all print styles included

OutputPage::setProperty (   $name,
  $value 
)

Set an additional output property

Since
1.21
Parameters
string$name
mixed$value
OutputPage::setRedirectedFrom (   $t)

Set $mRedirectedFrom, the Title of the page which redirected us to the current page.

Parameters
Title$t
OutputPage::setRevisionId (   $revid)

Set the revision ID which will be seen by the wiki text parser for things such as embedded {{REVISIONID}} variable use.

Parameters
int | null$revidAn positive integer, or null
Returns
mixed Previous value
OutputPage::setRevisionTimestamp (   $timestamp)

Set the timestamp of the revision which will be displayed. This is used to avoid a extra DB call in Skin::lastModified().

Parameters
string | null$timestamp
Returns
mixed Previous value
OutputPage::setRobotPolicy (   $policy)

Set the robot policy for the page: http://www.robotstxt.org/meta.html

Parameters
string$policyThe literal string to output as the contents of the meta tag. Will be parsed according to the spec and output in standardized form.
Returns
null
OutputPage::setStatusCode (   $statusCode)

Set the HTTP status code to send with the output.

Parameters
int$statusCode
OutputPage::setSubtitle (   $str)

Replace the subtitle with $str

Parameters
string | Message$strNew value of the subtitle. String should be safe HTML.
OutputPage::setSyndicated (   $show = true)

Add or remove feed links in the page header This is mainly kept for backward compatibility, see OutputPage::addFeedLink() for the new version

See Also
addFeedLink()
Parameters
bool$showTrue: add default feeds, false: remove all feeds
OutputPage::setTarget (   $target)

Sets ResourceLoader target for load.php links. If null, will be omitted

Parameters
string | null$target
OutputPage::setTitle ( Title  $t)

Set the Title object to use

Parameters
Title$t
static OutputPage::setupOOUI (   $skinName = 'default',
  $dir = 'ltr' 
)
static

Helper function to setup the PHP implementation of OOUI to use in this request.

Since
1.26
Parameters
String$skinNameThe Skin name to determine the correct OOUI theme
String$dirLanguage direction
OutputPage::showErrorPage (   $title,
  $msg,
  $params = [] 
)

Output a standard error page

showErrorPage( 'titlemsg', 'pagetextmsg' ); showErrorPage( 'titlemsg', 'pagetextmsg', [ 'param1', 'param2' ] ); showErrorPage( 'titlemsg', $messageObject ); showErrorPage( $titleMessageObject, $messageObject );

Parameters
string | Message$titleMessage key (string) for page title, or a Message object
string | Message$msgMessage key (string) for page text, or a Message object
array$paramsMessage parameters; ignored if $msg is a Message object
OutputPage::showLagWarning (   $lag)

Show a warning about replica DB lag

If the lag is higher than $wgSlaveLagCritical seconds, then the warning is a bit more obvious. If the lag is lower than $wgSlaveLagWarning, then no warning is shown.

Parameters
int$lagSlave lag
OutputPage::showNewSectionLink ( )

Show an "add new section" link?

Returns
bool
OutputPage::showPermissionsErrorPage ( array  $errors,
  $action = null 
)

Output a standard permission error page

Parameters
array$errorsError message keys or [key, param...] arrays
string$actionAction that was denied or null if unknown
OutputPage::styleLink (   $style,
array  $options 
)
protected

Generate <link> tags for stylesheets

Parameters
string$styleURL to the file
array$optionsOption, can contain 'condition', 'dir', 'media' keys
Returns
string HTML fragment
static OutputPage::transformCssMedia (   $media)
static

Transform "media" attribute based on request parameters

Parameters
string$mediaCurrent value of the "media" attribute
Returns
string Modified value of the "media" attribute, or null to skip this stylesheet
static OutputPage::transformFilePath (   $remotePathPrefix,
  $localPath,
  $file 
)
static

Utility method for transformResourceFilePath().

Caller is responsible for ensuring the file exists. Emits a PHP warning otherwise.

Since
1.27
Parameters
string$remotePathPrefixURL path prefix that points to $localPath
string$localPathFile directory exposed at $remotePath
string$filePath to target file relative to $localPath
Returns
string URL
static OutputPage::transformResourcePath ( Config  $config,
  $path 
)
static

Transform path to web-accessible static resource.

This is used to add a validation hash as query string. This aids various behaviors:

  • Put long Cache-Control max-age headers on responses for improved cache performance.
  • Get the correct version of a file as expected by the current page.
  • Instantly get the updated version of a file after deployment.

Avoid using this for urls included in HTML as otherwise clients may get different versions of a resource when navigating the site depending on when the page was cached. If changes to the url propagate, this is not a problem (e.g. if the url is in an external stylesheet).

Since
1.27
Parameters
Config$config
string$pathPath-absolute URL to file (from document root, must start with "/")
Returns
string URL
OutputPage::userCanPreview ( )

To make it harder for someone to slip a user a fake JavaScript or CSS preview, a random token is associated with the login session. If it's not passed back with the preview request, we won't render the code.

Returns
bool
OutputPage::versionRequired (   $version)

Display an error page indicating that a given version of MediaWiki is required to use it

Parameters
mixed$versionThe version of MediaWiki needed to use the page
OutputPage::wrapWikiMsg (   $wrap)

This function takes a number of message/argument specifications, wraps them in some overall structure, and then parses the result and adds it to the output.

In the $wrap, $1 is replaced with the first message, $2 with the second, and so on. The subsequent arguments may be either 1) strings, in which case they are message names, or 2) arrays, in which case, within each array, the first element is the message name, and subsequent elements are the parameters to that message.

Don't use this for messages that are not in the user's interface language.

For example:

$wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>", 'some-error' );

Is equivalent to:

$wgOut->addWikiText( "<div class='error'>\n" . wfMessage( 'some-error' )->plain() . "\n</div>" );

The newline after the opening div is needed in some wikitext. See T21226.

Parameters
string$wrap

Member Data Documentation

OutputPage::$mAllowedModules
protected
Initial value:
= [
ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL
OutputPage::$mCategories
protected
Initial value:
= [
'hidden' => []

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