/** @var array Array of elements in "<head>". Parser might add its own headers! */
protected $mHeadItems = [];
+ /** @var array Additional <body> classes; there are also <body> classes from other sources */
+ protected $mAdditionalBodyClasses = [];
+
/** @var array */
protected $mModules = [];
return isset( $this->mHeadItems[$name] );
}
+ /**
+ * Add a class to the <body> 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
// 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.
$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 );
}
}
$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 );
// IE and some other browsers use BCP 47 standards in
// their Accept-Language header, like "zh-CN" or "zh-Hant".
// We should handle these too.
- $variantBCP47 = wfBCP47( $variant );
+ $variantBCP47 = LanguageCode::bcp47( $variant );
if ( $variantBCP47 !== $variant ) {
$aloption[] = 'substr=' . $variantBCP47;
}
$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();
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;
$pieces = array_merge( $pieces, array_values( $this->getHeadLinksArray() ) );
$pieces = array_merge( $pieces, array_values( $this->mHeadItems ) );
- $min = ResourceLoader::inDebugMode() ? '' : '.min';
// Use an IE conditional comment to serve the script only to old IE
$pieces[] = '<!--[if lt IE 9]>' .
- Html::element( 'script', [
- 'src' => self::transformResourcePath(
- $this->getConfig(),
- "/resources/lib/html5shiv/html5shiv{$min}.js"
- ),
- ] ) .
+ ResourceLoaderClientHtml::makeLoad(
+ ResourceLoaderContext::newDummyContext(),
+ [ 'html5shiv' ],
+ ResourceLoaderModule::TYPE_SCRIPTS,
+ [ 'sync' => true ]
+ ) .
'<![endif]-->';
$pieces[] = Html::closeElement( 'head' );
- $bodyClasses = [];
+ $bodyClasses = $this->mAdditionalBodyClasses;
$bodyClasses[] = 'mediawiki';
# Classes for LTR/RTL directionality support
foreach ( $variants as $variant ) {
$tags["variant-$variant"] = Html::element( 'link', [
'rel' => 'alternate',
- 'hreflang' => wfBCP47( $variant ),
+ 'hreflang' => LanguageCode::bcp47( $variant ),
'href' => $this->getTitle()->getLocalURL(
[ 'variant' => $variant ] )
]