X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=7c463b6f02aed2dd5c8f19256da0617c809cd8f3;hb=75a3043b71e96dff59f3559eba62dd2c6e5b86b6;hp=dd21194bdba07d882460c785a26e07535d2dacad;hpb=c2dcf52c3cf62c3efff2876e0bfec5ce9974bfa0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index dd21194bdb..7c463b6f02 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -139,6 +139,9 @@ class OutputPage extends ContextSource { /** @var array Array of elements in "". Parser might add its own headers! */ protected $mHeadItems = []; + /** @var array Additional classes; there are also classes from other sources */ + protected $mAdditionalBodyClasses = []; + /** @var array */ protected $mModules = []; @@ -705,6 +708,16 @@ class OutputPage extends ContextSource { return isset( $this->mHeadItems[$name] ); } + /** + * Add a class to the element + * + * @since 1.30 + * @param string|string[] $classes One or more classes to add + */ + public function addBodyClasses( $classes ) { + $this->mAdditionalBodyClasses = array_merge( $this->mAdditionalBodyClasses, (array)$classes ); + } + /** * @deprecated since 1.28 Obsolete - wgUseETag experiment was removed. * @param string $tag @@ -1839,7 +1852,7 @@ class OutputPage extends ContextSource { // Avoid PHP 7.1 warning of passing $this by reference $outputPage = $this; Hooks::run( 'LanguageLinks', [ $this->getTitle(), &$this->mLanguageLinks, &$linkFlags ] ); - Hooks::run( 'OutputPageParserOutput', [ &$outputPage, $parserOutput ] ); + Hooks::runWithoutAbort( 'OutputPageParserOutput', [ &$outputPage, $parserOutput ] ); // This check must be after 'OutputPageParserOutput' runs in addParserOutputMetadata // so that extensions may modify ParserOutput to toggle TOC. @@ -1877,7 +1890,7 @@ class OutputPage extends ContextSource { $text = $parserOutput->getText(); // Avoid PHP 7.1 warning of passing $this by reference $outputPage = $this; - Hooks::run( 'OutputPageBeforeHTML', [ &$outputPage, &$text ] ); + Hooks::runWithoutAbort( 'OutputPageBeforeHTML', [ &$outputPage, &$text ] ); $this->addHTML( $text ); } @@ -2013,7 +2026,7 @@ class OutputPage extends ContextSource { } $age = time() - wfTimestamp( TS_UNIX, $mtime ); - $adaptiveTTL = max( .9 * $age, $minTTL ); + $adaptiveTTL = max( 0.9 * $age, $minTTL ); $adaptiveTTL = min( $adaptiveTTL, $maxTTL ); $this->lowerCdnMaxage( (int)$adaptiveTTL ); @@ -2423,7 +2436,7 @@ class OutputPage extends ContextSource { $outputPage = $this; // Hook that allows last minute changes to the output page, e.g. // adding of CSS or Javascript by extensions. - Hooks::run( 'BeforePageDisplay', [ &$outputPage, &$sk ] ); + Hooks::runWithoutAbort( 'BeforePageDisplay', [ &$outputPage, &$sk ] ); try { $sk->outputPage(); @@ -2435,7 +2448,7 @@ class OutputPage extends ContextSource { try { // This hook allows last minute changes to final overall output by modifying output buffer - Hooks::run( 'AfterFinalPageOutput', [ $this ] ); + Hooks::runWithoutAbort( 'AfterFinalPageOutput', [ $this ] ); } catch ( Exception $e ) { ob_end_clean(); // bug T129657 throw $e; @@ -2923,7 +2936,7 @@ class OutputPage extends ContextSource { $pieces[] = Html::closeElement( 'head' ); - $bodyClasses = []; + $bodyClasses = $this->mAdditionalBodyClasses; $bodyClasses[] = 'mediawiki'; # Classes for LTR/RTL directionality support