Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.php |
— | — | @@ -0,0 +1,51 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Usability Initiative NavigableTOC extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * |
| 9 | + * This file contains the include file for the NavigableTOC portion of the |
| 10 | + * UsabilityInitiative extension of MediaWiki. |
| 11 | + * |
| 12 | + * Usage: Include the following line in your LocalSettings.php |
| 13 | + * require_once( "$IP/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.php" ); |
| 14 | + * |
| 15 | + * @author Roan Kattouw <roan.kattouw@gmail.com> |
| 16 | + * @license GPL v2 or later |
| 17 | + * @version 0.1.1 |
| 18 | + */ |
| 19 | + |
| 20 | +/* Configuration */ |
| 21 | + |
| 22 | +// Each module may be configured individually to be globally on/off or user preference based |
| 23 | +$wgWikiEditorEnable = array( |
| 24 | + 'toolbar' => array( 'global' => false, 'user' => true ), |
| 25 | + 'toc' => array( 'global' => false, 'user' => true ), |
| 26 | + 'code' => array( 'global' => false, 'user' => true ), |
| 27 | +); |
| 28 | + |
| 29 | +/* Setup */ |
| 30 | + |
| 31 | +// Credits |
| 32 | +$wgExtensionCredits['other'][] = array( |
| 33 | + 'path' => __FILE__, |
| 34 | + 'name' => 'WikiEditor', |
| 35 | + 'author' => 'Trevor Parscal, Roan Kattouw and Nimish Goutam', |
| 36 | + 'version' => '0.1.2', |
| 37 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:UsabilityInitiative', |
| 38 | + 'descriptionmsg' => 'wikieditor-desc', |
| 39 | +); |
| 40 | + |
| 41 | +// Includes parent extension |
| 42 | +require_once( dirname( dirname( __FILE__ ) ) . "/UsabilityInitiative.php" ); |
| 43 | + |
| 44 | +// Adds Autoload Classes |
| 45 | +$wgAutoloadClasses['WikiEditorHooks'] = dirname( __FILE__ ) . '/WikiEditor.hooks.php'; |
| 46 | + |
| 47 | +// Adds Internationalized Messages |
| 48 | +$wgExtensionMessagesFiles['WikiEditor'] = dirname( __FILE__ ) . '/WikiEditor.i18n.php'; |
| 49 | + |
| 50 | +// Registers Hooks |
| 51 | +$wgHooks['EditPageBeforeEditToolbar'][] = 'WikiEditorHooks::addModules'; |
| 52 | +$wgHooks['GetPreferences'][] = 'WikiEditorHooks::addPreferences'; |
Property changes on: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 53 | + native |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php |
— | — | @@ -0,0 +1,93 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Hooks for Usability Initiative WikiEditor extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +class WikiEditorHooks { |
| 11 | + |
| 12 | + static $modules = array( |
| 13 | + 'toolbar' => array( |
| 14 | + 'preferences' => array( |
| 15 | + 'usebetatoolbar' => array( |
| 16 | + 'type' => 'toggle', |
| 17 | + 'label-message' => 'wikieditor-toolbar-preference', |
| 18 | + 'section' => 'editing/experimental', |
| 19 | + ), |
| 20 | + ), |
| 21 | + 'scripts' => array( |
| 22 | + 'raw' => array( 'src' => 'WikiEditor/Modules/Toolbar.js', 'version' => 1 ), |
| 23 | + 'min' => array( 'src' => 'WikiEditor/Modules/Toolbar.min.js', 'version' => 1 ), |
| 24 | + ) |
| 25 | + ), |
| 26 | + 'toc' => array( |
| 27 | + 'preferences' => array( |
| 28 | + 'usenavigabletoc' => array( |
| 29 | + 'type' => 'toggle', |
| 30 | + 'label-message' => 'wikieditor-toc-preference', |
| 31 | + 'section' => 'editing/experimental', |
| 32 | + ), |
| 33 | + ), |
| 34 | + 'scripts' => array( |
| 35 | + 'raw' => array( 'src' => 'WikiEditor/Modules/Toc.js', 'version' => 1 ), |
| 36 | + ) |
| 37 | + ), |
| 38 | + 'code' => array( |
| 39 | + 'preferences' => array( |
| 40 | + 'usebetacodeeditor' => array( |
| 41 | + 'type' => 'toggle', |
| 42 | + 'label-message' => 'wikieditor-code-preference', |
| 43 | + 'section' => 'editing/experimental', |
| 44 | + ), |
| 45 | + ), |
| 46 | + 'scripts' => array( |
| 47 | + 'raw' => array( 'src' => 'WikiEditor/Modules/Code', 'version' => 1 ), |
| 48 | + ) |
| 49 | + ), |
| 50 | + ); |
| 51 | + |
| 52 | + /* Static Functions */ |
| 53 | + |
| 54 | + /** |
| 55 | + * EditPage::showEditForm:initial hook |
| 56 | + * Adds the modules to the edit form |
| 57 | + */ |
| 58 | + public static function addModules( &$toolbar ) { |
| 59 | + global $wgUser, $wgWikiEditorStyleVersion, $wgWikiEditorEnable, $wgUsabilityInitiativeResourceMode; |
| 60 | + |
| 61 | + for ( $wgWikiEditorEnable as $module => $enable ) { |
| 62 | + if ( |
| 63 | + $enable['global'] || |
| 64 | + ( $enable['user'] && $wgUser->getOption( self::$modules[$module]['preference']['key'] ) ) |
| 65 | + ) { |
| 66 | + UsabilityInitiativeHooks::initialize(); |
| 67 | + $mode = $wgUsabilityInitiativeResourceMode; |
| 68 | + if ( !isset( self::$modules[$module]['scripts'][$mode] ) ) { |
| 69 | + $mode = 'raw'; |
| 70 | + } |
| 71 | + UsabilityInitiativeHooks::addScript( |
| 72 | + self::$modules[$module]['scripts'][$mode]['src'], |
| 73 | + self::$modules[$module]['scripts'][$mode]['version'] |
| 74 | + ); |
| 75 | + } |
| 76 | + } |
| 77 | + return true; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * GetPreferences hook |
| 82 | + * Add module-releated items to the preferences |
| 83 | + */ |
| 84 | + public static function addPreferences( $user, &$defaultPreferences ) { |
| 85 | + global $wgWikiEditorEnable; |
| 86 | + |
| 87 | + foreach ( $wgWikiEditorEnable as $module => $enable ) { |
| 88 | + foreach ( self::$modules[$module]['preferences'] as $key => $preference ) { |
| 89 | + $defaultPreferences[$key] = $preference; |
| 90 | + } |
| 91 | + } |
| 92 | + return true; |
| 93 | + } |
| 94 | +} |
Property changes on: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 95 | + native |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.i18n.php |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation for Usability Initiative NavigableTOC extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/* We need to merge all the i18n from the various WikiEditor modules here */ |
\ No newline at end of file |
Property changes on: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.i18n.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 13 | + native |