Rename $usableSkins to $allowedSkins
[lhc/web/wiklou.git] / includes / Skin.php
index 117e6e2..15b8545 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 /**
- * The main skin class that provide methods and properties for all other skins.
+ * The main skin class which provides methods and properties for all other skins.
  * This base class is also the "Standard" skin.
  *
  * See docs/skin.txt for more information.
@@ -81,14 +81,14 @@ abstract class Skin extends ContextSource {
         */
        static function getSkinNameMessages() {
                $messages = array();
-               foreach( self::getSkinNames() as $skinKey => $skinName ) {
+               foreach ( self::getSkinNames() as $skinKey => $skinName ) {
                        $messages[] = "skinname-$skinKey";
                }
                return $messages;
        }
 
        /**
-        * Fetch the list of usable skins in regards to $wgSkipSkins.
+        * Fetch the list of user-selectable skins in regards to $wgSkipSkins.
         * Useful for Special:Preferences and other places where you
         * only want to show skins users _can_ use.
         * @return array of strings
@@ -96,13 +96,13 @@ abstract class Skin extends ContextSource {
        public static function getUsableSkins() {
                global $wgSkipSkins;
 
-               $usableSkins = self::getSkinNames();
+               $allowedSkins = self::getSkinNames();
 
                foreach ( $wgSkipSkins as $skip ) {
-                       unset( $usableSkins[$skip] );
+                       unset( $allowedSkins[$skip] );
                }
 
-               return $usableSkins;
+               return $allowedSkins;
        }
 
        /**
@@ -162,23 +162,19 @@ abstract class Skin extends ContextSource {
                $className = "Skin{$skinName}";
 
                # Grab the skin class and initialise it.
-               if ( !MWInit::classExists( $className ) ) {
+               if ( !class_exists( $className ) ) {
 
-                       if ( !defined( 'MW_COMPILED' ) ) {
-                               require_once( "{$wgStyleDirectory}/{$skinName}.php" );
-                       }
+                       require_once "{$wgStyleDirectory}/{$skinName}.php";
 
                        # Check if we got if not fallback to default skin
-                       if ( !MWInit::classExists( $className ) ) {
+                       if ( !class_exists( $className ) ) {
                                # DO NOT die if the class isn't found. This breaks maintenance
                                # scripts and can cause a user account to be unrecoverable
                                # except by SQL manipulation if a previously valid skin name
                                # is no longer valid.
                                wfDebug( "Skin class does not exist: $className\n" );
                                $className = 'SkinVector';
-                               if ( !defined( 'MW_COMPILED' ) ) {
-                                       require_once( "{$wgStyleDirectory}/Vector.php" );
-                               }
+                               require_once "{$wgStyleDirectory}/Vector.php";
                        }
                }
                $skin = new $className( $key );
@@ -291,7 +287,7 @@ abstract class Skin extends ContextSource {
                        return $this->mRelevantUser;
                }
                $title = $this->getRelevantTitle();
-               if( $title->hasSubjectNamespace( NS_USER ) ) {
+               if ( $title->hasSubjectNamespace( NS_USER ) ) {
                        $rootUser = $title->getRootText();
                        if ( User::isIP( $rootUser ) ) {
                                $this->mRelevantUser = User::newFromName( $rootUser, false );
@@ -668,7 +664,7 @@ abstract class Skin extends ContextSource {
 
                                                if ( $c > 1 ) {
                                                        $subpages .= $wgLang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
-                                               } else  {
+                                               } else {
                                                        $subpages .= '< ';
                                                }
 
@@ -1015,7 +1011,7 @@ abstract class Skin extends ContextSource {
         */
        static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
                $title = SpecialPage::getSafeTitleFor( $name );
-               if( is_null( $proto ) ) {
+               if ( is_null( $proto ) ) {
                        return $title->getLocalURL( $urlaction );
                } else {
                        return $title->getFullURL( $urlaction, false, $proto );
@@ -1294,17 +1290,27 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * Gets new talk page messages for the current user.
-        * @return MediaWiki message or if no new talk page messages, nothing
+        * Gets new talk page messages for the current user and returns an
+        * appropriate alert message (or an empty string if there are no messages)
+        * @return String
         */
        function getNewtalks() {
+
+               $newMessagesAlert = '';
+               $user = $this->getUser();
+               $newtalks = $user->getNewMessageLinks();
                $out = $this->getOutput();
 
-               $newtalks = $this->getUser()->getNewMessageLinks();
-               $ntl = '';
+               // Allow extensions to disable or modify the new messages alert
+               if ( !wfRunHooks( 'GetNewMessagesAlert', array( &$newMessagesAlert, $newtalks, $user, $out ) ) ) {
+                       return '';
+               }
+               if ( $newMessagesAlert ) {
+                       return $newMessagesAlert;
+               }
 
                if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
-                       $uTalkTitle = $this->getUser()->getTalkPage();
+                       $uTalkTitle = $user->getTalkPage();
 
                        if ( !$uTalkTitle->equals( $out->getTitle() ) ) {
                                $lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
@@ -1343,26 +1349,25 @@ abstract class Skin extends ContextSource {
                                );
 
                                if ( $nofAuthors >= 1 && $nofAuthors <= 10 ) {
-                                       $ntl = $this->msg(
+                                       $newMessagesAlert = $this->msg(
                                                'youhavenewmessagesfromusers',
                                                $newMessagesLink,
                                                $newMessagesDiffLink
                                        )->numParams( $nofAuthors );
                                } else {
                                        // $nofAuthors === 11 signifies "11 or more" ("more than 10")
-                                       $ntl = $this->msg(
+                                       $newMessagesAlert = $this->msg(
                                                $nofAuthors > 10 ? 'youhavenewmessagesmanyusers' : 'youhavenewmessages',
                                                $newMessagesLink,
                                                $newMessagesDiffLink
                                        );
                                }
-                               $ntl = $ntl->text();
+                               $newMessagesAlert = $newMessagesAlert->text();
                                # Disable Squid cache
                                $out->setSquidMaxage( 0 );
                        }
                } elseif ( count( $newtalks ) ) {
-                       // _>" " for BC <= 1.16
-                       $sep = str_replace( '_', ' ', $this->msg( 'newtalkseparator' )->escaped() );
+                       $sep = $this->msg( 'newtalkseparator' )->escaped();
                        $msgs = array();
 
                        foreach ( $newtalks as $newtalk ) {
@@ -1372,11 +1377,11 @@ abstract class Skin extends ContextSource {
                                );
                        }
                        $parts = implode( $sep, $msgs );
-                       $ntl = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
+                       $newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
                        $out->setSquidMaxage( 0 );
                }
 
-               return $ntl;
+               return $newMessagesAlert;
        }
 
        /**
@@ -1392,17 +1397,17 @@ abstract class Skin extends ContextSource {
 
                $needParse = false;
 
-               if( $name === 'default' ) {
+               if ( $name === 'default' ) {
                        // special case
                        global $wgSiteNotice;
                        $notice = $wgSiteNotice;
-                       if( empty( $notice ) ) {
+                       if ( empty( $notice ) ) {
                                wfProfileOut( __METHOD__ );
                                return false;
                        }
                } else {
                        $msg = $this->msg( $name )->inContentLanguage();
-                       if( $msg->isDisabled() ) {
+                       if ( $msg->isDisabled() ) {
                                wfProfileOut( __METHOD__ );
                                return false;
                        }
@@ -1412,8 +1417,8 @@ abstract class Skin extends ContextSource {
                // Use the extra hash appender to let eg SSL variants separately cache.
                $key = wfMemcKey( $name . $wgRenderHashAppend );
                $cachedNotice = $parserMemc->get( $key );
-               if( is_array( $cachedNotice ) ) {
-                       if( md5( $notice ) == $cachedNotice['hash'] ) {
+               if ( is_array( $cachedNotice ) ) {
+                       if ( md5( $notice ) == $cachedNotice['hash'] ) {
                                $notice = $cachedNotice['html'];
                        } else {
                                $needParse = true;
@@ -1533,14 +1538,14 @@ abstract class Skin extends ContextSource {
                        # DoEditSectionLink: it can't change the brackets or the span.)
                        $result = wfMessage( 'editsection-brackets' )->rawParams( $result )
                                ->inLanguage( $lang )->escaped();
-                       return "<span class=\"editsection\">$result</span>";
+                       return "<span class=\"mw-editsection\">$result</span>";
                }
 
                # Add the brackets and the span, and *then* run the nice new hook, with
                # clean and non-redundant arguments.
                $result = wfMessage( 'editsection-brackets' )->rawParams( $link )
                        ->inLanguage( $lang )->escaped();
-               $result = "<span class=\"editsection\">$result</span>";
+               $result = "<span class=\"mw-editsection\">$result</span>";
 
                wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
                return $result;