From ec513507061172b6c1326c98685f8e821ca5151d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sat, 31 May 2014 14:49:24 +0200 Subject: [PATCH] SkinTemplate: Move $stylename to Skin and soft-deprecate 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 | 15 +++++++++++++++ includes/SkinTemplate.php | 6 ------ skins/monobook/MonoBook.php | 1 - 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index 0d165fe04f..25c0b04f90 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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"; } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 1f78ee5e56..f9799a5b5d 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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. diff --git a/skins/monobook/MonoBook.php b/skins/monobook/MonoBook.php index 7385d0ea8f..aeef8a9905 100644 --- a/skins/monobook/MonoBook.php +++ b/skins/monobook/MonoBook.php @@ -37,7 +37,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { class SkinMonoBook extends SkinTemplate { /** Using monobook. */ public $skinname = 'monobook'; - public $stylename = 'monobook'; public $template = 'MonoBookTemplate'; /** -- 2.20.1