Fix regression in unwatch links sent out by enotif. {{FULLPAGENAMEE}} happens to...
[lhc/web/wiklou.git] / includes / Skin.php
index e13dd08..9e2981d 100644 (file)
@@ -410,7 +410,7 @@ class Skin extends Linker {
                        'wgArticleId' => $wgTitle->getArticleId(),
                        'wgIsArticle' => $wgOut->isArticle(),
                        'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(),
-                       'wgUserGroups' => $wgUser->isAnon() ? null : $wgUser->getEffectiveGroups(),
+                       'wgUserGroups' => $wgUser->getEffectiveGroups(),
                        'wgUserLanguage' => $wgLang->getCode(),
                        'wgContentLanguage' => $wgContLang->getCode(),
                        'wgBreakFrames' => $wgBreakFrames,
@@ -548,6 +548,7 @@ class Skin extends Linker {
 
        /**
         * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
+        * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
         */
        protected function reallyGenerateUserStylesheet() {
                global $wgUser;
@@ -629,18 +630,21 @@ CSS;
                        $out->addStyle( self::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI ) );
                }
 
-               if( $wgUser->isLoggedIn() ) {
-                       // Ensure that logged-in users' generated CSS isn't clobbered
-                       // by anons' publicly cacheable generated CSS.
-                       $siteargs['smaxage'] = '0';
-                       $siteargs['ts'] = $wgUser->mTouched;
-               }
-               // Per-user styles based on preferences
-               $siteargs['gen'] = 'css';
-               if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
-                       $siteargs['useskin'] = $us;
+               global $wgAllowUserCssPrefs;
+               if( $wgAllowUserCssPrefs ){
+                       if( $wgUser->isLoggedIn() ) {
+                               // Ensure that logged-in users' generated CSS isn't clobbered
+                               // by anons' publicly cacheable generated CSS.
+                               $siteargs['smaxage'] = '0';
+                               $siteargs['ts'] = $wgUser->mTouched;
+                       }
+                       // Per-user styles based on preferences
+                       $siteargs['gen'] = 'css';
+                       if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
+                               $siteargs['useskin'] = $us;
+                       }
+                       $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
                }
-               $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
 
                // Per-user custom style pages
                if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
@@ -650,10 +654,13 @@ CSS;
                                // @FIXME: properly escape the cdata!
                                $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
                        } else {
-                               $out->addStyle( self::makeUrl(
-                                       $this->userpage . '/' . $this->getSkinName() . '.css',
-                                       'action=raw&ctype=text/css' )
-                               );
+                               $names = array( 'common', $this->getSkinName() );
+                               foreach( $names as $name ) {
+                                       $out->addStyle( self::makeUrl(
+                                               $this->userpage . '/' . $name . '.css',
+                                               'action=raw&ctype=text/css' )
+                                       );
+                               }
                        }
                }
 
@@ -2106,6 +2113,7 @@ CSS;
        
        /**
         * Add content from plain text
+        * @since 1.17
         * @param &$bar array
         * @param $text string
         */
@@ -2173,4 +2181,61 @@ CSS;
        public function commonPrintStylesheet() {
                return true;
        }
+
+       /**
+        * Gets new talk page messages for the current user.
+        * @return MediaWiki message or if no new talk page messages, nothing
+        */
+       function getNewtalks() {
+               global $wgUser, $wgOut;
+               $newtalks = $wgUser->getNewMessageLinks();
+
+               if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
+                       $userTitle = $this->mUser->getUserPage();
+                       $userTalkTitle = $userTitle->getTalkPage();
+
+                       if( !$userTalkTitle->equals( $this->mTitle ) ) {
+                               $newMessagesLink = $this->link(
+                                       $userTalkTitle,
+                                       wfMsgHtml( 'newmessageslink' ),
+                                       array(),
+                                       array( 'redirect' => 'no' ),
+                                       array( 'known', 'noclasses' )
+                               );
+
+                               $newMessagesDiffLink = $this->link(
+                                       $userTalkTitle,
+                                       wfMsgHtml( 'newmessagesdifflink' ),
+                                       array(),
+                                       array( 'diff' => 'cur' ),
+                                       array( 'known', 'noclasses' )
+                               );
+
+                               $ntl = wfMsg(
+                                       'youhavenewmessages',
+                                       $newMessagesLink,
+                                       $newMessagesDiffLink
+                               );
+                               # Disable Squid cache
+                               $wgOut->setSquidMaxage( 0 );
+                       }
+               } elseif( count( $newtalks ) ) {
+                       // _>" " for BC <= 1.16
+                       $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
+                       $msgs = array();
+                       foreach( $newtalks as $newtalk ) {
+                               $msgs[] = Xml::element(
+                                       'a',
+                                       array( 'href' => $newtalk['link'] ), $newtalk['wiki']
+                               );
+                       }
+                       $parts = implode( $sep, $msgs );
+                       $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
+                       $wgOut->setSquidMaxage( 0 );
+               } else {
+                       $ntl = '';
+               }
+               return $ntl;
+       }
+
 }