X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=24a506c7aaf1d13fc42cdabb4c2c7dade75b8091;hb=70471939f99abe606f2a14df21fb966a79ca53c0;hp=e71cf1866c604be60b83dd58d84733580efaa2c7;hpb=06657e715ae1ca3a9afc602724d0c113713e22c0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index e71cf1866c..24a506c7aa 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -285,9 +285,9 @@ class OutputPage extends ContextSource { 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 @@ -1839,6 +1839,14 @@ class OutputPage extends ContextSource { $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; + } } /** @@ -1879,7 +1887,6 @@ class OutputPage extends ContextSource { */ function addParserOutput( $parserOutput ) { $this->addParserOutputMetadata( $parserOutput ); - $parserOutput->setTOCEnabled( $this->mEnableTOC ); // Touch section edit links only if not previously disabled if ( $parserOutput->getEditSectionTokens() ) { @@ -2405,26 +2412,10 @@ class OutputPage extends ContextSource { } $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 @@ -3017,7 +3008,7 @@ class OutputPage extends ContextSource { && $this->userCanPreview(); } - private function isUserCssPreview() { + protected function isUserCssPreview() { return $this->getConfig()->get( 'AllowUserCss' ) && $this->getTitle() && $this->getTitle()->isCssSubpage() @@ -3653,10 +3644,21 @@ class OutputPage extends ContextSource { [ '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 ) ); @@ -3918,15 +3920,7 @@ class OutputPage extends ContextSource { } /** - * 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 */ @@ -3958,12 +3952,10 @@ class OutputPage extends ContextSource { * @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 ); @@ -3982,10 +3974,12 @@ class OutputPage extends ContextSource { ); $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', ] ); }