X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=e22f42ce213066c7c3c90671f2b238faebee4e2d;hb=15ca48adf291e1d0ab7d4c6d5c28fd54c4c994dd;hp=5c05ad75d05c89ecb102f887201a8ec9d08b01f8;hpb=fa32e55a7c7c133fd841f474237c6a11a1ff0588;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 5c05ad75d0..e22f42ce21 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 @@ -1773,17 +1773,6 @@ class OutputPage extends ContextSource { $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, @@ -1850,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; + } } /** @@ -1890,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() ) { @@ -2388,7 +2384,14 @@ class OutputPage extends ContextSource { // 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 ); @@ -2409,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 @@ -3021,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() @@ -3214,6 +3201,10 @@ class OutputPage extends ContextSource { $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 ); } @@ -3553,16 +3544,6 @@ class OutputPage extends ContextSource { 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 "" for a feed. * @@ -3663,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 ) ); @@ -3928,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 */