Jump to content

Podręcznik:$wgValidSkinNames

From mediawiki.org
This page is a translated version of the page Manual:$wgValidSkinNames and the translation is 13% complete.
Rozszerzenia: $wgValidSkinNames
List of valid skin names. Skins can optionally use this variable to tell MediaWiki that they are available.
Wprowadzono w wersji:1.7.0 (r15226)
Usunięto w wersji:nadal w użyciu
Dozwolone wartości:(array of lowercase skin names to either: ObjectFactory specifications; or to a string value which is the PHP class name when appended with Skin)
Domyślna wartość:[]

Szczegóły

Array with information on valid skin names. Optionally can be used by skins to tell MediaWiki that they are available.

This variable can be used to register a skin, but it doesn't have to be. Skins can also be registered dynamically, by using the methods of the SkinFactory, namely SkinFactory::register(). This means there is no guarantee that $wgValidSkinNames actually is a complete list of the installed skins!
  • The key should be the skin's id in all lower case.

Generally this should be the same as the name of the base folder inside skins/ that contains the skins css, resources, etc...

  • Prior to MediaWiki 1.35, the value should be an identifier which when prefixed with "Skin" becomes the class name of the class implemented by your skin.

i.e. If your skin's class name is "SkinFooBar" the value in the array should be $wgValidSkinNames['foobar'] = 'FooBar';

  • From MediaWiki 1.35, the value can be a specification for ObjectFactory . The old format, where the value is an identifier which when prefixed with "Skin" becomes the class name of the class implemented by your skin, is still supported.
  • Prior to MediaWiki 1.18 the value was a fallback display name and the class name was determined by running ucfirst on the lowercase skin id.

i.e. For $wgValidSkinNames['foobar'] = 'FooBar'; it would try to load the "SkinFoobar" class. This caused issues with our AutoLoader being case-sensitive despite PHP class names being case-insensitive.

The default skins will be added later, by SkinFactory::getSkinNames(). Use SkinFactory::getSkinNames() as an accessor if you wish to have access to the full list.

Przykłady

As of MediaWiki 1.35, the value is a specification for ObjectFactory . This allows for the skin name to be decoupled (such as PHP class namespacing) from the underlying PHP class name.

Wersja MediaWiki:
1.35

Old PHP loading style format:

$wgValidSkinNames["foobarskin"] = [
	"displayname" => "FooBarSkin",
	"class" => "MediaWiki\\Skins\\FooBar\\FooBarSkin"
];

skin.json format:

	"ValidSkinNames": {
		"foobarskin": {
			"class": "SkinMustache",
			"args": [
				{
					"@name": "key used for useskin=",
					"name": "foorbarskin",
					"@scripts": "List of ResourceLoader modules to be loaded",
					"scripts": [
						"skins.foo.js"
					],
					"@styles": "List of ResourceLoader style modules to be loaded",
					"styles": [
						"skins.foo.styles"
					],
					"@messages": "For skins that use SkinMustache, this will create translated template variables",
					"messages": [
						"foo-key"
					]
				}
			]
		}
	}