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
$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() ) {
}
$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';
- }
-
- $this->addModules( $coreModules );
- foreach ( $modules as $group ) {
+ 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()
[ '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
*/