Merge "Localisation updates from https://translatewiki.net."
[lhc/web/wiklou.git] / includes / skins / Skin.php
index 83f119d..3cc1d8f 100644 (file)
@@ -55,7 +55,7 @@ abstract class Skin extends ContextSource {
         * @return string[]
         */
        static function getSkinNameMessages() {
-               $messages = array();
+               $messages = [];
                foreach ( self::getSkinNames() as $skinKey => $skinName ) {
                        $messages[] = "skinname-$skinKey";
                }
@@ -122,10 +122,10 @@ abstract class Skin extends ContextSource {
 
                // 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];
@@ -184,20 +184,20 @@ abstract class Skin extends ContextSource {
 
                $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 ) {
@@ -226,7 +226,7 @@ abstract class Skin extends ContextSource {
         * Preload the existence of three commonly-requested pages in a single query
         */
        function preloadExistence() {
-               $titles = array();
+               $titles = [];
 
                $user = $this->getUser();
                $title = $this->getRelevantTitle();
@@ -246,7 +246,7 @@ abstract class Skin extends ContextSource {
                        $titles[] = $title->getTalkPage();
                }
 
-               Hooks::run( 'SkinPreloadExistence', array( &$titles, $this ) );
+               Hooks::run( 'SkinPreloadExistence', [ &$titles, $this ] );
 
                if ( count( $titles ) ) {
                        $lb = new LinkBatch( $titles );
@@ -370,13 +370,13 @@ abstract class Skin extends ContextSource {
        public static function getDynamicStylesheetQuery() {
                global $wgSquidMaxage;
 
-               return array(
+               return [
                                'action' => 'raw',
                                'maxage' => $wgSquidMaxage,
                                'usemsgcache' => 'yes',
                                'ctype' => 'text/css',
                                'smaxage' => $wgSquidMaxage,
-                       );
+                       ];
        }
 
        /**
@@ -423,11 +423,11 @@ abstract class Skin extends ContextSource {
         */
        public function getHtmlElementAttributes() {
                $lang = $this->getLanguage();
-               return array(
+               return [
                        'lang' => $lang->getHtmlCode(),
                        'dir' => $lang->getDir(),
                        'class' => 'client-nojs',
-               );
+               ];
        }
 
        /**
@@ -451,7 +451,7 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @return string
+        * @return string HTML
         */
        function getCategoryLinks() {
                global $wgUseCategoryBrowser;
@@ -542,25 +542,27 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @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' data-mw='interface'>{$catlinks}</div>";
+               return Html::rawElement(
+                       'div',
+                       [ 'id' => 'catlinks', 'class' => $classes, 'data-mw' => 'interface' ],
+                       $catlinks
+               );
        }
 
        /**
@@ -580,7 +582,7 @@ abstract class Skin extends ContextSource {
        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 ) != '' ) {
@@ -617,7 +619,7 @@ abstract class Skin extends ContextSource {
                // 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;
        }
@@ -678,7 +680,7 @@ abstract class Skin extends ContextSource {
                $out = $this->getOutput();
                $subpages = '';
 
-               if ( !Hooks::run( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
+               if ( !Hooks::run( 'SkinSubPageSubtitle', [ &$subpages, $this, $out ] ) ) {
                        return $subpages;
                }
 
@@ -789,7 +791,7 @@ abstract class Skin extends ContextSource {
 
                Hooks::run(
                        'SkinCopyrightFooter',
-                       array( $this->getTitle(), $type, &$msg, &$link, &$forContent )
+                       [ $this->getTitle(), $type, &$msg, &$link, &$forContent ]
                );
 
                return $this->msg( $msg )->rawParams( $link )->text();
@@ -843,7 +845,7 @@ abstract class Skin extends ContextSource {
                $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;
        }
 
@@ -917,7 +919,7 @@ abstract class Skin extends ContextSource {
                                $html = htmlspecialchars( $icon["alt"] );
                        }
                        if ( $url ) {
-                               $html = Html::rawElement( 'a', array( "href" => $url ), $html );
+                               $html = Html::rawElement( 'a', [ "href" => $url ], $html );
                        }
                }
                return $html;
@@ -996,7 +998,7 @@ abstract class Skin extends ContextSource {
         * @private
         */
        function editUrlOptions() {
-               $options = array( 'action' => 'edit' );
+               $options = [ 'action' => 'edit' ];
 
                if ( !$this->isRevisionCurrent() ) {
                        $options['oldid'] = intval( $this->getRevisionId() );
@@ -1164,10 +1166,10 @@ abstract class Skin extends ContextSource {
                $title = Title::newFromText( $name );
                self::checkTitle( $title, $name );
 
-               return array(
+               return [
                        'href' => $title->getLocalURL( $urlaction ),
                        'exists' => $title->isKnown(),
-               );
+               ];
        }
 
        /**
@@ -1180,10 +1182,10 @@ abstract class Skin extends ContextSource {
                $title = Title::newFromText( $name );
                self::checkTitle( $title, $name );
 
-               return array(
+               return [
                        'href' => $title->getLocalURL( $urlaction ),
                        'exists' => true
-               );
+               ];
        }
 
        /**
@@ -1227,9 +1229,9 @@ abstract class Skin extends ContextSource {
 
                $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;
                };
@@ -1240,14 +1242,14 @@ abstract class Skin extends ContextSource {
                                $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;
        }
@@ -1286,7 +1288,7 @@ abstract class Skin extends ContextSource {
                        if ( strpos( $line, '**' ) !== 0 ) {
                                $heading = trim( $line, '* ' );
                                if ( !array_key_exists( $heading, $bar ) ) {
-                                       $bar[$heading] = array();
+                                       $bar[$heading] = [];
                                }
                        } else {
                                $line = trim( $line, '* ' );
@@ -1300,7 +1302,7 @@ abstract class Skin extends ContextSource {
                                                continue;
                                        }
 
-                                       $extraAttribs = array();
+                                       $extraAttribs = [];
 
                                        $msgLink = $this->msg( $line[0] )->inContentLanguage();
                                        if ( $msgLink->exists() ) {
@@ -1342,12 +1344,12 @@ abstract class Skin extends ContextSource {
                                                }
                                        }
 
-                                       $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;
                                }
@@ -1386,7 +1388,7 @@ abstract class Skin extends ContextSource {
                $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 ) {
@@ -1417,17 +1419,17 @@ abstract class Skin extends ContextSource {
                        $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 ) {
@@ -1449,12 +1451,12 @@ abstract class Skin extends ContextSource {
                        $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 );
@@ -1509,12 +1511,12 @@ abstract class Skin extends ContextSource {
 
                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;
        }
 
@@ -1526,7 +1528,7 @@ abstract class Skin extends ContextSource {
        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 {
@@ -1542,7 +1544,7 @@ abstract class Skin extends ContextSource {
                        }
                }
 
-               Hooks::run( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
+               Hooks::run( 'SiteNoticeAfter', [ &$siteNotice, $this ] );
                return $siteNotice;
        }
 
@@ -1565,7 +1567,7 @@ abstract class Skin extends ContextSource {
 
                $lang = wfGetLangObj( $lang );
 
-               $attribs = array();
+               $attribs = [];
                if ( !is_null( $tooltip ) ) {
                        # Bug 25462: undo double-escaping.
                        $tooltip = Sanitizer::decodeCharReferences( $tooltip );
@@ -1573,21 +1575,21 @@ abstract class Skin extends ContextSource {
                                ->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'],
@@ -1609,7 +1611,7 @@ abstract class Skin extends ContextSource {
                // 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;
@@ -1625,7 +1627,7 @@ abstract class Skin extends ContextSource {
         * @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 );