Go to the documentation of this file.
242 'Accept-Encoding' =>
array(
'list-contains=gzip' ),
280 # Extensions should use `new RequestContext` instead of `new OutputPage` now.
293 public function redirect( $url, $responsecode =
'302' ) {
294 # Strip newlines as a paranoia check for header injection in PHP<5.1.2
295 $this->mRedirect = str_replace(
"\n",
'', $url );
296 $this->mRedirectCode = $responsecode;
314 $this->mStatusCode = $statusCode;
325 array_push( $this->mMetatags,
array(
$name, $val ) );
336 array_push( $this->mLinktags, $linkarr );
356 $this->mCanonicalUrl = $url;
365 # note: buggy CC software only reads first "meta" link
366 static $haveMeta =
false;
368 return 'alternate meta';
381 $this->mScripts .= $script .
"\n";
393 array_push( $this->mExtStyles, $url );
413 global $wgStylePath, $wgStyleVersion;
415 if ( substr(
$file, 0, 1 ) ==
'/' || preg_match(
'#^[a-z]*://#i',
$file ) ) {
418 $path =
"{$wgStylePath}/common/{$file}";
454 $filteredModules =
array();
455 foreach ( $modules
as $val ) {
459 && ( is_null( $position ) || $module->getPosition() == $position )
460 && ( !$this->mTarget || in_array( $this->mTarget, $module->getTargets() ) )
462 $filteredModules[] = $val;
465 return $filteredModules;
476 public function getModules( $filter =
false, $position =
null, $param =
'mModules' ) {
477 $modules = array_values( array_unique( $this->$param ) );
491 $this->mModules = array_merge( $this->mModules, (
array)$modules );
503 return $this->
getModules( $filter, $position,
'mModuleScripts' );
514 $this->mModuleScripts = array_merge( $this->mModuleScripts, (
array)$modules );
526 return $this->
getModules( $filter, $position,
'mModuleStyles' );
539 $this->mModuleStyles = array_merge( $this->mModuleStyles, (
array)$modules );
551 return $this->
getModules( $filter, $position,
'mModuleMessages' );
562 $this->mModuleMessages = array_merge( $this->mModuleMessages, (
array)$modules );
578 $this->mTarget = $target;
597 foreach ( $this->mHeadItems
as $item ) {
620 return isset( $this->mHeadItems[
$name] );
640 $this->mArticleBodyOnly = $only;
671 if ( isset( $this->mProperties[
$name] ) ) {
672 return $this->mProperties[
$name];
690 global $wgCachePages, $wgCacheEpoch, $wgUseSquid, $wgSquidMaxage;
693 wfDebug( __METHOD__ .
": CACHE DISABLED, NO TIMESTAMP\n" );
696 if ( !$wgCachePages ) {
697 wfDebug( __METHOD__ .
": CACHE DISABLED\n" );
702 $modifiedTimes =
array(
704 'user' => $this->
getUser()->getTouched(),
705 'epoch' => $wgCacheEpoch
713 $maxModified = max( $modifiedTimes );
716 $clientHeader = $this->
getRequest()->getHeader(
'If-Modified-Since' );
717 if ( $clientHeader ===
false ) {
718 wfDebug( __METHOD__ .
": client did not send If-Modified-Since header\n",
'log' );
722 # IE sends sizes after the date like this:
723 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
724 # this breaks strtotime().
725 $clientHeader = preg_replace(
'/;.*$/',
'', $clientHeader );
728 $clientHeaderTime = strtotime( $clientHeader );
730 if ( !$clientHeaderTime ) {
731 wfDebug( __METHOD__ .
": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
739 if ( $info !==
'' ) {
745 wfDebug( __METHOD__ .
": client sent If-Modified-Since: " .
747 wfDebug( __METHOD__ .
": effective Last-Modified: " .
749 if ( $clientHeaderTime < $maxModified ) {
750 wfDebug( __METHOD__ .
": STALE, $info\n",
'log' );
755 # Give a 304 response code and disable body output
756 wfDebug( __METHOD__ .
": NOT MODIFIED, $info\n",
'log' );
757 ini_set(
'zlib.output_compression', 0 );
758 $this->
getRequest()->response()->header(
"HTTP/1.1 304 Not Modified" );
791 if ( isset( $policy[
'index'] ) ) {
794 if ( isset( $policy[
'follow'] ) ) {
807 $policy = trim( $policy );
808 if ( in_array( $policy,
array(
'index',
'noindex' ) ) ) {
809 $this->mIndexPolicy = $policy;
821 $policy = trim( $policy );
822 if ( in_array( $policy,
array(
'follow',
'nofollow' ) ) ) {
823 $this->mFollowPolicy = $policy;
834 $this->mPageTitleActionText = $text;
843 if ( isset( $this->mPageTitleActionText ) ) {
856 if (
$name instanceof Message ) {
859 $this->mHTMLtitle =
$name;
878 $this->mRedirectedFrom =
$t;
890 if (
$name instanceof Message ) {
894 # change "<script>foo&bar</script>" to "<script>foo&bar</script>"
895 # but leave "<i>foobar</i>" alone
897 $this->mPagetitle = $nameWithTags;
899 # change "<i>foo&bar</i>" to "foo&bar"
902 ->inContentLanguage()
950 if ( $str instanceof Message ) {
951 $this->mSubtitle[] = $str->setContext( $this->
getContext() )->parse();
953 $this->mSubtitle[] = $str;
964 if (
$title->isRedirect() ) {
965 $query[
'redirect'] =
'no';
974 $this->mSubtitle =
array();
983 return implode(
"<br />\n\t\t\t\t", $this->mSubtitle );
991 $this->mPrintable =
true;
1007 $this->mDoNothing =
true;
1049 $this->mFeedLinks =
array();
1063 global $wgAdvertisedFeedTypes;
1065 $this->mFeedLinks =
array();
1067 foreach ( $wgAdvertisedFeedTypes
as $type ) {
1069 if ( is_string( $val ) ) {
1083 global $wgAdvertisedFeedTypes;
1085 if ( in_array( $format, $wgAdvertisedFeedTypes ) ) {
1086 $this->mFeedLinks[$format] = $href;
1095 return count( $this->mFeedLinks ) > 0;
1123 $this->mIsarticle = $v;
1125 $this->mIsArticleRelated = $v;
1146 $this->mIsArticleRelated = $v;
1148 $this->mIsarticle =
false;
1168 $this->mLanguageLinks += $newLinkArray;
1178 $this->mLanguageLinks = $newLinkArray;
1198 if ( !is_array( $categories ) || count( $categories ) == 0 ) {
1202 # Add the links to a LinkBatch
1205 $lb->setArray( $arr );
1207 # Fetch existence plus the hiddencat property
1210 array(
'page_id',
'page_namespace',
'page_title',
'page_len',
'page_is_redirect',
'page_latest',
'pp_value' ),
1211 $lb->constructSet(
'page',
$dbr ),
1214 array(
'page_props' =>
array(
'LEFT JOIN',
array(
'pp_propname' =>
'hiddencat',
'pp_page = page_id' ) ) )
1217 # Add the results to the link cache
1220 # Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
1221 $categories = array_combine(
1222 array_keys( $categories ),
1223 array_fill( 0, count( $categories ),
'normal' )
1226 # Mark hidden categories
1227 foreach (
$res as $row ) {
1228 if ( isset( $row->pp_value ) ) {
1229 $categories[$row->page_title] =
'hidden';
1233 # Add the remaining categories to the skin
1234 if (
wfRunHooks(
'OutputPageMakeCategoryLinks',
array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
1235 foreach ( $categories
as $category =>
$type ) {
1236 $origcategory = $category;
1239 if ( $category != $origcategory ) {
1240 if ( array_key_exists( $category, $categories ) ) {
1245 $this->mCategories[] =
$title->getText();
1257 $this->mCategoryLinks =
array();
1298 if ( $this->
getConfig()->
get(
'AllowSiteCSSOnRestrictedPages' ) ) {
1329 return min( array_values( $this->mAllowedModules ) );
1331 return isset( $this->mAllowedModules[
$type] )
1332 ? $this->mAllowedModules[
$type]
1377 public function addHTML( $text ) {
1378 $this->mBodytext .= $text;
1398 $this->mBodytext =
'';
1418 if ( !$this->mParserOptions ) {
1420 $this->mParserOptions->setEditSection(
false );
1433 $val = is_null( $revid ) ? null : intval( $revid );
1434 return wfSetVar( $this->mRevisionId, $val );
1476 $val =
array(
'time' =>
$file->getTimestamp(),
'sha1' =>
$file->getSha1() );
1478 return wfSetVar( $this->mFileVersion, $val,
true );
1518 public function addWikiText( $text, $linestart =
true, $interface =
true ) {
1575 $oldTidy = $popts->setTidy( $tidy );
1576 $popts->setInterfaceMessage( (
bool)$interface );
1580 $linestart,
true, $this->mRevisionId
1583 $popts->setTidy( $oldTidy );
1596 $this->mLanguageLinks += $parserOutput->getLanguageLinks();
1598 $this->mNewSectionLink = $parserOutput->getNewSection();
1599 $this->mHideNewSectionLink = $parserOutput->getHideNewSection();
1601 $this->mParseWarnings = $parserOutput->getWarnings();
1602 if ( !$parserOutput->isCacheable() ) {
1605 $this->mNoGallery = $parserOutput->getNoGallery();
1606 $this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
1607 $this->
addModules( $parserOutput->getModules() );
1612 $this->mPreventClickjacking = $this->mPreventClickjacking
1613 || $parserOutput->preventClickjacking();
1616 foreach ( (
array)$parserOutput->getTemplateIds()
as $ns => $dbks ) {
1617 if ( isset( $this->mTemplateIds[$ns] ) ) {
1618 $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
1620 $this->mTemplateIds[$ns] = $dbks;
1624 foreach ( (
array)$parserOutput->getFileSearchOptions()
as $dbk => $data ) {
1625 $this->mImageTimeKeys[$dbk] = $data;
1629 global $wgParserOutputHooks;
1630 foreach ( $parserOutput->getOutputHooks()
as $hookInfo ) {
1631 list( $hookName, $data ) = $hookInfo;
1632 if ( isset( $wgParserOutputHooks[$hookName] ) ) {
1633 call_user_func( $wgParserOutputHooks[$hookName], $this, $parserOutput, $data );
1639 $linkFlags =
array();
1641 wfRunHooks(
'OutputPageParserOutput',
array( &$this, $parserOutput ) );
1651 $parserOutput->setTOCEnabled( $this->mEnableTOC );
1654 if ( $parserOutput->getEditSectionTokens() ) {
1655 $parserOutput->setEditSectionTokens( $this->mEnableSectionEditLinks );
1657 $text = $parserOutput->getText();
1668 $this->
addHTML( $template->getHTML() );
1683 public function parse( $text, $linestart =
true, $interface =
false, $language =
null ) {
1686 if ( is_null( $this->
getTitle() ) ) {
1687 throw new MWException(
'Empty $mTitle in ' . __METHOD__ );
1692 $popts->setInterfaceMessage(
true );
1694 if ( $language !==
null ) {
1695 $oldLang = $popts->setTargetLanguage( $language );
1700 $linestart,
true, $this->mRevisionId
1704 $popts->setInterfaceMessage(
false );
1706 if ( $language !==
null ) {
1707 $popts->setTargetLanguage( $oldLang );
1710 return $parserOutput->getText();
1723 public function parseInline( $text, $linestart =
true, $interface =
false ) {
1724 $parsed = $this->
parse( $text, $linestart, $interface );
1727 if ( preg_match(
'/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
1740 $this->mSquidMaxage = min( $maxage, $this->mCdnMaxageLimit );
1749 $this->mCdnMaxageLimit = min( $maxage, $this->mCdnMaxageLimit );
1761 return wfSetVar( $this->mEnableClientCache, $state );
1775 "{$wgCookiePrefix}Token",
1776 "{$wgCookiePrefix}LoggedOut",
1794 $cookieHeader = $this->
getRequest()->getHeader(
'cookie' );
1795 if ( $cookieHeader ===
false ) {
1799 foreach ( $cvCookies
as $cookieName ) {
1800 # Check for a simple string match, like the way squid does it
1801 if ( strpos( $cookieHeader, $cookieName ) !==
false ) {
1802 wfDebug( __METHOD__ .
": found $cookieName\n" );
1806 wfDebug( __METHOD__ .
": no cache-varying cookies found\n" );
1819 if ( !array_key_exists( $header, $this->mVaryHeader ) ) {
1820 $this->mVaryHeader[$header] = (
array)$option;
1821 } elseif ( is_array( $option ) ) {
1822 if ( is_array( $this->mVaryHeader[$header] ) ) {
1823 $this->mVaryHeader[$header] = array_merge( $this->mVaryHeader[$header], $option );
1825 $this->mVaryHeader[$header] = $option;
1828 $this->mVaryHeader[$header] = array_unique( (
array)$this->mVaryHeader[$header] );
1838 return 'Vary: ' . join(
', ', array_keys( $this->mVaryHeader ) );
1846 public function getXVO() {
1849 $cookiesOption =
array();
1850 foreach ( $cvCookies
as $cookieName ) {
1851 $cookiesOption[] =
'string-contains=' . $cookieName;
1856 foreach ( $this->mVaryHeader
as $header => $option ) {
1857 $newheader = $header;
1858 if ( is_array( $option ) && count( $option ) > 0 ) {
1859 $newheader .=
';' . implode(
';', $option );
1861 $headers[] = $newheader;
1863 $xvo =
'X-Vary-Options: ' . implode(
',', $headers );
1877 $lang = $this->
getTitle()->getPageLanguage();
1878 if ( !$this->
getRequest()->getCheck(
'variant' ) && $lang->hasVariants() ) {
1879 $variants = $lang->getVariants();
1880 $aloption =
array();
1881 foreach ( $variants
as $variant ) {
1882 if ( $variant === $lang->getCode() ) {
1885 $aloption[] =
'string-contains=' . $variant;
1890 $variantBCP47 =
wfBCP47( $variant );
1891 if ( $variantBCP47 !== $variant ) {
1892 $aloption[] =
'string-contains=' . $variantBCP47;
1911 $this->mPreventClickjacking = $enable;
1920 $this->mPreventClickjacking =
false;
1941 global $wgBreakFrames, $wgEditPageFrameOptions;
1942 if ( $wgBreakFrames ) {
1944 } elseif ( $this->mPreventClickjacking && $wgEditPageFrameOptions ) {
1945 return $wgEditPageFrameOptions;
1954 global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgUseXVO;
1957 if ( $wgUseETag && $this->mETag ) {
1958 $response->header(
"ETag: $this->mETag" );
1964 # don't serve compressed data to clients who can't handle it
1965 # maintain different caches for logged-in users and non-logged in ones
1969 # Add an X-Vary-Options header for Squid with Wikimedia patches
1973 if ( $this->mEnableClientCache ) {
1975 $wgUseSquid && session_id() ==
'' && !$this->
isPrintable() &&
1979 # We'll purge the proxy cache explicitly, but require end user agents
1980 # to revalidate against the proxy on each visit.
1981 # Surrogate-Control controls our Squid, Cache-Control downstream caches
1982 wfDebug( __METHOD__ .
": proxy caching with ESI; {$this->mLastModified} **\n",
'log' );
1983 # start with a shorter timeout for initial testing
1984 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
1985 $response->header(
'Surrogate-Control: max-age=' . $wgSquidMaxage .
'+' . $this->mSquidMaxage .
', content="ESI/1.0"' );
1986 $response->header(
'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
1988 # We'll purge the proxy cache for anons explicitly, but require end user agents
1989 # to revalidate against the proxy on each visit.
1990 # IMPORTANT! The Squid needs to replace the Cache-Control header with
1991 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
1992 wfDebug( __METHOD__ .
": local proxy caching; {$this->mLastModified} **\n",
'log' );
1993 # start with a shorter timeout for initial testing
1994 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
1995 $response->header(
'Cache-Control: s-maxage=' . $this->mSquidMaxage .
', must-revalidate, max-age=0' );
1998 # We do want clients to cache if they can, but they *must* check for updates
1999 # on revisiting the page.
2000 wfDebug( __METHOD__ .
": private caching; {$this->mLastModified} **\n",
'log' );
2001 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
2002 $response->header(
"Cache-Control: private, must-revalidate, max-age=0" );
2004 if ( $this->mLastModified ) {
2005 $response->header(
"Last-Modified: {$this->mLastModified}" );
2008 wfDebug( __METHOD__ .
": no caching **\n",
'log' );
2010 # In general, the absence of a last modified header should be enough to prevent
2011 # the client from using its cache. We send a few other things just to make sure.
2012 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
2013 $response->header(
'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
2014 $response->header(
'Pragma: no-cache' );
2035 public function output() {
2036 global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP,
2037 $wgUseAjax, $wgResponsiveImages;
2039 if ( $this->mDoNothing ) {
2047 if ( $this->mRedirect !=
'' ) {
2048 # Standards require redirect URLs to be absolute
2054 if (
wfRunHooks(
"BeforePageRedirect",
array( $this, &$redirect, &$code ) ) ) {
2055 if ( $code ==
'301' || $code ==
'303' ) {
2056 if ( !$wgDebugRedirects ) {
2058 $response->header(
"HTTP/1.1 $code $message" );
2062 if ( $wgVaryOnXFP ) {
2067 $response->header(
"Content-Type: text/html; charset=utf-8" );
2068 if ( $wgDebugRedirects ) {
2069 $url = htmlspecialchars( $redirect );
2070 print
"<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
2071 print
"<p>Location: <a href=\"$url\">$url</a></p>\n";
2072 print
"</body>\n</html>\n";
2074 $response->header(
'Location: ' . $redirect );
2080 } elseif ( $this->mStatusCode ) {
2083 $response->header(
'HTTP/1.1 ' . $this->mStatusCode .
' ' . $message );
2087 # Buffer output; final headers may depend on later processing
2090 $response->header(
"Content-type: $wgMimeType; charset=UTF-8" );
2091 $response->header(
'Content-language: ' . $wgLanguageCode );
2095 if ( $frameOptions ) {
2096 $response->header(
"X-Frame-Options: $frameOptions" );
2099 if ( $this->mArticleBodyOnly ) {
2105 $modules = $sk->getDefaultModules();
2108 $coreModules =
array(
2110 'mediawiki.page.startup',
2115 if ( $wgResponsiveImages ) {
2116 $coreModules[] =
'mediawiki.hidpi';
2120 foreach ( $modules
as $group ) {
2154 public function out( $ins ) {
2179 if ( $htmlTitle !==
false ) {
2185 $this->mRedirect =
'';
2203 if ( !
$title instanceof Message ) {
2209 if ( $msg instanceof Message ) {
2211 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 );
2213 $this->
addHTML( $msg->parseAsBlock() );
2233 if ( in_array( $action,
array(
'read',
'edit',
'createpage',
'createtalk',
'upload' ) )
2234 && $this->
getUser()->isAnon() && count( $errors ) == 1 && isset( $errors[0][0] )
2235 && ( $errors[0][0] ==
'badaccess-groups' || $errors[0][0] ==
'badaccess-group0' )
2239 $displayReturnto =
null;
2241 # Due to bug 32276, if a user does not have read permissions,
2242 # $this->getTitle() will just give Special:Badtitle, which is
2243 # not especially useful as a returnto parameter. Use the title
2244 # from the request instead, if there was one.
2247 if ( $action ==
'edit' ) {
2248 $msg =
'whitelistedittext';
2249 $displayReturnto = $returnto;
2250 } elseif ( $action ==
'createpage' || $action ==
'createtalk' ) {
2251 $msg =
'nocreatetext';
2252 } elseif ( $action ==
'upload' ) {
2253 $msg =
'uploadnologintext';
2255 $msg =
'loginreqpagetext';
2262 $query[
'returnto'] = $returnto->getPrefixedText();
2264 if ( !$request->wasPosted() ) {
2265 $returntoquery = $request->getValues();
2266 unset( $returntoquery[
'title'] );
2267 unset( $returntoquery[
'returnto'] );
2268 unset( $returntoquery[
'returntoquery'] );
2274 $this->
msg(
'loginreqlink' )->escaped(),
2280 $this->
addHTML( $this->
msg( $msg )->rawParams( $loginLink )->
parse() );
2282 # Don't return to a page the user can't read otherwise
2283 # we'll end up in a pointless loop
2284 if ( $displayReturnto && $displayReturnto->userCan(
'read', $this->getUser() ) ) {
2333 if ( $action ==
null ) {
2334 $text = $this->
msg(
'permissionserrorstext', count( $errors ) )->plain() .
"\n\n";
2336 $action_desc = $this->
msg(
"action-$action" )->plain();
2338 'permissionserrorstext-withaction',
2341 )->plain() .
"\n\n";
2344 if ( count( $errors ) > 1 ) {
2345 $text .=
'<ul class="permissions-errors">' .
"\n";
2349 $text .= call_user_func_array(
array( $this,
'msg' ),
$error )->plain();
2354 $text .=
"<div class=\"permissions-errors\">\n" .
2355 call_user_func_array(
array( $this,
'msg' ), reset( $errors ) )->plain() .
2389 if ( $protected && empty( $reasons ) ) {
2390 $reasons[] =
array(
'badaccess-group0' );
2393 if ( !empty( $reasons ) ) {
2411 $pageLang = $this->
getTitle()->getPageLanguage();
2413 'id' =>
'wpTextbox1',
2414 'name' =>
'wpTextbox1',
2415 'cols' => $this->
getUser()->getOption(
'cols' ),
2416 'rows' => $this->
getUser()->getOption(
'rows' ),
2417 'readonly' =>
'readonly',
2418 'lang' => $pageLang->getHtmlCode(),
2419 'dir' => $pageLang->getDir(),
2425 $this->
addHTML(
"<div class='templatesUsed'>
2431 # If the title doesn't exist, it's fairly pointless to print a return
2432 # link to it. After all, you just tried editing it and couldn't, so
2433 # what's there to do there?
2434 if ( $this->
getTitle()->exists() ) {
2457 global $wgSlaveLagWarning, $wgSlaveLagCritical;
2458 if ( $lag >= $wgSlaveLagWarning ) {
2459 $message = $lag < $wgSlaveLagCritical
2502 $link = $this->
msg(
'returnto' )->rawParams(
2504 $this->
addHTML(
"<p id=\"mw-returnto\">{$link}</p>\n" );
2515 public function returnToMain( $unused =
null, $returnto =
null, $returntoquery =
null ) {
2516 if ( $returnto ==
null ) {
2517 $returnto = $this->
getRequest()->getText(
'returnto' );
2520 if ( $returntoquery ==
null ) {
2521 $returntoquery = $this->
getRequest()->getText(
'returntoquery' );
2524 if ( $returnto ===
'' ) {
2528 if ( is_object( $returnto ) ) {
2529 $titleObj = $returnto;
2533 if ( !is_object( $titleObj ) ) {
2559 # Don't bother with the newline if $head == ''
2560 $ret .=
"$openHead\n";
2579 $ret .=
Html::element(
'meta',
array(
'http-equiv' =>
'X-UA-Compatible',
'content' =>
'IE=EDGE' ) ) .
"\n";
2593 $ret .=
"$closeHead\n";
2596 $bodyClasses =
array();
2597 $bodyClasses[] =
'mediawiki';
2599 # Classes for LTR/RTL directionality support
2600 $bodyClasses[] = $userdir;
2601 $bodyClasses[] =
"sitedir-$sitedir";
2603 if ( $this->
getLanguage()->capitalizeAllNouns() ) {
2604 # A <body> class is probably not the best way to do this . . .
2605 $bodyClasses[] =
'capitalize-all-nouns';
2612 $bodyAttrs =
array();
2615 $bodyAttrs[
'class'] = implode(
' ', $bodyClasses );
2619 wfRunHooks(
'OutputPageBodyAttributes',
array( $this, $sk, &$bodyAttrs ) );
2632 if ( is_null( $this->mResourceLoader ) ) {
2648 global $wgResourceLoaderUseESI;
2650 $modules = (
array)$modules;
2654 'states' =>
array(),
2657 if ( !count( $modules ) ) {
2662 if ( count( $modules ) > 1 ) {
2664 $modules = array_unique( $modules );
2670 foreach ( $modules
as $name ) {
2672 $links[
'html'] .=
$link[
'html'];
2673 $links[
'states'] +=
$link[
'states'];
2679 if ( !is_null( $this->mTarget ) ) {
2686 foreach ( $modules
as $name ) {
2688 # Check that we're allowed to include this module on this page
2694 || ( $this->mTarget && !in_array( $this->mTarget, $module->getTargets() ) )
2699 $group = $module->getGroup();
2700 if ( !isset( $groups[$group] ) ) {
2701 $groups[$group] =
array();
2703 $groups[$group][
$name] = $module;
2706 foreach ( $groups
as $group => $grpModules ) {
2709 if ( ( $group ===
'user' || $group ===
'private' ) && $this->
getUser()->isLoggedIn() ) {
2718 $this->
getSkin()->getSkinName(),
2730 foreach ( $grpModules
as $key => $module ) {
2733 if ( $module->isKnownEmpty(
$context ) ) {
2734 unset( $grpModules[$key] );
2736 $links[
'states'][$key] =
'ready';
2742 if ( count( $grpModules ) === 0 ) {
2750 if ( $group ===
'private' ) {
2762 $links[
'html'] .=
"\n";
2772 if ( $group ===
'user' ) {
2775 foreach ( $grpModules
as $module ) {
2783 array_keys( $grpModules ),
2785 $this->
getSkin()->getSkinName(),
2794 if ( $useESI && $wgResourceLoaderUseESI ) {
2805 } elseif ( $loadCall ) {
2816 foreach ( $grpModules
as $key => $module ) {
2818 if ( $key !==
'startup' ) {
2819 $links[
'states'][$key] =
'loading';
2825 if ( $group ==
'noscript' ) {
2828 $links[
'html'] .=
$link .
"\n";
2844 if ( !is_array(
$link ) ) {
2848 $states +=
$link[
'states'];
2852 if ( count( $states ) ) {
2870 global $wgResourceLoaderExperimentalAsyncLoading;
2886 $embedScripts =
array(
'user.options',
'user.tokens' );
2905 if ( $wgResourceLoaderExperimentalAsyncLoading ) {
2922 global $wgUseSiteJs, $wgAllowUserJs;
2939 $modules = $this->
getModules(
true,
'bottom' );
2953 false,
array(), $inHead
2958 # XXX: additional security check/prompt?
2962 array(
'excludepage' => $this->
getTitle()->getPrefixedDBkey() ), $inHead
2973 false,
array(), $inHead
2979 false,
array(), $inHead
2990 global $wgResourceLoaderExperimentalAsyncLoading;
2998 if ( !$wgResourceLoaderExperimentalAsyncLoading ) {
3022 if ( is_array(
$keys ) ) {
3024 $this->mJsConfigVars[$key] =
$value;
3049 $canonicalSpecialPageName =
false; # bug 21115
3052 $ns =
$title->getNamespace();
3065 $curRevisionId = $wikiPage->getLatest();
3066 $articleId = $wikiPage->getId();
3069 $lang =
$title->getPageLanguage();
3072 $separatorTransTable = $lang->separatorTransformTable();
3073 $separatorTransTable = $separatorTransTable ? $separatorTransTable :
array();
3074 $compactSeparatorTransTable =
array(
3075 implode(
"\t", array_keys( $separatorTransTable ) ),
3076 implode(
"\t", $separatorTransTable ),
3078 $digitTransTable = $lang->digitTransformTable();
3079 $digitTransTable = $digitTransTable ? $digitTransTable :
array();
3080 $compactDigitTransTable =
array(
3081 implode(
"\t", array_keys( $digitTransTable ) ),
3082 implode(
"\t", $digitTransTable ),
3088 'wgCanonicalNamespace' => $canonicalNamespace,
3089 'wgCanonicalSpecialPageName' => $canonicalSpecialPageName,
3090 'wgNamespaceNumber' =>
$title->getNamespace(),
3091 'wgPageName' =>
$title->getPrefixedDBkey(),
3092 'wgTitle' =>
$title->getText(),
3093 'wgCurRevisionId' => $curRevisionId,
3095 'wgArticleId' => $articleId,
3097 'wgIsRedirect' => $title->isRedirect(),
3099 'wgUserName' =>
$user->isAnon() ? null :
$user->getName(),
3100 'wgUserGroups' =>
$user->getEffectiveGroups(),
3103 'wgPageContentLanguage' => $lang->getCode(),
3104 'wgPageContentModel' =>
$title->getContentModel(),
3105 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
3106 'wgDigitTransformTable' => $compactDigitTransTable,
3107 'wgDefaultDateFormat' => $lang->getDefaultDateFormat(),
3108 'wgMonthNames' => $lang->getMonthNamesArray(),
3109 'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
3110 'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
3112 if (
$user->isLoggedIn() ) {
3114 $vars[
'wgUserEditCount'] =
$user->getEditCount();
3116 $vars[
'wgUserRegistration'] = $userReg !==
null ? ( $userReg * 1000 ) :
null;
3120 $vars[
'wgUserNewMsgRevisionId'] =
$user->getNewMessageRevisionId();
3130 if (
$title->isMainPage() ) {
3131 $vars[
'wgIsMainPage'] =
true;
3133 if ( $this->mRedirectedFrom ) {
3134 $vars[
'wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBkey();
3136 if ( $relevantUser ) {
3137 $vars[
'wgRelevantUserName'] = $relevantUser->getName();
3160 if ( $this->
getRequest()->getVal(
'action' ) !=
'submit'
3162 || !$this->
getUser()->matchEditToken(
3163 $this->
getRequest()->getVal(
'wpEditToken' ) )
3167 if ( !$this->
getTitle()->isJsSubpage() && !$this->
getTitle()->isCssSubpage() ) {
3170 if ( !$this->
getTitle()->isSubpageOf( $this->
getUser()->getUserPage() ) ) {
3175 return !count( $this->
getTitle()->getUserPermissionsErrors(
'edit', $this->
getUser() ) );
3182 global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI,
3183 $wgSitename, $wgVersion,
3184 $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
3185 $wgDisableLangConversion, $wgCanonicalLanguageLinks,
3186 $wgRightsPage, $wgRightsUrl;
3193 'name' =>
'generator',
3194 'content' =>
"MediaWiki $wgVersion",
3197 $p =
"{$this->mIndexPolicy},{$this->mFollowPolicy}";
3198 if ( $p !==
'index,follow' ) {
3207 foreach ( $this->mMetatags
as $tag ) {
3208 if ( 0 == strcasecmp(
'http:', substr( $tag[0], 0, 5 ) ) ) {
3210 $tag[0] = substr( $tag[0], 5 );
3214 $tagName =
"meta-{$tag[0]}";
3215 if ( isset( $tags[$tagName] ) ) {
3216 $tagName .= $tag[1];
3221 'content' => $tag[1]
3226 foreach ( $this->mLinktags
as $tag ) {
3230 # Universal edit button
3236 $msg = $this->
msg(
'edit' )->text();
3238 'rel' =>
'alternate',
3239 'type' =>
'application/x-wiki',
3241 'href' => $this->
getTitle()->getLocalURL(
'action=edit' )
3247 'href' => $this->
getTitle()->getLocalURL(
'action=edit' )
3252 # Generally the order of the favicon and apple-touch-icon links
3253 # should not matter, but Konqueror (3.5.9 at least) incorrectly
3254 # uses whichever one appears later in the HTML source. Make sure
3255 # apple-touch-icon is specified first to avoid this.
3256 if ( $wgAppleTouchIcon !==
false ) {
3257 $tags[
'apple-touch-icon'] =
Html::element(
'link',
array(
'rel' =>
'apple-touch-icon',
'href' => $wgAppleTouchIcon ) );
3260 if ( $wgFavicon !==
false ) {
3261 $tags[
'favicon'] =
Html::element(
'link',
array(
'rel' =>
'shortcut icon',
'href' => $wgFavicon ) );
3264 # OpenSearch description link
3267 'type' =>
'application/opensearchdescription+xml',
3268 'href' =>
wfScript(
'opensearch_desc' ),
3269 'title' => $this->
msg(
'opensearch-desc' )->inContentLanguage()->
text(),
3272 if ( $wgEnableAPI ) {
3273 # Real Simple Discovery link, provides auto-discovery information
3274 # for the MediaWiki API (and potentially additional custom API
3275 # support such as WordPress or Twitter-compatible APIs for a
3276 # blogging extension, etc)
3279 'type' =>
'application/rsd+xml',
3287 if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks ) {
3288 $lang = $this->
getTitle()->getPageLanguage();
3289 if ( $lang->hasVariants() ) {
3291 $urlvar = $lang->getURLVariant();
3294 $variants = $lang->getVariants();
3295 foreach ( $variants
as $_v ) {
3297 'rel' =>
'alternate',
3299 'href' => $this->
getTitle()->getLocalURL(
array(
'variant' => $_v ) ) )
3303 $canonicalUrl = $this->
getTitle()->getLocalURL();
3310 if ( $wgRightsPage ) {
3314 $copyright = $copy->getLocalURL();
3318 if ( !$copyright && $wgRightsUrl ) {
3319 $copyright = $wgRightsUrl;
3324 'rel' =>
'copyright',
3325 'href' => $copyright )
3332 # Use the page name for the title. In principle, this could
3333 # lead to issues with having the same name for different feeds
3334 # corresponding to the same page, but we can't avoid that at
3340 # Used
messages:
'page-rss-feed' and
'page-atom-feed' (
for an easier grep)
3341 $this->
msg(
"page-{$format}-feed", $this->
getTitle()->getPrefixedText() )->
text()
3345 # Recent changes feed should appear on every page (except recentchanges,
3346 # that would be redundant). Put it after the per-page feed to avoid
3347 # changing existing behavior. It's still available, probably via a
3348 # menu in your browser. Some sites might have a different feed they'd
3349 # like to promote instead of the RC feed (maybe like a "Recent New Articles"
3350 # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
3351 # If so, use it instead.
3352 if ( $wgOverrideSiteFeed ) {
3353 foreach ( $wgOverrideSiteFeed
as $type => $feedUrl ) {
3358 $this->
msg(
"site-{$type}-feed", $wgSitename )->
text()
3361 } elseif ( !$this->
getTitle()->isSpecial(
'Recentchanges' ) ) {
3363 foreach ( $wgAdvertisedFeedTypes
as $format ) {
3366 $rctitle->getLocalURL(
array(
'feed' => $format ) ),
3367 $this->
msg(
"site-{$format}-feed", $wgSitename )->text() # For grep:
'site-rss-feed',
'site-atom-feed'.
3374 global $wgEnableCanonicalServerLink;
3375 if ( $wgEnableCanonicalServerLink ) {
3376 if ( $canonicalUrl !==
false ) {
3379 $reqUrl = $this->
getRequest()->getRequestURL();
3383 if ( $canonicalUrl !==
false ) {
3385 'rel' =>
'canonical',
3386 'href' => $canonicalUrl
3408 private function feedLink( $type, $url, $text ) {
3410 'rel' =>
'alternate',
3411 'type' =>
"application/$type+xml",
3426 public function addStyle( $style, $media =
'', $condition =
'',
$dir =
'' ) {
3434 $options[
'condition'] = $condition;
3448 if ( $flip ===
'flip' && $this->
getLanguage()->isRTL() ) {
3449 # If wanted, and the interface is right-to-left, flip the CSS
3464 $this->
getSkin()->setupSkinUserCss( $this );
3476 $moduleStyles[] =
'site';
3477 $moduleStyles[] =
'noscript';
3478 $moduleStyles[] =
'user.groups';
3485 array(
'excludepage' => $this->
getTitle()->getPrefixedDBkey() )
3487 $otherTags .=
$link[
'html'];
3492 $previewedCSS = $this->
getRequest()->getText(
'wpTextbox1' );
3499 $moduleStyles[] =
'user';
3503 $moduleStyles[] =
'user.cssprefs';
3505 foreach ( $moduleStyles
as $name ) {
3510 $group = $module->getGroup();
3525 $links[] =
Html::element(
'meta',
array(
'name' =>
'ResourceLoaderDynamicStyles',
'content' =>
'' ) ) .
"\n";
3530 foreach (
array(
'site',
'noscript',
'private',
'user' )
as $group ) {
3547 foreach ( $this->mExtStyles
as $url ) {
3550 $this->mExtStyles =
array();
3575 if ( isset(
$options[
'media'] ) ) {
3577 if ( is_null( $media ) ) {
3584 if ( substr( $style, 0, 1 ) ==
'/' ||
3585 substr( $style, 0, 5 ) ==
'http:' ||
3586 substr( $style, 0, 6 ) ==
'https:' ) {
3589 global $wgStylePath, $wgStyleVersion;
3590 $url = $wgStylePath .
'/' . $style .
'?' . $wgStyleVersion;
3595 if ( isset(
$options[
'condition'] ) ) {
3596 $condition = htmlspecialchars(
$options[
'condition'] );
3597 $link =
"<!--[if $condition]>$link<![endif]-->";
3613 $screenMediaQueryRegex =
'/^(?:only\s+)?screen\b/i';
3617 'printable' =>
'print',
3618 'handheld' =>
'handheld',
3620 foreach ( $switches
as $switch => $targetMedia ) {
3621 if ( $wgRequest->getBool( $switch ) ) {
3622 if ( $media == $targetMedia ) {
3624 } elseif ( preg_match( $screenMediaQueryRegex, $media ) === 1 ) {
3635 if ( $targetMedia ==
'print' || $media ==
'screen' ) {
3652 $args = func_get_args();
3693 $msgSpecs = func_get_args();
3694 array_shift( $msgSpecs );
3695 $msgSpecs = array_values( $msgSpecs );
3697 foreach ( $msgSpecs
as $n => $spec ) {
3698 if ( is_array( $spec ) ) {
3701 if ( isset(
$args[
'options'] ) ) {
3702 unset(
$args[
'options'] );
3704 'Adding "options" to ' . __METHOD__ .
' is no longer supported',
3712 $s = str_replace(
'$' . (
$n + 1 ), $this->
msg( $name,
$args )->plain(),
$s );
3735 public function enableTOC( $flag =
true ) {
3736 $this->mEnableTOC = $flag;
3753 $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:".
getConfig()
Get the Config object.
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
const ORIGIN_USER_SITEWIDE
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.
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.
int $mCdnMaxageLimit
Upper limit on mSquidMaxage *.
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,...
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()
Do not allow scripts which can be modified by wiki users to load on this page; only allow scripts bun...
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.
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.
getAllowedModules( $type)
Get the level of JavaScript / CSS untrustworthiness allowed on this page.
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.
lowerCdnMaxage( $maxage)
Lower the value of the "s-maxage" part of the "Cache-control" HTTP header.
$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.