* @return string[]
*/
static function getSkinNameMessages() {
- $messages = array();
+ $messages = [];
foreach ( self::getSkinNames() as $skinKey => $skinName ) {
$messages[] = "skinname-$skinKey";
}
// Older versions of the software used a numeric setting
// in the user preferences.
- $fallback = array(
+ $fallback = [
0 => $defaultSkin,
2 => 'cologneblue'
- );
+ ];
if ( isset( $fallback[$key] ) ) {
$key = $fallback[$key];
$out = $this->getOutput();
$user = $out->getUser();
- $modules = array(
+ $modules = [
// modules that enhance the page content in some way
- 'content' => array(
+ 'content' => [
'mediawiki.page.ready',
- ),
+ ],
// modules that exist for legacy reasons
'legacy' => ResourceLoaderStartUpModule::getLegacyModules(),
// modules relating to search functionality
- 'search' => array(),
+ 'search' => [],
// modules relating to functionality relating to watching an article
- 'watch' => array(),
+ 'watch' => [],
// modules which relate to the current users preferences
- 'user' => array(),
- );
+ 'user' => [],
+ ];
// Add various resources if required
if ( $wgUseAjax && $wgEnableAPI ) {
* Preload the existence of three commonly-requested pages in a single query
*/
function preloadExistence() {
- $titles = array();
+ $titles = [];
$user = $this->getUser();
$title = $this->getRelevantTitle();
$titles[] = $title->getTalkPage();
}
- Hooks::run( 'SkinPreloadExistence', array( &$titles, $this ) );
+ Hooks::run( 'SkinPreloadExistence', [ &$titles, $this ] );
if ( count( $titles ) ) {
$lb = new LinkBatch( $titles );
public static function getDynamicStylesheetQuery() {
global $wgSquidMaxage;
- return array(
+ return [
'action' => 'raw',
'maxage' => $wgSquidMaxage,
'usemsgcache' => 'yes',
'ctype' => 'text/css',
'smaxage' => $wgSquidMaxage,
- );
+ ];
}
/**
*/
public function getHtmlElementAttributes() {
$lang = $this->getLanguage();
- return array(
+ return [
'lang' => $lang->getHtmlCode(),
'dir' => $lang->getDir(),
'class' => 'client-nojs',
- );
+ ];
}
/**
}
/**
- * @return string
+ * @return string HTML
*/
function getCategoryLinks() {
global $wgUseCategoryBrowser;
}
/**
- * @return string
+ * @return string HTML
*/
function getCategories() {
$out = $this->getOutput();
-
$catlinks = $this->getCategoryLinks();
- $classes = 'catlinks';
-
// Check what we're showing
$allCats = $out->getCategoryLinks();
$showHidden = $this->getUser()->getBoolOption( 'showhiddencats' ) ||
$this->getTitle()->getNamespace() == NS_CATEGORY;
+ $classes = [ 'catlinks' ];
if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
- $classes .= ' catlinks-allhidden';
+ $classes[] = 'catlinks-allhidden';
}
- return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
+ return Html::rawElement(
+ 'div',
+ [ 'id' => 'catlinks', 'class' => $classes, 'data-mw' => 'interface' ],
+ $catlinks
+ );
}
/**
protected function afterContentHook() {
$data = '';
- if ( Hooks::run( 'SkinAfterContent', array( &$data, $this ) ) ) {
+ if ( Hooks::run( 'SkinAfterContent', [ &$data, $this ] ) ) {
// adding just some spaces shouldn't toggle the output
// of the whole <div/>, so we use trim() here
if ( trim( $data ) != '' ) {
// OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
// up at some point
$bottomScriptText = $this->getOutput()->getBottomScripts();
- Hooks::run( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
+ Hooks::run( 'SkinAfterBottomScripts', [ $this, &$bottomScriptText ] );
return $bottomScriptText;
}
$out = $this->getOutput();
$subpages = '';
- if ( !Hooks::run( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
+ if ( !Hooks::run( 'SkinSubPageSubtitle', [ &$subpages, $this, $out ] ) ) {
return $subpages;
}
Hooks::run(
'SkinCopyrightFooter',
- array( $this->getTitle(), $type, &$msg, &$link, &$forContent )
+ [ $this->getTitle(), $type, &$msg, &$link, &$forContent ]
);
return $this->msg( $msg )->rawParams( $link )->text();
$text = '<a href="//www.mediawiki.org/"><img src="' . $url1
. '" srcset="' . $url1_5 . ' 1.5x, ' . $url2 . ' 2x" '
. 'height="31" width="88" alt="Powered by MediaWiki" /></a>';
- Hooks::run( 'SkinGetPoweredBy', array( &$text, $this ) );
+ Hooks::run( 'SkinGetPoweredBy', [ &$text, $this ] );
return $text;
}
$html = htmlspecialchars( $icon["alt"] );
}
if ( $url ) {
- $html = Html::rawElement( 'a', array( "href" => $url ), $html );
+ $html = Html::rawElement( 'a', [ "href" => $url ], $html );
}
}
return $html;
* @private
*/
function editUrlOptions() {
- $options = array( 'action' => 'edit' );
+ $options = [ 'action' => 'edit' ];
if ( !$this->isRevisionCurrent() ) {
$options['oldid'] = intval( $this->getRevisionId() );
$title = Title::newFromText( $name );
self::checkTitle( $title, $name );
- return array(
+ return [
'href' => $title->getLocalURL( $urlaction ),
'exists' => $title->isKnown(),
- );
+ ];
}
/**
$title = Title::newFromText( $name );
self::checkTitle( $title, $name );
- return array(
+ return [
'href' => $title->getLocalURL( $urlaction ),
'exists' => true
- );
+ ];
}
/**
$that = $this;
$callback = function () use ( $that ) {
- $bar = array();
+ $bar = [];
$that->addToSidebar( $bar, 'sidebar' );
- Hooks::run( 'SkinBuildSidebar', array( $that, &$bar ) );
+ Hooks::run( 'SkinBuildSidebar', [ $that, &$bar ] );
return $bar;
};
$cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
$wgSidebarCacheExpiry,
$callback,
- array( 'lockTSE' => 30 )
+ [ 'lockTSE' => 30 ]
);
} else {
$sidebar = $callback();
}
// Apply post-processing to the cached value
- Hooks::run( 'SidebarBeforeOutput', array( $this, &$sidebar ) );
+ Hooks::run( 'SidebarBeforeOutput', [ $this, &$sidebar ] );
return $sidebar;
}
if ( strpos( $line, '**' ) !== 0 ) {
$heading = trim( $line, '* ' );
if ( !array_key_exists( $heading, $bar ) ) {
- $bar[$heading] = array();
+ $bar[$heading] = [];
}
} else {
$line = trim( $line, '* ' );
continue;
}
- $extraAttribs = array();
+ $extraAttribs = [];
$msgLink = $this->msg( $line[0] )->inContentLanguage();
if ( $msgLink->exists() ) {
}
}
- $bar[$heading][] = array_merge( array(
+ $bar[$heading][] = array_merge( [
'text' => $text,
'href' => $href,
'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
'active' => false
- ), $extraAttribs );
+ ], $extraAttribs );
} else {
continue;
}
$out = $this->getOutput();
// Allow extensions to disable or modify the new messages alert
- if ( !Hooks::run( 'GetNewMessagesAlert', array( &$newMessagesAlert, $newtalks, $user, $out ) ) ) {
+ if ( !Hooks::run( 'GetNewMessagesAlert', [ &$newMessagesAlert, $newtalks, $user, $out ] ) ) {
return '';
}
if ( $newMessagesAlert ) {
$newMessagesLink = Linker::linkKnown(
$uTalkTitle,
$this->msg( 'newmessageslinkplural' )->params( $plural )->escaped(),
- array(),
- array( 'redirect' => 'no' )
+ [],
+ [ 'redirect' => 'no' ]
);
$newMessagesDiffLink = Linker::linkKnown(
$uTalkTitle,
$this->msg( 'newmessagesdifflinkplural' )->params( $plural )->escaped(),
- array(),
+ [],
$lastSeenRev !== null
- ? array( 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' )
- : array( 'diff' => 'cur' )
+ ? [ 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' ]
+ : [ 'diff' => 'cur' ]
);
if ( $nofAuthors >= 1 && $nofAuthors <= 10 ) {
$out->setCdnMaxage( 0 );
} elseif ( count( $newtalks ) ) {
$sep = $this->msg( 'newtalkseparator' )->escaped();
- $msgs = array();
+ $msgs = [];
foreach ( $newtalks as $newtalk ) {
$msgs[] = Xml::element(
'a',
- array( 'href' => $newtalk['link'] ), $newtalk['wiki']
+ [ 'href' => $newtalk['link'] ], $newtalk['wiki']
);
}
$parts = implode( $sep, $msgs );
if ( $needParse ) {
$parsed = $this->getOutput()->parse( $notice );
- $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
+ $parserMemc->set( $key, [ 'html' => $parsed, 'hash' => md5( $notice ) ], 600 );
$notice = $parsed;
}
- $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
- 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $notice );
+ $notice = Html::rawElement( 'div', [ 'id' => 'localNotice',
+ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ], $notice );
return $notice;
}
function getSiteNotice() {
$siteNotice = '';
- if ( Hooks::run( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
+ if ( Hooks::run( 'SiteNoticeBefore', [ &$siteNotice, $this ] ) ) {
if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
$siteNotice = $this->getCachedNotice( 'sitenotice' );
} else {
}
}
- Hooks::run( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
+ Hooks::run( 'SiteNoticeAfter', [ &$siteNotice, $this ] );
return $siteNotice;
}
$lang = wfGetLangObj( $lang );
- $attribs = array();
+ $attribs = [];
if ( !is_null( $tooltip ) ) {
# Bug 25462: undo double-escaping.
$tooltip = Sanitizer::decodeCharReferences( $tooltip );
->inLanguage( $lang )->text();
}
- $links = array(
- 'editsection' => array(
+ $links = [
+ 'editsection' => [
'text' => wfMessage( 'editsection' )->inLanguage( $lang )->escaped(),
'targetTitle' => $nt,
'attribs' => $attribs,
- 'query' => array( 'action' => 'edit', 'section' => $section ),
- 'options' => array( 'noclasses', 'known' )
- )
- );
+ 'query' => [ 'action' => 'edit', 'section' => $section ],
+ 'options' => [ 'noclasses', 'known' ]
+ ]
+ ];
- Hooks::run( 'SkinEditSectionLinks', array( $this, $nt, $section, $tooltip, &$links, $lang ) );
+ Hooks::run( 'SkinEditSectionLinks', [ $this, $nt, $section, $tooltip, &$links, $lang ] );
$result = '<span class="mw-editsection"><span class="mw-editsection-bracket">[</span>';
- $linksHtml = array();
+ $linksHtml = [];
foreach ( $links as $k => $linkDetails ) {
$linksHtml[] = Linker::link(
$linkDetails['targetTitle'],
// Deprecated, use SkinEditSectionLinks hook instead
Hooks::run(
'DoEditSectionLink',
- array( $this, $nt, $section, $tooltip, &$result, $lang ),
+ [ $this, $nt, $section, $tooltip, &$result, $lang ],
'1.25'
);
return $result;
* @return mixed
*/
function __call( $fname, $args ) {
- $realFunction = array( 'Linker', $fname );
+ $realFunction = [ 'Linker', $fname ];
if ( is_callable( $realFunction ) ) {
wfDeprecated( get_class( $this ) . '::' . $fname, '1.21' );
return call_user_func_array( $realFunction, $args );