r78494 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78493‎ | r78494 | r78495 >
Date:16:09, 16 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added new class for static methods and javascript file stub for the translation interface
Modified paths:
  • /trunk/extensions/LiveTranslate/LiveTranslate.php (modified) (history)
  • /trunk/extensions/LiveTranslate/includes (added) (history)
  • /trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php (added) (history)
  • /trunk/extensions/LiveTranslate/includes/ext.livetranslate.js (added) (history)

Diff [purge]

Index: trunk/extensions/LiveTranslate/LiveTranslate.php
@@ -47,6 +47,7 @@
4848
4949 $wgAutoloadClasses['LiveTranslateHooks'] = $egLiveTranslateIP . '/LiveTranslate.hooks.php';
5050 $wgAutoloadClasses['ApiLiveTranslate'] = $egLiveTranslateIP . '/api/ApiLiveTranslate.php';
 51+$wgAutoloadClasses['LiveTranslateFunctions'] = $egLiveTranslateIP . '/includes/LiveTranslateFunctions.php';
5152
5253 $wgAPIModules['livetranslate'] = 'ApiLiveTranslate';
5354
@@ -55,5 +56,23 @@
5657 $wgHooks['ArticleSaveComplete'][] = 'LiveTranslateHooks::onArticleSaveComplete';
5758 $wgHooks['OutputPageBeforeHTML'][] = 'LiveTranslateHooks::onOutputPageBeforeHTML';
5859
 60+$egLTJSMessages = array(
5961
 62+);
 63+
 64+// For backward compatibility with MW < 1.17.
 65+if ( is_callable( array( 'OutputPage', 'addModules' ) ) ) {
 66+ $moduleTemplate = array(
 67+ 'localBasePath' => dirname( __FILE__ ),
 68+ 'remoteBasePath' => $egLiveTranslateScriptPath,
 69+ 'group' => 'ext.livetranslate'
 70+ );
 71+
 72+ $wgResourceModules['ext.livetranslate'] = $moduleTemplate + array(
 73+ 'scripts' => 'includes/ext.livetranslate.js',
 74+ 'dependencies' => array(),
 75+ 'messages' => $egLTJSMessages
 76+ );
 77+}
 78+
6079 require_once 'LiveTranslate_Settings.php';
Index: trunk/extensions/LiveTranslate/includes/ext.livetranslate.js
@@ -0,0 +1,28 @@
 2+/**
 3+ * JavasSript for the Push tab in the Push extension.
 4+ * @see http://www.mediawiki.org/wiki/Extension:Push
 5+ *
 6+ * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
 7+ */
 8+
 9+(function($) { $( document ).ready( function() {
 10+
 11+ // Compatibility with pre-RL code.
 12+ // Messages will have been loaded into wgPushMessages.
 13+ if ( typeof mediaWiki === 'undefined' ) {
 14+ mediaWiki = new Object();
 15+
 16+ mediaWiki.msg = function() {
 17+ message = window.wgLTEMessages[arguments[0]];
 18+
 19+ for ( var i = arguments.length - 1; i > 0; i-- ) {
 20+ message = message.replace( '$' + i, arguments[i] );
 21+ }
 22+
 23+ return message;
 24+ }
 25+ }
 26+
 27+
 28+
 29+} ); })(jQuery);
\ No newline at end of file
Property changes on: trunk/extensions/LiveTranslate/includes/ext.livetranslate.js
___________________________________________________________________
Added: svn:eol-style
130 + native
Index: trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php
@@ -0,0 +1,33 @@
 2+<?php
 3+
 4+/**
 5+ * Statis class with utility methods for the Live Translate extension.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file LiveTranslate_Functions.php
 10+ * @ingroup LiveTranslate
 11+ *
 12+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 13+ */
 14+final class PushFunctions {
 15+
 16+ /**
 17+ * Adds the needed JS messages to the page output.
 18+ * This is for backward compatibility with pre-RL MediaWiki.
 19+ *
 20+ * @since 0.1
 21+ */
 22+ public static function addJSLocalisation() {
 23+ global $egLTJSMessages, $wgOut;
 24+
 25+ $data = array();
 26+
 27+ foreach ( $egLTJSMessages as $msg ) {
 28+ $data[$msg] = wfMsgNoTrans( $msg );
 29+ }
 30+
 31+ $wgOut->addInlineScript( 'var wgLTEMessages = ' . json_encode( $data ) . ';' );
 32+ }
 33+
 34+}
\ No newline at end of file
Property changes on: trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php
___________________________________________________________________
Added: svn:eol-style
135 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r78495Comment fix - follow up to r78494jeroendedauw16:24, 16 December 2010

Status & tagging log