Officially deprecate skin autodiscovery
[lhc/web/wiklou.git] / includes / Skin.php
index 9d1034b..0d165fe 100644 (file)
 
 /**
  * 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.
  *
  * @ingroup Skins
  */
 abstract class Skin extends ContextSource {
-       protected $skinname = 'standard';
+       protected $skinname = null;
        protected $mRelevantTitle = null;
        protected $mRelevantUser = null;
 
@@ -64,6 +63,29 @@ abstract class Skin extends ContextSource {
 
                                        if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
                                                $aSkin = $matches[1];
+
+                                               // Explicitly disallow loading core skins via the autodiscovery mechanism.
+                                               //
+                                               // They should be loaded already (in a non-autodicovery way), but old files might still
+                                               // exist on the server because our MW version upgrade process is widely documented as
+                                               // requiring just copying over all files, without removing old ones.
+                                               //
+                                               // This is one of the reasons we should have never used autodiscovery in the first
+                                               // place. This hack can be safely removed when autodiscovery is gone.
+                                               if ( in_array( $aSkin, array( 'CologneBlue', 'Modern', 'MonoBook', 'Vector' ) ) ) {
+                                                       wfLogWarning(
+                                                               "An old copy of the $aSkin skin was found in your skins/ directory. " .
+                                                               "You should remove it to avoid problems in the future." .
+                                                               "See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for details."
+                                                       );
+                                                       continue;
+                                               }
+
+                                               wfLogWarning(
+                                                       "A skin using autodiscovery mechanism, $aSkin, was found in your skins/ directory. " .
+                                                       "The mechanism will be removed in MediaWiki 1.25 and the skin will no longer be recognized. " .
+                                                       "See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for information how to fix this."
+                                               );
                                                $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
                                        }
                                }
@@ -82,7 +104,7 @@ abstract class Skin extends ContextSource {
        static function getSkinNameMessages() {
                $messages = array();
                foreach ( self::getSkinNames() as $skinKey => $skinName ) {
-                       // Messages: skinname-cologneblue, skinname-monobook, skinname-modern, skinname-vector
+                       // Messages: skinname-vector, skinname-monobook
                        $messages[] = "skinname-$skinKey";
                }
                return $messages;
@@ -119,8 +141,8 @@ 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 string $key 'monobook', 'standard', etc.
+        * default, or the hardcoded default if that's broken.
+        * @param string $key 'monobook', 'vector', etc.
         * @return string
         */
        static function normalizeKey( $key ) {
@@ -160,7 +182,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * Factory method for loading a skin of a given type
-        * @param string $key 'monobook', 'standard', etc.
+        * @param string $key 'monobook', 'vector', etc.
         * @return Skin
         */
        static function &newFromKey( $key ) {
@@ -185,7 +207,6 @@ abstract class Skin extends ContextSource {
                                # is no longer valid.
                                wfDebug( "Skin class does not exist: $className\n" );
                                $className = 'SkinVector';
-                               require_once "{$wgStyleDirectory}/Vector.php";
                        }
                }
                $skin = new $className( $key );
@@ -721,7 +742,6 @@ abstract class Skin extends ContextSource {
         * @return string
         */
        function subPageSubtitle() {
-               global $wgLang;
                $out = $this->getOutput();
                $subpages = '';
 
@@ -737,6 +757,7 @@ abstract class Skin extends ContextSource {
                                $c = 0;
                                $growinglink = '';
                                $display = '';
+                               $lang = $this->getLanguage();
 
                                foreach ( $links as $link ) {
                                        $growinglink .= $link;
@@ -752,7 +773,7 @@ abstract class Skin extends ContextSource {
                                                $c++;
 
                                                if ( $c > 1 ) {
-                                                       $subpages .= $wgLang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
+                                                       $subpages .= $lang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
                                                } else {
                                                        $subpages .= '< ';
                                                }
@@ -830,6 +851,7 @@ abstract class Skin extends ContextSource {
                }
 
                // Allow for site and per-namespace customization of copyright notice.
+               // @todo Remove deprecated $forContent param from hook handlers and then remove here.
                $forContent = true;
 
                wfRunHooks(
@@ -837,20 +859,7 @@ abstract class Skin extends ContextSource {
                        array( $this->getTitle(), $type, &$msg, &$link, &$forContent )
                );
 
-               $msgObj = $this->msg( $msg )->rawParams( $link );
-               if ( $forContent ) {
-                       $msg = $msgObj->inContentLanguage()->text();
-                       if ( $this->getLanguage()->getCode() !== $wgContLang->getCode() ) {
-                               $msg = Html::rawElement( 'span', array(
-                                       'lang' => $wgContLang->getHtmlCode(),
-                                       'dir' => $wgContLang->getDir()
-                               ), $msg );
-                       }
-
-                       return $msg;
-               } else {
-                       return $msgObj->text();
-               }
+               return $this->msg( $msg )->rawParams( $link )->text();
        }
 
        /**