SkinTemplate: Move $stylename to Skin and soft-deprecate
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 31 May 2014 12:49:24 +0000 (14:49 +0200)
committerLegoktm <legoktm.wikipedia@gmail.com>
Fri, 20 Jun 2014 19:13:21 +0000 (19:13 +0000)
It is *used* by Skin, so let's define and document it there as well.

Also, it was never necessary to set this to anything, but we were
pretending it was. This only served to increase the amount of magic
skin creators have to accept.

Change-Id: I61c6e952ede72bad37db38fefe1299da798914b8

includes/Skin.php
includes/SkinTemplate.php
skins/monobook/MonoBook.php

index 0d165fe..25c0b04 100644 (file)
@@ -36,6 +36,12 @@ abstract class Skin extends ContextSource {
        protected $mRelevantTitle = null;
        protected $mRelevantUser = null;
 
+       /**
+        * @var string Stylesheets set to use. Subdirectory in skins/ where various stylesheets are
+        *   located. Only needs to be set if you intend to use the getSkinStylePath() method.
+        */
+       public $stylename = null;
+
        /**
         * Fetch the set of available skins.
         * @return array Associative array of strings
@@ -1092,11 +1098,20 @@ abstract class Skin extends ContextSource {
         * 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.
+        *
+        * Requires $stylename to be set, otherwise throws MWException.
+        *
         * @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 ) {
                global $wgStylePath, $wgStyleVersion;
+
+               if ( $this->stylename === null ) {
+                       $class = get_class( $this );
+                       throw new MWException( "$class::\$stylename must be set to use getSkinStylePath()" );
+               }
+
                return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
        }
 
index 1f78ee5..f9799a5 100644 (file)
@@ -74,12 +74,6 @@ class SkinTemplate extends Skin {
         */
        public $skinname = 'monobook';
 
-       /**
-        * @var string Stylesheets set to use. Subdirectory in skins/ where various
-        *   stylesheets are located.  Child classes should override the default.
-        */
-       public $stylename = 'monobook';
-
        /**
         * @var string For QuickTemplate, the name of the subclass which will
         *   actually fill the template.  Child classes should override the default.
index 7385d0e..aeef8a9 100644 (file)
@@ -37,7 +37,6 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 class SkinMonoBook extends SkinTemplate {
        /** Using monobook. */
        public $skinname = 'monobook';
-       public $stylename = 'monobook';
        public $template = 'MonoBookTemplate';
 
        /**