private $mTarget = null;
/**
- * @var bool Whether parser output should contain table of contents
+ * @var bool Whether parser output contains a table of contents
*/
- private $mEnableTOC = true;
+ private $mEnableTOC = false;
/**
* @var bool Whether parser output should contain section edit links
private $mEnableSectionEditLinks = true;
/**
- * @var string|null The URL to send in a <link> element with rel=copyright
+ * @var string|null The URL to send in a <link> element with rel=license
*/
private $copyrightUrl;
$this->addParserOutput( $parserOutput );
}
- /**
- * Add a ParserOutput object, but without Html.
- *
- * @deprecated since 1.24, use addParserOutputMetadata() instead.
- * @param ParserOutput $parserOutput
- */
- public function addParserOutputNoText( $parserOutput ) {
- wfDeprecated( __METHOD__, '1.24' );
- $this->addParserOutputMetadata( $parserOutput );
- }
-
/**
* Add all metadata associated with a ParserOutput object, but without the actual HTML. This
* includes categories, language links, ResourceLoader modules, effects of certain magic words,
$outputPage = $this;
Hooks::run( 'LanguageLinks', [ $this->getTitle(), &$this->mLanguageLinks, &$linkFlags ] );
Hooks::run( 'OutputPageParserOutput', [ &$outputPage, $parserOutput ] );
+
+ // This check must be after 'OutputPageParserOutput' runs in addParserOutputMetadata
+ // so that extensions may modify ParserOutput to toggle TOC.
+ // This cannot be moved to addParserOutputText because that is not
+ // called by EditPage for Preview.
+ if ( $parserOutput->getTOCEnabled() && $parserOutput->getTOCHTML() ) {
+ $this->mEnableTOC = true;
+ }
}
/**
*/
function addParserOutput( $parserOutput ) {
$this->addParserOutputMetadata( $parserOutput );
- $parserOutput->setTOCEnabled( $this->mEnableTOC );
// Touch section edit links only if not previously disabled
if ( $parserOutput->getEditSectionTokens() ) {
// jQuery etc. can work correctly.
$response->header( 'X-UA-Compatible: IE=Edge' );
- $this->addLogoPreloadLinkHeaders();
+ if ( !$this->mArticleBodyOnly ) {
+ $sk = $this->getSkin();
+
+ if ( $sk->shouldPreloadLogo() ) {
+ $this->addLogoPreloadLinkHeaders();
+ }
+ }
+
$linkHeader = $this->getLinkHeader();
if ( $linkHeader ) {
$response->header( $linkHeader );
if ( $this->mArticleBodyOnly ) {
echo $this->mBodytext;
} else {
- $sk = $this->getSkin();
- // add skin specific modules
- $modules = $sk->getDefaultModules();
-
- // Enforce various default modules for all pages and all skins
- $coreModules = [
- // Keep this list as small as possible
- 'site',
- 'mediawiki.page.startup',
- 'mediawiki.user',
- ];
-
- // Support for high-density display images if enabled
- if ( $config->get( 'ResponsiveImages' ) ) {
- $coreModules[] = 'mediawiki.hidpi';
+ // Enable safe mode if requested
+ if ( $this->getRequest()->getBool( 'safemode' ) ) {
+ $this->disallowUserJs();
}
- $this->addModules( $coreModules );
- foreach ( $modules as $group ) {
+ $sk = $this->getSkin();
+ foreach ( $sk->getDefaultModules() as $group ) {
$this->addModules( $group );
}
+
MWDebug::addModules( $this );
// Avoid PHP 7.1 warning of passing $this by reference
&& $this->userCanPreview();
}
- private function isUserCssPreview() {
+ protected function isUserCssPreview() {
return $this->getConfig()->get( 'AllowUserCss' )
&& $this->getTitle()
&& $this->getTitle()->isCssSubpage()
$vars['wgIsProbablyEditable'] = $title->quickUserCan( 'edit', $user )
&& ( $title->exists() || $title->quickUserCan( 'create', $user ) );
+ $vars['wgRelevantPageIsProbablyEditable'] = $relevantTitle
+ && $relevantTitle->quickUserCan( 'edit', $user )
+ && ( $relevantTitle->exists() || $relevantTitle->quickUserCan( 'create', $user ) );
+
foreach ( $title->getRestrictionTypes() as $type ) {
$vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
}
if ( $copyright ) {
$tags['copyright'] = Html::element( 'link', [
- 'rel' => 'copyright',
+ 'rel' => 'license',
'href' => $copyright ]
);
}
return $tags;
}
- /**
- * @return string HTML tag links to be put in the header.
- * @deprecated since 1.24 Use OutputPage::headElement or if you have to,
- * OutputPage::getHeadLinksArray directly.
- */
- public function getHeadLinks() {
- wfDeprecated( __METHOD__, '1.24' );
- return implode( "\n", $this->getHeadLinksArray() );
- }
-
/**
* Generate a "<link rel/>" for a feed.
*
[ 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ]
);
+ $separateReq = [ 'site.styles', 'user.styles' ];
foreach ( $this->rlExemptStyleModules as $group => $moduleNames ) {
- $chunks[] = $this->makeResourceLoaderLink( $moduleNames,
+ // Combinable modules
+ $chunks[] = $this->makeResourceLoaderLink(
+ array_diff( $moduleNames, $separateReq ),
ResourceLoaderModule::TYPE_STYLES
);
+
+ foreach ( array_intersect( $moduleNames, $separateReq ) as $name ) {
+ // These require their own dedicated request in order to support "@import"
+ // syntax, which is incompatible with concatenation. (T147667, T37562)
+ $chunks[] = $this->makeResourceLoaderLink( $name,
+ ResourceLoaderModule::TYPE_STYLES
+ );
+ }
}
return self::combineWrappedStrings( array_merge( $chunks, $append ) );
}
/**
- * Enables/disables TOC, doesn't override __NOTOC__
- * @param bool $flag
- * @since 1.22
- */
- public function enableTOC( $flag = true ) {
- $this->mEnableTOC = $flag;
- }
-
- /**
+ * Whether the output has a table of contents
* @return bool
* @since 1.22
*/
* @param String $skinName The Skin name to determine the correct OOUI theme
* @param String $dir Language direction
*/
- public static function setupOOUI( $skinName = '', $dir = 'ltr' ) {
- $themes = ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
- // Make keys (skin names) lowercase for case-insensitive matching.
- $themes = array_change_key_case( $themes, CASE_LOWER );
- $theme = isset( $themes[$skinName] ) ? $themes[$skinName] : 'MediaWiki';
- // For example, 'OOUI\MediaWikiTheme'.
+ public static function setupOOUI( $skinName = 'default', $dir = 'ltr' ) {
+ $themes = ResourceLoaderOOUIModule::getSkinThemeMap();
+ $theme = isset( $themes[$skinName] ) ? $themes[$skinName] : $themes['default'];
+ // For example, 'OOUI\WikimediaUITheme'.
$themeClass = "OOUI\\{$theme}Theme";
OOUI\Theme::setSingleton( new $themeClass() );
OOUI\Element::setDefaultDir( $dir );
);
$this->addModuleStyles( [
'oojs-ui-core.styles',
- 'oojs-ui.styles.icons',
'oojs-ui.styles.indicators',
'oojs-ui.styles.textures',
'mediawiki.widgets.styles',
+ 'oojs-ui.styles.icons-content',
+ 'oojs-ui.styles.icons-alerts',
+ 'oojs-ui.styles.icons-interactions',
] );
}
/**
* Add Link headers for preloading the wiki's logo.
*
- * @since 1.26
+ * @since 1.26
*/
protected function addLogoPreloadLinkHeaders() {
- $logo = $this->getConfig()->get( 'Logo' ); // wgLogo
- $logoHD = $this->getConfig()->get( 'LogoHD' ); // wgLogoHD
+ $logo = ResourceLoaderSkinModule::getLogo( $this->getConfig() );
$tags = [];
$logosPerDppx = [];
$logos = [];
- $logosPerDppx['1.0'] = $logo;
-
- if ( !$logoHD ) {
+ if ( !is_array( $logo ) ) {
// No media queries required if we only have one variant
$this->addLinkHeader( '<' . $logo . '>;rel=preload;as=image' );
return;
}
- foreach ( $logoHD as $dppx => $src ) {
- // Only 1.5x and 2x are supported
- // Note: Keep in sync with ResourceLoaderSkinModule
- if ( in_array( $dppx, [ '1.5x', '2x' ] ) ) {
- // LogoHD uses a string in this format: "1.5x"
- $dppx = substr( $dppx, 0, -1 );
- $logosPerDppx[$dppx] = $src;
- }
+ foreach ( $logo as $dppx => $src ) {
+ // Keys are in this format: "1.5x"
+ $dppx = substr( $dppx, 0, -1 );
+ $logosPerDppx[$dppx] = $src;
}
// Because PHP can't have floats as array keys
// (e.g. can't express ">= 1.5 and not >= 2).
// Workaround: Use <= 1.9999 in place of < 2.
$upper_bound = floatval( $logos[ $i + 1 ]['dppx'] ) - 0.000001;
- $media_query = '(min-resolution: ' . $logos[ $i ]['dppx'] .
+ $media_query = '(min-resolution: ' . $logos[ $i ]['dppx'] .
'dppx) and (max-resolution: ' . $upper_bound . 'dppx)';
} else {
// Largest dppx