Index: trunk/extensions/UsabilityInitiative/WikiEditorCode/WikiEditorCode.js |
— | — | @@ -0,0 +1,5 @@ |
| 2 | +/* JavaScript for WikiEditorCode extension */ |
| 3 | + |
| 4 | +js2AddOnloadHook( function() { |
| 5 | + $j( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'code' ); |
| 6 | +}); |
Property changes on: trunk/extensions/UsabilityInitiative/WikiEditorCode/WikiEditorCode.js |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 7 | + native |
Index: trunk/extensions/UsabilityInitiative/WikiEditorCode/WikiEditorCode.i18n.php |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation for Usability Initiative WikiEditorCode extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Roan Kattouw |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'wikieditorcode' => 'Improved code editing for wikiEditor', |
| 17 | + 'wikieditorcode-desc' => 'Uses a content-editable iframe in place of a textarea in the wikiEditor UI. Experimental. Do not deploy this ever!', |
| 18 | + 'wikieditorcode-preference' => 'Enable improved code editing (this is experimental)', |
| 19 | +); |
| 20 | + |
Property changes on: trunk/extensions/UsabilityInitiative/WikiEditorCode/WikiEditorCode.i18n.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 21 | + native |
Index: trunk/extensions/UsabilityInitiative/WikiEditorCode/WikiEditorCode.php |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Usability Initiative WikiEditorCode extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * |
| 9 | + * This file contains the include file for the WikiEditorCode 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/WikiEditorCode/WikiEditorCode.php" ); |
| 14 | + * |
| 15 | + * @author Trevor Parscal <tparscal@wikimedia.org> |
| 16 | + * @license GPL v2 or later |
| 17 | + * @version 0.0.1 |
| 18 | + */ |
| 19 | + |
| 20 | +/* Configuration */ |
| 21 | + |
| 22 | +// Set this to true to simply force WikiEditorCode on everyone |
| 23 | +$wgWikiEditorCodeGlobalEnable = false; |
| 24 | + |
| 25 | +// Set this to true to add a preference to the editing section of preferences |
| 26 | +// which enables and disables WikiEditorCode (if $wgWikiEditorCodeGlobalEnable, this |
| 27 | +// will not do anything) |
| 28 | +$wgWikiEditorCodeUserEnable = true; |
| 29 | + |
| 30 | +// Bump the version number every time you change any of the .css/.js files |
| 31 | +$wgWikiEditorCodeStyleVersion = 1; |
| 32 | + |
| 33 | +/* Setup */ |
| 34 | + |
| 35 | +// Credits |
| 36 | +$wgExtensionCredits['other'][] = array( |
| 37 | + 'path' => __FILE__, |
| 38 | + 'name' => 'WikiEditorCode', |
| 39 | + 'author' => 'Trevor Parscal', |
| 40 | + 'version' => '0.0.1', |
| 41 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:UsabilityInitiative', |
| 42 | + 'descriptionmsg' => 'wikieditorcode-desc', |
| 43 | +); |
| 44 | + |
| 45 | +// Includes parent extension |
| 46 | +require_once( dirname( dirname( __FILE__ ) ) . "/UsabilityInitiative.php" ); |
| 47 | + |
| 48 | +// Adds Autoload Classes |
| 49 | +$wgAutoloadClasses['WikiEditorCodeHooks'] = |
| 50 | + dirname( __FILE__ ) . '/WikiEditorCode.hooks.php'; |
| 51 | + |
| 52 | +// Adds Internationalized Messages |
| 53 | +$wgExtensionMessagesFiles['WikiEditorCode'] = |
| 54 | + dirname( __FILE__ ) . '/WikiEditorCode.i18n.php'; |
| 55 | + |
| 56 | +// Registers Hooks |
| 57 | +$wgHooks['EditPageBeforeEditToolbar'][] = 'WikiEditorCodeHooks::addCode'; |
| 58 | +$wgHooks['GetPreferences'][] = 'WikiEditorCodeHooks::addPreferences'; |
Property changes on: trunk/extensions/UsabilityInitiative/WikiEditorCode/WikiEditorCode.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 59 | + native |
Index: trunk/extensions/UsabilityInitiative/WikiEditorCode/WikiEditorCode.hooks.php |
— | — | @@ -0,0 +1,50 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Hooks for Usability Initiative WikiEditorCode extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +class WikiEditorCodeHooks { |
| 11 | + |
| 12 | + /* Static Functions */ |
| 13 | + |
| 14 | + /** |
| 15 | + * EditPage::showEditForm:initial hook |
| 16 | + * Adds the TOC to the edit form |
| 17 | + */ |
| 18 | + public static function addCode( &$toolbar ) { |
| 19 | + global $wgWikiEditorCodeStyleVersion, $wgUser; |
| 20 | + global $wgWikiEditorCodeGlobalEnable, $wgWikiEditorCodeUserEnable; |
| 21 | + |
| 22 | + if ( $wgWikiEditorCodeGlobalEnable || ( $wgWikiEditorCodeUserEnable && $wgUser->getOption( 'usewikieditorcode' ) ) ) { |
| 23 | + // Adds script to document |
| 24 | + UsabilityInitiativeHooks::initialize(); |
| 25 | + UsabilityInitiativeHooks::addScript( |
| 26 | + 'WikiEditorCode/WikiEditorCode.js', $wgWikiEditorCodeStyleVersion |
| 27 | + ); |
| 28 | + } |
| 29 | + return true; |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * GetPreferences hook |
| 34 | + * Add WikiEditorCode-related items to the preferences |
| 35 | + */ |
| 36 | + public static function addPreferences( $user, &$defaultPreferences ) { |
| 37 | + global $wgWikiEditorCodeGlobalEnable, $wgWikiEditorCodeUserEnable; |
| 38 | + |
| 39 | + if ( !$wgWikiEditorCodeGlobalEnable && $wgWikiEditorCodeUserEnable ) { |
| 40 | + wfLoadExtensionMessages( 'WikiEditorCode' ); |
| 41 | + // Adds preference for opting in |
| 42 | + $defaultPreferences['usewikieditorcode'] = |
| 43 | + array( |
| 44 | + 'type' => 'toggle', |
| 45 | + 'label-message' => 'wikieditorcode-preference', |
| 46 | + 'section' => 'editing/experimental', |
| 47 | + ); |
| 48 | + } |
| 49 | + return true; |
| 50 | + } |
| 51 | +} |
Property changes on: trunk/extensions/UsabilityInitiative/WikiEditorCode/WikiEditorCode.hooks.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 52 | + native |