*/
private $factoryFunctions = array();
/**
- * Map of name => human readable name
+ * Map of name => fallback human-readable name, used when the 'skinname-<skin>' message is not
+ * available
+ *
* @var array
*/
private $displayNames = array();
+ /**
+ * Map of name => class name without "Skin" prefix, for legacy skins using the autodiscovery
+ * mechanism
+ *
+ * @var array
+ */
+ private $legacySkins = array();
/**
* @var SkinFactory
}
/**
- * Register a new Skin factory function
- * Will override if it's already registered
- * @param string $name
- * @param string $displayName
- * @param callable $callback That takes the skin name as an argument
+ * Register a new Skin factory function.
+ *
+ * Will override if it's already registered.
+ *
+ * @param string $name Internal skin name. Should be all-lowercase (technically doesn't have
+ * to be, but doing so would change the case of i18n message keys).
+ * @param string $displayName For backwards-compatibility with old skin loading system. This is
+ * the text used as skin's human-readable name when the 'skinname-<skin>' message is not
+ * available. It should be the same as the skin name provided in $wgExtensionCredits.
+ * @param callable $callback Callback that takes the skin name as an argument
* @throws InvalidArgumentException If an invalid callback is provided
*/
public function register( $name, $displayName, $callback ) {
* @return array
*/
private function getLegacySkinNames() {
- global $wgValidSkinNames;
static $skinsInitialised = false;
- if ( !$skinsInitialised || !count( $wgValidSkinNames ) ) {
+ if ( !$skinsInitialised || !count( $this->legacySkins ) ) {
# Get a list of available skins
# Build using the regular expression '^(.*).php$'
# Array keys are all lower case, array value keep the case used by filename
"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;
+ $this->legacySkins[strtolower( $aSkin )] = $aSkin;
}
}
$skinDir->close();
$skinsInitialised = true;
wfProfileOut( __METHOD__ . '-init' );
}
- return $wgValidSkinNames;
+ return $this->legacySkins;
}
}
/**
- * Get a legacy skin which uses $wgValidSkinNames
- * or autoloading
+ * Get a legacy skin which uses the autodiscovery mechanism.
*
* @param string $name
- * @return Skin|bool false if the skin couldn't be constructed
+ * @return Skin|bool False if the skin couldn't be constructed
*/
private function getLegacySkin( $name ) {
$skinNames = $this->getLegacySkinNames();
*/
public function makeSkin( $name ) {
if ( !isset( $this->factoryFunctions[$name] ) ) {
- // Check the legacy method of skin loading
+ // Check the legacy autodiscovery method of skin loading
$legacy = $this->getLegacySkin( $name );
if ( $legacy ) {
return $legacy;