Index: trunk/extensions/MoodBar/Hooks.php |
— | — | @@ -0,0 +1,31 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class MoodBarHooks { |
| 5 | + /** |
| 6 | + * Adds MoodBar JS to the output if appropriate. |
| 7 | + */ |
| 8 | + public static function onPageDisplay( &$output, &$skin ) { |
| 9 | + if ( self::shouldShowMoodbar() ) { |
| 10 | + $output->addModules( array('ext.moodbar') ); |
| 11 | + } |
| 12 | + |
| 13 | + return true; |
| 14 | + } |
| 15 | + |
| 16 | + /** |
| 17 | + * Determines whether or not we should show the MoodBar. |
| 18 | + */ |
| 19 | + public static function shouldShowMoodbar() { |
| 20 | + return true; |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Runs MoodBar schema updates |
| 25 | + */ |
| 26 | + public static function onLoadExtensionSchemaUpdates( $updater = null ) { |
| 27 | + $updater->addExtensionUpdate( array( 'addTable', 'moodbar_feedback', |
| 28 | + dirname(__FILE__).'/moodbar.sql' ) ); |
| 29 | + |
| 30 | + return true; |
| 31 | + } |
| 32 | +} |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -20,6 +20,11 @@ |
21 | 21 | $wgAutoloadClasses['ApiMoodBar'] = dirname(__FILE__).'/ApiMoodBar.php'; |
22 | 22 | $wgAPIModules['moodbar'] = 'ApiMoodBar'; |
23 | 23 | |
| 24 | +// Hooks |
| 25 | +$wgAutoloadClasses['MoodBarHooks'] = dirname(__FILE__).'/Hooks.php'; |
| 26 | +$wgHooks['BeforePageDisplay'][] = 'MoodBarHooks::onPageDisplay'; |
| 27 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'MoodBarHooks::onLoadExtensionSchemaUpdates'; |
| 28 | + |
24 | 29 | // Internationalisation |
25 | 30 | $wgExtensionMessagesFiles = dirname(__FILE__).'/Messages.php'; |
26 | 31 | |
— | — | @@ -29,7 +34,7 @@ |
30 | 35 | 'remoteExtPath' => 'MoodBar' |
31 | 36 | ); |
32 | 37 | |
33 | | -$wgResourceModules['ext.moodBar'] = $mbResourceTemplate + array( |
| 38 | +$wgResourceModules['ext.moodbar'] = $mbResourceTemplate + array( |
34 | 39 | 'styles' => array( ), |
35 | 40 | 'scripts' => array( ), |
36 | 41 | 'dependencies' => array( ), |