Go to the documentation of this file.
238 'Accept-Encoding' =>
array(
'list-contains=gzip' ),
276 # Extensions should use `new RequestContext` instead of `new OutputPage` now.
289 public function redirect( $url, $responsecode =
'302' ) {
290 # Strip newlines as a paranoia check for header injection in PHP<5.1.2
291 $this->mRedirect = str_replace(
"\n",
'', $url );
292 $this->mRedirectCode = $responsecode;
310 $this->mStatusCode = $statusCode;
321 array_push( $this->mMetatags,
array(
$name, $val ) );
332 array_push( $this->mLinktags, $linkarr );
352 $this->mCanonicalUrl = $url;
361 # note: buggy CC software only reads first "meta" link
362 static $haveMeta =
false;
364 return 'alternate meta';
377 $this->mScripts .= $script .
"\n";
389 array_push( $this->mExtStyles, $url );
409 global $wgStylePath, $wgStyleVersion;
411 if ( substr(
$file, 0, 1 ) ==
'/' || preg_match(
'#^[a-z]*://#i',
$file ) ) {
414 $path =
"{$wgStylePath}/common/{$file}";
450 $filteredModules =
array();
451 foreach ( $modules
as $val ) {
455 && ( is_null( $position ) || $module->getPosition() == $position )
456 && ( !$this->mTarget || in_array( $this->mTarget, $module->getTargets() ) )
458 $filteredModules[] = $val;
461 return $filteredModules;
472 public function getModules( $filter =
false, $position =
null, $param =
'mModules' ) {
473 $modules = array_values( array_unique( $this->$param ) );
487 $this->mModules = array_merge( $this->mModules, (
array)$modules );
499 return $this->
getModules( $filter, $position,
'mModuleScripts' );
510 $this->mModuleScripts = array_merge( $this->mModuleScripts, (
array)$modules );
522 return $this->
getModules( $filter, $position,
'mModuleStyles' );
535 $this->mModuleStyles = array_merge( $this->mModuleStyles, (
array)$modules );
547 return $this->
getModules( $filter, $position,
'mModuleMessages' );
558 $this->mModuleMessages = array_merge( $this->mModuleMessages, (
array)$modules );
574 $this->mTarget = $target;
593 foreach ( $this->mHeadItems
as $item ) {
616 return isset( $this->mHeadItems[
$name] );
636 $this->mArticleBodyOnly = $only;
667 if ( isset( $this->mProperties[
$name] ) ) {
668 return $this->mProperties[
$name];
686 global $wgCachePages, $wgCacheEpoch, $wgUseSquid, $wgSquidMaxage;
689 wfDebug( __METHOD__ .
": CACHE DISABLED, NO TIMESTAMP\n" );
692 if ( !$wgCachePages ) {
693 wfDebug( __METHOD__ .
": CACHE DISABLED\n" );
698 $modifiedTimes =
array(
700 'user' => $this->
getUser()->getTouched(),
701 'epoch' => $wgCacheEpoch
709 $maxModified = max( $modifiedTimes );
712 $clientHeader = $this->
getRequest()->getHeader(
'If-Modified-Since' );
713 if ( $clientHeader ===
false ) {
714 wfDebug( __METHOD__ .
": client did not send If-Modified-Since header\n",
'log' );
718 # IE sends sizes after the date like this:
719 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
720 # this breaks strtotime().
721 $clientHeader = preg_replace(
'/;.*$/',
'', $clientHeader );
724 $clientHeaderTime = strtotime( $clientHeader );
726 if ( !$clientHeaderTime ) {
727 wfDebug( __METHOD__ .
": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
735 if ( $info !==
'' ) {
741 wfDebug( __METHOD__ .
": client sent If-Modified-Since: " .
743 wfDebug( __METHOD__ .
": effective Last-Modified: " .
745 if ( $clientHeaderTime < $maxModified ) {
746 wfDebug( __METHOD__ .
": STALE, $info\n",
'log' );
751 # Give a 304 response code and disable body output
752 wfDebug( __METHOD__ .
": NOT MODIFIED, $info\n",
'log' );
753 ini_set(
'zlib.output_compression', 0 );
754 $this->
getRequest()->response()->header(
"HTTP/1.1 304 Not Modified" );
787 if ( isset( $policy[
'index'] ) ) {
790 if ( isset( $policy[
'follow'] ) ) {
803 $policy = trim( $policy );
804 if ( in_array( $policy,
array(
'index',
'noindex' ) ) ) {
805 $this->mIndexPolicy = $policy;
817 $policy = trim( $policy );
818 if ( in_array( $policy,
array(
'follow',
'nofollow' ) ) ) {
819 $this->mFollowPolicy = $policy;
830 $this->mPageTitleActionText = $text;
839 if ( isset( $this->mPageTitleActionText ) ) {
852 if (
$name instanceof Message ) {
855 $this->mHTMLtitle =
$name;
874 $this->mRedirectedFrom =
$t;
886 if (
$name instanceof Message ) {
890 # change "<script>foo&bar</script>" to "<script>foo&bar</script>"
891 # but leave "<i>foobar</i>" alone
893 $this->mPagetitle = $nameWithTags;
895 # change "<i>foo&bar</i>" to "foo&bar"
898 ->inContentLanguage()
946 if ( $str instanceof Message ) {
947 $this->mSubtitle[] = $str->setContext( $this->
getContext() )->parse();
949 $this->mSubtitle[] = $str;
960 if (
$title->isRedirect() ) {
961 $query[
'redirect'] =
'no';
970 $this->mSubtitle =
array();
979 return implode(
"<br />\n\t\t\t\t", $this->mSubtitle );
987 $this->mPrintable =
true;
1003 $this->mDoNothing =
true;
1045 $this->mFeedLinks =
array();
1059 global $wgAdvertisedFeedTypes;
1061 $this->mFeedLinks =
array();
1063 foreach ( $wgAdvertisedFeedTypes
as $type ) {
1065 if ( is_string( $val ) ) {
1079 global $wgAdvertisedFeedTypes;
1081 if ( in_array( $format, $wgAdvertisedFeedTypes ) ) {
1082 $this->mFeedLinks[$format] = $href;
1091 return count( $this->mFeedLinks ) > 0;
1119 $this->mIsarticle = $v;
1121 $this->mIsArticleRelated = $v;
1142 $this->mIsArticleRelated = $v;
1144 $this->mIsarticle =
false;
1164 $this->mLanguageLinks += $newLinkArray;
1174 $this->mLanguageLinks = $newLinkArray;
1194 if ( !is_array( $categories ) || count( $categories ) == 0 ) {
1198 # Add the links to a LinkBatch
1201 $lb->setArray( $arr );
1203 # Fetch existence plus the hiddencat property
1206 array(
'page_id',
'page_namespace',
'page_title',
'page_len',
'page_is_redirect',
'page_latest',
'pp_value' ),
1207 $lb->constructSet(
'page',
$dbr ),
1210 array(
'page_props' =>
array(
'LEFT JOIN',
array(
'pp_propname' =>
'hiddencat',
'pp_page = page_id' ) ) )
1213 # Add the results to the link cache
1216 # Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
1217 $categories = array_combine(
1218 array_keys( $categories ),
1219 array_fill( 0, count( $categories ),
'normal' )
1222 # Mark hidden categories
1223 foreach (
$res as $row ) {
1224 if ( isset( $row->pp_value ) ) {
1225 $categories[$row->page_title] =
'hidden';
1229 # Add the remaining categories to the skin
1230 if (
wfRunHooks(
'OutputPageMakeCategoryLinks',
array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
1231 foreach ( $categories
as $category =>
$type ) {
1232 $origcategory = $category;
1235 if ( $category != $origcategory ) {
1236 if ( array_key_exists( $category, $categories ) ) {
1241 $this->mCategories[] =
$title->getText();
1253 $this->mCategoryLinks =
array();
1348 $this->mAllowedModuleOrigin = min( $this->mAllowedModuleOrigin, $level );
1365 public function addHTML( $text ) {
1366 $this->mBodytext .= $text;
1386 $this->mBodytext =
'';
1406 if ( !$this->mParserOptions ) {
1408 $this->mParserOptions->setEditSection(
false );
1421 $val = is_null( $revid ) ? null : intval( $revid );
1422 return wfSetVar( $this->mRevisionId, $val );
1464 $val =
array(
'time' =>
$file->getTimestamp(),
'sha1' =>
$file->getSha1() );
1466 return wfSetVar( $this->mFileVersion, $val,
true );
1506 public function addWikiText( $text, $linestart =
true, $interface =
true ) {
1563 $oldTidy = $popts->setTidy( $tidy );
1564 $popts->setInterfaceMessage( (
bool)$interface );
1568 $linestart,
true, $this->mRevisionId
1571 $popts->setTidy( $oldTidy );
1584 $this->mLanguageLinks += $parserOutput->getLanguageLinks();
1586 $this->mNewSectionLink = $parserOutput->getNewSection();
1587 $this->mHideNewSectionLink = $parserOutput->getHideNewSection();
1589 $this->mParseWarnings = $parserOutput->getWarnings();
1590 if ( !$parserOutput->isCacheable() ) {
1593 $this->mNoGallery = $parserOutput->getNoGallery();
1594 $this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
1595 $this->
addModules( $parserOutput->getModules() );
1600 $this->mPreventClickjacking = $this->mPreventClickjacking
1601 || $parserOutput->preventClickjacking();
1604 foreach ( (
array)$parserOutput->getTemplateIds()
as $ns => $dbks ) {
1605 if ( isset( $this->mTemplateIds[$ns] ) ) {
1606 $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
1608 $this->mTemplateIds[$ns] = $dbks;
1612 foreach ( (
array)$parserOutput->getFileSearchOptions()
as $dbk => $data ) {
1613 $this->mImageTimeKeys[$dbk] = $data;
1617 global $wgParserOutputHooks;
1618 foreach ( $parserOutput->getOutputHooks()
as $hookInfo ) {
1619 list( $hookName, $data ) = $hookInfo;
1620 if ( isset( $wgParserOutputHooks[$hookName] ) ) {
1621 call_user_func( $wgParserOutputHooks[$hookName], $this, $parserOutput, $data );
1627 $linkFlags =
array();
1629 wfRunHooks(
'OutputPageParserOutput',
array( &$this, $parserOutput ) );
1639 $parserOutput->setTOCEnabled( $this->mEnableTOC );
1642 if ( $parserOutput->getEditSectionTokens() ) {
1643 $parserOutput->setEditSectionTokens( $this->mEnableSectionEditLinks );
1645 $text = $parserOutput->getText();
1656 $this->
addHTML( $template->getHTML() );
1671 public function parse( $text, $linestart =
true, $interface =
false, $language =
null ) {
1674 if ( is_null( $this->
getTitle() ) ) {
1675 throw new MWException(
'Empty $mTitle in ' . __METHOD__ );
1680 $popts->setInterfaceMessage(
true );
1682 if ( $language !==
null ) {
1683 $oldLang = $popts->setTargetLanguage( $language );
1688 $linestart,
true, $this->mRevisionId
1692 $popts->setInterfaceMessage(
false );
1694 if ( $language !==
null ) {
1695 $popts->setTargetLanguage( $oldLang );
1698 return $parserOutput->getText();
1711 public function parseInline( $text, $linestart =
true, $interface =
false ) {
1712 $parsed = $this->
parse( $text, $linestart, $interface );
1715 if ( preg_match(
'/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
1728 $this->mSquidMaxage = $maxage;
1739 return wfSetVar( $this->mEnableClientCache, $state );
1753 "{$wgCookiePrefix}Token",
1754 "{$wgCookiePrefix}LoggedOut",
1772 $cookieHeader = $this->
getRequest()->getHeader(
'cookie' );
1773 if ( $cookieHeader ===
false ) {
1777 foreach ( $cvCookies
as $cookieName ) {
1778 # Check for a simple string match, like the way squid does it
1779 if ( strpos( $cookieHeader, $cookieName ) !==
false ) {
1780 wfDebug( __METHOD__ .
": found $cookieName\n" );
1784 wfDebug( __METHOD__ .
": no cache-varying cookies found\n" );
1797 if ( !array_key_exists( $header, $this->mVaryHeader ) ) {
1798 $this->mVaryHeader[$header] = (
array)$option;
1799 } elseif ( is_array( $option ) ) {
1800 if ( is_array( $this->mVaryHeader[$header] ) ) {
1801 $this->mVaryHeader[$header] = array_merge( $this->mVaryHeader[$header], $option );
1803 $this->mVaryHeader[$header] = $option;
1806 $this->mVaryHeader[$header] = array_unique( (
array)$this->mVaryHeader[$header] );
1816 return 'Vary: ' . join(
', ', array_keys( $this->mVaryHeader ) );
1824 public function getXVO() {
1827 $cookiesOption =
array();
1828 foreach ( $cvCookies
as $cookieName ) {
1829 $cookiesOption[] =
'string-contains=' . $cookieName;
1834 foreach ( $this->mVaryHeader
as $header => $option ) {
1835 $newheader = $header;
1836 if ( is_array( $option ) && count( $option ) > 0 ) {
1837 $newheader .=
';' . implode(
';', $option );
1839 $headers[] = $newheader;
1841 $xvo =
'X-Vary-Options: ' . implode(
',', $headers );
1855 $lang = $this->
getTitle()->getPageLanguage();
1856 if ( !$this->
getRequest()->getCheck(
'variant' ) && $lang->hasVariants() ) {
1857 $variants = $lang->getVariants();
1858 $aloption =
array();
1859 foreach ( $variants
as $variant ) {
1860 if ( $variant === $lang->getCode() ) {
1863 $aloption[] =
'string-contains=' . $variant;
1868 $variantBCP47 =
wfBCP47( $variant );
1869 if ( $variantBCP47 !== $variant ) {
1870 $aloption[] =
'string-contains=' . $variantBCP47;
1889 $this->mPreventClickjacking = $enable;
1898 $this->mPreventClickjacking =
false;
1919 global $wgBreakFrames, $wgEditPageFrameOptions;
1920 if ( $wgBreakFrames ) {
1922 } elseif ( $this->mPreventClickjacking && $wgEditPageFrameOptions ) {
1923 return $wgEditPageFrameOptions;
1932 global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgUseXVO;
1935 if ( $wgUseETag && $this->mETag ) {
1936 $response->header(
"ETag: $this->mETag" );
1942 # don't serve compressed data to clients who can't handle it
1943 # maintain different caches for logged-in users and non-logged in ones
1947 # Add an X-Vary-Options header for Squid with Wikimedia patches
1951 if ( $this->mEnableClientCache ) {
1953 $wgUseSquid && session_id() ==
'' && !$this->
isPrintable() &&
1957 # We'll purge the proxy cache explicitly, but require end user agents
1958 # to revalidate against the proxy on each visit.
1959 # Surrogate-Control controls our Squid, Cache-Control downstream caches
1960 wfDebug( __METHOD__ .
": proxy caching with ESI; {$this->mLastModified} **\n",
'log' );
1961 # start with a shorter timeout for initial testing
1962 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
1963 $response->header(
'Surrogate-Control: max-age=' . $wgSquidMaxage .
'+' . $this->mSquidMaxage .
', content="ESI/1.0"' );
1964 $response->header(
'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
1966 # We'll purge the proxy cache for anons explicitly, but require end user agents
1967 # to revalidate against the proxy on each visit.
1968 # IMPORTANT! The Squid needs to replace the Cache-Control header with
1969 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
1970 wfDebug( __METHOD__ .
": local proxy caching; {$this->mLastModified} **\n",
'log' );
1971 # start with a shorter timeout for initial testing
1972 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
1973 $response->header(
'Cache-Control: s-maxage=' . $this->mSquidMaxage .
', must-revalidate, max-age=0' );
1976 # We do want clients to cache if they can, but they *must* check for updates
1977 # on revisiting the page.
1978 wfDebug( __METHOD__ .
": private caching; {$this->mLastModified} **\n",
'log' );
1979 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
1980 $response->header(
"Cache-Control: private, must-revalidate, max-age=0" );
1982 if ( $this->mLastModified ) {
1983 $response->header(
"Last-Modified: {$this->mLastModified}" );
1986 wfDebug( __METHOD__ .
": no caching **\n",
'log' );
1988 # In general, the absence of a last modified header should be enough to prevent
1989 # the client from using its cache. We send a few other things just to make sure.
1990 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
1991 $response->header(
'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
1992 $response->header(
'Pragma: no-cache' );
2013 public function output() {
2014 global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP,
2015 $wgUseAjax, $wgResponsiveImages;
2017 if ( $this->mDoNothing ) {
2025 if ( $this->mRedirect !=
'' ) {
2026 # Standards require redirect URLs to be absolute
2032 if (
wfRunHooks(
"BeforePageRedirect",
array( $this, &$redirect, &$code ) ) ) {
2033 if ( $code ==
'301' || $code ==
'303' ) {
2034 if ( !$wgDebugRedirects ) {
2036 $response->header(
"HTTP/1.1 $code $message" );
2040 if ( $wgVaryOnXFP ) {
2045 $response->header(
"Content-Type: text/html; charset=utf-8" );
2046 if ( $wgDebugRedirects ) {
2047 $url = htmlspecialchars( $redirect );
2048 print
"<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
2049 print
"<p>Location: <a href=\"$url\">$url</a></p>\n";
2050 print
"</body>\n</html>\n";
2052 $response->header(
'Location: ' . $redirect );
2058 } elseif ( $this->mStatusCode ) {
2061 $response->header(
'HTTP/1.1 ' . $this->mStatusCode .
' ' . $message );
2065 # Buffer output; final headers may depend on later processing
2068 $response->header(
"Content-type: $wgMimeType; charset=UTF-8" );
2069 $response->header(
'Content-language: ' . $wgLanguageCode );
2073 if ( $frameOptions ) {
2074 $response->header(
"X-Frame-Options: $frameOptions" );
2077 if ( $this->mArticleBodyOnly ) {
2083 $modules = $sk->getDefaultModules();
2086 $coreModules =
array(
2088 'mediawiki.page.startup',
2093 if ( $wgResponsiveImages ) {
2094 $coreModules[] =
'mediawiki.hidpi';
2098 foreach ( $modules
as $group ) {
2132 public function out( $ins ) {
2157 if ( $htmlTitle !==
false ) {
2163 $this->mRedirect =
'';
2181 if ( !
$title instanceof Message ) {
2187 if ( $msg instanceof Message ) {
2189 trigger_error(
'Argument ignored: $params. The message parameters argument is discarded when the $msg argument is a Message object instead of a string.', E_USER_NOTICE );
2191 $this->
addHTML( $msg->parseAsBlock() );
2211 if ( in_array( $action,
array(
'read',
'edit',
'createpage',
'createtalk',
'upload' ) )
2212 && $this->
getUser()->isAnon() && count( $errors ) == 1 && isset( $errors[0][0] )
2213 && ( $errors[0][0] ==
'badaccess-groups' || $errors[0][0] ==
'badaccess-group0' )
2217 $displayReturnto =
null;
2219 # Due to bug 32276, if a user does not have read permissions,
2220 # $this->getTitle() will just give Special:Badtitle, which is
2221 # not especially useful as a returnto parameter. Use the title
2222 # from the request instead, if there was one.
2225 if ( $action ==
'edit' ) {
2226 $msg =
'whitelistedittext';
2227 $displayReturnto = $returnto;
2228 } elseif ( $action ==
'createpage' || $action ==
'createtalk' ) {
2229 $msg =
'nocreatetext';
2230 } elseif ( $action ==
'upload' ) {
2231 $msg =
'uploadnologintext';
2233 $msg =
'loginreqpagetext';
2240 $query[
'returnto'] = $returnto->getPrefixedText();
2242 if ( !$request->wasPosted() ) {
2243 $returntoquery = $request->getValues();
2244 unset( $returntoquery[
'title'] );
2245 unset( $returntoquery[
'returnto'] );
2246 unset( $returntoquery[
'returntoquery'] );
2252 $this->
msg(
'loginreqlink' )->escaped(),
2258 $this->
addHTML( $this->
msg( $msg )->rawParams( $loginLink )->
parse() );
2260 # Don't return to a page the user can't read otherwise
2261 # we'll end up in a pointless loop
2262 if ( $displayReturnto && $displayReturnto->userCan(
'read', $this->getUser() ) ) {
2311 if ( $action ==
null ) {
2312 $text = $this->
msg(
'permissionserrorstext', count( $errors ) )->plain() .
"\n\n";
2314 $action_desc = $this->
msg(
"action-$action" )->plain();
2316 'permissionserrorstext-withaction',
2319 )->plain() .
"\n\n";
2322 if ( count( $errors ) > 1 ) {
2323 $text .=
'<ul class="permissions-errors">' .
"\n";
2327 $text .= call_user_func_array(
array( $this,
'msg' ),
$error )->plain();
2332 $text .=
"<div class=\"permissions-errors\">\n" .
2333 call_user_func_array(
array( $this,
'msg' ), reset( $errors ) )->plain() .
2367 if ( $protected && empty( $reasons ) ) {
2368 $reasons[] =
array(
'badaccess-group0' );
2371 if ( !empty( $reasons ) ) {
2389 $pageLang = $this->
getTitle()->getPageLanguage();
2391 'id' =>
'wpTextbox1',
2392 'name' =>
'wpTextbox1',
2393 'cols' => $this->
getUser()->getOption(
'cols' ),
2394 'rows' => $this->
getUser()->getOption(
'rows' ),
2395 'readonly' =>
'readonly',
2396 'lang' => $pageLang->getHtmlCode(),
2397 'dir' => $pageLang->getDir(),
2403 $this->
addHTML(
"<div class='templatesUsed'>
2409 # If the title doesn't exist, it's fairly pointless to print a return
2410 # link to it. After all, you just tried editing it and couldn't, so
2411 # what's there to do there?
2412 if ( $this->
getTitle()->exists() ) {
2435 global $wgSlaveLagWarning, $wgSlaveLagCritical;
2436 if ( $lag >= $wgSlaveLagWarning ) {
2437 $message = $lag < $wgSlaveLagCritical
2480 $link = $this->
msg(
'returnto' )->rawParams(
2482 $this->
addHTML(
"<p id=\"mw-returnto\">{$link}</p>\n" );
2493 public function returnToMain( $unused =
null, $returnto =
null, $returntoquery =
null ) {
2494 if ( $returnto ==
null ) {
2495 $returnto = $this->
getRequest()->getText(
'returnto' );
2498 if ( $returntoquery ==
null ) {
2499 $returntoquery = $this->
getRequest()->getText(
'returntoquery' );
2502 if ( $returnto ===
'' ) {
2506 if ( is_object( $returnto ) ) {
2507 $titleObj = $returnto;
2511 if ( !is_object( $titleObj ) ) {
2537 # Don't bother with the newline if $head == ''
2538 $ret .=
"$openHead\n";
2557 $ret .=
Html::element(
'meta',
array(
'http-equiv' =>
'X-UA-Compatible',
'content' =>
'IE=EDGE' ) ) .
"\n";
2571 $ret .=
"$closeHead\n";
2574 $bodyClasses =
array();
2575 $bodyClasses[] =
'mediawiki';
2577 # Classes for LTR/RTL directionality support
2578 $bodyClasses[] = $userdir;
2579 $bodyClasses[] =
"sitedir-$sitedir";
2581 if ( $this->
getLanguage()->capitalizeAllNouns() ) {
2582 # A <body> class is probably not the best way to do this . . .
2583 $bodyClasses[] =
'capitalize-all-nouns';
2590 $bodyAttrs =
array();
2593 $bodyAttrs[
'class'] = implode(
' ', $bodyClasses );
2597 wfRunHooks(
'OutputPageBodyAttributes',
array( $this, $sk, &$bodyAttrs ) );
2610 if ( is_null( $this->mResourceLoader ) ) {
2626 global $wgResourceLoaderUseESI;
2628 $modules = (
array)$modules;
2632 'states' =>
array(),
2635 if ( !count( $modules ) ) {
2640 if ( count( $modules ) > 1 ) {
2642 $modules = array_unique( $modules );
2648 foreach ( $modules
as $name ) {
2650 $links[
'html'] .=
$link[
'html'];
2651 $links[
'states'] +=
$link[
'states'];
2657 if ( !is_null( $this->mTarget ) ) {
2664 foreach ( $modules
as $name ) {
2666 # Check that we're allowed to include this module on this page
2672 || ( $this->mTarget && !in_array( $this->mTarget, $module->getTargets() ) )
2677 $group = $module->getGroup();
2678 if ( !isset( $groups[$group] ) ) {
2679 $groups[$group] =
array();
2681 $groups[$group][
$name] = $module;
2684 foreach ( $groups
as $group => $grpModules ) {
2687 if ( ( $group ===
'user' || $group ===
'private' ) && $this->
getUser()->isLoggedIn() ) {
2696 $this->
getSkin()->getSkinName(),
2708 foreach ( $grpModules
as $key => $module ) {
2711 if ( $module->isKnownEmpty(
$context ) ) {
2712 unset( $grpModules[$key] );
2714 $links[
'states'][$key] =
'ready';
2720 if ( count( $grpModules ) === 0 ) {
2728 if ( $group ===
'private' ) {
2740 $links[
'html'] .=
"\n";
2750 if ( $group ===
'user' ) {
2753 foreach ( $grpModules
as $module ) {
2761 array_keys( $grpModules ),
2763 $this->
getSkin()->getSkinName(),
2772 if ( $useESI && $wgResourceLoaderUseESI ) {
2783 } elseif ( $loadCall ) {
2794 foreach ( $grpModules
as $key => $module ) {
2796 if ( $key !==
'startup' ) {
2797 $links[
'states'][$key] =
'loading';
2803 if ( $group ==
'noscript' ) {
2806 $links[
'html'] .=
$link .
"\n";
2822 if ( !is_array(
$link ) ) {
2826 $states +=
$link[
'states'];
2830 if ( count( $states ) ) {
2848 global $wgResourceLoaderExperimentalAsyncLoading;
2864 $embedScripts =
array(
'user.options',
'user.tokens' );
2883 if ( $wgResourceLoaderExperimentalAsyncLoading ) {
2900 global $wgUseSiteJs, $wgAllowUserJs;
2917 $modules = $this->
getModules(
true,
'bottom' );
2931 false,
array(), $inHead
2936 # XXX: additional security check/prompt?
2940 array(
'excludepage' => $this->
getTitle()->getPrefixedDBkey() ), $inHead
2951 false,
array(), $inHead
2957 false,
array(), $inHead
2968 global $wgResourceLoaderExperimentalAsyncLoading;
2976 if ( !$wgResourceLoaderExperimentalAsyncLoading ) {
3000 if ( is_array(
$keys ) ) {
3002 $this->mJsConfigVars[$key] =
$value;
3027 $canonicalSpecialPageName =
false; # bug 21115
3030 $ns =
$title->getNamespace();
3043 $curRevisionId = $wikiPage->getLatest();
3044 $articleId = $wikiPage->getId();
3047 $lang =
$title->getPageLanguage();
3050 $separatorTransTable = $lang->separatorTransformTable();
3051 $separatorTransTable = $separatorTransTable ? $separatorTransTable :
array();
3052 $compactSeparatorTransTable =
array(
3053 implode(
"\t", array_keys( $separatorTransTable ) ),
3054 implode(
"\t", $separatorTransTable ),
3056 $digitTransTable = $lang->digitTransformTable();
3057 $digitTransTable = $digitTransTable ? $digitTransTable :
array();
3058 $compactDigitTransTable =
array(
3059 implode(
"\t", array_keys( $digitTransTable ) ),
3060 implode(
"\t", $digitTransTable ),
3066 'wgCanonicalNamespace' => $canonicalNamespace,
3067 'wgCanonicalSpecialPageName' => $canonicalSpecialPageName,
3068 'wgNamespaceNumber' =>
$title->getNamespace(),
3069 'wgPageName' =>
$title->getPrefixedDBkey(),
3070 'wgTitle' =>
$title->getText(),
3071 'wgCurRevisionId' => $curRevisionId,
3073 'wgArticleId' => $articleId,
3075 'wgIsRedirect' => $title->isRedirect(),
3077 'wgUserName' =>
$user->isAnon() ? null :
$user->getName(),
3078 'wgUserGroups' =>
$user->getEffectiveGroups(),
3081 'wgPageContentLanguage' => $lang->getCode(),
3082 'wgPageContentModel' =>
$title->getContentModel(),
3083 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
3084 'wgDigitTransformTable' => $compactDigitTransTable,
3085 'wgDefaultDateFormat' => $lang->getDefaultDateFormat(),
3086 'wgMonthNames' => $lang->getMonthNamesArray(),
3087 'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
3088 'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
3090 if (
$user->isLoggedIn() ) {
3092 $vars[
'wgUserEditCount'] =
$user->getEditCount();
3094 $vars[
'wgUserRegistration'] = $userReg !==
null ? ( $userReg * 1000 ) :
null;
3098 $vars[
'wgUserNewMsgRevisionId'] =
$user->getNewMessageRevisionId();
3108 if (
$title->isMainPage() ) {
3109 $vars[
'wgIsMainPage'] =
true;
3111 if ( $this->mRedirectedFrom ) {
3112 $vars[
'wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBkey();
3114 if ( $relevantUser ) {
3115 $vars[
'wgRelevantUserName'] = $relevantUser->getName();
3138 if ( $this->
getRequest()->getVal(
'action' ) !=
'submit'
3140 || !$this->
getUser()->matchEditToken(
3141 $this->
getRequest()->getVal(
'wpEditToken' ) )
3145 if ( !$this->
getTitle()->isJsSubpage() && !$this->
getTitle()->isCssSubpage() ) {
3149 return !count( $this->
getTitle()->getUserPermissionsErrors(
'edit', $this->
getUser() ) );
3156 global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI,
3157 $wgSitename, $wgVersion,
3158 $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
3159 $wgDisableLangConversion, $wgCanonicalLanguageLinks,
3160 $wgRightsPage, $wgRightsUrl;
3167 'name' =>
'generator',
3168 'content' =>
"MediaWiki $wgVersion",
3171 $p =
"{$this->mIndexPolicy},{$this->mFollowPolicy}";
3172 if ( $p !==
'index,follow' ) {
3181 foreach ( $this->mMetatags
as $tag ) {
3182 if ( 0 == strcasecmp(
'http:', substr( $tag[0], 0, 5 ) ) ) {
3184 $tag[0] = substr( $tag[0], 5 );
3188 $tagName =
"meta-{$tag[0]}";
3189 if ( isset( $tags[$tagName] ) ) {
3190 $tagName .= $tag[1];
3195 'content' => $tag[1]
3200 foreach ( $this->mLinktags
as $tag ) {
3204 # Universal edit button
3210 $msg = $this->
msg(
'edit' )->text();
3212 'rel' =>
'alternate',
3213 'type' =>
'application/x-wiki',
3215 'href' => $this->
getTitle()->getLocalURL(
'action=edit' )
3221 'href' => $this->
getTitle()->getLocalURL(
'action=edit' )
3226 # Generally the order of the favicon and apple-touch-icon links
3227 # should not matter, but Konqueror (3.5.9 at least) incorrectly
3228 # uses whichever one appears later in the HTML source. Make sure
3229 # apple-touch-icon is specified first to avoid this.
3230 if ( $wgAppleTouchIcon !==
false ) {
3231 $tags[
'apple-touch-icon'] =
Html::element(
'link',
array(
'rel' =>
'apple-touch-icon',
'href' => $wgAppleTouchIcon ) );
3234 if ( $wgFavicon !==
false ) {
3235 $tags[
'favicon'] =
Html::element(
'link',
array(
'rel' =>
'shortcut icon',
'href' => $wgFavicon ) );
3238 # OpenSearch description link
3241 'type' =>
'application/opensearchdescription+xml',
3242 'href' =>
wfScript(
'opensearch_desc' ),
3243 'title' => $this->
msg(
'opensearch-desc' )->inContentLanguage()->
text(),
3246 if ( $wgEnableAPI ) {
3247 # Real Simple Discovery link, provides auto-discovery information
3248 # for the MediaWiki API (and potentially additional custom API
3249 # support such as WordPress or Twitter-compatible APIs for a
3250 # blogging extension, etc)
3253 'type' =>
'application/rsd+xml',
3261 if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks ) {
3262 $lang = $this->
getTitle()->getPageLanguage();
3263 if ( $lang->hasVariants() ) {
3265 $urlvar = $lang->getURLVariant();
3268 $variants = $lang->getVariants();
3269 foreach ( $variants
as $_v ) {
3271 'rel' =>
'alternate',
3273 'href' => $this->
getTitle()->getLocalURL(
array(
'variant' => $_v ) ) )
3277 $canonicalUrl = $this->
getTitle()->getLocalURL();
3284 if ( $wgRightsPage ) {
3288 $copyright = $copy->getLocalURL();
3292 if ( !$copyright && $wgRightsUrl ) {
3293 $copyright = $wgRightsUrl;
3298 'rel' =>
'copyright',
3299 'href' => $copyright )
3306 # Use the page name for the title. In principle, this could
3307 # lead to issues with having the same name for different feeds
3308 # corresponding to the same page, but we can't avoid that at
3314 # Used
messages:
'page-rss-feed' and
'page-atom-feed' (
for an easier grep)
3315 $this->
msg(
"page-{$format}-feed", $this->
getTitle()->getPrefixedText() )->
text()
3319 # Recent changes feed should appear on every page (except recentchanges,
3320 # that would be redundant). Put it after the per-page feed to avoid
3321 # changing existing behavior. It's still available, probably via a
3322 # menu in your browser. Some sites might have a different feed they'd
3323 # like to promote instead of the RC feed (maybe like a "Recent New Articles"
3324 # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
3325 # If so, use it instead.
3326 if ( $wgOverrideSiteFeed ) {
3327 foreach ( $wgOverrideSiteFeed
as $type => $feedUrl ) {
3332 $this->
msg(
"site-{$type}-feed", $wgSitename )->
text()
3335 } elseif ( !$this->
getTitle()->isSpecial(
'Recentchanges' ) ) {
3337 foreach ( $wgAdvertisedFeedTypes
as $format ) {
3340 $rctitle->getLocalURL(
array(
'feed' => $format ) ),
3341 $this->
msg(
"site-{$format}-feed", $wgSitename )->text() # For grep:
'site-rss-feed',
'site-atom-feed'.
3348 global $wgEnableCanonicalServerLink;
3349 if ( $wgEnableCanonicalServerLink ) {
3350 if ( $canonicalUrl !==
false ) {
3353 $reqUrl = $this->
getRequest()->getRequestURL();
3357 if ( $canonicalUrl !==
false ) {
3359 'rel' =>
'canonical',
3360 'href' => $canonicalUrl
3382 private function feedLink( $type, $url, $text ) {
3384 'rel' =>
'alternate',
3385 'type' =>
"application/$type+xml",
3400 public function addStyle( $style, $media =
'', $condition =
'',
$dir =
'' ) {
3408 $options[
'condition'] = $condition;
3422 if ( $flip ===
'flip' && $this->
getLanguage()->isRTL() ) {
3423 # If wanted, and the interface is right-to-left, flip the CSS
3438 $this->
getSkin()->setupSkinUserCss( $this );
3450 $moduleStyles[] =
'site';
3451 $moduleStyles[] =
'noscript';
3452 $moduleStyles[] =
'user.groups';
3459 array(
'excludepage' => $this->
getTitle()->getPrefixedDBkey() )
3461 $otherTags .=
$link[
'html'];
3466 $previewedCSS = $this->
getRequest()->getText(
'wpTextbox1' );
3473 $moduleStyles[] =
'user';
3477 $moduleStyles[] =
'user.cssprefs';
3479 foreach ( $moduleStyles
as $name ) {
3484 $group = $module->getGroup();
3499 $links[] =
Html::element(
'meta',
array(
'name' =>
'ResourceLoaderDynamicStyles',
'content' =>
'' ) ) .
"\n";
3504 foreach (
array(
'site',
'noscript',
'private',
'user' )
as $group ) {
3521 foreach ( $this->mExtStyles
as $url ) {
3524 $this->mExtStyles =
array();
3549 if ( isset(
$options[
'media'] ) ) {
3551 if ( is_null( $media ) ) {
3558 if ( substr( $style, 0, 1 ) ==
'/' ||
3559 substr( $style, 0, 5 ) ==
'http:' ||
3560 substr( $style, 0, 6 ) ==
'https:' ) {
3563 global $wgStylePath, $wgStyleVersion;
3564 $url = $wgStylePath .
'/' . $style .
'?' . $wgStyleVersion;
3569 if ( isset(
$options[
'condition'] ) ) {
3570 $condition = htmlspecialchars(
$options[
'condition'] );
3571 $link =
"<!--[if $condition]>$link<![endif]-->";
3587 $screenMediaQueryRegex =
'/^(?:only\s+)?screen\b/i';
3591 'printable' =>
'print',
3592 'handheld' =>
'handheld',
3594 foreach ( $switches
as $switch => $targetMedia ) {
3595 if ( $wgRequest->getBool( $switch ) ) {
3596 if ( $media == $targetMedia ) {
3598 } elseif ( preg_match( $screenMediaQueryRegex, $media ) === 1 ) {
3609 if ( $targetMedia ==
'print' || $media ==
'screen' ) {
3626 $args = func_get_args();
3667 $msgSpecs = func_get_args();
3668 array_shift( $msgSpecs );
3669 $msgSpecs = array_values( $msgSpecs );
3671 foreach ( $msgSpecs
as $n => $spec ) {
3672 if ( is_array( $spec ) ) {
3675 if ( isset(
$args[
'options'] ) ) {
3676 unset(
$args[
'options'] );
3678 'Adding "options" to ' . __METHOD__ .
' is no longer supported',
3686 $s = str_replace(
'$' . (
$n + 1 ), $this->
msg( $name,
$args )->plain(),
$s );
3709 public function enableTOC( $flag =
true ) {
3710 $this->mEnableTOC = $flag;
3727 $this->mEnableSectionEditLinks = $flag;
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
static getActionName(IContextSource $context)
Get the action that will be executed, not necessarily the one passed passed through the "action" requ...
preventClickjacking( $enable=true)
Set a flag which will cause an X-Frame-Options header appropriate for edit pages to be sent.
static makeLoaderConditionalScript( $script)
Returns JS code which runs given JS code if the client-side framework is present.
addCategoryLinks( $categories)
Add an array of categories, with names in the keys.
Set options of the Parser.
getCategoryLinks()
Get the list of category links, in a 2-D array with the following format: $arr[$type][] = $link,...
addMeta( $name, $val)
Add a new "<meta>" tag To add an http-equiv meta tag, precede the name with "http:".
setArticleRelated( $v)
Set whether this page is related an article on the wiki Setting false will cause the change of "artic...
Object passed around to modules which contains information about the state of a specific loader reque...
$mRevisionId
should be private. To include the variable {{REVISIONID}}
$mHeadItems
Array of elements in "<head>". Parser might add its own headers!
getSubtitle()
Get the subtitle.
WebRequest clone which takes values from a provided array.
setAllowedModules( $type, $level)
Set the highest level of CSS/JS untrustworthiness allowed.
enableClientCache( $state)
Use enableClientCache(false) to force it to send nocache headers.
styleLink( $style, $options)
Generate <link> tags for stylesheets.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
addWikiMsg()
Add a wikitext-formatted message to the output.
getContext()
Get the RequestContext object.
getLanguageLinks()
Get the list of language links.
reduceAllowedModules( $type, $level)
Limit the highest level of CSS/JS untrustworthiness allowed.
wfBCP47( $code)
Get the normalised IETF language tag See unit test for examples.
addSubtitle( $str)
Add $str to the subtitle.
addAcceptLanguage()
bug 21672: Add Accept-Language to Vary and XVO headers if there's no 'variant' parameter existed in G...
bool $mEnableSectionEditLinks
Whether parser output should contain section edit links.
static formatRobotPolicy( $policy)
Converts a String robot policy into an associative array, to allow merging of several policies using ...
getJSVars()
Get an array containing the variables to be set in mw.config in JavaScript.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static makeConfigSetScript(array $configuration)
Returns JS code which will set the MediaWiki configuration array to the given value.
static htmlHeader( $attribs=array())
Constructs the opening html-tag with necessary doctypes depending on global variables.
Show an error when the user tries to do something whilst blocked.
showFileRenameError( $old, $new)
$mBodytext
Contains all of the "<body>" content. Should be private we got set/get accessors and the append() met...
getScriptsForBottomQueue( $inHead)
JS stuff to put at the 'bottom', which can either be the bottom of the "<body>" or the bottom of the ...
Title $mRedirectedFrom
If the current page was reached through a redirect, $mRedirectedFrom contains the Title of the redire...
setTitle(Title $t)
Set the Title object to use.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Class representing a list of titles The execute() method checks them all for existence and adds them ...
hasHeadItem( $name)
Check if the header item $name is already set.
__construct(IContextSource $context=null)
Constructor for OutputPage.
addModuleMessages( $modules)
Add only messages of one or more modules recognized by the resource loader.
getScript()
Get all registered JS and CSS tags for the header.
addModuleStyles( $modules)
Add only CSS of one or more modules recognized by the resource loader.
loginToUse()
Produce the stock "please login to use the wiki" page.
$mLanguageLinks
Should be private. Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page')
$mSubtitle
Should be private.
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
isArticleRelated()
Return whether this page is related an article on the wiki.
enableSectionEditLinks( $flag=true)
Enables/disables section edit links, doesn't override NOEDITSECTION
setArticleBodyOnly( $only)
Set whether the output should only contain the body of the article, without any skin,...
getFrameOptions()
Get the X-Frame-Options header value (without the name part), or false if there isn't one.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
blockedPage()
Produce a "user is blocked" page.
getRevisionId()
Get the displayed revision ID.
addParserOutput(&$parserOutput)
Add a ParserOutput object.
addWikiTextTitleTidy( $text, &$title, $linestart=true)
Add wikitext with a custom Title object and tidy enabled.
clearHTML()
Clear the body HTML.
static newMainPage()
Create a new Title for the Main Page.
setCategoryLinks( $categories)
Reset the category links (but not the category list) and add $categories.
addScript( $script)
Add raw HTML to the list of scripts (including <script> tag, etc.)
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
returnToMain( $unused=null, $returnto=null, $returntoquery=null)
Add a "return to" link pointing to a specified title, or the title indicated in the request,...
$mIsArticleRelated
Should be private.
$mHTMLtitle
Should be private. Stores contents of "<title>" tag.
wfProfileIn( $functionname)
Begin profiling of a function.
setPageTitleActionText( $text)
Set the new value of the "action text", this will be added to the "HTML title", separated from it wit...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
if( $wgRCFilterByAge) if( $wgSkipSkin) if( $wgLocalInterwiki) if( $wgSharedPrefix===false) if(! $wgCookiePrefix) $wgCookiePrefix
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
isUserJsAllowed()
Return whether user JavaScript is allowed for this page.
getBottomScripts()
JS stuff to put at the bottom of the "<body>".
showFileNotFoundError( $name)
static getHtmlFromLoaderLinks(Array $links)
Build html output from an array of links from makeResourceLoaderLink.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success such as when responding to a resource loader request or generating HTML output & $resourceLoader
getModuleStyles( $filter=false, $position=null)
Get the list of module CSS to include on this page.
addToBodyAttributes( $out, &$bodyAttrs)
This will be called by OutputPage::headElement when it is creating the "<body>" tag,...
versionRequired( $version)
Display an error page indicating that a given version of MediaWiki is required to use it.
parseInline( $text, $linestart=true, $interface=false)
Parse wikitext, strip paragraphs, and return the HTML.
addScriptFile( $file, $version=null)
Add a JavaScript file out of skins/common, or a given relative path.
parserOptions( $options=null)
Get/set the ParserOptions object to use for wikitext parsing.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
getFileVersion()
Get the displayed file version.
getSyndicationLinks()
Return URLs for each supported syndication format for this page.
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
getRequest()
Get the WebRequest object.
Show an error when a user tries to do something they do not have the necessary permissions for.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. Handler functions that modify $result should generally return false to further attempts at conversion. 'ContribsPager you ll need to handle error messages
static groupHasPermission( $group, $role)
Check, if the given group has the given permission.
getRedirect()
Get the URL to redirect to, or an empty string if not redirect URL set.
setCanonicalUrl( $url)
Set the URL to be used for the <link rel="canonical">.
$mExtStyles
Additional stylesheets. Looks like this is for extensions. Might be replaced by resource loader.
getUser()
Get the User object.
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
getTitle()
Get the Title object.
getHtmlElementAttributes()
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
permissionRequired( $permission)
Display an error page noting that a given permission bit is required.
static stripAllTags( $text)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed,...
showFileDeleteError( $name)
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
addHTML( $text)
Append $text to the body HTML.
addHeadItem( $name, $value)
Add or replace an header item to the output.
addWikiTextTidy( $text, $linestart=true)
Add wikitext with tidy enabled.
$mArticleBodyOnly
Flag if output should only contain the body of the article.
getModuleScripts( $filter=false, $position=null)
Get the list of module JS to include on this page.
getRevisionTimestamp()
Get the timestamp of displayed revision.
addWikiMsgArray( $name, $args)
Add a wikitext-formatted message to the output.
enableTOC( $flag=true)
Enables/disables TOC, doesn't override NOTOC
static transformCssMedia( $media)
Transform "media" attribute based on request parameters.
setLastModified( $timestamp)
Override the last modified timestamp.
$mNoGallery
Comes from the parser.
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
getAllowedModules( $type=null)
Get the level of JavaScript / CSS untrustworthiness allowed on this page.
getLanguage()
Get the Language object.
static makeLoaderQuery( $modules, $lang, $skin, $user=null, $version=null, $debug=false, $only=null, $printable=false, $handheld=false, $extraQuery=array())
Build a query array (array representation of query string) for load.php.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
forceHideNewSectionLink()
Forcibly hide the new section link?
addWikiTextWithTitle( $text, &$title, $linestart=true)
Add wikitext with a custom Title object.
static closeElement( $element)
Returns "</$element>", except if $wgWellFormedXml is off, in which case it returns the empty string w...
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
static isXmlMimeType( $mimetype)
Determines if the given mime type is xml.
readOnlyPage( $source=null, $protected=false, $reasons=array(), $action=null)
Display a page stating that the Wiki is in read-only mode, and optionally show the source of the page...
showErrorPage( $title, $msg, $params=array())
Output a standard error page.
static openElement( $element, $attribs=array())
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
getModuleMessages( $filter=false, $position=null)
Get the list of module messages to include on this page.
if( $wgAPIRequestLog) $lb
Implements some public methods and some protected utility functions which are required by multiple ch...
feedLink( $type, $url, $text)
Generate a "<link rel/>" for a feed.
$mLastModified
mLastModified and mEtag are used for sending cache control.
addStyle( $style, $media='', $condition='', $dir='')
Add a local or specified stylesheet, with the given media options.
sendCacheControl()
Send cache control HTTP headers.
setETag( $tag)
Set the value of the ETag HTTP header, only used if $wgUseETag is true.
out( $ins)
Actually output something with print.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfRestoreWarnings()
Restore error level to previous value.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
output()
Finally, all the text has been munged and accumulated into the object, let's actually output it:
bool $mEnableTOC
Whether parser output should contain table of contents.
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
$mInlineStyles
Inline CSS styles.
setFileVersion( $file)
Set the displayed file version.
showUnexpectedValueError( $name, $val)
static makeLoaderStateScript( $name, $state=null)
Returns a JS call to mw.loader.state, which sets the state of a module or modules to a given value.
getResourceLoader()
Get a ResourceLoader object associated with this OutputPage.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
static linkedScript( $url)
Output a "<script>" tag linking to the given URL, e.g., "<script src=foo.js></script>".
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
getWikiPage()
Get the WikiPage object.
setFeedAppendQuery( $val)
Add default feeds to the page header This is mainly kept for backward compatibility,...
int $mAllowedModuleOrigin
The level of 'untrustworthiness' allowed for modules loaded on this page.
isDisabled()
Return whether the output will be completely disabled.
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
setRevisionId( $revid)
Set the revision ID which will be seen by the wiki text parser for things such as embedded {{REVISION...
wfProfileOut( $functionname='missing')
Stop profiling of a function.
setArticleFlag( $v)
Set whether the displayed content is related to the source of the corresponding article on the wiki S...
disallowUserJs()
Restrict the page to loading modules bundled the software.
getSkin()
Get the Skin object.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
setSubtitle( $str)
Replace the subtitle with $str.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
addVaryHeader( $header, $option=null)
Add an HTTP header that will influence on the cache.
static getStatusMessage( $code)
Get the message associated with the HTTP response code $code.
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...
Show an error when the user hits a rate limit.
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
getVaryHeader()
Return a Vary: header on which to vary caches.
addModules( $modules)
Add one or more modules recognized by the resource loader.
showLagWarning( $lag)
Show a warning about slave lag.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
appendSubtitle( $str)
Add $str to the subtitle.
getPageTitleActionText()
Get the value of the "action text".
getCacheVaryCookies()
Get the list of cookies that will influence on the cache.
getHeadItems()
Get all header items in a string.
when a variable name is used in a it is silently declared as a new masking the global
addLanguageLinks( $newLinkArray)
Add new language links.
formatPermissionsErrorMessage( $errors, $action=null)
Format a list of error messages.
static makeLoaderURL( $modules, $lang, $skin, $user=null, $version=null, $debug=false, $only=null, $printable=false, $handheld=false, $extraQuery=array())
Build a load.php URL.
return false to override stock group removal can be modified modifiable will be added to $_SESSION & $cookies
getOrigin()
Get this module's origin.
addBacklinkSubtitle(Title $title)
Add a subtitle containing a backlink to a page.
setContext(IContextSource $context)
Set the IContextSource object.
addParserOutputNoText(&$parserOutput)
Add a ParserOutput object, but without Html.
isArticle()
Return whether the content displayed page is related to the source of the corresponding article on th...
This class should be covered by a general architecture document which does not exist as of January 20...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
ParserOptions $mParserOptions
lazy initialised, use parserOptions()
addLink( $linkarr)
Add a new <link> tag to the page header.
addInlineScript( $script)
Add a self-contained script tag with the given contents.
getArticleBodyOnly()
Return whether the output will contain only the body of the article.
getPreventClickjacking()
Get the prevent-clickjacking flag.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
getExtStyle()
Get all styles added by extensions.
setStatusCode( $statusCode)
Set the HTTP status code to send with the output.
includeJQuery( $modules=array())
Include jQuery core.
makeResourceLoaderLink( $modules, $only, $useESI=false, array $extraQuery=array(), $loadCall=false)
TODO: Document.
haveCacheVaryCookies()
Check if the request has a cache-varying cookie header If it does, it's very important that we don't ...
getPageTitle()
Return the "page title", i.e.
disable()
Disable output completely, i.e.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
sectionEditLinksEnabled()
setIndexPolicy( $policy)
Set the index policy for the page, but leave the follow policy un- touched.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getRelevantTitle()
Return the "relevant" title.
presenting them properly to the user as errors is done by the caller $title
getPageClasses( $title)
TODO: document.
showPermissionsErrorPage( $errors, $action=null)
Output a standard permission error page.
setRevisionTimestamp( $timestamp)
Set the timestamp of the revision which will be displayed.
Allows to change the fields on the form that will be generated $name
getHeadItemsArray()
Get an array of head items.
wfClearOutputBuffers()
More legible than passing a 'false' parameter to wfResetOutputBuffers():
rateLimited()
Turn off regular page output and return an error response for when rate limiting has triggered.
const ORIGIN_USER_INDIVIDUAL
const TS_ISO_8601_BASIC
ISO 8601 basic format with no timezone: 19860209T200000Z.
reduceAllowedModuleOrigin( $level)
Limit the highest level of CSS/JS untrustworthiness allowed.
getProperty( $name)
Get an additional output property.
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
setSquidMaxage( $maxage)
Set the value of the "s-maxage" part of the "Cache-control" HTTP header.
setTarget( $target)
Sets ResourceLoader target for load.php links.
setHTMLTitle( $name)
"HTML title" means the contents of "<title>".
$styles
An array of stylesheet filenames (relative from skins path), with options for CSS media,...
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
$mProperties
Additional key => value data.
wrapWikiMsg( $wrap)
This function takes a number of message/argument specifications, wraps them in some overall structure...
buildCssLinks()
Build a set of "<link>" elements for the stylesheets specified in the $this->styles array.
static inlineStyle( $contents, $media='all')
Output a "<style>" tag with the given contents for the given media type (if any).
filterModules( $modules, $position=null, $type=ResourceLoaderModule::TYPE_COMBINED)
Filter an array of modules to remove insufficiently trustworthy members, and modules which are no lon...
prependHTML( $text)
Prepend $text to the body HTML.
static formatTemplates( $templates, $preview=false, $section=false, $more=null)
Returns HTML for the "templates used on this page" list.
static exists( $index)
Returns whether the specified namespace exists.
getHTMLTitle()
Return the "HTML title", i.e.
showFileCopyError( $old, $new)
const ORIGIN_CORE_INDIVIDUAL
clearSubtitle()
Clear the subtitles.
getMetadataAttribute()
Get the value of the "rel" attribute for metadata links.
static getMessage( $code)
Get the message associated with HTTP response code $code.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
$mScripts
Should be private.
getModules( $filter=false, $position=null, $param='mModules')
Get the list of modules to include on this page.
Interface for objects which can provide a context on request.
setFollowPolicy( $policy)
Set the follow policy for the page, but leave the index policy un- touched.
setPageTitle( $name)
"Page title" means the contents of <h1>.
$mDebugtext
Holds the debug lines that will be output as comments in page source if $wgDebugComments is enabled.
if(PHP_SAPI !='cli') $file
checkLastModified( $timestamp)
checkLastModified tells the client to use the client-cached page if possible.
Represents a title within MediaWiki.
Abstraction for resource loader modules, with name registration and maxage functionality.
addReturnTo( $title, $query=array(), $text=null, $options=array())
Add a "return to" link pointing to a specified title.
Dynamic JavaScript and CSS resource loading system.
setProperty( $name, $value)
Set an additional output property.
isPrintable()
Return whether the page is "printable".
setSyndicated( $show=true)
Add or remove feed links in the page header This is mainly kept for backward compatibility,...
string null $mTarget
ResourceLoader target for load.php links.
addInlineStyle( $style_css, $flip='noflip')
Adds inline CSS styles.
if(count( $args)==0) $dir
userCanPreview()
To make it harder for someone to slip a user a fake user-JavaScript or user-CSS preview,...
static linkedStyle( $url, $media='all')
Output a "<link rel=stylesheet>" linking to the given URL for the given media type (if any).
addExtensionStyle( $url)
Register and add a stylesheet from an extension directory.
static inDebugMode()
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie,...
setLanguageLinks( $newLinkArray)
Reset the language links and add new language links.
setRedirectedFrom( $t)
Set $mRedirectedFrom, the Title of the page which redirected us to the current page.
addWikiTextTitle( $text, Title $title, $linestart, $tidy=false, $interface=false)
Add wikitext with a custom Title object.
$mMetatags
Should be private. Used with addMeta() which adds "<meta>".
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
getHeadScripts()
JS stuff to put in the "<head>".
redirect( $url, $responsecode='302')
Redirect to $url rather than displaying the normal page.
setPrintable()
Set the page as printable, i.e.
$mJQueryDone
Whether jQuery is already handled.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
addModuleScripts( $modules)
Add only JS of one or more modules recognized by the resource loader.
allowClickjacking()
Turn off frame-breaking.
addElement( $element, $attribs=array(), $contents='')
Shortcut for adding an Html::element via addHTML.
showFatalError( $message)
getHTML()
Get the body HTML.
getRelevantUser()
Return the "relevant" user.
if(PHP_SAPI !='cli') $source
static normalizeCharReferences( $text)
Ensure that any entities and character references are legal for XML and XHTML specifically.
static addModules(OutputPage $out)
Add ResourceLoader modules to the OutputPage object if debugging is enabled.
addMetadataLink( $linkarr)
Add a new <link> with "rel" attribute set to "meta".
showNewSectionLink()
Show an "add new section" link?
static transform( $css, $swapLtrRtlInURL=false, $swapLeftRightInURL=false)
Transform an LTR stylesheet to RTL.
parse( $text, $linestart=true, $interface=false, $language=null)
Parse wikitext and return the HTML.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
addJsConfigVars( $keys, $value=null)
Add one or more variables to be set in mw.config in JavaScript.
$mPrintable
Should be private.
The main skin class which provides methods and properties for all other skins.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
$mPagetitle
Should be private - has getter and setter. Contains the HTML title.
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
getJsConfigVars()
Get the javascript config vars to include on this page.
getTemplateIds()
Get the templates used on this page.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
isSyndicated()
Should we output feed links for this page?
getFileSearchOptions()
Get the files used on this page.
$mFeedLinks
Handles the atom / rss links.
bool $mDoNothing
Whether output is disabled.
static & singleton()
Get an instance of this class.
getXVO()
Get a complete X-Vary-Options header.
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
prepareErrorPage( $pageTitle, $htmlTitle=false)
Prepare this object to display an error page; disable caching and indexing, clear the current text an...
addTemplate(&$template)
Add the output of a QuickTemplate to the output buffer.
getFeedAppendQuery()
Will currently always return null.
$mPageLinkTitle
Used by skin template.
$mIsarticle
Should be private. Is the displayed content related to the source of the corresponding wiki article.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
addFeedLink( $format, $href)
Add a feed link to the page header.
setRobotPolicy( $policy)
Set the robot policy for the page: http://www.robotstxt.org/meta.html
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes two arrays as input, and returns a CGI-style string, e.g.
static removeHTMLtags( $text, $processCallback=null, $args=array(), $extratags=array(), $removetags=array())
Cleans up HTML, removes dangerous tags and attributes, and removes HTML comments.
headElement(Skin $sk, $includeStyle=true)
getCategories()
Get the list of category names this page belongs to.