*/
function getToolbox() {
- $toolbox = array();
+ $toolbox = [];
if ( isset( $this->data['nav_urls']['whatlinkshere'] )
&& $this->data['nav_urls']['whatlinkshere']
) {
}
if ( isset( $this->data['feeds'] ) && $this->data['feeds'] ) {
$toolbox['feeds']['id'] = 'feedlinks';
- $toolbox['feeds']['links'] = array();
+ $toolbox['feeds']['links'] = [];
foreach ( $this->data['feeds'] as $key => $feed ) {
$toolbox['feeds']['links'][$key] = $feed;
$toolbox['feeds']['links'][$key]['id'] = "feed-$key";
$toolbox['feeds']['links'][$key]['class'] = 'feedlink';
}
}
- foreach ( array( 'contributions', 'log', 'blockip', 'emailuser',
- 'userrights', 'upload', 'specialpages' ) as $special
+ foreach ( [ 'contributions', 'log', 'blockip', 'emailuser',
+ 'userrights', 'upload', 'specialpages' ] as $special
) {
if ( isset( $this->data['nav_urls'][$special] ) && $this->data['nav_urls'][$special] ) {
$toolbox[$special] = $this->data['nav_urls'][$special];
$toolbox['info']['id'] = 't-info';
}
- Hooks::run( 'BaseTemplateToolbox', array( &$this, &$toolbox ) );
+ Hooks::run( 'BaseTemplateToolbox', [ &$this, &$toolbox ] );
return $toolbox;
}
* @return array
*/
function getPersonalTools() {
- $personal_tools = array();
+ $personal_tools = [];
foreach ( $this->get( 'personal_urls' ) as $key => $plink ) {
# The class on a personal_urls item is meant to go on the <a> instead
# of the <li> so we have to use a single item "links" array instead
# of using most of the personal_url's keys directly.
- $ptool = array(
- 'links' => array(
- array( 'single-id' => "pt-$key" ),
- ),
+ $ptool = [
+ 'links' => [
+ [ 'single-id' => "pt-$key" ],
+ ],
'id' => "pt-$key",
- );
+ ];
if ( isset( $plink['active'] ) ) {
$ptool['active'] = $plink['active'];
}
- foreach ( array( 'href', 'class', 'text', 'dir' ) as $k ) {
+ foreach ( [ 'href', 'class', 'text', 'dir' ] as $k ) {
if ( isset( $plink[$k] ) ) {
$ptool['links'][0][$k] = $plink[$k];
}
return $personal_tools;
}
- function getSidebar( $options = array() ) {
+ function getSidebar( $options = [] ) {
// Force the rendering of the following portals
$sidebar = $this->data['sidebar'];
if ( !isset( $sidebar['SEARCH'] ) ) {
unset( $sidebar['LANGUAGES'] );
}
- $boxes = array();
+ $boxes = [];
foreach ( $sidebar as $boxName => $content ) {
if ( $content === false ) {
continue;
switch ( $boxName ) {
case 'SEARCH':
// Search is a special case, skins should custom implement this
- $boxes[$boxName] = array(
+ $boxes[$boxName] = [
'id' => 'p-search',
'header' => $this->getMsg( 'search' )->text(),
'generated' => false,
'content' => true,
- );
+ ];
break;
case 'TOOLBOX':
$msgObj = $this->getMsg( 'toolbox' );
- $boxes[$boxName] = array(
+ $boxes[$boxName] = [
'id' => 'p-tb',
'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
'generated' => false,
'content' => $this->getToolbox(),
- );
+ ];
break;
case 'LANGUAGES':
if ( $this->data['language_urls'] ) {
$msgObj = $this->getMsg( 'otherlanguages' );
- $boxes[$boxName] = array(
+ $boxes[$boxName] = [
'id' => 'p-lang',
'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
'generated' => false,
'content' => $this->data['language_urls'],
- );
+ ];
}
break;
default:
$msgObj = $this->getMsg( $boxName );
- $boxes[$boxName] = array(
+ $boxes[$boxName] = [
'id' => "p-$boxName",
'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
'generated' => true,
'content' => $content,
- );
+ ];
break;
}
}
ob_start();
// We pass an extra 'true' at the end so extensions using BaseTemplateToolbox
// can abort and avoid outputting double toolbox links
- Hooks::run( 'SkinTemplateToolboxEnd', array( &$this, true ) );
+ Hooks::run( 'SkinTemplateToolboxEnd', [ &$this, true ] );
$hookContents = ob_get_contents();
ob_end_clean();
if ( !trim( $hookContents ) ) {
}
} else {
if ( $hookContents ) {
- $boxes['TOOLBOXEND'] = array(
+ $boxes['TOOLBOXEND'] = [
'id' => 'p-toolboxend',
'header' => $boxes['TOOLBOX']['header'],
'generated' => false,
'content' => "<ul>{$hookContents}</ul>",
- );
+ ];
// HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
- $boxes2 = array();
+ $boxes2 = [];
foreach ( $boxes as $key => $box ) {
if ( $key === 'TOOLBOXEND' ) {
continue;
*/
protected function renderAfterPortlet( $name ) {
$content = '';
- Hooks::run( 'BaseTemplateAfterPortlet', array( $this, $name, &$content ) );
+ Hooks::run( 'BaseTemplateAfterPortlet', [ $this, $name, &$content ] );
if ( $content !== '' ) {
echo "<div class='after-portlet after-portlet-$name'>$content</div>";
*
* @return string
*/
- function makeLink( $key, $item, $options = array() ) {
+ function makeLink( $key, $item, $options = [] ) {
if ( isset( $item['text'] ) ) {
$text = $item['text'];
} else {
if ( isset( $options['text-wrapper'] ) ) {
$wrapper = $options['text-wrapper'];
if ( isset( $wrapper['tag'] ) ) {
- $wrapper = array( $wrapper );
+ $wrapper = [ $wrapper ];
}
while ( count( $wrapper ) > 0 ) {
$element = array_pop( $wrapper );
if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) {
$attrs = $item;
- foreach ( array( 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary',
- 'tooltip-params' ) as $k ) {
+ foreach ( [ 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary',
+ 'tooltip-params' ] as $k ) {
unset( $attrs[$k] );
}
$item['single-id'] = $item['id'];
}
- $tooltipParams = array();
+ $tooltipParams = [];
if ( isset( $item['tooltip-params'] ) ) {
$tooltipParams = $item['tooltip-params'];
}
*
* @return string
*/
- function makeListItem( $key, $item, $options = array() ) {
+ function makeListItem( $key, $item, $options = [] ) {
if ( isset( $item['links'] ) ) {
- $links = array();
+ $links = [];
foreach ( $item['links'] as $linkKey => $link ) {
$links[] = $this->makeLink( $linkKey, $link, $options );
}
} else {
$link = $item;
// These keys are used by makeListItem and shouldn't be passed on to the link
- foreach ( array( 'id', 'class', 'active', 'tag', 'itemtitle' ) as $k ) {
+ foreach ( [ 'id', 'class', 'active', 'tag', 'itemtitle' ] as $k ) {
unset( $link[$k] );
}
if ( isset( $item['id'] ) && !isset( $item['single-id'] ) ) {
$html = $this->makeLink( $key, $link, $options );
}
- $attrs = array();
- foreach ( array( 'id', 'class' ) as $attr ) {
+ $attrs = [];
+ foreach ( [ 'id', 'class' ] as $attr ) {
if ( isset( $item[$attr] ) ) {
$attrs[$attr] = $item[$attr];
}
return Html::rawElement( isset( $options['tag'] ) ? $options['tag'] : 'li', $attrs, $html );
}
- function makeSearchInput( $attrs = array() ) {
- $realAttrs = array(
+ function makeSearchInput( $attrs = [] ) {
+ $realAttrs = [
'type' => 'search',
'name' => 'search',
'placeholder' => wfMessage( 'searchsuggest-search' )->text(),
'value' => $this->get( 'search', '' ),
- );
+ ];
$realAttrs = array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
return Html::element( 'input', $realAttrs );
}
- function makeSearchButton( $mode, $attrs = array() ) {
+ function makeSearchButton( $mode, $attrs = [] ) {
switch ( $mode ) {
case 'go':
case 'fulltext':
- $realAttrs = array(
+ $realAttrs = [
'type' => 'submit',
'name' => $mode,
'value' => $this->translator->translate(
$mode == 'go' ? 'searcharticle' : 'searchbutton' ),
- );
+ ];
$realAttrs = array_merge(
$realAttrs,
Linker::tooltipAndAccesskeyAttribs( "search-$mode" ),
);
return Html::element( 'input', $realAttrs );
case 'image':
- $buttonAttrs = array(
+ $buttonAttrs = [
'type' => 'submit',
'name' => 'button',
- );
+ ];
$buttonAttrs = array_merge(
$buttonAttrs,
Linker::tooltipAndAccesskeyAttribs( 'search-fulltext' ),
unset( $buttonAttrs['alt'] );
unset( $buttonAttrs['width'] );
unset( $buttonAttrs['height'] );
- $imgAttrs = array(
+ $imgAttrs = [
'src' => $attrs['src'],
'alt' => isset( $attrs['alt'] )
? $attrs['alt']
: $this->translator->translate( 'searchbutton' ),
'width' => isset( $attrs['width'] ) ? $attrs['width'] : null,
'height' => isset( $attrs['height'] ) ? $attrs['height'] : null,
- );
+ ];
return Html::rawElement( 'button', $buttonAttrs, Html::element( 'img', $imgAttrs ) );
default:
throw new MWException( 'Unknown mode passed to BaseTemplate::makeSearchButton' );
$footerlinks = $this->get( 'footerlinks' );
// Reduce footer links down to only those which are being used
- $validFooterLinks = array();
+ $validFooterLinks = [];
foreach ( $footerlinks as $category => $links ) {
- $validFooterLinks[$category] = array();
+ $validFooterLinks[$category] = [];
foreach ( $links as $link ) {
if ( isset( $this->data[$link] ) && $this->data[$link] ) {
$validFooterLinks[$category][] = $link;
foreach ( $this->data['indicators'] as $id => $content ) {
$out .= Html::rawElement(
'div',
- array(
+ [
'id' => Sanitizer::escapeId( "mw-indicator-$id" ),
'class' => 'mw-indicator',
- ),
+ ],
$content
) . "\n";
}
* @ingroup Skins
*/
class MediaWikiI18N {
- private $context = array();
+ private $context = [];
function set( $varName, $value ) {
$this->context[$varName] = $value;
$value = wfMessage( $value )->text();
// interpolate variables
- $m = array();
+ $m = [];
while ( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
list( $src, $var ) = $m;
MediaWiki\suppressWarnings();
* @param Config $config
*/
function __construct( Config $config = null ) {
- $this->data = array();
+ $this->data = [];
$this->translator = new MediaWikiI18N();
if ( $config === null ) {
wfDebug( __METHOD__ . ' was called with no Config instance passed to it' );
* @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',
- );
+ ];
}
/**
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 );
// Skip work and hooks for stuff we don't use
function buildSidebar() {
- return array();
+ return [];
}
function getNewtalks() {
}
public function getLanguages() {
- return array();
+ return [];
}
protected function buildPersonalUrls() {
- return array();
+ return [];
}
protected function buildContentNavigationUrls() {
- return array();
+ return [];
}
protected function buildNavUrls() {
- return array();
+ return [];
}
}
// Skip work and hooks for stuff we don't use
function getToolbox() {
- return array();
+ return [];
}
function getPersonalTools() {
- return array();
+ return [];
}
- function getSidebar( $options = array() ) {
- return array();
+ function getSidebar( $options = [] ) {
+ return [];
}
}
* Map of name => callback
* @var array
*/
- private $factoryFunctions = array();
+ private $factoryFunctions = [];
/**
* Map of name => fallback human-readable name, used when the 'skinname-<skin>' message is not
* available
*
* @var array
*/
- private $displayNames = array();
+ private $displayNames = [];
/**
* @var SkinFactory
$enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER );
if ( $installedSkins ) {
- $skinsInstalledText = array();
- $skinsInstalledSnippet = array();
+ $skinsInstalledText = [];
+ $skinsInstalledSnippet = [];
foreach ( $installedSkins as $skin ) {
$normalizedKey = strtolower( $skin );
<form action="<?php $this->text( 'wgScript' ) ?>">
<input type="hidden" name="title" value="<?php $this->text( 'searchtitle' ) ?>" />
<h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
- <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ) ?>
+ <?php echo $this->makeSearchInput( [ "id" => "searchInput" ] ) ?>
<?php echo $this->makeSearchButton( 'go' ) ?>
</form>
* @param OutputPage $out
*/
function setupSkinUserCss( OutputPage $out ) {
- $moduleStyles = array(
+ $moduleStyles = [
'mediawiki.legacy.shared',
'mediawiki.legacy.commonPrint',
'mediawiki.sectionAnchor'
- );
+ ];
if ( $out->isSyndicated() ) {
$moduleStyles[] = 'mediawiki.feedlink';
}
public function getLanguages() {
global $wgHideInterlanguageLinks;
if ( $wgHideInterlanguageLinks ) {
- return array();
+ return [];
}
$userLang = $this->getLanguage();
- $languageLinks = array();
+ $languageLinks = [];
foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
$class = 'interlanguage-link interwiki-' . explode( ':', $languageLinkText, 2 )[0];
}
$ilInterwikiCodeBCP47 = wfBCP47( $ilInterwikiCode );
- $languageLink = array(
+ $languageLink = [
'href' => $languageLinkTitle->getFullURL(),
'text' => $ilLangName,
'title' => $ilTitle,
'class' => $class,
'lang' => $ilInterwikiCodeBCP47,
'hreflang' => $ilInterwikiCodeBCP47,
- );
+ ];
Hooks::run(
'SkinTemplateGetLanguageLink',
- array( &$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput() )
+ [ &$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput() ]
);
$languageLinks[] = $languageLink;
}
$this->thispage = $title->getPrefixedDBkey();
$this->titletxt = $title->getPrefixedText();
$this->userpage = $user->getUserPage()->getPrefixedText();
- $query = array();
+ $query = [];
if ( !$request->wasPosted() ) {
$query = $request->getValues();
unset( $query['title'] );
$tpl->set( 'catlinks', $this->getCategories() );
if ( $out->isSyndicated() ) {
- $feeds = array();
+ $feeds = [];
foreach ( $out->getSyndicationLinks() as $format => $link ) {
- $feeds[$format] = array(
+ $feeds[$format] = [
// Messages: feed-atom, feed-rss
'text' => $this->msg( "feed-$format" )->text(),
'href' => $link
- );
+ ];
}
$tpl->setRef( 'feeds', $feeds );
} else {
$tpl->set( 'privacy', $this->privacyLink() );
$tpl->set( 'about', $this->aboutLink() );
- $tpl->set( 'footerlinks', array(
- 'info' => array(
+ $tpl->set( 'footerlinks', [
+ 'info' => [
'lastmod',
'numberofwatchingusers',
'credits',
'copyright',
- ),
- 'places' => array(
+ ],
+ 'places' => [
'privacy',
'about',
'disclaimer',
- ),
- ) );
+ ],
+ ] );
global $wgFooterIcons;
$tpl->set( 'footericons', $wgFooterIcons );
$tpl->set( 'printfooter', $this->printSource() );
# An ID that includes the actual body text; without categories, contentSub, ...
- $realBodyAttribs = array( 'id' => 'mw-content-text' );
+ $realBodyAttribs = [ 'id' => 'mw-content-text' ];
# Add a mw-content-ltr/rtl class to be able to style based on text direction
# when the content is different from the UI language, i.e.:
# not for special pages or file pages AND only when viewing
- if ( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
+ if ( !in_array( $title->getNamespace(), [ NS_SPECIAL, NS_FILE ] ) &&
Action::getActionName( $this ) === 'view' ) {
$pageLang = $title->getPageViewLanguage();
$realBodyAttribs['lang'] = $pageLang->getHtmlCode();
$tpl->set( 'reporttime', wfReportTime() );
// original version by hansm
- if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
+ if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', [ &$this, &$tpl ] ) ) {
wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
}
// start not outputting information.
$tpl->data['bodytext'] .= Html::rawElement(
'div',
- array( 'class' => 'printfooter' ),
+ [ 'class' => 'printfooter' ],
"\n{$tpl->data['printfooter']}"
) . "\n";
$tpl->data['bodytext'] .= $tpl->data['debughtml'];
$pageurl = $title->getLocalURL();
/* set up the default links for the personal toolbar */
- $personal_urls = array();
+ $personal_urls = [];
# Due to bug 32276, if a user does not have read permissions,
# $this->getTitle() will just give Special:Badtitle, which is
$page = Title::newFromText( $request->getVal( 'title', '' ) );
}
$page = $request->getVal( 'returnto', $page );
- $a = array();
+ $a = [];
if ( strval( $page ) !== '' ) {
$a['returnto'] = $page;
$query = $request->getVal( 'returntoquery', $this->thisquery );
$returnto = wfArrayToCgi( $a );
if ( $this->loggedin ) {
- $personal_urls['userpage'] = array(
+ $personal_urls['userpage'] = [
'text' => $this->username,
'href' => &$this->userpageUrlDetails['href'],
'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
'dir' => 'auto'
- );
+ ];
$usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
- $personal_urls['mytalk'] = array(
+ $personal_urls['mytalk'] = [
'text' => $this->msg( 'mytalk' )->text(),
'href' => &$usertalkUrlDetails['href'],
'class' => $usertalkUrlDetails['exists'] ? false : 'new',
'active' => ( $usertalkUrlDetails['href'] == $pageurl )
- );
+ ];
$href = self::makeSpecialUrl( 'Preferences' );
- $personal_urls['preferences'] = array(
+ $personal_urls['preferences'] = [
'text' => $this->msg( 'mypreferences' )->text(),
'href' => $href,
'active' => ( $href == $pageurl )
- );
+ ];
if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
$href = self::makeSpecialUrl( 'Watchlist' );
- $personal_urls['watchlist'] = array(
+ $personal_urls['watchlist'] = [
'text' => $this->msg( 'mywatchlist' )->text(),
'href' => $href,
'active' => ( $href == $pageurl )
- );
+ ];
}
# We need to do an explicit check for Special:Contributions, as we
}
$href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
- $personal_urls['mycontris'] = array(
+ $personal_urls['mycontris'] = [
'text' => $this->msg( 'mycontris' )->text(),
'href' => $href,
'active' => $active
- );
- $personal_urls['logout'] = array(
+ ];
+ $personal_urls['logout'] = [
'text' => $this->msg( 'pt-userlogout' )->text(),
'href' => self::makeSpecialUrl( 'Userlogout',
// userlogout link must always contain an & character, otherwise we might not be able
$title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto
),
'active' => false
- );
+ ];
} else {
$useCombinedLoginLink = $this->useCombinedLoginLink();
$loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
: 'pt-login';
$is_signup = $request->getText( 'type' ) == 'signup';
- $login_url = array(
+ $login_url = [
'text' => $this->msg( $loginlink )->text(),
'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
'active' => $title->isSpecial( 'Userlogin' )
&& ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
- );
- $createaccount_url = array(
+ ];
+ $createaccount_url = [
'text' => $this->msg( 'pt-createaccount' )->text(),
'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
- );
+ ];
// No need to show Talk and Contributions to anons if they can't contribute!
if ( User::groupHasPermission( '*', 'edit' ) ) {
// Show the text "Not logged in"
- $personal_urls['anonuserpage'] = array(
+ $personal_urls['anonuserpage'] = [
'text' => $this->msg( 'notloggedin' )->text()
- );
+ ];
// Because of caching, we can't link directly to the IP talk and
// contributions pages. Instead we use the special page shortcuts
// determine whether these links are active or not, but since major
// skins (MonoBook, Vector) don't use this information, it's not a
// huge loss.
- $personal_urls['anontalk'] = array(
+ $personal_urls['anontalk'] = [
'text' => $this->msg( 'anontalk' )->text(),
'href' => self::makeSpecialUrlSubpage( 'Mytalk', false ),
'active' => false
- );
- $personal_urls['anoncontribs'] = array(
+ ];
+ $personal_urls['anoncontribs'] = [
'text' => $this->msg( 'anoncontribs' )->text(),
'href' => self::makeSpecialUrlSubpage( 'Mycontributions', false ),
'active' => false
- );
+ ];
}
if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
$personal_urls['login'] = $login_url;
}
- Hooks::run( 'PersonalUrls', array( &$personal_urls, &$title, $this ) );
+ Hooks::run( 'PersonalUrls', [ &$personal_urls, &$title, $this ] );
return $personal_urls;
}
* @return array
*/
function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
- $classes = array();
+ $classes = [];
if ( $selected ) {
$classes[] = 'selected';
}
MWNamespace::getSubject( $title->getNamespace() ) );
}
- $result = array();
- if ( !Hooks::run( 'SkinTemplateTabAction', array( &$this,
+ $result = [];
+ if ( !Hooks::run( 'SkinTemplateTabAction', [ &$this,
$title, $message, $selected, $checkEdit,
- &$classes, &$query, &$text, &$result ) ) ) {
+ &$classes, &$query, &$text, &$result ] ) ) {
return $result;
}
- return array(
+ return [
'class' => implode( ' ', $classes ),
'text' => $text,
'href' => $title->getLocalURL( $query ),
- 'primary' => true );
+ 'primary' => true ];
}
function makeTalkUrlDetails( $name, $urlaction = '' ) {
}
$title = $title->getTalkPage();
self::checkTitle( $title, $name );
- return array(
+ return [
'href' => $title->getLocalURL( $urlaction ),
'exists' => $title->isKnown(),
- );
+ ];
}
/**
$title = Title::newFromText( $name );
$title = $title->getSubjectPage();
self::checkTitle( $title, $name );
- return array(
+ return [
'href' => $title->getLocalURL( $urlaction ),
'exists' => $title->exists(),
- );
+ ];
}
/**
$request = $this->getRequest();
$user = $this->getUser();
- $content_navigation = array(
- 'namespaces' => array(),
- 'views' => array(),
- 'actions' => array(),
- 'variants' => array()
- );
+ $content_navigation = [
+ 'namespaces' => [],
+ 'views' => [],
+ 'actions' => [],
+ 'variants' => []
+ ];
// parameters
$action = $request->getVal( 'action', 'view' );
$userCanRead = $title->quickUserCan( 'read', $user );
$preventActiveTabs = false;
- Hooks::run( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
+ Hooks::run( 'SkinTemplatePreventOtherActiveTabs', [ &$this, &$preventActiveTabs ] );
// Checks if page is some kind of content
if ( $title->canExist() ) {
$skname = $this->skinname;
// Adds namespace links
- $subjectMsg = array( "nstab-$subjectId" );
+ $subjectMsg = [ "nstab-$subjectId" ];
if ( $subjectPage->isMainPage() ) {
array_unshift( $subjectMsg, 'mainpage-nstab' );
}
);
$content_navigation['namespaces'][$subjectId]['context'] = 'subject';
$content_navigation['namespaces'][$talkId] = $this->tabAction(
- $talkPage, array( "nstab-$talkId", 'talk' ), $isTalk && !$preventActiveTabs, '', $userCanRead
+ $talkPage, [ "nstab-$talkId", 'talk' ], $isTalk && !$preventActiveTabs, '', $userCanRead
);
$content_navigation['namespaces'][$talkId]['context'] = 'talk';
if ( $title->exists() || $isForeignFile ) {
$content_navigation['views']['view'] = $this->tabAction(
$isTalk ? $talkPage : $subjectPage,
- array( "$skname-view-view", 'view' ),
+ [ "$skname-view-view", 'view' ],
( $onPage && ( $action == 'view' || $action == 'purge' ) ), '', true
);
// signal to hide this from simple content_actions
// If it is a non-local file, show a link to the file in its own repository
if ( $isForeignFile ) {
$file = $this->getWikiPage()->getFile();
- $content_navigation['views']['view-foreign'] = array(
+ $content_navigation['views']['view-foreign'] = [
'class' => '',
'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )->
setContext( $this->getContext() )->
params( $file->getRepo()->getDisplayName() )->text(),
'href' => $file->getDescriptionUrl(),
'primary' => false,
- );
+ ];
}
// Checks if user can edit the current page if it exists or create it otherwise
} else {
$msgKey = $isForeignFile ? 'create-local' : 'create';
}
- $content_navigation['views']['edit'] = array(
+ $content_navigation['views']['edit'] = [
'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
? 'selected'
: ''
->setContext( $this->getContext() )->text(),
'href' => $title->getLocalURL( $this->editUrlOptions() ),
'primary' => !$isForeignFile, // don't collapse this in vector
- );
+ ];
// section link
if ( $showNewSection ) {
// Adds new section link
// $content_navigation['actions']['addsection']
- $content_navigation['views']['addsection'] = array(
+ $content_navigation['views']['addsection'] = [
'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )
->setContext( $this->getContext() )->text(),
'href' => $title->getLocalURL( 'action=edit§ion=new' )
- );
+ ];
}
// Checks if the page has some kind of viewable content
} elseif ( $title->hasSourceText() ) {
// Adds view source view link
- $content_navigation['views']['viewsource'] = array(
+ $content_navigation['views']['viewsource'] = [
'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )
->setContext( $this->getContext() )->text(),
'href' => $title->getLocalURL( $this->editUrlOptions() ),
'primary' => true, // don't collapse this in vector
- );
+ ];
}
// Checks if the page exists
if ( $title->exists() ) {
// Adds history view link
- $content_navigation['views']['history'] = array(
+ $content_navigation['views']['history'] = [
'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-view-history", 'history_short' )
->setContext( $this->getContext() )->text(),
'href' => $title->getLocalURL( 'action=history' ),
- );
+ ];
if ( $title->quickUserCan( 'delete', $user ) ) {
- $content_navigation['actions']['delete'] = array(
+ $content_navigation['actions']['delete'] = [
'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
->setContext( $this->getContext() )->text(),
'href' => $title->getLocalURL( 'action=delete' )
- );
+ ];
}
if ( $title->quickUserCan( 'move', $user ) ) {
$moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
- $content_navigation['actions']['move'] = array(
+ $content_navigation['actions']['move'] = [
'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-move", 'move' )
->setContext( $this->getContext() )->text(),
'href' => $moveTitle->getLocalURL()
- );
+ ];
}
} else {
// article doesn't exist or is deleted
// If the user can't undelete but can view deleted
// history show them a "View .. deleted" tab instead.
$msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
- $content_navigation['actions']['undelete'] = array(
+ $content_navigation['actions']['undelete'] = [
'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
->setContext( $this->getContext() )->numParams( $n )->text(),
'href' => $undelTitle->getLocalURL()
- );
+ ];
}
}
}
if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
- MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== array( '' )
+ MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
) {
$mode = $title->isProtected() ? 'unprotect' : 'protect';
- $content_navigation['actions'][$mode] = array(
+ $content_navigation['actions'][$mode] = [
'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-$mode", $mode )
->setContext( $this->getContext() )->text(),
'href' => $title->getLocalURL( "action=$mode" )
- );
+ ];
}
// Checks if the user is logged in
* the global versions.
*/
$mode = $user->isWatched( $title ) ? 'unwatch' : 'watch';
- $content_navigation['actions'][$mode] = array(
+ $content_navigation['actions'][$mode] = [
'class' => 'mw-watchlink ' . (
$onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : ''
),
// uses 'watch' or 'unwatch' message
'text' => $this->msg( $mode )->text(),
- 'href' => $title->getLocalURL( array( 'action' => $mode ) )
- );
+ 'href' => $title->getLocalURL( [ 'action' => $mode ] )
+ ];
}
}
- Hooks::run( 'SkinTemplateNavigation', array( &$this, &$content_navigation ) );
+ Hooks::run( 'SkinTemplateNavigation', [ &$this, &$content_navigation ] );
if ( $userCanRead && !$wgDisableLangConversion ) {
$pageLang = $title->getPageLanguage();
$params = $request->getQueryValues();
unset( $params['title'] );
} else {
- $params = array();
+ $params = [];
}
// Loops over each variant
foreach ( $variants as $code ) {
// Gets variant name from language code
$varname = $pageLang->getVariantname( $code );
// Appends variant link
- $content_navigation['variants'][] = array(
+ $content_navigation['variants'][] = [
'class' => ( $code == $preferred ) ? 'selected' : false,
'text' => $varname,
- 'href' => $title->getLocalURL( array( 'variant' => $code ) + $params ),
+ 'href' => $title->getLocalURL( [ 'variant' => $code ] + $params ),
'lang' => wfBCP47( $code ),
'hreflang' => wfBCP47( $code ),
- );
+ ];
}
}
}
} else {
// If it's not content, it's got to be a special page
- $content_navigation['namespaces']['special'] = array(
+ $content_navigation['namespaces']['special'] = [
'class' => 'selected',
'text' => $this->msg( 'nstab-special' )->text(),
'href' => $request->getRequestURL(), // @see: bug 2457, bug 2510
'context' => 'subject'
- );
+ ];
Hooks::run( 'SkinTemplateNavigation::SpecialPage',
- array( &$this, &$content_navigation ) );
+ [ &$this, &$content_navigation ] );
}
// Equiv to SkinTemplateContentActions
- Hooks::run( 'SkinTemplateNavigation::Universal', array( &$this, &$content_navigation ) );
+ Hooks::run( 'SkinTemplateNavigation::Universal', [ &$this, &$content_navigation ] );
// Setup xml ids and tooltip info
foreach ( $content_navigation as $section => &$links ) {
# give the edit tab an accesskey, because that's fairly
# superfluous and conflicts with an accesskey (Ctrl-E) often
# used for editing in Safari.
- if ( in_array( $action, array( 'edit', 'submit' ) ) ) {
+ if ( in_array( $action, [ 'edit', 'submit' ] ) ) {
if ( isset( $content_navigation['views']['edit'] ) ) {
$content_navigation['views']['edit']['tooltiponly'] = true;
}
// compatibility and also for skins that just want simple tabs content_actions
// is now built by flattening the content_navigation arrays into one
- $content_actions = array();
+ $content_actions = [];
foreach ( $content_navigation as $links ) {
foreach ( $links as $key => $value ) {
$out = $this->getOutput();
$request = $this->getRequest();
- $nav_urls = array();
- $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
+ $nav_urls = [];
+ $nav_urls['mainpage'] = [ 'href' => self::makeMainPageUrl() ];
if ( $wgUploadNavigationUrl ) {
- $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
+ $nav_urls['upload'] = [ 'href' => $wgUploadNavigationUrl ];
} elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
- $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
+ $nav_urls['upload'] = [ 'href' => self::makeSpecialUrl( 'Upload' ) ];
} else {
$nav_urls['upload'] = false;
}
- $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) );
+ $nav_urls['specialpages'] = [ 'href' => self::makeSpecialUrl( 'Specialpages' ) ];
$nav_urls['print'] = false;
$nav_urls['permalink'] = false;
// A print stylesheet is attached to all pages, but nobody ever
// figures that out. :) Add a link...
if ( !$out->isPrintable() && ( $out->isArticle() || $this->getTitle()->isSpecialPage() ) ) {
- $nav_urls['print'] = array(
+ $nav_urls['print'] = [
'text' => $this->msg( 'printableversion' )->text(),
'href' => $this->getTitle()->getLocalURL(
$request->appendQueryValue( 'printable', 'yes' ) )
- );
+ ];
}
if ( $out->isArticle() ) {
// Also add a "permalink" while we're at it
$revid = $this->getRevisionId();
if ( $revid ) {
- $nav_urls['permalink'] = array(
+ $nav_urls['permalink'] = [
'text' => $this->msg( 'permalink' )->text(),
'href' => $this->getTitle()->getLocalURL( "oldid=$revid" )
- );
+ ];
}
// Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
Hooks::run( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
- array( &$this, &$nav_urls, &$revid, &$revid ) );
+ [ &$this, &$nav_urls, &$revid, &$revid ] );
}
if ( $out->isArticleRelated() ) {
- $nav_urls['whatlinkshere'] = array(
+ $nav_urls['whatlinkshere'] = [
'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalURL()
- );
+ ];
- $nav_urls['info'] = array(
+ $nav_urls['info'] = [
'text' => $this->msg( 'pageinfo-toolboxlink' )->text(),
'href' => $this->getTitle()->getLocalURL( "action=info" )
- );
+ ];
if ( $this->getTitle()->exists() ) {
- $nav_urls['recentchangeslinked'] = array(
+ $nav_urls['recentchangeslinked'] = [
'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalURL()
- );
+ ];
}
}
if ( $user ) {
$rootUser = $user->getName();
- $nav_urls['contributions'] = array(
+ $nav_urls['contributions'] = [
'text' => $this->msg( 'contributions', $rootUser )->text(),
'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser ),
- 'tooltip-params' => array( $rootUser ),
- );
+ 'tooltip-params' => [ $rootUser ],
+ ];
- $nav_urls['log'] = array(
+ $nav_urls['log'] = [
'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser )
- );
+ ];
if ( $this->getUser()->isAllowed( 'block' ) ) {
- $nav_urls['blockip'] = array(
+ $nav_urls['blockip'] = [
'text' => $this->msg( 'blockip', $rootUser )->text(),
'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
- );
+ ];
}
if ( $this->showEmailUser( $user ) ) {
- $nav_urls['emailuser'] = array(
+ $nav_urls['emailuser'] = [
'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser ),
- 'tooltip-params' => array( $rootUser ),
- );
+ 'tooltip-params' => [ $rootUser ],
+ ];
}
if ( !$user->isAnon() ) {
$sur = new UserrightsPage;
$sur->setContext( $this->getContext() );
if ( $sur->userCanExecute( $this->getUser() ) ) {
- $nav_urls['userrights'] = array(
+ $nav_urls['userrights'] = [
'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
- );
+ ];
}
}
}
}
public function makeListItemProvider() {
- return array(
- array(
+ return [
+ [
'<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>',
'',
- array(
+ [
'class' => 'class',
'itemtitle' => 'itemtitle',
'href' => 'url',
'title' => 'title',
'text' => 'text'
- ),
- array(),
+ ],
+ [],
'Test makteListItem with normal values'
- )
- );
+ ]
+ ];
}
}
private function initMessagesHref() {
# List of default messages for the sidebar. The sidebar doesn't care at
# all whether they are full URLs, interwiki links or local titles.
- $URL_messages = array(
+ $URL_messages = [
'mainpage',
'portal-url',
'currentevents-url',
'recentchanges-url',
'randompage-url',
'helppage',
- );
+ ];
# We're assuming that isValidURI works as advertised: it's also
# tested separately, in tests/phpunit/includes/HttpTest.php.
* @todo this assert method to should be converted to a test using a dataprovider..
*/
private function assertSideBar( $expected, $text, $message = '' ) {
- $bar = array();
+ $bar = [];
$this->skin->addToSidebarPlain( $bar, $text );
$this->assertEquals( $expected, $bar, $message );
}
*/
public function testSidebarWithOnlyTwoTitles() {
$this->assertSideBar(
- array(
- 'Title1' => array(),
- 'Title2' => array(),
- ),
+ [
+ 'Title1' => [],
+ 'Title2' => [],
+ ],
'* Title1
* Title2
'
*/
public function testExpandMessages() {
$this->assertSidebar(
- array( 'Title' => array(
- array(
+ [ 'Title' => [
+ [
'text' => 'Help',
'href' => $this->messages['helppage']['href'],
'id' => 'n-help',
'active' => null
- )
- ) ),
+ ]
+ ] ],
'* Title
** helppage|help
'
* @covers SkinTemplate::addToSidebarPlain
*/
public function testExternalUrlsRequireADescription() {
- $this->setMwGlobals( array(
+ $this->setMwGlobals( [
'wgNoFollowLinks' => true,
- 'wgNoFollowDomainExceptions' => array(),
- 'wgNoFollowNsExceptions' => array(),
- ) );
+ 'wgNoFollowDomainExceptions' => [],
+ 'wgNoFollowNsExceptions' => [],
+ ] );
$this->assertSidebar(
- array( 'Title' => array(
+ [ 'Title' => [
# ** http://www.mediawiki.org/| Home
- array(
+ [
'text' => 'Home',
'href' => 'http://www.mediawiki.org/',
'id' => 'n-Home',
'active' => null,
'rel' => 'nofollow',
- ),
+ ],
# ** http://valid.no.desc.org/
# ... skipped since it is missing a pipe with a description
- ) ),
+ ] ],
'* Title
** http://www.mediawiki.org/| Home
** http://valid.no.desc.org/
*/
public function testTrickyPipe() {
$this->assertSidebar(
- array( 'Title' => array(
+ [ 'Title' => [
# The first 2 are skipped
# Doesn't really test the url properly
# because it will vary with $wgArticlePath et al.
# ** Baz|Fred
- array(
+ [
'text' => 'Fred',
'href' => Title::newFromText( 'Baz' )->getLocalURL(),
'id' => 'n-Fred',
'active' => null,
- ),
- array(
+ ],
+ [
'text' => 'title-to-display',
'href' => Title::newFromText( 'page-to-go-to' )->getLocalURL(),
'id' => 'n-title-to-display',
'active' => null,
- ),
- ) ),
+ ],
+ ] ],
'* Title
** {{PAGENAME|Foo}}
** Bar
$text = '* Title
** http://www.mediawiki.org/| Home';
- $bar = array();
+ $bar = [];
$this->skin->addToSideBarPlain( $bar, $text );
return $bar['Title'][0];
* Simple test to verify our helper assertAttribs() is functional
*/
public function testTestAttributesAssertionHelper() {
- $this->setMwGlobals( array(
+ $this->setMwGlobals( [
'wgNoFollowLinks' => true,
- 'wgNoFollowDomainExceptions' => array(),
- 'wgNoFollowNsExceptions' => array(),
+ 'wgNoFollowDomainExceptions' => [],
+ 'wgNoFollowNsExceptions' => [],
'wgExternalLinkTarget' => false,
- ) );
+ ] );
$attribs = $this->getAttribs();
$this->assertArrayHasKey( 'rel', $attribs );
}
public static function dataRespectExternallinktarget() {
- return array(
- array( '_blank' ),
- array( '_self' ),
- );
+ return [
+ [ '_blank' ],
+ [ '_self' ],
+ ];
}
}