*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\WrappedString;
+use Wikimedia\WrappedStringList;
/**
* @defgroup Skins Skins
'syndicate' => [],
];
- // Support for high-density display images if enabled
- if ( $config->get( 'ResponsiveImages' ) ) {
- $modules['core'][] = 'mediawiki.hidpi';
- }
-
// Preload jquery.tablesorter for mediawiki.page.ready
if ( strpos( $out->getHTML(), 'sortable' ) !== false ) {
$modules['content'][] = 'jquery.tablesorter';
- $modules['styles']['content'][] = 'jquery.tablesorter.styles';
}
// Preload jquery.makeCollapsible for mediawiki.page.ready
if ( $out->isTOCEnabled() ) {
$modules['content'][] = 'mediawiki.toc';
+ $modules['styles']['content'][] = 'mediawiki.toc.styles';
}
// Add various resources if required
/**
* Outputs the HTML generated by other functions.
- * @param OutputPage $out
+ * @param OutputPage|null $out
*/
abstract function outputPage( OutputPage $out = null );
/**
* @param array $data
- * @param string $nonce OutputPage::getCSPNonce()
- * @return string
+ * @param string|null $nonce OutputPage::getCSPNonce()
+ * @return string|WrappedString HTML
*/
- static function makeVariablesScript( $data, $nonce = null ) {
+ public static function makeVariablesScript( $data, $nonce = null ) {
if ( $data ) {
return ResourceLoader::makeInlineScript(
ResourceLoader::makeConfigSetScript( $data ),
$nonce
);
- } else {
- return '';
}
+ return '';
}
/**
if ( $title->isSpecialPage() ) {
$type = 'ns-special';
// T25315: provide a class based on the canonical special page name without subpages
- list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+ list( $canonicalName ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $title->getDBkey() );
if ( $canonicalName ) {
$type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
} else {
/**
* This gets called shortly before the "</body>" tag.
*
- * @return string HTML-wrapped JS code to be put before "</body>"
+ * @return string|WrappedStringList HTML containing scripts to put before `</body>`
*/
function bottomScripts() {
// TODO and the suckage continues. This function is really just a wrapper around
// OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
// up at some point
- $bottomScriptText = $this->getOutput()->getBottomScripts();
- Hooks::run( 'SkinAfterBottomScripts', [ $this, &$bottomScriptText ] );
-
- return $bottomScriptText;
+ $chunks = [ $this->getOutput()->getBottomScripts() ];
+
+ // Keep the hook appendage separate to preserve WrappedString objects.
+ // This enables BaseTemplate::getTrail() to merge them where possible.
+ $extraHtml = '';
+ Hooks::run( 'SkinAfterBottomScripts', [ $this, &$extraHtml ] );
+ if ( $extraHtml !== '' ) {
+ $chunks[] = $extraHtml;
+ }
+ return WrappedString::join( "\n", $chunks );
}
/**
}
/**
- * @param OutputPage $out Defaults to $this->getOutput() if left as null
+ * @param OutputPage|null $out Defaults to $this->getOutput() if left as null
* @return string
*/
function subPageSubtitle( $out = null ) {
if ( is_string( $icon ) ) {
$html = $icon;
} else { // Assuming array
- $url = isset( $icon["url"] ) ? $icon["url"] : null;
+ $url = $icon["url"] ?? null;
unset( $icon["url"] );
if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
// do this the lazy way, just pass icon data as an attribute array
[
'checkKeys' => [
// Unless there is both no exact $code override nor an i18n definition
- // in the the software, the only MediaWiki page to check is for $code.
+ // in the software, the only MediaWiki page to check is for $code.
$msgCache->getCheckKey( $this->getLanguage()->getCode() )
],
'lockTSE' => 30
if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
$uTalkTitle = $user->getTalkPage();
- $lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
+ $lastSeenRev = $newtalks[0]['rev'] ?? null;
$nofAuthors = 0;
if ( $lastSeenRev !== null ) {
$plural = true; // Default if we have a last seen revision: if unknown, use plural
* should fall back to the next notice in its sequence
*/
private function getCachedNotice( $name ) {
- global $wgRenderHashAppend, $wgContLang;
+ global $wgRenderHashAppend;
$needParse = false;
}
);
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
return Html::rawElement(
'div',
[
'id' => 'localNotice',
- 'lang' => $wgContLang->getHtmlCode(),
- 'dir' => $wgContLang->getDir()
+ 'lang' => $contLang->getHtmlCode(),
+ 'dir' => $contLang->getDir()
],
$parsed
);
}
/**
- * Create a section edit link. This supersedes editSectionLink() and
- * editSectionLinkForOther().
+ * Create a section edit link.
*
* @param Title $nt The title being linked to (may not be the same as
* the current page, if the section is included from a template)
* @param string $section The designation of the section being pointed to,
* to be included in the link, like "§ion=$section"
- * @param string $tooltip The tooltip to use for the link: will be escaped
+ * @param string|null $tooltip The tooltip to use for the link: will be escaped
* and wrapped in the 'editsectionhint' message
* @param string $lang Language code
* @return string HTML to use for edit link