Add BetaFeatures support

Bug: T133379
Change-Id: I793665cf41ec5624034910d7aedde689ba0854b2
This commit is contained in:
addshore 2016-05-04 14:59:07 +01:00
parent cfee0dfae9
commit 9bd8eb07a8
4 changed files with 39 additions and 9 deletions

View file

@ -14,6 +14,19 @@ class RevisionSliderHooks {
Revision $oldRev,
Revision $newRev
) {
global $wgUser;
/**
* If this extension is deployed with the BetaFeatures extension then require the
* current user to have it enabled as a BetaFeature.
*/
if (
class_exists( BetaFeatures::class ) &&
!BetaFeatures::isFeatureEnabled( $wgUser, 'revisionslider' ) )
{
return true;
}
$out = RequestContext::getMain()->getOutput();
$out->addModules( 'ext.RevisionSlider.init' );
$out->addHTML(
@ -44,6 +57,16 @@ class RevisionSliderHooks {
)
)
);
return true;
}
public static function getBetaFeaturePreferences( $user, &$prefs ) {
$prefs['revisionslider'] = array(
'label-message' => 'revisionslider-beta-feature-message',
'desc-message' => 'revisionslider-beta-feature-description',
'info-link' => 'https://www.mediawiki.org/wiki/Extension:RevisionSlider',
'discussion-link' => 'https://www.mediawiki.org/wiki/Extension_talk:RevisionSlider',
);
}
public static function onResourceLoaderTestModules( array &$testModules, ResourceLoader $rl ) {

View file

@ -70,6 +70,9 @@
"DiffViewHeader": [
"RevisionSliderHooks::onDiffViewHeader"
],
"GetBetaFeaturePreferences": [
"RevisionSliderHooks::getBetaFeaturePreferences"
],
"ResourceLoaderTestModules": [
"RevisionSliderHooks::onResourceLoaderTestModules"
]

View file

@ -6,6 +6,8 @@
},
"revisionslider": "RevisionSlider",
"revisionslider-desc": "Shows a slider allowing selecting and comparing of revisions on a diff page",
"revisionslider-beta-feature-message": "Revision Slider",
"revisionslider-beta-feature-description": "Show a revision slider when comparing two revisions of a page.",
"revisionslider-loading-placeholder": "The revision slider is loading.",
"revisionslider-loading-noscript": "As you have JavaScript disabled the revision slider will not be able to load."
}

View file

@ -1,11 +1,13 @@
{
"@metadata": {
"authors": [
"WMDE"
]
},
"revisionslider": "Revision Slider",
"revisionslider-desc": "{{desc|name=RevisionSlider|url=https://www.mediawiki.org/wiki/Extension:RevisionSlider}}",
"revisionslider-loading-placeholder": "Message shown while the RevisionSlider is still loading on a diff page. Once loaded the message is removed.",
"revisionslider-loading-noscript": "Message shown while the RevisionSlider is trying to load but when JavaScript is disabled and thus it will not be successful."
"@metadata": {
"authors": [
"WMDE"
]
},
"revisionslider": "Revision Slider",
"revisionslider-desc": "{{desc|name=RevisionSlider|url=https://www.mediawiki.org/wiki/Extension:RevisionSlider}}",
"revisionslider-beta-feature-message": "Label for the revision slider Beta Feature.",
"revisionslider-beta-feature-description": "Description for the revision slider Beta Feature, describing the feature that will be enabled.",
"revisionslider-loading-placeholder": "Message shown while the RevisionSlider is still loading on a diff page. Once loaded the message is removed.",
"revisionslider-loading-noscript": "Message shown while the RevisionSlider is trying to load but when JavaScript is disabled and thus it will not be successful."
}