(bug 41729) Move section edit links to after the headings
[lhc/web/wiklou.git] / includes / Skin.php
index 3e6b72f..cc957c4 100644 (file)
@@ -56,17 +56,19 @@ abstract class Skin extends ContextSource {
 
                        $skinDir = dir( $wgStyleDirectory );
 
-                       # while code from www.php.net
-                       while ( false !== ( $file = $skinDir->read() ) ) {
-                               // Skip non-PHP files, hidden files, and '.dep' includes
-                               $matches = array();
-
-                               if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
-                                       $aSkin = $matches[1];
-                                       $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
+                       if ( $skinDir !== false && $skinDir !== null ) {
+                               # while code from www.php.net
+                               while ( false !== ( $file = $skinDir->read() ) ) {
+                                       // Skip non-PHP files, hidden files, and '.dep' includes
+                                       $matches = array();
+
+                                       if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
+                                               $aSkin = $matches[1];
+                                               $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
+                                       }
                                }
+                               $skinDir->close();
                        }
-                       $skinDir->close();
                        $skinsInitialised = true;
                        wfProfileOut( __METHOD__ . '-init' );
                }
@@ -79,7 +81,7 @@ 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;
@@ -107,7 +109,7 @@ abstract class Skin extends ContextSource {
         * Normalize a skin preference value to a form that can be loaded.
         * If a skin can't be found, it will fall back to the configured
         * default (or the old 'Classic' skin if that's broken).
-        * @param $key String: 'monobook', 'standard', etc.
+        * @param string $key 'monobook', 'standard', etc.
         * @return string
         */
        static function normalizeKey( $key ) {
@@ -129,7 +131,6 @@ abstract class Skin extends ContextSource {
                // in the user preferences.
                $fallback = array(
                        0 => $wgDefaultSkin,
-                       1 => 'nostalgia',
                        2 => 'cologneblue'
                );
 
@@ -148,7 +149,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Factory method for loading a skin of a given type
-        * @param $key String: 'monobook', 'standard', etc.
+        * @param string $key 'monobook', 'standard', etc.
         * @return Skin
         */
        static function &newFromKey( $key ) {
@@ -167,7 +168,7 @@ abstract class Skin extends ContextSource {
                                require_once( "{$wgStyleDirectory}/{$skinName}.php" );
                        }
 
-                       # Check if we got if not failback to default skin
+                       # Check if we got if not fallback to default skin
                        if ( !MWInit::classExists( $className ) ) {
                                # DO NOT die if the class isn't found. This breaks maintenance
                                # scripts and can cause a user account to be unrecoverable
@@ -290,7 +291,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 );
@@ -481,8 +482,8 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * Render the array as a serie of links.
-        * @param $tree Array: categories tree returned by Title::getParentCategoryTree
+        * Render the array as a series of links.
+        * @param array $tree categories tree returned by Title::getParentCategoryTree
         * @return String separated by >, terminate with "\n"
         */
        function drawCategoryBrowser( $tree ) {
@@ -667,7 +668,7 @@ abstract class Skin extends ContextSource {
 
                                                if ( $c > 1 ) {
                                                        $subpages .= $wgLang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
-                                               } else  {
+                                               } else {
                                                        $subpages .= '< ';
                                                }
 
@@ -850,9 +851,9 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * Renders a $wgFooterIcons icon acording to the method's arguments
-        * @param $icon Array: The icon to build the html for, see $wgFooterIcons for the format of this array
-        * @param $withImage Bool|String: Whether to use the icon's image or output a text-only footericon
+        * Renders a $wgFooterIcons icon according to the method's arguments
+        * @param array $icon The icon to build the html for, see $wgFooterIcons for the format of this array
+        * @param bool|String $withImage Whether to use the icon's image or output a text-only footericon
         * @return String HTML
         */
        function makeFooterIcon( $icon, $withImage = 'withImage' ) {
@@ -968,7 +969,7 @@ abstract class Skin extends ContextSource {
         * Return a fully resolved style path url to images or styles stored in the common folder.
         * This method returns a url resolved using the configured skin style path
         * and includes the style version inside of the url.
-        * @param $name String: The name or path of a skin resource file
+        * @param string $name The name or path of a skin resource file
         * @return String The fully resolved style path url including styleversion
         */
        function getCommonStylePath( $name ) {
@@ -977,10 +978,10 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * Return a fully resolved style path url to images or styles stored in the curent skins's folder.
+        * Return a fully resolved style path url to images or styles stored in the current skins's folder.
         * This method returns a url resolved using the configured skin style path
         * and includes the style version inside of the url.
-        * @param $name String: The name or path of a skin resource file
+        * @param string $name The name or path of a skin resource file
         * @return String The fully resolved style path url including styleversion
         */
        function getSkinStylePath( $name ) {
@@ -1007,14 +1008,14 @@ abstract class Skin extends ContextSource {
         * If $proto is set to null, make a local URL. Otherwise, make a full
         * URL with the protocol specified.
         *
-        * @param $name string Name of the Special page
-        * @param $urlaction string Query to append
+        * @param string $name Name of the Special page
+        * @param string $urlaction Query to append
         * @param $proto Protocol to use or null for a local URL
         * @return String
         */
        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 );
@@ -1101,7 +1102,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Make URL details where the article exists (or at least it's convenient to think so)
-        * @param $name String Article name
+        * @param string $name Article name
         * @param $urlaction String
         * @return Array
         */
@@ -1252,7 +1253,7 @@ abstract class Skin extends ContextSource {
                                                }
 
                                                global $wgExternalLinkTarget;
-                                               if ( $wgExternalLinkTarget) {
+                                               if ( $wgExternalLinkTarget ) {
                                                        $extraAttribs['target'] = $wgExternalLinkTarget;
                                                }
                                        } else {
@@ -1381,7 +1382,7 @@ abstract class Skin extends ContextSource {
        /**
         * Get a cached notice
         *
-        * @param $name String: message name, or 'default' for $wgSiteNotice
+        * @param string $name message name, or 'default' for $wgSiteNotice
         * @return String: HTML fragment
         */
        private function getCachedNotice( $name ) {
@@ -1391,17 +1392,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;
                        }
@@ -1411,8 +1412,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;
@@ -1489,9 +1490,9 @@ abstract class Skin extends ContextSource {
         *
         * @param $nt      Title  The title being linked to (may not be the same as
         *   $wgTitle, if the section is included from a template)
-        * @param $section string The designation of the section being pointed to,
+        * @param string $section The designation of the section being pointed to,
         *   to be included in the link, like "&section=$section"
-        * @param $tooltip string The tooltip to use for the link: will be escaped
+        * @param string $tooltip The tooltip to use for the link: will be escaped
         *   and wrapped in the 'editsectionhint' message
         * @param $lang    string Language code
         * @return         string HTML to use for edit link
@@ -1532,14 +1533,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;
@@ -1549,14 +1550,15 @@ abstract class Skin extends ContextSource {
         * Use PHP's magic __call handler to intercept legacy calls to the linker
         * for backwards compatibility.
         *
-        * @param $fname String Name of called method
-        * @param $args Array Arguments to the method
+        * @param string $fname Name of called method
+        * @param array $args Arguments to the method
         * @throws MWException
         * @return mixed
         */
        function __call( $fname, $args ) {
                $realFunction = array( 'Linker', $fname );
                if ( is_callable( $realFunction ) ) {
+                       wfDeprecated( get_class( $this ) . '::' . $fname, '1.21' );
                        return call_user_func_array( $realFunction, $args );
                } else {
                        $className = get_class( $this );