Comments and whitespace fixes only.
[lhc/web/wiklou.git] / includes / Skin.php
index 8d32a04..74d9fa0 100644 (file)
@@ -178,17 +178,15 @@ class Skin extends Linker {
 
                wfProfileIn( __METHOD__ );
 
-               # Add favicons and Apple touch icons, if they're not the defaults
-               #
                # Generally the order of the favicon and apple-touch-icon links
                # should not matter, but Konqueror (3.5.9 at least) incorrectly
                # uses whichever one appears later in the HTML source.  Make sure
                # apple-touch-icon is specified first to avoid this.
-               if( false !== $wgAppleTouchIcon && wfExpandUrl('/apple-touch-icon.png') != wfExpandUrl($wgAppleTouchIcon) ) {
+               if( false !== $wgAppleTouchIcon ) {
                        $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
                }
 
-               if( false !== $wgFavicon && wfExpandUrl('/favicon.ico') != wfExpandUrl($wgFavicon) ) {
+               if( false !== $wgFavicon ) {
                        $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
                }
 
@@ -333,13 +331,17 @@ class Skin extends Linker {
        }
 
        static function makeVariablesScript( $data ) {
-               $r = array();
-               foreach ( $data as $name => $value ) {
-                       $encValue = Xml::encodeJsVar( $value );
-                       $r[] = "var $name = $encValue;";
+               if( $data ) {
+                       $r = array();
+                       foreach ( $data as $name => $value ) {
+                               $encValue = Xml::encodeJsVar( $value );
+                               $r[] = "$name=$encValue";
+                       }
+                       $js = 'var ' . implode( ",\n", $r ) . ';';
+                       return Html::inlineScript( "\n$js\n" );
+               } else {
+                       return '';
                }
-               return Html::inlineScript( "\n\t\t" . implode( "\n\t\t", $r ) .
-                       "\n\t\t" );
        }
 
        /**
@@ -354,7 +356,7 @@ class Skin extends Linker {
                        $skinName = $skinName['skinname'];
                }
                global $wgScript, $wgTitle, $wgStylePath, $wgUser;
-               global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
+               global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
                global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
                global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
                global $wgUseAjax, $wgAjaxWatch;
@@ -397,7 +399,6 @@ class Skin extends Linker {
                        'wgIsArticle' => $wgOut->isArticle(),
                        'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(),
                        'wgUserGroups' => $wgUser->isAnon() ? NULL : $wgUser->getEffectiveGroups(),
-                       'wgUserVariant' => $wgVariant->getCode(),
                        'wgUserLanguage' => $wgLang->getCode(),
                        'wgContentLanguage' => $wgContLang->getCode(),
                        'wgBreakFrames' => $wgBreakFrames,
@@ -408,15 +409,17 @@ class Skin extends Linker {
                        'wgSeparatorTransformTable' => $compactSeparatorTransTable,
                        'wgDigitTransformTable' => $compactDigitTransTable,
                        'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null,
+                       'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
+                       'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
                );
-               if ( !( $wgContLang->hasVariants() ) ) {
-                       unset( $vars['wgUserVariant'] );
+               if ( $wgContLang->hasVariants() ) {
+                       $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
                }
 
                //if on upload page output the extension list & js_upload
-               if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) ==  "Upload" ){
+               if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) ==  "Upload" ) {
                        global $wgFileExtensions, $wgAjaxUploadInterface;
-                       $vars['wgFileExtensions']        = $wgFileExtensions;
+                       $vars['wgFileExtensions'] = $wgFileExtensions;
                        $vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface;
                }
 
@@ -467,8 +470,6 @@ class Skin extends Linker {
 
                $vars = self::makeGlobalVariablesScript( $this->getSkinName() );
 
-               //moved wikibits to be called earlier on
-               //$out->addScriptFile( "{$wgStylePath}/common/wikibits.js" );
                if( $wgUseSiteJs ) {
                        $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
                        $wgOut->addScriptFile(  self::makeUrl( '-',
@@ -479,12 +480,12 @@ class Skin extends Linker {
                }
                if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
                        $userpage = $wgUser->getUserPage();
-                       $userjs =  self::makeUrl(
-                               $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
-                               'action=raw&ctype='.$wgJsMimeType );
+                       $userjs = self::makeUrl(
+                               $userpage->getPrefixedText() . '/' . $this->getSkinName() . '.js',
+                               'action=raw&ctype=' . $wgJsMimeType );
                        $wgOut->addScriptFile( $userjs );
                }
-               return "\t" . $vars . "\t" . $out->mScripts;
+               return $vars . "\n" . $out->mScripts;
        }
 
        /**
@@ -524,15 +525,15 @@ class Skin extends Linker {
         * top.  For now Monobook.js will be maintained, but it should be consi-
         * dered deprecated.
         *
-        * @param force_skin  lets you override the skin name
+        * @param $force_skin string If set, overrides the skin name
         *
         * @return string
         */
-       public function generateUserJs( $skinName = null) {
+       public function generateUserJs( $skinName = null ) {
                global $wgStylePath;
 
                wfProfileIn( __METHOD__ );
-               if(!$skinName){
+               if( !$skinName ) {
                        $skinName =     $this->getSkinName();
                }
 
@@ -548,7 +549,7 @@ class Skin extends Linker {
                $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
                // avoid inclusion of non defined user JavaScript (with custom skins only)
                // by checking for default message content
-               $msgKey = ucfirst( $skinName ).'.js';
+               $msgKey = ucfirst( $skinName ) . '.js';
                $userJS = wfMsgForContent( $msgKey );
                if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
                        $s .= $userJS;
@@ -898,14 +899,11 @@ END;
 
                $classes = 'catlinks';
 
-               if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
-                       strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
+               if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false ) {
                        $classes .= ' catlinks-allhidden';
                }
 
-               if( !empty( $catlinks ) ){
-                       return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
-               }
+               return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
        }
 
        function getQuickbarCompensator( $rows = 1 ) {
@@ -976,7 +974,7 @@ END;
         * @return String HTML-wrapped JS code to be put before </body>
         */
        function bottomScripts() {
-               $bottomScriptText = "\n\t\t" . Html::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
+               $bottomScriptText = "\n" . Html::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
                wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
                return $bottomScriptText;
        }
@@ -1100,7 +1098,7 @@ END;
 
                $s = array();
 
-               if ( !$wgRequest->getBool( 'printable' ) ) {
+               if ( !$wgOut->isPrintable() ) {
                        $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
                        $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
                }
@@ -1509,7 +1507,7 @@ END;
 
        function lastModified() {
                global $wgLang, $wgArticle;
-               if( $this->mRevisionId ) {
+               if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest()) {
                        $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
                } else {
                        $timestamp = $wgArticle->getTimestamp();