Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php |
— | — | @@ -16,14 +16,28 @@ |
17 | 17 | */ |
18 | 18 | public static function intercept( &$toolbar ) { |
19 | 19 | global $wgUser, $wgOut, $wgJsMimeType; |
| 20 | + global $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable; |
20 | 21 | |
| 22 | + // Checks if... |
| 23 | + if ( |
| 24 | + // The following is NOT true |
| 25 | + !( |
| 26 | + // Toolbar is globablly enabled |
| 27 | + $wgEditToolbarGlobalEnable || |
| 28 | + // Or... |
| 29 | + ( |
| 30 | + // Toolbar is per-user enablable |
| 31 | + $wgEditToolbarUserEnable && |
| 32 | + // And this user has enabled it |
| 33 | + $wgUser->getOption( 'usebetatoolbar' ) |
| 34 | + ) |
| 35 | + ) |
| 36 | + ) { |
| 37 | + // Returns without using the toolbar |
| 38 | + return true; |
| 39 | + } |
21 | 40 | // Internationalization |
22 | 41 | wfLoadExtensionMessages( 'EditToolbar' ); |
23 | | - // Checks if the user has not opted to use this toolbar |
24 | | - if ( !$wgUser->getOption( 'usebetatoolbar' ) ) { |
25 | | - // Exists the function without doing anything |
26 | | - return true; |
27 | | - } |
28 | 42 | // Adds toolbar container |
29 | 43 | $toolbar = '<div id="edittoolbar"></div>'; |
30 | 44 | // List of messages to be sent to the client for use in the toolbar |
— | — | @@ -92,13 +106,25 @@ |
93 | 107 | * Add toolbar related items to the preferences |
94 | 108 | */ |
95 | 109 | public static function addPreferences( $user, $defaultPreferences ) { |
96 | | - wfLoadExtensionMessages( 'EditToolbar' ); |
97 | | - $defaultPreferences['usebetatoolbar'] = |
98 | | - array( |
99 | | - 'type' => 'toggle', |
100 | | - 'label-message' => 'edittoolbar-preference', |
101 | | - 'section' => 'editing/advancedediting', |
102 | | - ); |
| 110 | + global $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable; |
| 111 | + |
| 112 | + // Checks if... |
| 113 | + if ( |
| 114 | + // Toolbar is NOT globablly enabled |
| 115 | + !$wgEditToolbarGlobalEnable && |
| 116 | + // And Toolbar is per-user enablable |
| 117 | + $wgEditToolbarUserEnable |
| 118 | + ) { |
| 119 | + // Internationalization |
| 120 | + wfLoadExtensionMessages( 'EditToolbar' ); |
| 121 | + // Adds preference for opting in |
| 122 | + $defaultPreferences['usebetatoolbar'] = |
| 123 | + array( |
| 124 | + 'type' => 'toggle', |
| 125 | + 'label-message' => 'edittoolbar-preference', |
| 126 | + 'section' => 'editing/advancedediting', |
| 127 | + ); |
| 128 | + } |
103 | 129 | return true; |
104 | 130 | } |
105 | 131 | |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -32,6 +32,14 @@ |
33 | 33 | // Bump the version number every time you change any of the .css/.js files |
34 | 34 | $wgEditToolbarStyleVersion = 0; |
35 | 35 | |
| 36 | +// Set this to true to simply override the stock toolbar for everyone |
| 37 | +$wgEditToolbarGlobalEnable = false; |
| 38 | + |
| 39 | +// Set this to true to add a preference to the editing section of preferences |
| 40 | +// which enables and disables this toolbar (if $wgEditToolbarGlobalEnable, this |
| 41 | +// will not do anything) |
| 42 | +$wgEditToolbarUserEnable = true; |
| 43 | + |
36 | 44 | // Autoload Classes |
37 | 45 | $wgAutoloadClasses['EditToolbarHooks'] = $dir . 'EditToolbar.hooks.php'; |
38 | 46 | |