diff --git a/Popups.hooks.php b/Popups.hooks.php index 10957d5f3..07e62cb0e 100644 --- a/Popups.hooks.php +++ b/Popups.hooks.php @@ -20,9 +20,23 @@ */ class PopupsHooks { + static function getPreferences( User $user, array &$prefs ){ + global $wgExtensionAssetsPath; + + $prefs['popups'] = array( + 'label-message' => 'popups-message', + 'desc-message' => 'popups-desc', + 'screenshot' => $wgExtensionAssetsPath . '/Popups/popups.svg', + 'info-link' => 'https://www.mediawiki.org/wiki/Navigation_Popups_%28Restyling_and_Enhancements%29', + 'discussion-link' => 'https://www.mediawiki.org/wiki/Talk:Beta_Features/Hovercards', + ); + } + public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin) { - // Depends on PageImages & TextExtracts extensions - if ( class_exists( 'ApiQueryExtracts' ) + // Enable only if the user has turned it on in Beta Preferences. Also depends on PageImages & TextExtracts extensions. + if ( ( ( class_exists( 'BetaFeatures' ) && BetaFeatures::isFeatureEnabled( $skin->getUser(), 'popups' ) ) + || !class_exists( 'BetaFeatures' ) ) + && class_exists( 'ApiQueryExtracts' ) && class_exists( 'ApiQueryPageImages' ) ) { $out->addModules( array( 'ext.popups' ) ); diff --git a/Popups.i18n.php b/Popups.i18n.php index 1572fce35..1ae10ed5d 100644 --- a/Popups.i18n.php +++ b/Popups.i18n.php @@ -25,11 +25,13 @@ $messages = array(); * English */ $messages['en'] = array( - 'popups-desc' => 'Displays popups when you hover over page links', + 'popups-message' => 'Popups', + 'popups-desc' => 'Displays popups with summaries of article contents when the user hovers over an article link.', ); /** Message documentation (Message documentation) */ $messages['qqq'] = array( + 'popups-message' => 'Name shown in user preference for this extension', 'popups-desc' => '{{desc|name=Popups|url=https://www.mediawiki.org/wiki/Extension:Popups}}', ); diff --git a/Popups.php b/Popups.php index 80a98d847..3faafaa58 100644 --- a/Popups.php +++ b/Popups.php @@ -50,4 +50,6 @@ $wgResourceModules = array_merge( $wgResourceModules, array( $wgAutoloadClasses['PopupsHooks'] = __DIR__ . '/Popups.hooks.php'; $wgExtensionMessagesFiles['Popups'] = __DIR__ . '/Popups.i18n.php'; + +$wgHooks['GetBetaFeaturePreferences'][] = 'PopupsHooks::getPreferences'; $wgHooks['BeforePageDisplay'][] = 'PopupsHooks::onBeforePageDisplay'; diff --git a/popups.svg b/popups.svg new file mode 100644 index 000000000..5e769f40d --- /dev/null +++ b/popups.svg @@ -0,0 +1,61 @@ + + + NavigationPopups_BetaFeaturesIcon + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file