diff --git a/ApiQueryGadgets.php b/ApiQueryGadgets.php
index c3b8a4c3..bc9fa32d 100644
--- a/ApiQueryGadgets.php
+++ b/ApiQueryGadgets.php
@@ -119,6 +119,7 @@ class ApiQueryGadgets extends ApiQueryBase {
return array(
'settings' => array(
'rights' => $g->getRequiredRights(),
+ 'skins' => $g->getRequiredSkins(),
'default' => $g->isOnByDefault(),
'hidden' => false, // Only exists in RL2 branch
'shared' => false, // Only exists in RL2 branch
@@ -136,6 +137,7 @@ class ApiQueryGadgets extends ApiQueryBase {
private function setIndexedTagNameForMetadata( &$metadata ) {
static $tagNames = array(
'rights' => 'right',
+ 'skins' => 'skin',
'scripts' => 'script',
'styles' => 'style',
'dependencies' => 'dependency',
diff --git a/Gadgets.i18n.php b/Gadgets.i18n.php
index f640b65b..0c555ffe 100644
--- a/Gadgets.i18n.php
+++ b/Gadgets.i18n.php
@@ -36,6 +36,7 @@ This overview provides easy access to the system message pages that define each
'gadgets-required-rights' => 'Requires the following {{PLURAL:$2|right|rights}}:
$1',
+ 'gadgets-required-skins' => 'Available on the {{PLURAL:$2|$1 skin|following skins: $1}}.',
'gadgets-default' => 'Enabled for everyone by default.',
'gadgets-export' => 'Export',
'gadgets-export-title' => 'Gadget export',
@@ -71,6 +72,9 @@ $messages['qqq'] = array(
See [http://meta.wikimedia.org/wiki/Special:Gadgets Gadgets page in meta.wikimedia.org]",
'gadgets-required-rights' => 'Parameters:
* $1 - a list in wikitext.
+* $2 - the number of items in list $1 for PLURAL use.',
+ 'gadgets-required-skins' => 'Parameters:
+* $1 - a comma list.
* $2 - the number of items in list $1 for PLURAL use.',
'gadgets-export' => 'Used on [[Special:Gadgets]]. This is a verb, not noun.
{{Identical|Export}}',
diff --git a/Gadgets_body.php b/Gadgets_body.php
index 6386471b..96e34002 100644
--- a/Gadgets_body.php
+++ b/Gadgets_body.php
@@ -239,6 +239,7 @@ class Gadget {
$definition,
$resourceLoaded = false,
$requiredRights = array(),
+ $requiredSkins = array(),
$onByDefault = false,
$category;
@@ -280,6 +281,9 @@ class Gadget {
case 'rights':
$gadget->requiredRights = $params;
break;
+ case 'skins':
+ $gadget->requiredSkins = array_intersect( array_keys( Skin::getSkinNames() ), $params );
+ break;
case 'default':
$gadget->onByDefault = true;
break;
@@ -359,7 +363,8 @@ class Gadget {
* @return Boolean
*/
public function isAllowed( $user ) {
- return count( array_intersect( $this->requiredRights, $user->getRights() ) ) == count( $this->requiredRights );
+ return count( array_intersect( $this->requiredRights, $user->getRights() ) ) == count( $this->requiredRights )
+ && ( !count( $this->requiredSkins ) || in_array( $user->getOption( 'skin' ), $this->requiredSkins ) );
}
/**
@@ -465,6 +470,14 @@ class Gadget {
return $this->requiredRights;
}
+ /**
+ * Returns array of skins where this gadget works
+ * @return Array
+ */
+ public function getRequiredSkins() {
+ return $this->requiredSkins;
+ }
+
/**
* Loads and returns a list of all gadgets
* @return Mixed: Array of gadgets or false
diff --git a/SpecialGadgets.php b/SpecialGadgets.php
index 9d446eb6..8fc1db7d 100644
--- a/SpecialGadgets.php
+++ b/SpecialGadgets.php
@@ -117,17 +117,27 @@ class SpecialGadgets extends SpecialPage {
$lnk[] = $skin->link( $t, htmlspecialchars( $t->getText() ) );
}
$wgOut->addHTML( $wgLang->commaList( $lnk ) );
+
$rights = array();
foreach ( $gadget->getRequiredRights() as $right ) {
$rights[] = '* ' . wfMessage( "right-$right" )->plain();
}
-
if ( count( $rights ) ) {
$wgOut->addHTML( '
' .
wfMessage( 'gadgets-required-rights', implode( "\n", $rights ), count( $rights ) )->parse()
);
}
+ $skins = array();
+ foreach ( $gadget->getRequiredSkins() as $skinid ) {
+ $skins[] = wfMessage( "skinname-$skinid" )->plain();
+ }
+ if ( count( $skins ) ) {
+ $wgOut->addHTML( '
' .
+ wfMessage( 'gadgets-required-skins', $wgLang->commaList( $skins ), count( $skins ) )->parse()
+ );
+ }
+
if ( $gadget->isOnByDefault() ) {
$wgOut->addHTML( '
' . wfMessage( 'gadgets-default' )->parse() );
}