* $wgDebugTidy feature
[lhc/web/wiklou.git] / includes / Skin.php
index 3feb583..e4769d5 100644 (file)
@@ -156,21 +156,24 @@ class Skin extends Linker {
        }
 
        function initPage( &$out ) {
-               global $wgFavicon, $wgScriptPath, $wgSitename, $wgLanguageCode, $wgLanguageNames;
+               global $wgFavicon, $wgScriptPath, $wgSitename, $wgContLang;
 
-               $fname = 'Skin::initPage';
-               wfProfileIn( $fname );
+               wfProfileIn( __METHOD__ );
 
                if( false !== $wgFavicon ) {
                        $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
                }
 
+               $code = $wgContLang->getCode();
+               $name = $wgContLang->getLanguageName( $code );
+               $langName = $name ? $name : $code;
+
                # OpenSearch description link
                $out->addLink( array( 
                        'rel' => 'search', 
                        'type' => 'application/opensearchdescription+xml',
                        'href' => "$wgScriptPath/opensearch_desc.php",
-                       'title' => "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})",
+                       'title' => "$wgSitename ($langName)",
                ));
 
                $this->addMetadataLinks($out);
@@ -179,7 +182,7 @@ class Skin extends Linker {
                
                $this->preloadExistence();
 
-               wfProfileOut( $fname );
+               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -336,7 +339,6 @@ class Skin extends Linker {
                }
 
                if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
-                       $msgNames = array( 'watch', 'unwatch', 'watching', 'unwatching' );
                        $msgs = (object)array();
                        foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
                                $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
@@ -355,11 +357,12 @@ class Skin extends Linker {
                $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
                global $wgUseSiteJs;
                if ($wgUseSiteJs) {
-                       if ($wgUser->isLoggedIn()) {
-                               $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
-                       } else {
-                               $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
-                       }
+                       $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
+                       $r .= "<script type=\"$wgJsMimeType\" src=\"".
+                               htmlspecialchars(self::makeUrl('-',
+                                       "action=raw$jsCache&gen=js&useskin=" .
+                                       urlencode( $this->getSkinName() ) ) ) .
+                               "\"><!-- site js --></script>\n";
                }
                if( $allowUserJs && $wgUser->isLoggedIn() ) {
                        $userpage = $wgUser->getUserPage();
@@ -413,17 +416,23 @@ class Skin extends Linker {
        }
 
        /**
-        * This returns MediaWiki:Common.js.  For some bizarre reason, it does
-        * *not* return any custom user JS from user subpages.  Huh?
+        * This returns MediaWiki:Common.js, and derived classes may add other JS.
+        * Despite its name, it does *not* return any custom user JS from user
+        * subpages.  The returned script is sitewide and publicly cacheable and
+        * therefore must not include anything that varies according to user,
+        * interface language, etc. (although it may vary by skin).  See
+        * makeGlobalVariablesScript for things that can vary per page view and are
+        * not cacheable.
         *
-        * @return string
+        * @return string Raw JavaScript to be returned
         */
-       function getUserJs() {
+       public function getUserJs() {
                wfProfileIn( __METHOD__ );
 
                global $wgStylePath;
                $s = "/* generated javascript */\n";
-               $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
+               $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n";
+               $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
                $s .= "\n\n/* MediaWiki:Common.js */\n";
                $commonJs = wfMsgForContent('common.js');
                if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
@@ -470,7 +479,7 @@ class Skin extends Linker {
        function reallyDoGetUserStyles() {
                global $wgUser;
                $s = '';
-               if (($undopt = $wgUser->getOption("underline")) != 2) {
+               if (($undopt = $wgUser->getOption("underline")) < 2) {
                        $underline = $undopt ? 'underline' : 'none';
                        $s .= "a { text-decoration: $underline; }\n";
                }
@@ -481,17 +490,14 @@ class Skin extends Linker {
 a.new, #quickbar a.new,
 a.stub, #quickbar a.stub {
        color: inherit;
-       text-decoration: inherit;
 }
 a.new:after, #quickbar a.new:after {
        content: "?";
        color: #CC2200;
-       text-decoration: $underline;
 }
 a.stub:after, #quickbar a.stub:after {
        content: "!";
        color: #772233;
-       text-decoration: $underline;
 }
 END;
                }
@@ -702,7 +708,9 @@ END;
         */
        function bottomScripts() {
                global $wgJsMimeType;
-               return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
+               $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
+               wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
+               return $bottomScriptText;
        }
 
        /** @return string Retrievied from HTML text */
@@ -774,7 +782,7 @@ END;
        }
 
        function getUndeleteLink() {
-               global $wgUser, $wgTitle, $wgContLang, $action;
+               global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
                if(     $wgUser->isAllowed( 'deletedhistory' ) &&
                        (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
                        ($n = $wgTitle->isDeleted() ) )
@@ -787,7 +795,7 @@ END;
                        return wfMsg( $msg,
                                $this->makeKnownLinkObj(
                                        SpecialPage::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
-                                       wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
+                                       wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
                }
                return '';
        }
@@ -1068,7 +1076,10 @@ END;
                                "' AND  wl_namespace=" . $wgTitle->getNamespace() ;
                        $res = $dbr->query( $sql, 'Skin::pageStats');
                        $x = $dbr->fetchObject( $res );
-                       $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n );
+
+                       $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
+                               array( 'parseinline' ), $wgLang->formatNum($x->n)
+                       );
                }
 
                return $s . ' ' .  $this->getCopyright();
@@ -1214,7 +1225,8 @@ END;
                        // Otherwise, we display the link for the user, described in their
                        // language (which may or may not be the same as the default language),
                        // but we make the link target be the one site-wide page.
-                       return $this->makeKnownLink( wfMsgForContent( $page ), wfMsg( $desc ) );
+                       return $this->makeKnownLink( wfMsgForContent( $page ),
+                               wfMsgExt( $desc, array( 'parsemag', 'escape' ) ) );
                }
        }
 
@@ -1646,5 +1658,5 @@ END;
                wfProfileOut( $fname );
                return $bar;
        }
-}
-
+       
+}
\ No newline at end of file