23use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
29use Wikimedia\WrappedString;
30use Wikimedia\WrappedStringList;
48 use ProtectedHookAccessorTrait;
203 ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL,
286 'Accept-Encoding' =>
null,
352 $this->getHookContainer()
362 public function redirect( $url, $responsecode =
'302' ) {
363 # Strip newlines as a paranoia check for header injection in PHP<5.1.2
364 $this->mRedirect = str_replace(
"\n",
'', $url );
365 $this->mRedirectCode = (string)$responsecode;
374 return $this->mRedirect;
386 $this->copyrightUrl = $url;
395 $this->mStatusCode = $statusCode;
406 $this->mMetatags[] = [ $name, $val ];
416 return $this->mMetatags;
427 $this->mLinktags[] = $linkarr;
437 return $this->mLinktags;
446 $this->mCanonicalUrl = $url;
457 return $this->mCanonicalUrl;
468 $this->mScripts .= $script;
480 $this->
addScript( Html::linkedScript(
$file, $this->CSP->getNonce() ) );
490 $this->mScripts .= Html::inlineScript(
"\n$script\n", $this->CSP->getNonce() ) .
"\n";
502 $type = ResourceLoaderModule::TYPE_COMBINED
505 $filteredModules = [];
507 $module = $resourceLoader->getModule( $val );
511 if ( $this->mTarget && !in_array( $this->mTarget, $module->getTargets() ) ) {
515 $filteredModules[] = $val;
518 return $filteredModules;
522 static $warnings = [];
523 if ( isset( $warnings[$this->mTarget][$moduleName] ) ) {
526 $warnings[$this->mTarget][$moduleName] =
true;
528 'Module "{module}" not loadable on target "{target}".',
530 'module' => $moduleName,
531 'target' => $this->mTarget,
545 public function getModules( $filter =
false, $position =
null, $param =
'mModules',
546 $type = ResourceLoaderModule::TYPE_COMBINED
548 $modules = array_values( array_unique( $this->$param ) );
560 $this->mModules = array_merge( $this->mModules, (array)
$modules );
571 return $this->
getModules( $filter,
null,
'mModuleStyles',
572 ResourceLoaderModule::TYPE_STYLES
586 $this->mModuleStyles = array_merge( $this->mModuleStyles, (array)
$modules );
593 return $this->mTarget;
602 $this->mTarget = $target;
613 if ( !$this->contentOverrides ) {
617 return $this->contentOverrides[$key] ??
null;
622 $this->contentOverrides[$key] =
$content;
633 $this->contentOverrideCallbacks[] = $callback;
644 $this->mAdditionalHtmlClasses = array_merge( $this->mAdditionalHtmlClasses, (array)$classes );
653 return $this->mHeadItems;
669 $this->mHeadItems[$name] = $value;
679 $this->mHeadItems = array_merge( $this->mHeadItems, (array)$values );
689 return isset( $this->mHeadItems[$name] );
699 $this->mAdditionalBodyClasses = array_merge( $this->mAdditionalBodyClasses, (array)$classes );
710 $this->mArticleBodyOnly = $only;
719 return $this->mArticleBodyOnly;
730 $this->mProperties[$name] = $value;
741 return $this->mProperties[$name] ??
null;
756 if ( !$timestamp || $timestamp ==
'19700101000000' ) {
757 wfDebug( __METHOD__ .
": CACHE DISABLED, NO TIMESTAMP" );
761 if ( !$config->get(
'CachePages' ) ) {
762 wfDebug( __METHOD__ .
": CACHE DISABLED" );
768 'page' => $timestamp,
769 'user' => $this->
getUser()->getTouched(),
770 'epoch' => $config->get(
'CacheEpoch' )
772 if ( $config->get(
'UseCdn' ) ) {
775 $config->get(
'CdnMaxAge' )
778 $this->getHookRunner()->onOutputPageCheckLastModified( $modifiedTimes, $this );
780 $maxModified = max( $modifiedTimes );
781 $this->mLastModified =
wfTimestamp( TS_RFC2822, $maxModified );
783 $clientHeader = $this->
getRequest()->getHeader(
'If-Modified-Since' );
784 if ( $clientHeader ===
false ) {
785 wfDebug( __METHOD__ .
": client did not send If-Modified-Since header",
'private' );
789 # IE sends sizes after the date like this:
790 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
791 # this breaks strtotime().
792 $clientHeader = preg_replace(
'/;.*$/',
'', $clientHeader );
794 Wikimedia\suppressWarnings();
795 $clientHeaderTime = strtotime( $clientHeader );
796 Wikimedia\restoreWarnings();
797 if ( !$clientHeaderTime ) {
799 .
": unable to parse the client's If-Modified-Since header: $clientHeader" );
802 $clientHeaderTime =
wfTimestamp( TS_MW, $clientHeaderTime );
806 foreach ( $modifiedTimes as $name => $value ) {
807 if ( $info !==
'' ) {
810 $info .=
"$name=" .
wfTimestamp( TS_ISO_8601, $value );
813 wfDebug( __METHOD__ .
": client sent If-Modified-Since: " .
814 wfTimestamp( TS_ISO_8601, $clientHeaderTime ),
'private' );
815 wfDebug( __METHOD__ .
": effective Last-Modified: " .
816 wfTimestamp( TS_ISO_8601, $maxModified ),
'private' );
817 if ( $clientHeaderTime < $maxModified ) {
818 wfDebug( __METHOD__ .
": STALE, $info",
'private' );
823 # Give a 304 Not Modified response code and disable body output
824 wfDebug( __METHOD__ .
": NOT MODIFIED, $info",
'private' );
825 ini_set(
'zlib.output_compression', 0 );
826 $this->
getRequest()->response()->statusHeader( 304 );
848 return $reqTime - $maxAge;
858 $this->mLastModified =
wfTimestamp( TS_RFC2822, $timestamp );
870 $policy = Article::formatRobotPolicy( $policy );
872 if ( isset( $policy[
'index'] ) ) {
875 if ( isset( $policy[
'follow'] ) ) {
887 return "{$this->mIndexPolicy},{$this->mFollowPolicy}";
898 $policy = trim( $policy );
899 if ( in_array( $policy, [
'index',
'noindex' ] ) ) {
900 $this->mIndexPolicy = $policy;
910 return $this->mIndexPolicy;
921 $policy = trim( $policy );
922 if ( in_array( $policy, [
'follow',
'nofollow' ] ) ) {
923 $this->mFollowPolicy = $policy;
933 return $this->mFollowPolicy;
943 if ( $name instanceof
Message ) {
944 $this->mHTMLtitle = $name->setContext( $this->
getContext() )->text();
946 $this->mHTMLtitle = $name;
956 return $this->mHTMLtitle;
965 $this->mRedirectedFrom =
$t;
981 if ( $name instanceof
Message ) {
982 $name = $name->setContext( $this->
getContext() )->text();
985 # change "<script>foo&bar</script>" to "<script>foo&bar</script>"
986 # but leave "<i>foobar</i>" alone
987 $nameWithTags = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $name ) );
988 $this->mPageTitle = $nameWithTags;
990 # change "<i>foo&bar</i>" to "foo&bar"
992 $this->
msg(
'pagetitle' )->plaintextParams( Sanitizer::stripAllTags( $nameWithTags ) )
993 ->inContentLanguage()
1003 return $this->mPageTitle;
1014 $this->displayTitle = $html;
1026 $html = $this->displayTitle;
1027 if ( $html ===
null ) {
1028 $html = $this->
getTitle()->getPrefixedText();
1031 return Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $html ) );
1042 $nsPrefix = $this->
getTitle()->getNsText() .
':';
1043 $prefix = preg_quote( $nsPrefix,
'/' );
1045 return preg_replace(
"/^$prefix/i",
'', $text );
1075 if ( $str instanceof
Message ) {
1076 $this->mSubtitle[] = $str->setContext( $this->
getContext() )->parse();
1078 $this->mSubtitle[] = $str;
1091 if (
$title->isRedirect() ) {
1092 $query[
'redirect'] =
'no';
1094 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
1096 ->rawParams( $linkRenderer->makeLink(
$title,
null, [], $query ) );
1113 $this->mSubtitle = [];
1122 return implode(
"<br />\n\t\t\t\t", $this->mSubtitle );
1130 $this->mPrintable =
true;
1139 return $this->mPrintable;
1146 $this->mDoNothing =
true;
1155 return $this->mDoNothing;
1164 return $this->mNewSectionLink;
1173 return $this->mHideNewSectionLink;
1188 $this->mFeedLinks = [];
1199 if ( $this->
getConfig()->
get(
'Feed' ) ) {
1200 return $this->
getConfig()->get(
'AdvertisedFeedTypes' );
1216 $this->mFeedLinks = [];
1219 $query =
"feed=$type";
1220 if ( is_string( $val ) ) {
1221 $query .=
'&' . $val;
1223 $this->mFeedLinks[
$type] = $this->
getTitle()->getLocalURL( $query );
1235 $this->mFeedLinks[$format] = $href;
1244 return count( $this->mFeedLinks ) > 0;
1252 return $this->mFeedLinks;
1261 return $this->mFeedLinksAppendQuery;
1272 $this->mIsArticle = $newVal;
1274 $this->mIsArticleRelated = $newVal;
1285 return $this->mIsArticle;
1295 $this->mIsArticleRelated = $newVal;
1297 $this->mIsArticle =
false;
1307 return $this->mIsArticleRelated;
1316 $this->mHasCopyright = $hasCopyright;
1329 return $this->
isArticle() || $this->mHasCopyright;
1339 $this->mLanguageLinks = array_merge( $this->mLanguageLinks, $newLinkArray );
1349 $this->mLanguageLinks = $newLinkArray;
1358 return $this->mLanguageLinks;
1367 if ( !$categories ) {
1373 # Set all the values to 'normal'.
1374 $categories = array_fill_keys( array_keys( $categories ),
'normal' );
1376 # Mark hidden categories
1377 foreach (
$res as $row ) {
1378 if ( isset( $row->pp_value ) ) {
1379 $categories[$row->page_title] =
'hidden';
1383 # Add the remaining categories to the skin
1384 if ( $this->getHookRunner()->onOutputPageMakeCategoryLinks(
1385 $this, $categories, $this->mCategoryLinks )
1387 $services = MediaWikiServices::getInstance();
1388 $linkRenderer = $services->getLinkRenderer();
1389 foreach ( $categories as $category =>
$type ) {
1391 $category = (string)$category;
1392 $origcategory = $category;
1397 $services->getContentLanguage()->findVariantLink( $category,
$title,
true );
1398 if ( $category != $origcategory && array_key_exists( $category, $categories ) ) {
1401 $text = $services->getContentLanguage()->convertHtml(
$title->getText() );
1413 # Add the links to a LinkBatch
1418 # Fetch existence plus the hiddencat property
1420 $fields = array_merge(
1421 LinkCache::getSelectFields(),
1422 [
'page_namespace',
'page_title',
'pp_value' ]
1425 $res =
$dbr->select( [
'page',
'page_props' ],
1427 $lb->constructSet(
'page',
$dbr ),
1430 [
'page_props' => [
'LEFT JOIN', [
1431 'pp_propname' =>
'hiddencat',
1436 # Add the results to the link cache
1437 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
1438 $lb->addResultToCache( $linkCache,
$res );
1449 $this->mCategoryLinks = [];
1462 return $this->mCategoryLinks;
1475 if (
$type ===
'all' ) {
1476 $allCategories = [];
1477 foreach ( $this->mCategories as $categories ) {
1478 $allCategories = array_merge( $allCategories, $categories );
1480 return $allCategories;
1482 if ( !isset( $this->mCategories[
$type] ) ) {
1483 throw new InvalidArgumentException(
'Invalid category type given: ' .
$type );
1485 return $this->mCategories[
$type];
1498 $this->mIndicators = $indicators + $this->mIndicators;
1500 ksort( $this->mIndicators );
1512 return $this->mIndicators;
1525 $text = $this->
msg(
'helppage-top-gethelp' )->escaped();
1527 if ( $overrideBaseUrl ) {
1530 $toUrlencoded =
wfUrlencode( str_replace(
' ',
'_', $to ) );
1531 $helpUrl =
"https://www.mediawiki.org/wiki/Special:MyLanguage/$toUrlencoded";
1534 $link = Html::rawElement(
1538 'target' =>
'_blank',
1539 'class' =>
'mw-helplink',
1557 ResourceLoaderModule::TYPE_SCRIPTS,
1558 ResourceLoaderModule::ORIGIN_CORE_INDIVIDUAL
1563 if ( $this->
getConfig()->
get(
'AllowSiteCSSOnRestrictedPages' ) ) {
1564 $styleOrigin = ResourceLoaderModule::ORIGIN_USER_SITEWIDE;
1566 $styleOrigin = ResourceLoaderModule::ORIGIN_CORE_INDIVIDUAL;
1569 ResourceLoaderModule::TYPE_STYLES,
1581 if (
$type == ResourceLoaderModule::TYPE_COMBINED ) {
1582 return min( array_values( $this->mAllowedModules ) );
1584 return $this->mAllowedModules[
$type] ?? ResourceLoaderModule::ORIGIN_ALL;
1607 $this->mBodytext = $text . $this->mBodytext;
1616 $this->mBodytext .= $text;
1628 public function addElement( $element, array $attribs = [], $contents =
'' ) {
1629 $this->
addHTML( Html::element( $element, $attribs, $contents ) );
1636 $this->mBodytext =
'';
1645 return $this->mBodytext;
1655 if ( !$this->mParserOptions ) {
1656 if ( !$this->
getUser()->isSafeToLoad() ) {
1660 $po = ParserOptions::newFromAnon();
1661 $po->setAllowUnsafeRawHtml(
false );
1662 $po->isBogus =
true;
1666 $this->mParserOptions = ParserOptions::newFromContext( $this->
getContext() );
1667 $this->mParserOptions->setAllowUnsafeRawHtml(
false );
1670 return $this->mParserOptions;
1681 $val = $revid ===
null ? null : intval( $revid );
1682 return wfSetVar( $this->mRevisionId, $val,
true );
1691 return $this->mRevisionId;
1701 return $this->mRevisionId == 0 || $this->mRevisionId == $this->
getTitle()->getLatestRevID();
1712 return wfSetVar( $this->mRevisionTimestamp, $timestamp,
true );
1722 return $this->mRevisionTimestamp;
1734 $val = [
'time' =>
$file->getTimestamp(),
'sha1' =>
$file->getSha1() ];
1736 return wfSetVar( $this->mFileVersion, $val,
true );
1745 return $this->mFileVersion;
1755 return $this->mTemplateIds;
1765 return $this->mImageTimeKeys;
1810 $wrapperClass, $text
1859 $text,
Title $title, $linestart, $interface, $wrapperClass =
null
1862 $text,
$title, $linestart, $interface
1866 'enableSectionEditLinks' =>
false,
1867 'wrapperDivClass' => $wrapperClass ??
'',
1880 $this->mLanguageLinks =
1891 $this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->
getHeadItems() );
1895 $this->mPreventClickjacking = $this->mPreventClickjacking
1898 foreach ( $scriptSrcs as $src ) {
1899 $this->
getCSP()->addScriptSrc( $src );
1902 foreach ( $defaultSrcs as $src ) {
1903 $this->
getCSP()->addDefaultSrc( $src );
1906 foreach ( $styleSrcs as $src ) {
1907 $this->
getCSP()->addStyleSrc( $src );
1917 if ( $this->
getConfig()->
get(
'ImagePreconnect' ) && count( $parserOutput->
getImages() ) ) {
1919 $repoGroup = MediaWikiServices::getInstance()->getRepoGroup();
1920 $repoGroup->forEachForeignRepo(
function ( $repo ) use ( &$preconnect ) {
1921 $preconnect[] =
wfParseUrl( $repo->getZoneUrl(
'thumb' ) )[
'host'];
1923 $preconnect[] =
wfParseUrl( $repoGroup->getLocalRepo()->getZoneUrl(
'thumb' ) )[
'host'];
1924 foreach ( $preconnect as $host ) {
1926 $this->
addLink( [
'rel' =>
'preconnect',
'href' =>
'//' . $host ] );
1933 foreach ( (array)$parserOutput->
getTemplateIds() as $ns => $dbks ) {
1934 if ( isset( $this->mTemplateIds[$ns] ) ) {
1935 $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
1937 $this->mTemplateIds[$ns] = $dbks;
1942 $this->mImageTimeKeys[$dbk] = $data;
1946 $parserOutputHooks = $this->
getConfig()->get(
'ParserOutputHooks' );
1948 list( $hookName, $data ) = $hookInfo;
1949 if ( isset( $parserOutputHooks[$hookName] ) ) {
1950 $parserOutputHooks[$hookName]( $this, $parserOutput, $data );
1960 if ( !$this->limitReportJSData ) {
1967 $this->getHookRunner()->onLanguageLinks( $this->
getTitle(), $this->mLanguageLinks, $linkFlags );
1968 $this->getHookRunner()->onOutputPageParserOutput( $this, $parserOutput );
1975 $this->mEnableTOC =
true;
2004 $text = $parserOutput->
getText( $poOptions );
2005 $this->getHookRunner()->onOutputPageBeforeHTML( $this, $text );
2026 $this->
addHTML( $template->getHTML() );
2042 $text, $this->
getTitle(), $linestart,
false
2044 'enableSectionEditLinks' =>
false,
2045 'wrapperDivClass' =>
''
2063 $text, $this->
getTitle(), $linestart,
true
2065 'enableSectionEditLinks' =>
false,
2066 'wrapperDivClass' =>
''
2085 return Parser::stripOuterParagraph(
2104 throw new MWException(
'Empty $mTitle in ' . __METHOD__ );
2109 $oldInterface = $popts->setInterfaceMessage( (
bool)$interface );
2111 $parserOutput = MediaWikiServices::getInstance()->getParser()->getFreshParser()->parse(
2113 $linestart,
true, $this->mRevisionId
2116 $popts->setInterfaceMessage( $oldInterface );
2118 return $parserOutput;
2127 $this->mCdnMaxage = min( $maxage, $this->mCdnMaxageLimit );
2140 $this->mCdnMaxageLimit = min( $maxage, $this->mCdnMaxageLimit );
2157 $minTTL = $minTTL ?: IExpiringStore::TTL_MINUTE;
2158 $maxTTL = $maxTTL ?: $this->
getConfig()->get(
'CdnMaxAge' );
2160 if ( $mtime ===
null || $mtime ===
false ) {
2164 $age = MWTimestamp::time() - (int)
wfTimestamp( TS_UNIX, $mtime );
2165 $adaptiveTTL = max( 0.9 * $age, $minTTL );
2166 $adaptiveTTL = min( $adaptiveTTL, $maxTTL );
2179 return wfSetVar( $this->mEnableClientCache, $state );
2189 if ( !$this->cacheIsFinal ) {
2199 return $this->mEnableClientCache;
2212 $this->cacheIsFinal =
true;
2221 if ( self::$cacheVaryCookies ===
null ) {
2223 self::$cacheVaryCookies = array_values( array_unique( array_merge(
2224 SessionManager::singleton()->getVaryCookies(),
2228 $config->get(
'CacheVaryCookies' )
2230 $this->getHookRunner()->onGetCacheVaryCookies( $this, self::$cacheVaryCookies );
2232 return self::$cacheVaryCookies;
2244 if ( $request->getCookie( $cookieName,
'',
'' ) !==
'' ) {
2245 wfDebug( __METHOD__ .
": found $cookieName" );
2249 wfDebug( __METHOD__ .
": no cache-varying cookies found" );
2263 if ( $option !==
null && count( $option ) > 0 ) {
2265 'The $option parameter to addVaryHeader is ignored since MediaWiki 1.34',
2268 if ( !array_key_exists(
$header, $this->mVaryHeader ) ) {
2269 $this->mVaryHeader[
$header] =
null;
2285 foreach ( SessionManager::singleton()->getVaryHeaders() as
$header => $options ) {
2288 return 'Vary: ' . implode(
', ', array_keys( $this->mVaryHeader ) );
2297 $this->mLinkHeader[] =
$header;
2306 if ( !$this->mLinkHeader ) {
2310 return 'Link: ' . implode(
',', $this->mLinkHeader );
2327 if ( !$this->
getRequest()->getCheck(
'variant' ) &&
$lang->hasVariants() ) {
2343 $this->mPreventClickjacking = $enable;
2352 $this->mPreventClickjacking =
false;
2362 return $this->mPreventClickjacking;
2374 if ( $config->get(
'BreakFrames' ) ) {
2376 } elseif ( $this->mPreventClickjacking && $config->get(
'EditPageFrameOptions' ) ) {
2377 return $config->get(
'EditPageFrameOptions' );
2391 return $config->get(
'OriginTrials' );
2397 $expiry = $config->get(
'ReportToExpiry' );
2403 $endpoints = $config->get(
'ReportToEndpoints' );
2405 if ( !$endpoints ) {
2409 $output = [
'max_age' => $expiry,
'endpoints' => [] ];
2411 foreach ( $endpoints as $endpoint ) {
2412 $output[
'endpoints'][] = [
'url' => $endpoint ];
2415 return json_encode( $output, JSON_UNESCAPED_SLASHES );
2421 $features = $config->get(
'FeaturePolicyReportOnly' );
2422 return implode(
';', $features );
2435 # don't serve compressed data to clients who can't handle it
2436 # maintain different caches for logged-in users and non-logged in ones
2439 if ( $this->mEnableClientCache ) {
2441 $config->get(
'UseCdn' ) &&
2442 !$response->hasCookies() &&
2445 !SessionManager::getGlobalSession()->isPersistent() &&
2446 !$this->isPrintable() &&
2447 $this->mCdnMaxage != 0 &&
2448 !$this->haveCacheVaryCookies()
2450 # We'll purge the proxy cache for anons explicitly, but require end user agents
2451 # to revalidate against the proxy on each visit.
2452 # IMPORTANT! The CDN needs to replace the Cache-Control header with
2453 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
2455 ": local proxy caching; {$this->mLastModified} **",
'private' );
2456 # start with a shorter timeout for initial testing
2457 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
2458 $response->header(
"Cache-Control: " .
2459 "s-maxage={$this->mCdnMaxage}, must-revalidate, max-age=0" );
2461 # We do want clients to cache if they can, but they *must* check for updates
2462 # on revisiting the page, after the max-age period.
2463 wfDebug( __METHOD__ .
": private caching; {$this->mLastModified} **",
'private' );
2465 if ( $response->hasCookies() || SessionManager::getGlobalSession()->isPersistent() ) {
2466 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
2467 $response->header(
"Cache-Control: private, must-revalidate, max-age=0" );
2470 'Expires: ' . gmdate(
'D, d M Y H:i:s', time() + $config->get(
'LoggedOutMaxAge' ) ) .
' GMT'
2473 "Cache-Control: private, must-revalidate, max-age={$config->get( 'LoggedOutMaxAge' )}"
2477 if ( $this->mLastModified ) {
2478 $response->header(
"Last-Modified: {$this->mLastModified}" );
2481 wfDebug( __METHOD__ .
": no caching **",
'private' );
2483 # In general, the absence of a last modified header should be enough to prevent
2484 # the client from using its cache. We send a few other things just to make sure.
2485 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
2486 $response->header(
'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
2487 $response->header(
'Pragma: no-cache' );
2497 foreach ( $sk->getDefaultModules() as $group =>
$modules ) {
2498 if ( $group ===
'styles' ) {
2499 foreach (
$modules as $key => $moduleMembers ) {
2519 if ( $this->mDoNothing ) {
2520 return $return ?
'' :
null;
2526 if ( $this->mRedirect !=
'' ) {
2527 # Standards require redirect URLs to be absolute
2530 $redirect = $this->mRedirect;
2531 $code = $this->mRedirectCode;
2534 if ( $this->getHookRunner()->onBeforePageRedirect( $this, $redirect, $code ) ) {
2535 if ( $code ==
'301' || $code ==
'303' ) {
2536 if ( !$config->get(
'DebugRedirects' ) ) {
2537 $response->statusHeader( $code );
2541 if ( $config->get(
'VaryOnXFP' ) ) {
2546 $response->header(
"Content-Type: text/html; charset=utf-8" );
2547 if ( $config->get(
'DebugRedirects' ) ) {
2548 $url = htmlspecialchars( $redirect );
2549 $content =
"<!DOCTYPE html>\n<html>\n<head>\n"
2550 .
"<title>Redirect</title>\n</head>\n<body>\n"
2551 .
"<p>Location: <a href=\"$url\">$url</a></p>\n"
2552 .
"</body>\n</html>\n";
2559 $response->header(
'Location: ' . $redirect );
2564 } elseif ( $this->mStatusCode ) {
2565 $response->statusHeader( $this->mStatusCode );
2568 # Buffer output; final headers may depend on later processing
2571 $response->header(
'Content-type: ' . $config->get(
'MimeType' ) .
'; charset=UTF-8' );
2572 $response->header(
'Content-language: ' .
2573 MediaWikiServices::getInstance()->getContentLanguage()->getHtmlCode() );
2576 if ( $linkHeader ) {
2577 $response->header( $linkHeader );
2582 if ( $frameOptions ) {
2583 $response->header(
"X-Frame-Options: $frameOptions" );
2587 foreach ( $originTrials as $originTrial ) {
2588 $response->header(
"Origin-Trial: $originTrial",
false );
2593 $response->header(
"Report-To: $reportTo" );
2597 if ( $featurePolicyReportOnly ) {
2598 $response->header(
"Feature-Policy-Report-Only: $featurePolicyReportOnly" );
2601 if ( $this->mArticleBodyOnly ) {
2602 $this->CSP->sendHeaders();
2603 echo $this->mBodytext;
2606 if ( $this->
getRequest()->getBool(
'safemode' ) ) {
2613 MWDebug::addModules( $this );
2617 $this->getHookRunner()->onBeforePageDisplay( $this, $sk );
2619 $this->CSP->sendHeaders();
2623 }
catch ( Exception $e ) {
2631 $this->getHookRunner()->onAfterFinalPageOutput( $this );
2632 }
catch ( Exception $e ) {
2640 return ob_get_clean();
2659 if ( $htmlTitle !==
false ) {
2665 $this->mRedirect =
'';
2689 if ( $msg instanceof
Message ) {
2690 if ( $params !== [] ) {
2691 trigger_error(
'Argument ignored: $params. The message parameters argument '
2692 .
'is discarded when the $msg argument is a Message object instead of '
2693 .
'a string.', E_USER_NOTICE );
2695 $this->
addHTML( $msg->parseAsBlock() );
2710 $services = MediaWikiServices::getInstance();
2711 $permissionManager = $services->getPermissionManager();
2712 foreach ( $errors as $key => $error ) {
2713 $errors[$key] = (array)$error;
2722 if ( in_array( $action, [
'read',
'edit',
'createpage',
'createtalk',
'upload' ] )
2723 && $this->
getUser()->isAnon() && count( $errors ) == 1 && isset( $errors[0][0] )
2724 && ( $errors[0][0] ==
'badaccess-groups' || $errors[0][0] ==
'badaccess-group0' )
2725 && ( $permissionManager->groupHasPermission(
'user', $action )
2726 || $permissionManager->groupHasPermission(
'autoconfirmed', $action ) )
2728 $displayReturnto =
null;
2730 # Due to T34276, if a user does not have read permissions,
2731 # $this->getTitle() will just give Special:Badtitle, which is
2732 # not especially useful as a returnto parameter. Use the title
2733 # from the request instead, if there was one.
2735 $returnto = Title::newFromText( $request->getVal(
'title',
'' ) );
2736 if ( $action ==
'edit' ) {
2737 $msg =
'whitelistedittext';
2738 $displayReturnto = $returnto;
2739 } elseif ( $action ==
'createpage' || $action ==
'createtalk' ) {
2740 $msg =
'nocreatetext';
2741 } elseif ( $action ==
'upload' ) {
2742 $msg =
'uploadnologintext';
2744 $msg =
'loginreqpagetext';
2745 $displayReturnto = Title::newMainPage();
2751 $query[
'returnto'] = $returnto->getPrefixedText();
2753 if ( !$request->wasPosted() ) {
2754 $returntoquery = $request->getValues();
2755 unset( $returntoquery[
'title'] );
2756 unset( $returntoquery[
'returnto'] );
2757 unset( $returntoquery[
'returntoquery'] );
2758 $query[
'returntoquery'] =
wfArrayToCgi( $returntoquery );
2763 $linkRenderer = $services->getLinkRenderer();
2765 $loginLink = $linkRenderer->makeKnownLink(
2767 $this->
msg(
'loginreqlink' )->text(),
2773 $this->
addHTML( $this->
msg( $msg )->rawParams( $loginLink )->params( $loginUrl )->parse() );
2775 # Don't return to a page the user can't read otherwise
2776 # we'll end up in a pointless loop
2777 if ( $displayReturnto && $permissionManager->userCan(
2778 'read', $this->getUser(), $displayReturnto
2797 $this->
addWikiMsg(
'versionrequiredtext', $version );
2809 if ( $action ==
null ) {
2810 $text = $this->
msg(
'permissionserrorstext', count( $errors ) )->plain() .
"\n\n";
2812 $action_desc = $this->
msg(
"action-$action" )->plain();
2814 'permissionserrorstext-withaction',
2817 )->plain() .
"\n\n";
2820 if ( count( $errors ) > 1 ) {
2821 $text .=
'<ul class="permissions-errors">' .
"\n";
2823 foreach ( $errors as $error ) {
2825 $text .= $this->
msg( ...$error )->plain();
2830 $text .=
"<div class=\"permissions-errors\">\n" .
2831 $this->
msg( ...reset( $errors ) )->plain() .
2849 if ( $lag >= $config->get(
'SlaveLagWarning' ) ) {
2850 $lag = floor( $lag );
2851 $message = $lag < $config->get(
'SlaveLagCritical' )
2855 $wrap = Html::rawElement(
'div', [
'class' =>
"mw-{$message}" ],
"\n$1\n" );
2881 $linkRenderer = MediaWikiServices::getInstance()
2882 ->getLinkRendererFactory()->createFromLegacyOptions( $options );
2883 $link = $this->
msg(
'returnto' )->rawParams(
2884 $linkRenderer->makeLink(
$title, $text, [], $query ) )->escaped();
2885 $this->
addHTML(
"<p id=\"mw-returnto\">{$link}</p>\n" );
2896 public function returnToMain( $unused =
null, $returnto =
null, $returntoquery =
null ) {
2897 if ( $returnto ==
null ) {
2898 $returnto = $this->
getRequest()->getText(
'returnto' );
2901 if ( $returntoquery ==
null ) {
2902 $returntoquery = $this->
getRequest()->getText(
'returntoquery' );
2905 if ( $returnto ===
'' ) {
2906 $returnto = Title::newMainPage();
2909 if ( is_object( $returnto ) ) {
2910 $titleObj = $returnto;
2912 $titleObj = Title::newFromText( $returnto );
2916 if ( !is_object( $titleObj ) || $titleObj->isExternal() ) {
2917 $titleObj = Title::newMainPage();
2924 if ( !$this->rlClientContext ) {
2928 $this->
getSkin()->getSkinName(),
2929 $this->
getUser()->isLoggedIn() ? $this->
getUser()->getName() :
null,
2940 if ( $this->contentOverrideCallbacks ) {
2942 $this->rlClientContext->setContentOverrideCallback(
function (
Title $title ) {
2943 foreach ( $this->contentOverrideCallbacks as $callback ) {
2946 $text = ContentHandler::getContentText(
$content );
2947 if ( strpos( $text,
'</script>' ) !==
false ) {
2951 $titleFormatted =
$title->getPrefixedText();
2953 Xml::encodeJsCall(
'mw.log.error', [
2954 "Cannot preview $titleFormatted due to script-closing tag."
2965 return $this->rlClientContext;
2980 if ( !$this->rlClient ) {
2992 $this->
getSkin()->setupSkinUserCss( $this );
2995 $exemptGroups = [
'site' => [],
'noscript' => [],
'private' => [],
'user' => [] ];
3001 $userBatch = [
'user.styles',
'user' ];
3002 $siteBatch = array_diff( $moduleStyles, $userBatch );
3004 ResourceLoaderWikiModule::preloadTitleInfo(
$context,
$dbr, $siteBatch );
3005 ResourceLoaderWikiModule::preloadTitleInfo(
$context,
$dbr, $userBatch );
3008 $moduleStyles = array_filter( $moduleStyles,
3009 function ( $name ) use ( $rl,
$context, &$exemptGroups, &$exemptStates ) {
3010 $module = $rl->getModule( $name );
3012 $group = $module->getGroup();
3013 if ( isset( $exemptGroups[$group] ) ) {
3014 $exemptStates[$name] =
'ready';
3015 if ( !$module->isKnownEmpty(
$context ) ) {
3017 $exemptGroups[$group][] = $name;
3025 $this->rlExemptStyleModules = $exemptGroups;
3029 'nonce' => $this->CSP->getNonce(),
3037 'safemode' => ( $this->getAllowedModules( ResourceLoaderModule::TYPE_COMBINED )
3038 <= ResourceLoaderModule::ORIGIN_CORE_INDIVIDUAL
3047 return $this->rlClient;
3058 $sitedir = MediaWikiServices::getInstance()->getContentLanguage()->getDir();
3061 $htmlAttribs = Sanitizer::mergeAttributes( Sanitizer::mergeAttributes(
3064 ), [
'class' => implode(
' ', $this->mAdditionalHtmlClasses ) ] );
3065 $pieces[] = Html::htmlHeader( $htmlAttribs );
3066 $pieces[] = Html::openElement(
'head' );
3072 if ( !Html::isXmlMimeType( $config->get(
'MimeType' ) ) ) {
3081 $pieces[] = Html::element(
'meta', [
'charset' =>
'UTF-8' ] );
3084 $pieces[] = Html::element(
'title',
null, $this->
getHTMLTitle() );
3085 $pieces[] = $this->
getRlClient()->getHeadHtml( $htmlAttribs[
'class'] ??
null );
3088 $pieces = array_merge( $pieces, array_values( $this->mHeadItems ) );
3096 $shivUrl = $config->get(
'ResourceBasePath' ) .
'/resources/lib/html5shiv/html5shiv.js';
3097 $pieces[] =
'<!--[if lt IE 9]>' .
3098 Html::linkedScript( $shivUrl, $this->CSP->getNonce() ) .
3101 $pieces[] = Html::closeElement(
'head' );
3103 $bodyClasses = $this->mAdditionalBodyClasses;
3104 $bodyClasses[] =
'mediawiki';
3106 # Classes for LTR/RTL directionality support
3107 $bodyClasses[] = $userdir;
3108 $bodyClasses[] =
"sitedir-$sitedir";
3110 $underline = $this->
getUser()->getOption(
'underline' );
3111 if ( $underline < 2 ) {
3115 $bodyClasses[] =
'mw-underline-' . ( $underline ?
'always' :
'never' );
3118 if ( $this->
getLanguage()->capitalizeAllNouns() ) {
3119 # A <body> class is probably not the best way to do this . . .
3120 $bodyClasses[] =
'capitalize-all-nouns';
3126 $bodyClasses[] =
'mw-hide-empty-elt';
3129 $bodyClasses[] =
'skin-' . Sanitizer::escapeClass( $sk->
getSkinName() );
3131 'action-' . Sanitizer::escapeClass( Action::getActionName( $this->
getContext() ) );
3136 $bodyAttrs[
'class'] = implode(
' ', $bodyClasses );
3140 if ( method_exists( $sk,
'addToBodyAttributes' ) ) {
3142 $sk->addToBodyAttributes( $this, $bodyAttrs );
3143 wfDeprecated(
'Skin::addToBodyAttributes method to add body attributes',
'1.35' );
3147 $this->getHookRunner()->onOutputPageBodyAttributes( $this, $sk, $bodyAttrs );
3149 $pieces[] = Html::openElement(
'body', $bodyAttrs );
3151 return self::combineWrappedStrings( $pieces );
3160 if ( $this->mResourceLoader ===
null ) {
3162 $this->mResourceLoader = MediaWikiServices::getInstance()->getResourceLoader();
3164 return $this->mResourceLoader;
3184 $this->CSP->getNonce()
3196 $chunks = array_filter( $chunks,
'strlen' );
3197 return WrappedString::join(
"\n", $chunks );
3211 $chunks[] = $this->mScripts;
3213 if ( $this->limitReportJSData ) {
3216 [
'wgPageParseReport' => $this->limitReportJSData ]
3218 $this->CSP->getNonce()
3222 return self::combineWrappedStrings( $chunks );
3232 return $this->mJsConfigVars;
3242 if ( is_array(
$keys ) ) {
3243 foreach (
$keys as $key => $value ) {
3244 $this->mJsConfigVars[$key] = $value;
3249 $this->mJsConfigVars[
$keys] = $value;
3264 $canonicalSpecialPageName =
false; # T23115
3265 $services = MediaWikiServices::getInstance();
3268 $ns =
$title->getNamespace();
3269 $nsInfo = $services->getNamespaceInfo();
3270 $canonicalNamespace = $nsInfo->exists( $ns )
3271 ? $nsInfo->getCanonicalName( $ns )
3277 $relevantTitle = $sk->getRelevantTitle();
3278 $relevantUser = $sk->getRelevantUser();
3281 list( $canonicalSpecialPageName, ) =
3282 $services->getSpecialPageFactory()->
3283 resolveAlias(
$title->getDBkey() );
3286 $curRevisionId = $wikiPage->getLatest();
3287 $articleId = $wikiPage->getId();
3293 $separatorTransTable =
$lang->separatorTransformTable();
3294 $separatorTransTable = $separatorTransTable ?: [];
3295 $compactSeparatorTransTable = [
3296 implode(
"\t", array_keys( $separatorTransTable ) ),
3297 implode(
"\t", $separatorTransTable ),
3299 $digitTransTable =
$lang->digitTransformTable();
3300 $digitTransTable = $digitTransTable ?: [];
3301 $compactDigitTransTable = [
3302 implode(
"\t", array_keys( $digitTransTable ) ),
3303 implode(
"\t", $digitTransTable ),
3314 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
3315 'wgDigitTransformTable' => $compactDigitTransTable,
3316 'wgDefaultDateFormat' =>
$lang->getDefaultDateFormat(),
3317 'wgMonthNames' =>
$lang->getMonthNamesArray(),
3320 'wgRequestId' => WebRequest::getRequestId(),
3323 'wgCSPNonce' => $this->CSP->getNonce(),
3328 'wgCanonicalNamespace' => $canonicalNamespace,
3329 'wgCanonicalSpecialPageName' => $canonicalSpecialPageName,
3330 'wgNamespaceNumber' =>
$title->getNamespace(),
3331 'wgPageName' =>
$title->getPrefixedDBkey(),
3332 'wgTitle' =>
$title->getText(),
3333 'wgCurRevisionId' => $curRevisionId,
3335 'wgArticleId' => $articleId,
3337 'wgIsRedirect' =>
$title->isRedirect(),
3338 'wgAction' => Action::getActionName( $this->
getContext() ),
3339 'wgUserName' => $user->isAnon() ? null : $user->getName(),
3340 'wgUserGroups' => $user->getEffectiveGroups(),
3342 'wgPageContentLanguage' =>
$lang->getCode(),
3343 'wgPageContentModel' =>
$title->getContentModel(),
3344 'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
3345 'wgRelevantArticleId' => $relevantTitle->getArticleID(),
3347 if ( $user->isLoggedIn() ) {
3348 $vars[
'wgUserId'] = $user->getId();
3349 $vars[
'wgUserEditCount'] = $user->getEditCount();
3350 $userReg = $user->getRegistration();
3351 $vars[
'wgUserRegistration'] = $userReg ? (int)
wfTimestamp( TS_UNIX, $userReg ) * 1000 :
null;
3358 if ( $userNewMsgRevId ) {
3359 $vars[
'wgUserNewMsgRevisionId'] = $userNewMsgRevId;
3362 $contLang = $services->getContentLanguage();
3363 if ( $contLang->hasVariants() ) {
3364 $vars[
'wgUserVariant'] = $contLang->getPreferredVariant();
3368 $vars[
'wgRelevantPageIsProbablyEditable'] = $relevantTitle &&
3370 foreach (
$title->getRestrictionTypes() as
$type ) {
3373 $vars[
'wgRestriction' . ucfirst(
$type )] =
$title->getRestrictions(
$type );
3375 if (
$title->isMainPage() ) {
3376 $vars[
'wgIsMainPage'] =
true;
3378 if ( $relevantUser && ( !$relevantUser->isHidden() ||
3379 $services->getPermissionManager()->userHasRight( $user,
'hideuser' ) )
3383 $vars[
'wgRelevantUserName'] = $relevantUser->getName();
3387 if ( $this->mRedirectedFrom ) {
3389 $vars[
'wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBkey();
3396 $this->getHookRunner()->onMakeGlobalVariablesScript( $vars, $this );
3408 $services = MediaWikiServices::getInstance();
3410 $userHasNewMessages = $services
3411 ->getTalkPageNotificationManager()
3412 ->userHasNewMessages( $user );
3413 if ( !$userHasNewMessages ) {
3417 $timestamp = $services
3418 ->getTalkPageNotificationManager()
3419 ->getLatestSeenMessageTimestamp( $user );
3421 if ( !$timestamp ) {
3425 $revRecord = $services->getRevisionLookup()->getRevisionByTimestamp(
3426 $user->getTalkPage(),
3430 if ( !$revRecord ) {
3434 return $revRecord->getId();
3449 $request->getVal(
'action' ) !==
'submit' ||
3450 !$request->wasPosted()
3457 if ( !$user->isLoggedIn() ) {
3461 if ( !$user->matchEditToken( $request->getVal(
'wpEditToken' ) ) ) {
3466 $errors = MediaWikiServices::getInstance()->getPermissionManager()
3467 ->getPermissionErrors(
'edit', $user,
$title );
3468 if ( count( $errors ) !== 0 ) {
3484 $pm = MediaWikiServices::getInstance()->getPermissionManager();
3485 return $pm->quickUserCan(
'edit', $user,
$title )
3486 && ( $this->
getTitle()->exists() ||
3487 $pm->quickUserCan(
'create', $user,
$title ) );
3497 $canonicalUrl = $this->mCanonicalUrl;
3499 $tags[
'meta-generator'] = Html::element(
'meta', [
3500 'name' =>
'generator',
3504 if ( $config->get(
'ReferrerPolicy' ) !==
false ) {
3507 foreach ( array_reverse( (array)$config->get(
'ReferrerPolicy' ) ) as $i => $policy ) {
3508 $tags[
"meta-referrer-$i"] = Html::element(
'meta', [
3509 'name' =>
'referrer',
3510 'content' => $policy,
3515 $p =
"{$this->mIndexPolicy},{$this->mFollowPolicy}";
3516 if ( $p !==
'index,follow' ) {
3519 $tags[
'meta-robots'] = Html::element(
'meta', [
3525 foreach ( $this->mMetatags as $tag ) {
3526 if ( strncasecmp( $tag[0],
'http:', 5 ) === 0 ) {
3528 $tag[0] = substr( $tag[0], 5 );
3529 } elseif ( strncasecmp( $tag[0],
'og:', 3 ) === 0 ) {
3534 $tagName =
"meta-{$tag[0]}";
3535 if ( isset( $tags[$tagName] ) ) {
3536 $tagName .= $tag[1];
3538 $tags[$tagName] = Html::element(
'meta',
3541 'content' => $tag[1]
3546 foreach ( $this->mLinktags as $tag ) {
3547 $tags[] = Html::element(
'link', $tag );
3550 # Universal edit button
3551 if ( $config->get(
'UniversalEditButton' ) && $this->isArticleRelated() ) {
3554 $msg = $this->
msg(
'edit' )->text();
3555 $tags[
'universal-edit-button'] = Html::element(
'link', [
3556 'rel' =>
'alternate',
3557 'type' =>
'application/x-wiki',
3559 'href' => $this->
getTitle()->getEditURL(),
3562 $tags[
'alternative-edit'] = Html::element(
'link', [
3565 'href' => $this->
getTitle()->getEditURL(),
3570 # Generally the order of the favicon and apple-touch-icon links
3571 # should not matter, but Konqueror (3.5.9 at least) incorrectly
3572 # uses whichever one appears later in the HTML source. Make sure
3573 # apple-touch-icon is specified first to avoid this.
3574 if ( $config->get(
'AppleTouchIcon' ) !==
false ) {
3575 $tags[
'apple-touch-icon'] = Html::element(
'link', [
3576 'rel' =>
'apple-touch-icon',
3577 'href' => $config->get(
'AppleTouchIcon' )
3581 if ( $config->get(
'Favicon' ) !==
false ) {
3582 $tags[
'favicon'] = Html::element(
'link', [
3583 'rel' =>
'shortcut icon',
3584 'href' => $config->get(
'Favicon' )
3588 # OpenSearch description link
3589 $tags[
'opensearch'] = Html::element(
'link', [
3591 'type' =>
'application/opensearchdescription+xml',
3592 'href' =>
wfScript(
'opensearch_desc' ),
3593 'title' => $this->
msg(
'opensearch-desc' )->inContentLanguage()->text(),
3596 # Real Simple Discovery link, provides auto-discovery information
3597 # for the MediaWiki API (and potentially additional custom API
3598 # support such as WordPress or Twitter-compatible APIs for a
3599 # blogging extension, etc)
3600 $tags[
'rsd'] = Html::element(
'link', [
3602 'type' =>
'application/rsd+xml',
3608 [
'action' =>
'rsd' ] ),
3614 if ( !$config->get(
'DisableLangConversion' ) ) {
3616 if (
$lang->hasVariants() ) {
3617 $variants =
$lang->getVariants();
3618 foreach ( $variants as $variant ) {
3619 $tags[
"variant-$variant"] = Html::element(
'link', [
3620 'rel' =>
'alternate',
3621 'hreflang' => LanguageCode::bcp47( $variant ),
3622 'href' => $this->
getTitle()->getLocalURL(
3623 [
'variant' => $variant ] )
3627 # x-default link per https:
3628 $tags[
"variant-x-default"] = Html::element(
'link', [
3629 'rel' =>
'alternate',
3630 'hreflang' =>
'x-default',
3631 'href' => $this->
getTitle()->getLocalURL() ] );
3636 if ( $this->copyrightUrl !==
null ) {
3637 $copyright = $this->copyrightUrl;
3640 if ( $config->get(
'RightsPage' ) ) {
3641 $copy = Title::newFromText( $config->get(
'RightsPage' ) );
3644 $copyright = $copy->getLocalURL();
3648 if ( !$copyright && $config->get(
'RightsUrl' ) ) {
3649 $copyright = $config->get(
'RightsUrl' );
3654 $tags[
'copyright'] = Html::element(
'link', [
3656 'href' => $copyright ]
3661 if ( $config->get(
'Feed' ) ) {
3665 # Use the page name for the title. In principle, this could
3666 # lead to issues with having the same name for different feeds
3667 # corresponding to the same page, but we can't avoid that at
3673 # Used messages:
'page-rss-feed' and
'page-atom-feed' (
for an easier grep)
3675 "page-{$format}-feed", $this->
getTitle()->getPrefixedText()
3680 # Recent changes feed should appear on every page (except recentchanges,
3681 # that would be redundant). Put it after the per-page feed to avoid
3682 # changing existing behavior. It's still available, probably via a
3683 # menu in your browser. Some sites might have a different feed they'd
3684 # like to promote instead of the RC feed (maybe like a "Recent New Articles"
3685 # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
3686 # If so, use it instead.
3687 $sitename = $config->get(
'Sitename' );
3688 $overrideSiteFeed = $config->get(
'OverrideSiteFeed' );
3689 if ( $overrideSiteFeed ) {
3690 foreach ( $overrideSiteFeed as
$type => $feedUrl ) {
3695 $this->
msg(
"site-{$type}-feed", $sitename )->text()
3698 } elseif ( !$this->
getTitle()->isSpecial(
'Recentchanges' ) ) {
3703 $rctitle->getLocalURL( [
'feed' => $format ] ),
3704 # For grep:
'site-rss-feed',
'site-atom-feed'
3705 $this->
msg(
"site-{$format}-feed", $sitename )->text()
3710 # Allow extensions to change the list pf feeds. This hook is primarily for changing,
3711 # manipulating or removing existing feed tags. If you want to add new feeds, you should
3712 # use OutputPage::addFeedLink() instead.
3713 $this->getHookRunner()->onAfterBuildFeedLinks( $feedLinks );
3715 $tags += $feedLinks;
3719 if ( $config->get(
'EnableCanonicalServerLink' ) ) {
3720 if ( $canonicalUrl !==
false ) {
3730 $action = Action::getActionName( $this->
getContext() );
3731 if ( in_array( $action, [
'history',
'info' ] ) ) {
3732 $query =
"action={$action}";
3736 $canonicalUrl = $this->
getTitle()->getCanonicalURL( $query );
3738 $reqUrl = $this->
getRequest()->getRequestURL();
3742 if ( $canonicalUrl !==
false ) {
3743 $tags[] = Html::element(
'link', [
3744 'rel' =>
'canonical',
3745 'href' => $canonicalUrl
3754 $this->getHookRunner()->onOutputPageAfterGetHeadLinksArray( $tags, $this );
3768 return Html::element(
'link', [
3769 'rel' =>
'alternate',
3770 'type' =>
"application/$type+xml",
3785 public function addStyle( $style, $media =
'', $condition =
'', $dir =
'' ) {
3788 $options[
'media'] = $media;
3791 $options[
'condition'] = $condition;
3794 $options[
'dir'] = $dir;
3796 $this->styles[$style] = $options;
3807 if ( $flip ===
'flip' && $this->
getLanguage()->isRTL() ) {
3808 # If wanted, and the interface is right-to-left, flip the CSS
3809 $style_css = CSSJanus::transform( $style_css,
true,
false );
3811 $this->mInlineStyles .= Html::inlineStyle( $style_css );
3843 $separateReq = [
'site.styles',
'user.styles' ];
3844 foreach ( $this->rlExemptStyleModules as $group => $moduleNames ) {
3845 if ( $moduleNames ) {
3847 array_diff( $moduleNames, $separateReq ),
3848 ResourceLoaderModule::TYPE_STYLES
3851 foreach ( array_intersect( $moduleNames, $separateReq ) as $name ) {
3855 ResourceLoaderModule::TYPE_STYLES
3861 $chunks[] = Html::element(
3863 [
'name' =>
'ResourceLoaderDynamicStyles',
'content' =>
'' ]
3865 $chunks = array_merge( $chunks, $append );
3868 return self::combineWrappedStrings( $chunks );
3877 foreach ( $this->styles as
$file => $options ) {
3880 $links[
$file] = $link;
3894 if ( isset( $options[
'dir'] ) && $this->
getLanguage()->getDir() != $options[
'dir'] ) {
3898 if ( isset( $options[
'media'] ) ) {
3899 $media = self::transformCssMedia( $options[
'media'] );
3900 if ( $media ===
null ) {
3907 if ( substr( $style, 0, 1 ) ==
'/' ||
3908 substr( $style, 0, 5 ) ==
'http:' ||
3909 substr( $style, 0, 6 ) ==
'https:' ) {
3914 $url = self::transformResourcePath(
3916 $config->get(
'StylePath' ) .
'/' . $style
3920 $link = Html::linkedStyle( $url, $media );
3922 if ( isset( $options[
'condition'] ) ) {
3923 $condition = htmlspecialchars( $options[
'condition'] );
3924 $link =
"<!--[if $condition]>$link<![endif]-->";
3954 $remotePathPrefix = $config->
get(
'ResourceBasePath' );
3955 if ( $remotePathPrefix ===
'' ) {
3960 $remotePath = $remotePathPrefix;
3962 if ( strpos(
$path, $remotePath ) !== 0 || substr(
$path, 0, 2 ) ===
'//' ) {
3971 $uploadPath = $config->
get(
'UploadPath' );
3972 if ( strpos(
$path, $uploadPath ) === 0 ) {
3973 $localDir = $config->
get(
'UploadDirectory' );
3974 $remotePathPrefix = $remotePath = $uploadPath;
3977 $path = RelPath::getRelativePath(
$path, $remotePath );
3978 return self::transformFilePath( $remotePathPrefix, $localDir,
$path );
3993 $hash = md5_file(
"$localPath/$file" );
3994 if ( $hash ===
false ) {
3995 wfLogWarning( __METHOD__ .
": Failed to hash $localPath/$file" );
3998 return "$remotePathPrefix/$file?" . substr( $hash, 0, 5 );
4012 $screenMediaQueryRegex =
'/^(?:only\s+)?screen\b/i';
4016 'printable' =>
'print',
4017 'handheld' =>
'handheld',
4019 foreach ( $switches as $switch => $targetMedia ) {
4021 if ( $media == $targetMedia ) {
4023 } elseif ( preg_match( $screenMediaQueryRegex, $media ) === 1 ) {
4037 if ( $targetMedia ==
'print' || $media ==
'screen' ) {
4056 $name = array_shift(
$args );
4100 foreach ( $msgSpecs as $n => $spec ) {
4101 if ( is_array( $spec ) ) {
4103 $name = array_shift(
$args );
4108 $s = str_replace(
'$' . ( $n + 1 ), $this->
msg( $name,
$args )->plain(),
$s );
4119 return $this->mEnableTOC;
4129 public static function setupOOUI( $skinName =
'default', $dir =
'ltr' ) {
4130 $themes = ResourceLoaderOOUIModule::getSkinThemeMap();
4131 $theme = $themes[$skinName] ?? $themes[
'default'];
4133 $themeClass =
"OOUI\\{$theme}Theme";
4134 OOUI\Theme::setSingleton(
new $themeClass() );
4135 OOUI\Element::setDefaultDir( $dir );
4146 strtolower( $this->
getSkin()->getSkinName() ),
4150 'oojs-ui-core.styles',
4151 'oojs-ui.styles.indicators',
4152 'mediawiki.widgets.styles',
4153 'oojs-ui-core.icons',
4168 return $this->CSP->getNonce();
const MW_VERSION
The running version of MediaWiki.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
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...
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfClearOutputBuffers()
More legible than passing a 'false' parameter to wfResetOutputBuffers():
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
if(! $wgDBerrorLogTZ) $wgRequest
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
getWikiPage()
Get the WikiPage object.
setContext(IContextSource $context)
A mutable version of ResourceLoaderContext.
WebRequest clone which takes values from a provided array.
Implements some public methods and some protected utility functions which are required by multiple ch...
exists()
Returns true if file exists in the repository.
Marks HTML that shouldn't be escaped.
Content for JavaScript pages.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
setArray( $array)
Set the link list to a given 2-d array First key is the namespace, second is the DB key,...
The Message class deals with fetching and processing of interface message into a variety of formats.
This is one of the Core classes and should be read at least once by any new developers.
isArticle()
Return whether the content displayed page is related to the source of the corresponding article on th...
addLinkHeader( $header)
Add an HTTP Link: header.
setFileVersion( $file)
Set the displayed file version.
$mScripts
Used for JavaScript (predates ResourceLoader)
getDisplayTitle()
Returns page display title.
getCdnCacheEpoch( $reqTime, $maxAge)
disable()
Disable output completely, i.e.
addLink(array $linkarr)
Add a new <link> tag to the page header.
addWikiMsg(... $args)
Add a wikitext-formatted message to the output.
ResourceLoader $mResourceLoader
ContentSecurityPolicy $CSP
addWikiTextTitleInternal( $text, Title $title, $linestart, $interface, $wrapperClass=null)
Add wikitext with a custom Title object.
static array $cacheVaryCookies
A cache of the names of the cookies that will influence the cache.
getCanonicalUrl()
Returns the URL to be used for the <link rel=canonical>> if one is set.
getPageTitle()
Return the "page title", i.e.
isArticleRelated()
Return whether this page is related an article on the wiki.
addCategoryLinksToLBAndGetResult(array $categories)
getLanguageLinks()
Get the list of language links.
userCanEditOrCreate(User $user, LinkTarget $title)
addScriptFile( $file, $unused=null)
Add a JavaScript file to be loaded as <script> on this page.
allowClickjacking()
Turn off frame-breaking.
filterModules(array $modules, $position=null, $type=ResourceLoaderModule::TYPE_COMBINED)
Filter an array of modules to remove insufficiently trustworthy members, and modules which are no lon...
wrapWikiTextAsInterface( $wrapperClass, $text)
Convert wikitext in the user interface language to HTML and add it to the buffer with a <div class="$...
getSyndicationLinks()
Return URLs for each supported syndication format for this page.
setArticleFlag( $newVal)
Set whether the displayed content is related to the source of the corresponding article on the wiki S...
addMeta( $name, $val)
Add a new "<meta>" tag To add an http-equiv meta tag, precede the name with "http:".
$mFeedLinks
Handles the Atom / RSS links.
setCopyrightUrl( $url)
Set the copyright URL to send with the output.
setRobotPolicy( $policy)
Set the robot policy for the page: http://www.robotstxt.org/meta.html
__construct(IContextSource $context)
Constructor for OutputPage.
setIndexPolicy( $policy)
Set the index policy for the page, but leave the follow policy un- touched.
getTemplateIds()
Get the templates used on this page.
setDisplayTitle( $html)
Same as page title but only contains name of the page, not any other text.
setPageTitle( $name)
"Page title" means the contents of <h1>.
output( $return=false)
Finally, all the text has been munged and accumulated into the object, let's actually output it:
redirect( $url, $responsecode='302')
Redirect to $url rather than displaying the normal page.
getRedirect()
Get the URL to redirect to, or an empty string if not redirect URL set.
setLastModified( $timestamp)
Override the last modified timestamp.
considerCacheSettingsFinal()
Set the expectation that cache control will not change after this point.
setLanguageLinks(array $newLinkArray)
Reset the language links and add new language links.
addFeedLink( $format, $href)
Add a feed link to the page header.
setTitle(Title $t)
Set the Title object to use.
setCategoryLinks(array $categories)
Reset the category links (but not the category list) and add $categories.
getAdvertisedFeedTypes()
Return effective list of advertised feed types.
getFileVersion()
Get the displayed file version.
setSyndicated( $show=true)
Add or remove feed links in the page header This is mainly kept for backward compatibility,...
bool $mHideNewSectionLink
bool $mIsArticle
Is the displayed content related to the source of the corresponding wiki article.
adaptCdnTTL( $mtime, $minTTL=0, $maxTTL=0)
Get TTL in [$minTTL,$maxTTL] and pass it to lowerCdnMaxage()
showsCopyright()
Return whether the standard copyright should be shown for the current page.
sendCacheControl()
Send cache control HTTP headers.
setTarget( $target)
Sets ResourceLoader target for load.php links.
string[][] $mMetatags
Should be private.
addCategoryLinks(array $categories)
Add an array of categories, with names in the keys.
int $mRevisionId
To include the variable {{REVISIONID}}.
showLagWarning( $lag)
Show a warning about replica DB lag.
clearSubtitle()
Clear the subtitles.
wrapWikiMsg( $wrap,... $msgSpecs)
This function takes a number of message/argument specifications, wraps them in some overall structure...
showFatalError( $message)
Output an error page.
setCdnMaxage( $maxage)
Set the value of the "s-maxage" part of the "Cache-control" HTTP header.
getJsConfigVars()
Get the javascript config vars to include on this page.
getHTML()
Get the body HTML.
addContentOverride(LinkTarget $target, Content $content)
Add a mapping from a LinkTarget to a Content, for things like page preview.
getFeaturePolicyReportOnly()
parseAsContent( $text, $linestart=true)
Parse wikitext in the page content language and return the HTML.
setCopyright( $hasCopyright)
Set whether the standard copyright should be shown for the current page.
array $mAllowedModules
What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page?
addParserOutput(ParserOutput $parserOutput, $poOptions=[])
Add everything from a ParserOutput object.
getJSVars()
Get an array containing the variables to be set in mw.config in JavaScript.
bool $mPreventClickjacking
Controls if anti-clickjacking / frame-breaking headers will be sent.
haveCacheVaryCookies()
Check if the request has a cache-varying cookie header If it does, it's very important that we don't ...
isTOCEnabled()
Whether the output has a table of contents.
versionRequired( $version)
Display an error page indicating that a given version of MediaWiki is required to use it.
reduceAllowedModules( $type, $level)
Limit the highest level of CSS/JS untrustworthiness allowed.
addInlineStyle( $style_css, $flip='noflip')
Adds inline CSS styles Internal use only.
getRevisionTimestamp()
Get the timestamp of displayed revision.
preventClickjacking( $enable=true)
Set a flag which will cause an X-Frame-Options header appropriate for edit pages to be sent.
bool $mPrintable
We have to set isPrintable().
setFollowPolicy( $policy)
Set the follow policy for the page, but leave the index policy un- touched.
getHeadItemsArray()
Get an array of head items.
isPrintable()
Return whether the page is "printable".
getModules( $filter=false, $position=null, $param='mModules', $type=ResourceLoaderModule::TYPE_COMBINED)
Get the list of modules to include on this page.
setRedirectedFrom( $t)
Set $mRedirectedFrom, the Title of the page which redirected us to the current page.
getFeedAppendQuery()
Will currently always return null.
bool $cacheIsFinal
See OutputPage::couldBePublicCached.
addModuleStyles( $modules)
Load the styles of one or more style-only ResourceLoader modules on this page.
setHTMLTitle( $name)
"HTML title" means the contents of "<title>".
loadSkinModules( $sk)
Transfer styles and JavaScript modules from skin.
array $mAdditionalBodyClasses
Additional <body> classes; there are also <body> classes from other sources.
returnToMain( $unused=null, $returnto=null, $returntoquery=null)
Add a "return to" link pointing to a specified title, or the title indicated in the request,...
array $mHeadItems
Array of elements in "<head>".
isSyndicated()
Should we output feed links for this page?
$mLinkHeader
Link: header contents.
styleLink( $style, array $options)
Generate <link> tags for stylesheets.
addHtmlClasses( $classes)
Add a class to the <html> element.
parseAsInterface( $text, $linestart=true)
Parse wikitext in the user interface language and return the HTML.
addParserOutputMetadata(ParserOutput $parserOutput)
Add all metadata associated with a ParserOutput object, but without the actual HTML.
static transformResourcePath(Config $config, $path)
Transform path to web-accessible static resource.
addElement( $element, array $attribs=[], $contents='')
Shortcut for adding an Html::element via addHTML.
makeResourceLoaderLink( $modules, $only, array $extraQuery=[])
Explicily load or embed modules on a page.
getSubtitle()
Get the subtitle.
showPermissionsErrorPage(array $errors, $action=null)
Output a standard permission error page.
addSubtitle( $str)
Add $str to the subtitle.
static setupOOUI( $skinName='default', $dir='ltr')
Helper function to setup the PHP implementation of OOUI to use in this request.
setRevisionId( $revid)
Set the revision ID which will be seen by the wiki text parser for things such as embedded {{REVISION...
addParserOutputContent(ParserOutput $parserOutput, $poOptions=[])
Add the HTML and enhancements for it (like ResourceLoader modules) associated with a ParserOutput obj...
getPreventClickjacking()
Get the prevent-clickjacking flag.
enableOOUI()
Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with MediaW...
getIndexPolicy()
Get the current index policy for the page as a string.
getCategories( $type='all')
Get the list of category names this page belongs to.
getIndicators()
Get the indicators associated with this page.
$mProperties
Additional key => value data.
parseInlineAsInterface( $text, $linestart=true)
Parse wikitext in the user interface language, strip paragraph wrapper, and return the HTML.
addWikiMsgArray( $name, $args)
Add a wikitext-formatted message to the output.
array $contentOverrides
Map Title to Content.
addBodyClasses( $classes)
Add a class to the <body> element.
addParserOutputText(ParserOutput $parserOutput, $poOptions=[])
Add the HTML associated with a ParserOutput object, without any metadata.
warnModuleTargetFilter( $moduleName)
string $mBodytext
Contains all of the "<body>" content.
addScript( $script)
Add raw HTML to the list of scripts (including <script> tag, etc.) Internal use only.
clearHTML()
Clear the body HTML.
array $mSubtitle
Contains the page subtitle.
addVaryHeader( $header, array $option=null)
Add an HTTP header that will influence on the cache.
addStyle( $style, $media='', $condition='', $dir='')
Add a local or specified stylesheet, with the given media options.
getLinkHeader()
Return a Link: header.
setPrintable()
Set the page as printable, i.e.
getResourceLoader()
Get a ResourceLoader object associated with this OutputPage.
feedLink( $type, $url, $text)
Generate a "<link rel/>" for a feed.
bool $mNoGallery
Comes from the parser.
getModuleStyles( $filter=false, $position=null)
Get the list of style-only modules to load on this page.
enableClientCache( $state)
Use enableClientCache(false) to force it to send nocache headers.
userCanPreview()
To make it harder for someone to slip a user a fake JavaScript or CSS preview, a random token is asso...
array $limitReportJSData
Profiling data.
parseInternal( $text, $title, $linestart, $interface)
Parse wikitext and return the HTML (internal implementation helper)
getFileSearchOptions()
Get the files used on this page.
array $mAdditionalHtmlClasses
Additional <html> classes; This should be rarely modified; prefer mAdditionalBodyClasses.
isRevisionCurrent()
Whether the revision displayed is the latest revision of the page.
addHTML( $text)
Append $text to the body HTML.
formatPermissionsErrorMessage(array $errors, $action=null)
Format a list of error messages.
string $mRevisionTimestamp
string null $copyrightUrl
The URL to send in a <link> element with rel=license.
getCSP()
Get the ContentSecurityPolicy object.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getHTMLTitle()
Return the "HTML title", i.e.
disallowUserJs()
Do not allow scripts which can be modified by wiki users to load on this page; only allow scripts bun...
string $mHTMLtitle
Stores contents of "<title>" tag.
addJsConfigVars( $keys, $value=null)
Add one or more variables to be set in mw.config in JavaScript.
static transformCssMedia( $media)
Transform "media" attribute based on request parameters.
setCanonicalUrl( $url)
Set the URL to be used for the <link rel=canonical>>.
ParserOptions $mParserOptions
lazy initialised, use parserOptions()
addTemplate(&$template)
Add the output of a QuickTemplate to the output buffer.
getRlClient()
Call this to freeze the module queue and JS config and create a formatter.
static transformFilePath( $remotePathPrefix, $localPath, $file)
Utility method for transformResourceFilePath().
callable[] $contentOverrideCallbacks
int $mCdnMaxageLimit
Upper limit on mCdnMaxage.
ResourceLoaderClientHtml $rlClient
setArticleBodyOnly( $only)
Set whether the output should only contain the body of the article, without any skin,...
addInlineScript( $script)
Add a self-contained script tag with the given contents Internal use only.
addAcceptLanguage()
T23672: Add Accept-Language to Vary header if there's no 'variant' parameter in GET.
setStatusCode( $statusCode)
Set the HTTP status code to send with the output.
parserOptions()
Get/set the ParserOptions object to use for wikitext parsing.
getCacheVaryCookies()
Get the list of cookie names that will influence the cache.
getLastSeenUserTalkRevId()
Get the revision ID for the last user talk page revision viewed by the talk page owner.
ResourceLoaderContext $rlClientContext
showErrorPage( $title, $msg, $params=[])
Output a standard error page.
getLinkTags()
Returns the current <link> tags.
getArticleBodyOnly()
Return whether the output will contain only the body of the article.
setProperty( $name, $value)
Set an additional output property.
setRevisionTimestamp( $timestamp)
Set the timestamp of the revision which will be displayed.
checkLastModified( $timestamp)
checkLastModified tells the client to use the client-cached page if possible.
getVaryHeader()
Return a Vary: header on which to vary caches.
string $mLastModified
Used for sending cache control.
addWikiTextAsContent( $text, $linestart=true, Title $title=null)
Convert wikitext in the page content language to HTML and add it to the buffer.
showNewSectionLink()
Show an "add new section" link?
bool $mDoNothing
Whether output is disabled.
string $mPageTitle
The contents of.
string $mPageLinkTitle
Used by skin template.
addHeadItem( $name, $value)
Add or replace a head item to the output.
getRevisionId()
Get the displayed revision ID.
setIndicators(array $indicators)
Add an array of indicators, with their identifiers as array keys and HTML contents as values.
bool $mEnableTOC
Whether parser output contains a table of contents.
Title $mRedirectedFrom
If the current page was reached through a redirect, $mRedirectedFrom contains the Title of the redire...
lowerCdnMaxage( $maxage)
Set the value of the "s-maxage" part of the "Cache-control" HTTP header to $maxage if that is lower t...
getRobotPolicy()
Get the current robot policy for the page as a string in the form <index policy>,<follow policy>.
forceHideNewSectionLink()
Forcibly hide the new section link?
bool $mHasCopyright
Is the content subject to copyright.
string null $mTarget
ResourceLoader target for load.php links.
int $mCdnMaxage
Cache stuff.
addBacklinkSubtitle(Title $title, $query=[])
Add a subtitle containing a backlink to a page.
getAllowedModules( $type)
Show what level of JavaScript / CSS untrustworthiness is allowed on this page.
string $displayTitle
The displayed title of the page.
prependHTML( $text)
Prepend $text to the body HTML.
addLanguageLinks(array $newLinkArray)
Add new language links.
array $mLanguageLinks
Array of Interwiki Prefixed (non DB key) Titles (e.g.
setArticleRelated( $newVal)
Set whether this page is related an article on the wiki Setting false will cause the change of "artic...
string $mInlineStyles
Inline CSS styles.
getFollowPolicy()
Get the current follow policy for the page as a string.
addModules( $modules)
Load one or more ResourceLoader modules on this page.
buildExemptModules()
Build exempt modules and legacy non-ResourceLoader styles.
getProperty( $name)
Get an additional output property.
addWikiTextAsInterface( $text, $linestart=true, Title $title=null)
Convert wikitext in the user interface language to HTML and add it to the buffer.
headElement(Skin $sk, $includeStyle=true)
prepareErrorPage( $pageTitle, $htmlTitle=false)
Prepare this object to display an error page; disable caching and indexing, clear the current text an...
addContentOverrideCallback(callable $callback)
Add a callback for mapping from a Title to a Content object, for things like page preview.
static buildBacklinkSubtitle(Title $title, $query=[])
Build message object for a subtitle containing a backlink to a page.
setFeedAppendQuery( $val)
Add default feeds to the page header This is mainly kept for backward compatibility,...
getBottomScripts()
JS stuff to put at the bottom of the <body>.
addReturnTo( $title, array $query=[], $text=null, $options=[])
Add a "return to" link pointing to a specified title.
getMetaTags()
Returns the current <meta> tags.
getOriginTrials()
Get the Origin-Trial header values.
string bool $mCanonicalUrl
bool $mArticleBodyOnly
Flag if output should only contain the body of the article.
setSubtitle( $str)
Replace the subtitle with $str.
couldBePublicCached()
Whether the output might become publicly cached.
array $rlExemptStyleModules
getCategoryLinks()
Get the list of category links, in a 2-D array with the following format: $arr[$type][] = $link,...
getFrameOptions()
Get the X-Frame-Options header value (without the name part), or false if there isn't one.
addHeadItems( $values)
Add one or more head items to the output.
static combineWrappedStrings(array $chunks)
Combine WrappedString chunks and filter out empty ones.
bool $mIsArticleRelated
Stores "article flag" toggle.
getUnprefixedDisplayTitle()
Returns page display title without namespace prefix if possible.
getCSPNonce()
Get (and set if not yet set) the CSP nonce.
array $mVaryHeader
Headers that cause the cache to vary.
hasHeadItem( $name)
Check if the header item $name is already set.
array $styles
An array of stylesheet filenames (relative from skins path), with options for CSS media,...
isDisabled()
Return whether the output will be completely disabled.
Set options of the Parser.
preventClickjacking( $flag=null)
Get or set the prevent-clickjacking flag.
getExtraCSPStyleSrcs()
Get extra Content-Security-Policy 'style-src' directives.
getExtraCSPScriptSrcs()
Get extra Content-Security-Policy 'script-src' directives.
getText( $options=[])
Get the output HTML.
getExtraCSPDefaultSrcs()
Get extra Content-Security-Policy 'default-src' directives.
Load and configure a ResourceLoader client on an HTML page.
setModules(array $modules)
Ensure one or more modules are loaded.
static makeLoad(ResourceLoaderContext $mainContext, array $modules, $only, array $extraQuery=[], $nonce=null)
Explicitly load or embed modules on a page.
setConfig(array $vars)
Set mw.config variables.
setExemptStates(array $states)
Set state of special modules that are handled by the caller manually.
setModuleStyles(array $modules)
Ensure the styles of one or more modules are loaded.
Context object that contains information about the state of a specific ResourceLoader web request.
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
getOrigin()
Get this module's origin.
ResourceLoader is a loading system for JavaScript and CSS resources.
static makeInlineScript( $script, $nonce=null)
Make an HTML script that runs given JS code after startup and base modules.
static inDebugMode()
Determine whether debug mode is on.
static makeConfigSetScript(array $configuration)
Return JS code which will set the MediaWiki configuration array to the given value.
static makeLoaderQuery(array $modules, $lang, $skin, $user=null, $version=null, $debug=false, $only=null, $printable=false, $handheld=false, array $extraQuery=[])
Build a query array (array representation of query string) for load.php.
The main skin class which provides methods and properties for all other skins.
getHtmlElementAttributes()
Return values for <html> element.
getPageClasses( $title)
TODO: document.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
while(( $__line=Maintenance::readconsole()) !==false) print
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Base interface for content objects.
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!isset( $args[0])) $lang