http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95849
Revision: 95849
Author: siebrand
Date: 2011-08-31 10:38:42 +0000 (Wed, 31 Aug 2011)
Log Message:
-----------
stylize.php.
Use $dir instead of multiple times dirname( __FILE__ ).
Various whitespace and indentation updates.
Modified Paths:
--------------
trunk/extensions/Narayam/Narayam.hooks.php
trunk/extensions/Narayam/Narayam.i18n.php
trunk/extensions/Narayam/Narayam.php
trunk/extensions/Narayam/ext.narayam.core.js
trunk/extensions/Narayam/ext.narayam.rules.or-inscript.js
trunk/extensions/Narayam/ext.narayam.rules.si-singlish.js
trunk/extensions/Narayam/ext.narayam.rules.si-wijesekara.js
trunk/extensions/Narayam/ext.narayam.rules.ta.js
trunk/extensions/Narayam/ext.narayam.rules.ta99.js
Modified: trunk/extensions/Narayam/Narayam.hooks.php
===================================================================
--- trunk/extensions/Narayam/Narayam.hooks.php 2011-08-31 10:37:17 UTC (rev
95848)
+++ trunk/extensions/Narayam/Narayam.hooks.php 2011-08-31 10:38:42 UTC (rev
95849)
@@ -1,32 +1,37 @@
<?php
-
/**
* Hooks for Narayam extension
* @file
* @ingroup Extensions
*/
+
class NarayamHooks {
-
public static function addModules( $out, $skin ) {
global $wgUser;
+
if ( $wgUser->getOption( 'narayamDisable' ) ) {
// User disabled Narayam
return true;
}
+
$schemes = array_values( self::getSchemes () );
+
if ( count( $schemes ) ) {
$out->addModules( $schemes );
$out->addModules( 'ext.narayam' );
}
+
return true;
}
public static function addConfig( &$vars ) {
global $wgNarayamEnabledByDefault, $wgNarayamShortcutKey,
$wgUser;
+
if ( $wgUser->getOption( 'narayamDisable' ) ) {
// User disabled Narayam
return true;
}
+
$vars['wgNarayamEnabledByDefault'] = $wgNarayamEnabledByDefault;
$vars['wgNarayamShortcutKey'] = $wgNarayamShortcutKey;
@@ -35,11 +40,14 @@
public static function addVariables( &$vars ) {
global $wgUser;
+
if ( $wgUser->getOption( 'narayamDisable' ) ) {
// User disabled Narayam
return true;
}
+
$vars['wgNarayamAvailableSchemes'] = self::getSchemes(); //
Note: scheme names must be keys, not values
+
return true;
}
@@ -49,11 +57,13 @@
*/
protected static function getSchemes() {
global $wgLanguageCode, $wgLang, $wgNarayamSchemes;
+
$userlangCode = $wgLang->getCode();
$contlangSchemes = isset( $wgNarayamSchemes[$wgLanguageCode] ) ?
$wgNarayamSchemes[$wgLanguageCode] : array();
$userlangSchemes = isset( $wgNarayamSchemes[$userlangCode] ) ?
$wgNarayamSchemes[$userlangCode] : array();
+
return $userlangSchemes + $contlangSchemes;
}
@@ -64,7 +74,7 @@
'label-message' => 'narayam-disable-preference', // a
system message
'section' => 'editing/advancedediting', // under
'Advanced options' section of 'Editing' tab
);
+
return true;
}
-
}
Modified: trunk/extensions/Narayam/Narayam.i18n.php
===================================================================
--- trunk/extensions/Narayam/Narayam.i18n.php 2011-08-31 10:37:17 UTC (rev
95848)
+++ trunk/extensions/Narayam/Narayam.i18n.php 2011-08-31 10:38:42 UTC (rev
95849)
@@ -4,7 +4,7 @@
*
* @addtogroup Extensions
* @author Junaid P V <http://junaidpv.in>
- * @copyright 2010 Junaid P V
+ * @copyright 2010-2011 Junaid P V
* @license GNU General Public Licence 3.0 or later
*/
Modified: trunk/extensions/Narayam/Narayam.php
===================================================================
--- trunk/extensions/Narayam/Narayam.php 2011-08-31 10:37:17 UTC (rev
95848)
+++ trunk/extensions/Narayam/Narayam.php 2011-08-31 10:38:42 UTC (rev
95849)
@@ -1,5 +1,4 @@
<?php
-
/**
* NAME
* Narayam
@@ -23,11 +22,11 @@
* @copyright Copyright 2010 Junaid P V
* @license GPLv3
*/
+
if ( !defined( 'MEDIAWIKI' ) ) {
exit( 1 );
}
-
/* Configuration */
// Whether the input method should be active as default or not
@@ -91,6 +90,8 @@
/* Setup */
+$dir = dirname( __FILE__ );
+
// Register extension credits
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
@@ -102,7 +103,7 @@
);
// Localization
-$wgExtensionMessagesFiles['Narayam'] = dirname( __FILE__ ) .
'/Narayam.i18n.php';
+$wgExtensionMessagesFiles['Narayam'] = $dir . '/Narayam.i18n.php';
// Register hook function
$wgHooks['BeforePageDisplay'][] = 'NarayamHooks::addModules';
@@ -111,11 +112,11 @@
$wgHooks['GetPreferences'][] = 'NarayamHooks::addPreference';
// Autoloader
-$wgAutoloadClasses['NarayamHooks'] = dirname( __FILE__ ) .
'/Narayam.hooks.php';
+$wgAutoloadClasses['NarayamHooks'] = $dir . '/Narayam.hooks.php';
// ResourceLoader module registration
$narayamTpl = array(
- 'localBasePath' => dirname( __FILE__ ),
+ 'localBasePath' => $dir,
'remoteExtPath' => 'Narayam',
);
$wgResourceModules['ext.narayam'] = $narayamTpl + array(
Modified: trunk/extensions/Narayam/ext.narayam.core.js
===================================================================
--- trunk/extensions/Narayam/ext.narayam.core.js 2011-08-31 10:37:17 UTC
(rev 95848)
+++ trunk/extensions/Narayam/ext.narayam.core.js 2011-08-31 10:38:42 UTC
(rev 95849)
@@ -16,7 +16,7 @@
( function( $ ) {
$.narayam = new ( function() {
/* Private members */
-
+
// Reference to this object
var that = this;
// jQuery array holding all text inputs Narayam applies to
@@ -41,9 +41,9 @@
shiftKey: false,
key: null
};
-
+
/* Private functions */
-
+
/**
* Transliterate a string using the current scheme
* @param str String to transliterate
@@ -68,7 +68,7 @@
// No matches, return the input
return str;
}
-
+
/**
* Get the n characters in str that immediately precede pos
* Example: lastNChars( "foobarbaz", 5, 2 ) == "ba"
@@ -87,7 +87,7 @@
return str.substr( pos - n, n);
}
}
-
+
/**
* Find the point at which a and b diverge, i.e. the first position
* at which they don't have matching characters.
@@ -104,7 +104,7 @@
}
return -1;
}
-
+
/**
* Check whether a keypress event corresponds to the shortcut key
* @param e Event object
@@ -116,7 +116,7 @@
e.shiftKey == shortcutKey.shiftKey &&
String.fromCharCode( e.which ).toLowerCase() ==
shortcutKey.key.toLowerCase();
}
-
+
/**
* Get a description of the shortcut key, e.g. "Ctrl-M"
* @return string
@@ -136,7 +136,7 @@
text += shortcutKey.key.toUpperCase();
return text;
}
-
+
/**
* Change visual appearance of element (text input, textarea) according
* current state of Narayam
@@ -150,7 +150,7 @@
$element.removeClass( 'narayam-input' );
}
}
-
+
/**
* Keydown event handler. Handles shortcut key presses
* @param e Event object
@@ -168,7 +168,7 @@
}
return true;
}
-
+
/**
* Keypress event handler. This is where the real work happens
* @param e Event object
@@ -177,19 +177,19 @@
if ( !enabled ) {
return true;
}
-
+
if ( e.which == 8 ) { // Backspace
// Blank the keybuffer
$( this ).data( 'narayamKeyBuffer', '' );
return true;
}
-
+
// Leave non-ASCII stuff alone, as well as anything involving
// Alt (except for extended keymaps), Ctrl and Meta
if ( e.which < 32 || ( e.altKey &&
!currentScheme.extended_keyboard ) || e.ctrlKey || e.metaKey ) {
return true;
}
-
+
var $this = $( this );
var c = String.fromCharCode( e.which );
// Get the current caret position. The user may have selected
text to overwrite,
@@ -204,7 +204,7 @@
var input = lastNChars( $this.val(), startPos,
currentScheme.lookbackLength ) + c;
var keyBuffer = $this.data( 'narayamKeyBuffer' );
var replacement = transliterate( input, keyBuffer, e.altKey );
-
+
// Update the key buffer
keyBuffer += c;
if ( keyBuffer.length > currentScheme.keyBufferLength ) {
@@ -212,7 +212,7 @@
keyBuffer = keyBuffer.substring( keyBuffer.length -
currentScheme.keyBufferLength );
}
$this.data( 'narayamKeyBuffer', keyBuffer );
-
+
// textSelection() magic is expensive, so we avoid it as much
as we can
if ( replacement == input ) {
return true;
@@ -222,7 +222,7 @@
var divergingPos = firstDivergence( input, replacement );
input = input.substring( divergingPos );
replacement = replacement.substring( divergingPos );
-
+
// Select and replace the text
$this.textSelection( 'setSelection', {
'start': startPos - input.length + 1,
@@ -233,11 +233,11 @@
'replace': true,
'selectPeri': false
} );
-
+
e.stopPropagation();
return false;
}
-
+
/**
* Focus event handler.
* @param e Event object
@@ -246,7 +246,7 @@
$( this ).data( 'narayamKeyBuffer', '' );
changeVisual( $( this ) );
}
-
+
/**
* Blur event handler.
* @param e Event object
@@ -254,7 +254,7 @@
function onblur( e ) {
$( this ).removeClass( 'narayam-input' );
}
-
+
/**
* Change handler for the scheme dropdown. Updates the current scheme
* based on the new selection in the dropdown.
@@ -263,7 +263,7 @@
var scheme = $( this ).val();
that.setScheme( scheme );
}
-
+
/* Public functions */
/**
@@ -291,7 +291,7 @@
.bind( 'blur', onblur);
}
};
-
+
/**
* Enable Narayam
*/
@@ -302,7 +302,7 @@
enabled = true;
}
};
-
+
/**
* Disable Narayam
*/
@@ -313,7 +313,7 @@
enabled = false;
}
};
-
+
/**
* Toggle the enabled/disabled state
*/
@@ -324,7 +324,7 @@
that.enable();
}
};
-
+
/**
* Add a transliteration scheme. Schemes whose name is not in
* wgNarayamAvailableSchemes will be ignored.
@@ -373,7 +373,7 @@
return false;
}
};
-
+
/**
* Change the current transliteration scheme
* @param name String
@@ -385,7 +385,7 @@
$select.val( name );
}
};
-
+
/**
* Set up Narayam. This adds the scheme dropdown, binds the handlers
* and initializes the enabled/disabled state and selected scheme
@@ -403,18 +403,18 @@
haveSchemes = true;
}
$select.change( updateSchemeFromSelect );
-
+
if ( !haveSchemes ) {
// No schemes available, don't show the tool
return;
}
-
+
// Build enable/disable checkbox and label
var $checkbox = $( '<input type="checkbox" id="narayam-toggle"
/>' );
$checkbox
.attr( 'title', mw.msg( 'narayam-checkbox-tooltip' ) )
.click( that.toggle );
-
+
var helppage = mw.msg( 'narayam-help-page' );
var $label = $( '<label for="narayam-toggle" />' );
$label
@@ -424,7 +424,7 @@
// Link to the help page
$label.wrapInner( $( '<a />' ).attr( 'href',
mw.util.wikiGetlink( helppage ) ) );
}
-
+
var $checkboxAndLabel = $( '<span />' )
.addClass( 'narayam-toggle-wrapper' )
.append( $checkbox )
@@ -433,11 +433,11 @@
.addClass( 'narayam-wrapper' )
.append( $select )
.append( $checkboxAndLabel );
-
+
// Put the dropdown and the checkbox at the beginning of the
// search form. This seems to be the most reliable way across
skins.
$( '#searchform' ).prepend( $spanWithEverything );
-
+
// Restore state from cookies
var savedScheme = $.cookie( 'narayam-scheme' );
if ( savedScheme && savedScheme in schemes ) {
@@ -453,9 +453,9 @@
if ( enabledCookie ) {
$.cookie( 'narayam-enabled', enabledCookie, { 'path':
'/', 'expires': 30 } );
}
-
+
};
-
+
} )();
} )( jQuery );
Modified: trunk/extensions/Narayam/ext.narayam.rules.or-inscript.js
===================================================================
--- trunk/extensions/Narayam/ext.narayam.rules.or-inscript.js 2011-08-31
10:37:17 UTC (rev 95848)
+++ trunk/extensions/Narayam/ext.narayam.rules.or-inscript.js 2011-08-31
10:38:42 UTC (rev 95849)
@@ -5,7 +5,7 @@
* @date 2011-02-28
* License: GPLv3
*/
-
+
var rules = [
['X', '', '\u0B01'],
['x', '', '\u0B02'],
Modified: trunk/extensions/Narayam/ext.narayam.rules.si-singlish.js
===================================================================
--- trunk/extensions/Narayam/ext.narayam.rules.si-singlish.js 2011-08-31
10:37:17 UTC (rev 95848)
+++ trunk/extensions/Narayam/ext.narayam.rules.si-singlish.js 2011-08-31
10:38:42 UTC (rev 95849)
@@ -5,7 +5,7 @@
* @credits With help from Nishantha Anuruddha
(si.wikipedia.org/wiki/user:බිඟුවා)
* License: GPLv3
*/
-
+
// Normal rules
var rules = [
['\\\\([A-Za-z\\>_~\\.0-9])', '\\\\','$1'],
@@ -104,4 +104,4 @@
'lookbackLength': 5,
'keyBufferLength': 2,
'rules': rules
-} );
+} );
Modified: trunk/extensions/Narayam/ext.narayam.rules.si-wijesekara.js
===================================================================
--- trunk/extensions/Narayam/ext.narayam.rules.si-wijesekara.js 2011-08-31
10:37:17 UTC (rev 95848)
+++ trunk/extensions/Narayam/ext.narayam.rules.si-wijesekara.js 2011-08-31
10:38:42 UTC (rev 95849)
@@ -6,14 +6,14 @@
* http://www.ucsc.lk/ltrl/services/layout/
* License: GPLv3
*/
-
+
var rules = [
['`', '', '්ර'],
['~', '', 'ර්'],
['q', '', 'ු'],
['w', '', 'අ'],
-['e', '', 'ැ'],
+['e', '', 'ැ'],
['r', '', 'ර'],
['t', '', 'එ'],
['y', '', 'හ'],
@@ -95,4 +95,4 @@
'keyBufferLength': 0,
'rules': rules,
'rules_x': rules_x
-} );
+} );
Modified: trunk/extensions/Narayam/ext.narayam.rules.ta.js
===================================================================
--- trunk/extensions/Narayam/ext.narayam.rules.ta.js 2011-08-31 10:37:17 UTC
(rev 95848)
+++ trunk/extensions/Narayam/ext.narayam.rules.ta.js 2011-08-31 10:38:42 UTC
(rev 95849)
@@ -11,7 +11,7 @@
['ழ்h','h','ழ்ஹ்',],
//'(ஸ்ரிi|ஸ்ர்I)', '','',
-
+
['([க-ஹ])்a', '','$1'],
['([க-ஹ])(்A|a)', '','$1ா'],
['([க-ஹ])்i', '','$1ி'],
@@ -26,7 +26,7 @@
['([க-ஹ])u', '','$1ௌ'],
['([அ-ஹ][ெ-்]?)n', '','$1ன்'],
-
+
['அa', '','ஆ'],
['இi', '','ஈ'],
['உu', '','ஊ'],
@@ -34,14 +34,14 @@
['அi', '','ஐ'],
['ஒo', '','ஓ'],
['அu', '','ஔ'],
-
+
['(ந்|ன்)g', '','ங்'],
['(ந்|ன்)j', '','ஞ்'],
['ச்h', '','ச்'],
['ழ்h', '','ழ்'],
['ட்h', '','த்'],
['ஸ்h', '','ஷ்'],
-
+
['a', '','அ'],
['b', '','ப்'],
['c', '','ச்'],
Modified: trunk/extensions/Narayam/ext.narayam.rules.ta99.js
===================================================================
--- trunk/extensions/Narayam/ext.narayam.rules.ta99.js 2011-08-31 10:37:17 UTC
(rev 95848)
+++ trunk/extensions/Narayam/ext.narayam.rules.ta99.js 2011-08-31 10:38:42 UTC
(rev 95849)
@@ -100,7 +100,7 @@
['ணo', '','ண்ட'],
['ஞ\\[', '','ஞ்ச'],
['மj', '','ம்ப'],
-
+
['q', '','ஆ'],
['w', '','ஈ'],
['e', '','ஊ'],
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs