| Index: trunk/extensions/Gadgets/Gadgets_body.php |
| — | — | @@ -239,6 +239,7 @@ |
| 240 | 240 | $definition, |
| 241 | 241 | $resourceLoaded = false, |
| 242 | 242 | $requiredRights = array(), |
| | 243 | + $requiredSkins = array(), |
| 243 | 244 | $onByDefault = false, |
| 244 | 245 | $category; |
| 245 | 246 | |
| — | — | @@ -280,6 +281,9 @@ |
| 281 | 282 | case 'rights': |
| 282 | 283 | $gadget->requiredRights = $params; |
| 283 | 284 | break; |
| | 285 | + case 'skins': |
| | 286 | + $gadget->requiredSkins = array_intersect( array_keys( Skin::getSkinNames() ), $params ); |
| | 287 | + break; |
| 284 | 288 | case 'default': |
| 285 | 289 | $gadget->onByDefault = true; |
| 286 | 290 | break; |
| — | — | @@ -359,7 +363,8 @@ |
| 360 | 364 | * @return Boolean |
| 361 | 365 | */ |
| 362 | 366 | public function isAllowed( $user ) { |
| 363 | | - return count( array_intersect( $this->requiredRights, $user->getRights() ) ) == count( $this->requiredRights ); |
| | 367 | + return count( array_intersect( $this->requiredRights, $user->getRights() ) ) == count( $this->requiredRights ) |
| | 368 | + && ( !count( $this->requiredSkins ) || in_array( $user->getOption( 'skin' ), $this->requiredSkins ) ); |
| 364 | 369 | } |
| 365 | 370 | |
| 366 | 371 | /** |
| — | — | @@ -466,6 +471,14 @@ |
| 467 | 472 | } |
| 468 | 473 | |
| 469 | 474 | /** |
| | 475 | + * Returns array of skins where this gadget works |
| | 476 | + * @return Array |
| | 477 | + */ |
| | 478 | + public function getRequiredSkins() { |
| | 479 | + return $this->requiredSkins; |
| | 480 | + } |
| | 481 | + |
| | 482 | + /** |
| 470 | 483 | * Loads and returns a list of all gadgets |
| 471 | 484 | * @return Mixed: Array of gadgets or false |
| 472 | 485 | */ |
| Index: trunk/extensions/Gadgets/Gadgets.i18n.php |
| — | — | @@ -36,6 +36,7 @@ |
| 37 | 37 | 'gadgets-required-rights' => 'Requires the following {{PLURAL:$2|right|rights}}: |
| 38 | 38 | |
| 39 | 39 | $1', |
| | 40 | + 'gadgets-required-skins' => 'Available on the {{PLURAL:$2|$1 skin|following skins: $1}}.', |
| 40 | 41 | 'gadgets-default' => 'Enabled for everyone by default.', |
| 41 | 42 | 'gadgets-export' => 'Export', |
| 42 | 43 | 'gadgets-export-title' => 'Gadget export', |
| — | — | @@ -72,6 +73,9 @@ |
| 73 | 74 | 'gadgets-required-rights' => 'Parameters: |
| 74 | 75 | * $1 - a list in wikitext. |
| 75 | 76 | * $2 - the number of items in list $1 for PLURAL use.', |
| | 77 | + 'gadgets-required-skins' => 'Parameters: |
| | 78 | +* $1 - a comma list. |
| | 79 | +* $2 - the number of items in list $1 for PLURAL use.', |
| 76 | 80 | 'gadgets-export' => 'Used on [[Special:Gadgets]]. This is a verb, not noun. |
| 77 | 81 | {{Identical|Export}}', |
| 78 | 82 | 'gadgets-export-download' => 'Use the verb for this message. Submit button. |
| Index: trunk/extensions/Gadgets/ApiQueryGadgets.php |
| — | — | @@ -119,6 +119,7 @@ |
| 120 | 120 | return array( |
| 121 | 121 | 'settings' => array( |
| 122 | 122 | 'rights' => $g->getRequiredRights(), |
| | 123 | + 'skins' => $g->getRequiredSkins(), |
| 123 | 124 | 'default' => $g->isOnByDefault(), |
| 124 | 125 | 'hidden' => false, // Only exists in RL2 branch |
| 125 | 126 | 'shared' => false, // Only exists in RL2 branch |
| — | — | @@ -136,6 +137,7 @@ |
| 137 | 138 | private function setIndexedTagNameForMetadata( &$metadata ) { |
| 138 | 139 | static $tagNames = array( |
| 139 | 140 | 'rights' => 'right', |
| | 141 | + 'skins' => 'skin', |
| 140 | 142 | 'scripts' => 'script', |
| 141 | 143 | 'styles' => 'style', |
| 142 | 144 | 'dependencies' => 'dependency', |
| Index: trunk/extensions/Gadgets/SpecialGadgets.php |
| — | — | @@ -117,17 +117,27 @@ |
| 118 | 118 | $lnk[] = $skin->link( $t, htmlspecialchars( $t->getText() ) ); |
| 119 | 119 | } |
| 120 | 120 | $wgOut->addHTML( $wgLang->commaList( $lnk ) ); |
| | 121 | + |
| 121 | 122 | $rights = array(); |
| 122 | 123 | foreach ( $gadget->getRequiredRights() as $right ) { |
| 123 | 124 | $rights[] = '* ' . wfMessage( "right-$right" )->plain(); |
| 124 | 125 | } |
| 125 | | - |
| 126 | 126 | if ( count( $rights ) ) { |
| 127 | 127 | $wgOut->addHTML( '<br />' . |
| 128 | 128 | wfMessage( 'gadgets-required-rights', implode( "\n", $rights ), count( $rights ) )->parse() |
| 129 | 129 | ); |
| 130 | 130 | } |
| 131 | 131 | |
| | 132 | + $skins = array(); |
| | 133 | + foreach ( $gadget->getRequiredSkins() as $skinid ) { |
| | 134 | + $skins[] = wfMessage( "skinname-$skinid" )->plain(); |
| | 135 | + } |
| | 136 | + if ( count( $skins ) ) { |
| | 137 | + $wgOut->addHTML( '<br />' . |
| | 138 | + wfMessage( 'gadgets-required-skins', $wgLang->commaList( $skins ), count( $skins ) )->parse() |
| | 139 | + ); |
| | 140 | + } |
| | 141 | + |
| 132 | 142 | if ( $gadget->isOnByDefault() ) { |
| 133 | 143 | $wgOut->addHTML( '<br />' . wfMessage( 'gadgets-default' )->parse() ); |
| 134 | 144 | } |