Add hook for BetaFeatures

Change-Id: I2929c9cccc60330253f358a767e66297d20f401e
This commit is contained in:
Prateek Saxena 2014-02-07 17:22:40 +05:30
parent 6b0057a521
commit b23ed006f6
4 changed files with 82 additions and 3 deletions

View file

@ -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' ) );

View file

@ -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}}',
);

View file

@ -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';

61
popups.svg Normal file
View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="264px" height="162px" viewBox="0 0 264 162" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<title>NavigationPopups_BetaFeaturesIcon</title>
<description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
<defs>
<filter x="-20%" y="-20%" width="140%" height="140%" filterUnits="objectBoundingBox" id="filter-1">
<feOffset dx="1" dy="1" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="0" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0.831438303 0 0 0 0 0.831319273 0 0 0 0 0.831478775 0 0 0 0.7 0" in="shadowBlurOuter1" type="matrix" result="shadowMatrixOuter1"></feColorMatrix>
<feMerge>
<feMergeNode in="shadowMatrixOuter1"></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="Group" sketch:type="MSLayerGroup">
<path d="M24.833,151.362 L13.366,161.357 L0.5,151.749 L0.5,0.5 L263.5,0.5 L263.5,152.249 L254.5,158.954 L254.5,42.5 L215.5,42.5 L215.5,155.1 L211.107,151.369 L203.5,156.699 L203.5,42.5 L48.5,42.5 L48.5,153.349 L38.749,161.38 L24.833,151.362 Z" id="Shape" fill="#FFFFFF" sketch:type="MSShapeGroup"></path>
<path d="M263,1 L263,151.998 L255,157.958 L255,43 L255,42 L254,42 L216,42 L215,42 L215,43 L215,154.019 L211.726,151.24 L211.137,150.741 L210.504,151.181 L204,155.738 L204,43 L204,42 L203,42 L49,42 L48,42 L48,43 L48,153.099 L38.743,160.76 L25.448,151.191 L24.804,150.726 L24.206,151.247 L13.342,160.717 L1,151.499 L1,1 L263,1 L263,1 Z M264,0 L0,0 L0,152 L13.391,162 L24.864,152 L38.755,162 L49,153.6 L49,43 L203,43 L203,157.66 L211.078,152 L216,156.18 L216,43 L254,43 L254,159.95 L264,152.5 L264,0 L264,0 L264,0 L264,0 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
</g>
<path d="M203,43 L49,43 L49,153.6 L51.145,152 L63.7,162 L77.509,152 L91.738,162 L104.71,152 L117.683,162 L131.494,152 L143.63,162 L157.021,152 L171.25,162 L184.222,152 L197.196,162 L203,157.66 L203,43 Z" id="Shape" fill="#F7F7F7" sketch:type="MSShapeGroup"></path>
<path d="M11,36 C11,28.268 17.268,22 25,22 C32.732,22 39,28.268 39,36 C39,43.732 32.732,50 25,50 C17.268,50 11,43.732 11,36 C11,36 11,43.732 11,36 L11,36 L11,36 Z" id="Ellipse" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
<path d="M254,159.95 L254,43 L216,43 L216,156.18 L223.551,162 L237.362,152 L251.253,162 L254,159.95 L254,159.95 L254,159.95 L254,159.95 Z" id="Shape" fill="#F7F7F7" sketch:type="MSShapeGroup"></path>
<path d="M38,107 L38,72 L13,72 L13,107 L38,107 L38,107 L38,107 L38,107 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
<path d="M232.51,5 L258.51,5 L258.51,11 L232.51,11 L232.51,5 L232.51,5 L232.51,5 L232.51,5 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
<rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="208.51" y="5" width="22" height="6"></rect>
<path d="M142,6 L142,10 L50,10 L50,6 L142,6 L142,6 Z M143,5 L49,5 L49,11 L143,11 L143,5 L143,5 L143,5 L143,5 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
<rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="184.51" y="5" width="22" height="6"></rect>
<rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="161.51" y="5" width="13" height="6"></rect>
<rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="176.51" y="5" width="6" height="6"></rect>
<rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="153.51" y="5" width="6" height="6"></rect>
<rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="9" y="5" width="32" height="6"></rect>
<path d="M2,14.5 L262,14.5" id="Shape" stroke="#E5E5E5" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
<rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="52" y="7" width="2" height="2"></rect>
<path d="M38,59 L38,54 L13,54 L13,59 L38,59 L38,59 L38,59 L38,59 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
<g id="Group" sketch:type="MSLayerGroup" transform="translate(91.010000, 88.000000)">
<path d="M37.8857143,0 L11,0 L11,5.48571429 L37.8857143,5.48571429 L37.8857143,0 Z" id="Shape-copy" fill="#9B9B9B" sketch:type="MSShapeGroup"></path>
<path d="M77.8757143,24.6857143 L77.8757143,18.5142857 L42.0571429,18.5142857 L42.0571429,24.6857143 L77.8757143,24.6857143 L77.8757143,24.6857143 L77.8757143,24.6857143 L77.8757143,24.6857143 Z" id="Shape-copy-2" fill="#9B9B9B" sketch:type="MSShapeGroup"></path>
<path d="M14.6285714,8.91428571 L-0.0571428571,8.91428571 L-0.0571428571,15 L14.6285714,15 L14.6285714,8.91428571 Z" id="Shape-copy-2" fill="#9B9B9B" sketch:type="MSShapeGroup"></path>
<path d="M84.0857143,14.4 L84.0857143,8.91428571 L57.5142857,8.91428571 L57.5142857,14.4 L78.0857143,14.4 L84.0857143,14.4 Z" id="Shape-copy-4" fill="#9B9B9B" sketch:type="MSShapeGroup"></path>
<path d="M21.6,18.4285714 L3.48571429,18.4285714 L3.48571429,23.9142857 L21.6,23.9142857 L21.6,18.4285714 Z" id="Shape-copy-3" fill="#9B9B9B" sketch:type="MSShapeGroup"></path>
<path d="M74.1714286,0 L41.6,0 L41.6,5.48571429 L74.1714286,5.48571429 L74.1714286,0 Z" id="Shape-copy-5" fill="#9B9B9B" sketch:type="MSShapeGroup"></path>
<path d="M17.4285714,8.91428571 L17.4285714,15.4 L53.7714286,15.4 L53.7714286,8.91428571 L17.4285714,8.91428571 Z" id="Shape" fill="#0E73FC" sketch:type="MSShapeGroup"></path>
</g>
<g id="Rectangle-28" sketch:type="MSLayerGroup" transform="translate(108.000000, 106.000000)" filter="url(#filter-1)" fill="#FFFFFF">
<g sketch:type="MSShapeGroup">
<rect x="0" y="0" width="53" height="31"></rect>
</g>
</g>
<path d="" id="Path-34" stroke="#979797" sketch:type="MSShapeGroup"></path>
<path d="M161,106 L139,106 L139,137 L161,137 L161,106 L161,106 L161,106 L161,106 Z M148.107332,123 L152.297452,129.801 L154.572681,127.717 L158,131.9804 L143,132 L147.431258,123 L148.107332,123 Z" id="Shape" fill="#0E73FC" sketch:type="MSShapeGroup"></path>
<rect id="Rectangle-8-copy" fill="#D0D0D0" sketch:type="MSShapeGroup" x="113" y="110" width="20" height="1" rx="1"></rect>
<rect id="Rectangle-8-copy-2" fill="#D0D0D0" sketch:type="MSShapeGroup" x="113" y="113" width="20" height="1" rx="1"></rect>
<rect id="Rectangle-8-copy-3" fill="#D0D0D0" sketch:type="MSShapeGroup" x="113" y="116" width="20" height="1" rx="1"></rect>
<rect id="Rectangle-8-copy-4" fill="#D0D0D0" sketch:type="MSShapeGroup" x="113" y="119" width="20" height="1" rx="1"></rect>
<rect id="Rectangle-8-copy-5" fill="#D0D0D0" sketch:type="MSShapeGroup" x="113" y="122" width="20" height="1" rx="1"></rect>
<rect id="Rectangle-8-copy-6" fill="#D0D0D0" sketch:type="MSShapeGroup" x="113" y="125" width="20" height="1" rx="1"></rect>
<rect id="Rectangle-8-copy-7" fill="#D0D0D0" sketch:type="MSShapeGroup" x="113" y="128" width="20" height="1" rx="1"></rect>
<rect id="Rectangle-8-copy-8" fill="#D0D0D0" sketch:type="MSShapeGroup" x="113" y="131" width="20" height="1" rx="1"></rect>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.5 KiB