Make use of \File::getArchiveRel to avoid code duplication
[lhc/web/wiklou.git] / includes / Linker.php
index 2028197..b605acd 100644 (file)
@@ -227,7 +227,7 @@ class Linker {
         */
        private static function fnamePart( $url ) {
                $basename = strrchr( $url, '/' );
-               if ( false === $basename ) {
+               if ( $basename === false ) {
                        $basename = $url;
                } else {
                        $basename = substr( $basename, 1 );
@@ -334,7 +334,7 @@ class Linker {
 
                $prefix = $postfix = '';
 
-               if ( 'center' == $frameParams['align'] ) {
+               if ( $frameParams['align'] == 'center' ) {
                        $prefix = '<div class="center">';
                        $postfix = '</div>';
                        $frameParams['align'] = 'none';
@@ -916,7 +916,7 @@ class Linker {
                $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
        ) {
                global $wgUser, $wgDisableAnonTalk, $wgLang;
-               $talkable = !( $wgDisableAnonTalk && 0 == $userId );
+               $talkable = !( $wgDisableAnonTalk && $userId == 0 );
                $blockable = !( $flags & self::TOOL_LINKS_NOBLOCK );
                $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
 
@@ -1575,11 +1575,18 @@ class Linker {
         *
         * @since 1.16.3
         * @param string $toc Html of the Table Of Contents
-        * @param string|Language|bool $lang Language for the toc title, defaults to user language
+        * @param string|Language|bool|null $lang Language for the toc title, defaults to user language.
+        *  The types string and bool are deprecated.
         * @return string Full html of the TOC
         */
-       public static function tocList( $toc, $lang = false ) {
-               $lang = wfGetLangObj( $lang );
+       public static function tocList( $toc, $lang = null ) {
+               global $wgLang;
+               $lang = $lang ?? $wgLang;
+               if ( !is_object( $lang ) ) {
+                       wfDeprecated( __METHOD__ . ' with type other than Language for $lang', '1.33' );
+                       $lang = wfGetLangObj( $lang );
+               }
+
                $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
 
                return '<div id="toc" class="toc">'
@@ -1611,10 +1618,11 @@ class Linker {
         *
         * @since 1.16.3. $lang added in 1.17
         * @param array $tree Return value of ParserOutput::getSections()
-        * @param string|Language|bool $lang Language for the toc title, defaults to user language
+        * @param string|Language|bool|null $lang Language for the toc title, defaults to user language.
+        *  The types string and bool are deprecated.
         * @return string HTML fragment
         */
-       public static function generateTOC( $tree, $lang = false ) {
+       public static function generateTOC( $tree, $lang = null ) {
                $toc = '';
                $lastLevel = 0;
                foreach ( $tree as $section ) {