X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=7c463b6f02aed2dd5c8f19256da0617c809cd8f3;hb=748d75d4d8a34525292c2231437838489f664b79;hp=7a2cf0070ed198539b1b03c11b390763d0e3ab8b;hpb=5886ad074709f1737d480526545af889950aae8e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 7a2cf0070e..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 = []; @@ -571,6 +574,7 @@ class OutputPage extends ContextSource { * @param bool $filter Whether to filter out insufficiently trustworthy modules * @param string|null $position If not null, only return modules with this position * @param string $param + * @param string $type * @return array Array of module names */ public function getModules( $filter = false, $position = null, $param = 'mModules', @@ -688,7 +692,7 @@ class OutputPage extends ContextSource { * Add one or more head items to the output * * @since 1.28 - * @param string|string[] $value Raw HTML + * @param string|string[] $values Raw HTML */ public function addHeadItems( $values ) { $this->mHeadItems = array_merge( $this->mHeadItems, (array)$values ); @@ -704,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 @@ -1715,7 +1729,7 @@ class OutputPage extends ContextSource { * Add wikitext with a custom Title object * * @param string $text Wikitext - * @param Title $title + * @param Title &$title * @param bool $linestart Is this the start of a line? */ public function addWikiTextWithTitle( $text, &$title, $linestart = true ) { @@ -1726,7 +1740,7 @@ class OutputPage extends ContextSource { * Add wikitext with a custom Title object and tidy enabled. * * @param string $text Wikitext - * @param Title $title + * @param Title &$title * @param bool $linestart Is this the start of a line? */ function addWikiTextTitleTidy( $text, &$title, $linestart = true ) { @@ -1838,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. @@ -1876,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 ); } @@ -1899,7 +1913,7 @@ class OutputPage extends ContextSource { /** * Add the output of a QuickTemplate to the output buffer * - * @param QuickTemplate $template + * @param QuickTemplate &$template */ public function addTemplate( &$template ) { $this->addHTML( $template->getHTML() ); @@ -1963,7 +1977,7 @@ class OutputPage extends ContextSource { } /** - * @param $maxage + * @param int $maxage * @deprecated since 1.27 Use setCdnMaxage() instead */ public function setSquidMaxage( $maxage ) { @@ -1997,10 +2011,10 @@ class OutputPage extends ContextSource { * the TTL is higher the older the $mtime timestamp is. Essentially, the * TTL is 90% of the age of the object, subject to the min and max. * - * @param string|integer|float|bool|null $mtime Last-Modified timestamp - * @param integer $minTTL Mimimum TTL in seconds [default: 1 minute] - * @param integer $maxTTL Maximum TTL in seconds [default: $wgSquidMaxage] - * @return integer TTL in seconds + * @param string|int|float|bool|null $mtime Last-Modified timestamp + * @param int $minTTL Mimimum TTL in seconds [default: 1 minute] + * @param int $maxTTL Maximum TTL in seconds [default: $wgSquidMaxage] + * @return int TTL in seconds * @since 1.28 */ public function adaptCdnTTL( $mtime, $minTTL = 0, $maxTTL = 0 ) { @@ -2012,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 ); @@ -2422,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(); @@ -2434,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; @@ -2913,7 +2927,7 @@ class OutputPage extends ContextSource { // Use an IE conditional comment to serve the script only to old IE $pieces[] = '