r51593 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51592‎ | r51593 | r51594 >
Date:16:46, 8 June 2009
Author:tparscal
Status:deferred
Tags:
Comment:
Added configuration variables for globally enabling the toolbar as well as enabling/disabling the per-user opt-in via user preferences.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php
@@ -16,14 +16,28 @@
1717 */
1818 public static function intercept( &$toolbar ) {
1919 global $wgUser, $wgOut, $wgJsMimeType;
 20+ global $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable;
2021
 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+ }
2140 // Internationalization
2241 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 - }
2842 // Adds toolbar container
2943 $toolbar = '<div id="edittoolbar"></div>';
3044 // List of messages to be sent to the client for use in the toolbar
@@ -92,13 +106,25 @@
93107 * Add toolbar related items to the preferences
94108 */
95109 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+ }
103129 return true;
104130 }
105131
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php
@@ -32,6 +32,14 @@
3333 // Bump the version number every time you change any of the .css/.js files
3434 $wgEditToolbarStyleVersion = 0;
3535
 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+
3644 // Autoload Classes
3745 $wgAutoloadClasses['EditToolbarHooks'] = $dir . 'EditToolbar.hooks.php';
3846

Status & tagging log