]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19522 dragmath plugin now fully supports localization
authorskodak <skodak>
Tue, 16 Jun 2009 10:23:27 +0000 (10:23 +0000)
committerskodak <skodak>
Tue, 16 Jun 2009 10:23:27 +0000 (10:23 +0000)
lang/en_utf8/editor_tinymce.php
lib/editor/tinymce/extra/tools/compress_dragmath.cmd [new file with mode: 0644]
lib/editor/tinymce/plugins/dragmath/dragmath.php
lib/editor/tinymce/plugins/dragmath/editor_plugin.js
lib/editor/tinymce/plugins/dragmath/editor_plugin_src.js

index 152b832c9a316bcf8e184a165b80252be7d2b546..134513e17aac224489ed5a329d5c588c9a79117a 100644 (file)
@@ -1,9 +1,11 @@
 <?php
 
 //== Custom Moodle strings that are not part of upstream TinyMCE ==
+$string['dragmath:dragmath_desc'] = 'Inser equation';
+$string['dragmath:dragmath_javaneeded'] = 'To use this page you need a Java-enabled browser. Download the latest Java plug-in from $a.';
+$string['dragmath:dragmath_title'] = 'DragMath Equation Editor';
 $string['modulename'] = 'TinyMCE HTML editor';
 
-
 // == TinyMCE upstream lang strings from all plugins ==
 $string['advanced:address'] = 'Address';
 $string['advanced:anchor_delta_height'] = '';
diff --git a/lib/editor/tinymce/extra/tools/compress_dragmath.cmd b/lib/editor/tinymce/extra/tools/compress_dragmath.cmd
new file mode 100644 (file)
index 0000000..6d5dc5a
--- /dev/null
@@ -0,0 +1 @@
+java -jar yuicompressor.jar --line-break 1000 ..\..\plugins\dragmath\editor_plugin_src.js -o ..\..\plugins\dragmath\editor_plugin.js\r
index 4c579ddc162fe58f4d606c7294330002cec515aa..9a1b2cf27e6e112475a2dc021371aba180e01994 100644 (file)
@@ -1,19 +1,38 @@
 <?php
 
+define('NO_MOODLE_COOKIES', true);
+
 require("../../../../../config.php");
 
-$id = optional_param('id', SITEID, PARAM_INT);
+$lang = required_param('elanguage', PARAM_SAFEDIR);
 
-require_course_login($id);
-@header('Content-Type: text/html; charset=utf-8');
+if (file_exists("$CFG->dataroot/lang/$lang") or file_exists("$CFG->dirroot/lang/$lang")) {
+    $SESSION->lang = $lang;
+} else if (file_exists("$CFG->dataroot/lang/{$lang}_utf8") or file_exists("$CFG->dirroot/lang/{$lang}_utf8")) {
+    $SESSION->lang = $lang.'_utf8';
+}
+
+$lang = str_replace('_utf8', '', $lang);
+
+$langmapping = array('cs'=>'cz', 'pt_br'=>'pt-br');
 
+// fix non-standard lang names
+if (array_key_exists($lang, $langmapping)) {
+    $lang = $langmapping[$lang];
+}
+
+if (!file_exists("$CFG->dirroot/lib/dragmath/applet/lang/$lang.xml")) {
+    $lang = 'en';
+}
+
+@header('Content-Type: text/html; charset=utf-8');
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html>
 <head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<title>"DragMath Equation Editor</title>
+<title><?php print_string('dragmath:dragmath_title', 'editor_tinymce')?></title>
 <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
 <script type="text/javascript" src="js/dragmath.js"></script>
 </head>
@@ -26,17 +45,15 @@ require_course_login($id);
        archive="Project.jar,lib/AbsoluteLayout.jar,lib/swing-layout-1.0.jar,lib/jdom.jar,lib/jep.jar" 
        width="540" height="300"
 >
-       <param name="language" value="en" />
+       <param name="language" value="<?php echo $lang; ?>" />
        <param name="outputFormat" value="Latex" />
        <param name="showOutputToolBar" value="false" />
-       To use this page you need a Java-enabled browser. 
-       Download the latest Java plug-in from 
-       <a href="http://www.java.com">Java.com</a>
+    <?php print_string('dragmath:dragmath_javaneeded', 'editor_tinymce', '<a href="http://www.java.com">Java.com</a>')?>
 </applet>
 <form name="form" action="">
        <div>
-       <button type="button" onclick="return DragMathDialog.insert();">Insert</button>
-       <button type="button" onclick="return tinyMCEPopup.close();">Cancel</button>
+       <button type="button" onclick="return DragMathDialog.insert();"><?php print_string('common:insert', 'editor_tinymce'); ?></button>
+       <button type="button" onclick="return tinyMCEPopup.close();"><?php print_string('cancel'); ?></button>
        </div>
 </form>
 
index 96c5c639a8ebdab5d2db0fb5239ebdf8dd624ba1..437c97fb44c598bdbfbff9424a91b091983d37d5 100644 (file)
@@ -1 +1 @@
-(function(){tinymce.create('tinymce.plugins.DragMathPlugin',{init:function(ed,url){course_id=tinyMCE.activeEditor.getParam('moodleimage_course_id');ed.addCommand('mceDragMath',function(){ed.windowManager.open({file:url+'/dragmath.php?id='+course_id,width:540,height:380,inline:1},{plugin_url:url,some_custom_arg:'custom arg'});});ed.addButton('dragmath',{title:'Insert Equation',cmd:'mceDragMath',image:url+'/img/dragmath.gif'});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('dragmath',n.nodeName=='IMG');});},createControl:function(n,cm){return null;},getInfo:function(){return{longname:'Moodle Dragmath plugin',author:'Glen Davies',authorurl:'http://www.canterbury.ac.nz',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',version:"1.0"};}});tinymce.PluginManager.add('dragmath',tinymce.plugins.DragMathPlugin);})();
\ No newline at end of file
+(function(){tinymce.create("tinymce.plugins.DragMathPlugin",{init:function(a,b){lang=tinyMCE.activeEditor.getParam("language");a.addCommand("mceDragMath",function(){a.windowManager.open({file:b+"/dragmath.php?elanguage="+lang,width:540,height:380,inline:1},{plugin_url:b,some_custom_arg:"custom arg"})});a.addButton("dragmath",{title:"Insert Equation",cmd:"mceDragMath",image:b+"/img/dragmath.gif"});a.onNodeChange.add(function(d,c,e){c.setActive("dragmath",e.nodeName=="IMG")})},createControl:function(b,a){return null},getInfo:function(){return{longname:"Moodle Dragmath plugin",author:"Glen Davies",authorurl:"http://www.canterbury.ac.nz",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example",version:"1.0"}}});tinymce.PluginManager.add("dragmath",tinymce.plugins.DragMathPlugin)})();
\ No newline at end of file
index 1ae22fbac2aee9fa12914980d65aae9d57e548d3..be68393e5db25dc2386e0f5a43266f8edaca5baf 100644 (file)
@@ -1,78 +1,78 @@
-(function() {\r
-       // Load plugin specific language pack\r
-       //tinymce.PluginManager.requireLangPack('example');\r
-\r
-       tinymce.create('tinymce.plugins.DragMathPlugin', {\r
-               /**\r
-                * Initializes the plugin, this will be executed after the plugin has been created.\r
-                * This call is done before the editor instance has finished it's initialization so use the onInit event\r
-                * of the editor instance to intercept that event.\r
-                *\r
-                * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.\r
-                * @param {string} url Absolute URL to where the plugin is located.\r
-                */\r
-               init : function(ed, url) {\r
-                       // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');\r
-                       course_id = tinyMCE.activeEditor.getParam('moodleimage_course_id');\r
-                       \r
-                       ed.addCommand('mceDragMath', function() {\r
-                               ed.windowManager.open({\r
-                                       \r
-                                       file : url + '/dragmath.php?id=' + course_id,\r
-                                       width : 540,\r
-                                       height : 380,\r
-                                       inline : 1\r
-                               }, {\r
-                                       plugin_url : url, // Plugin absolute URL\r
-                                       some_custom_arg : 'custom arg' // Custom argument\r
-                               });\r
-                       });\r
-\r
-                       // Register example button\r
-                       ed.addButton('dragmath', {\r
-                               title : 'Insert Equation',\r
-                               cmd : 'mceDragMath',\r
-                               image : url + '/img/dragmath.gif'\r
-                       });\r
-                       \r
-\r
-                       // Add a node change handler, selects the button in the UI when a image is selected\r
-                       ed.onNodeChange.add(function(ed, cm, n) {\r
-                               cm.setActive('dragmath', n.nodeName == 'IMG');\r
-                       });\r
-               },\r
-\r
-               /**\r
-                * Creates control instances based in the incomming name. This method is normally not\r
-                * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons\r
-                * but you sometimes need to create more complex controls like listboxes, split buttons etc then this\r
-                * method can be used to create those.\r
-                *\r
-                * @param {String} n Name of the control to create.\r
-                * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.\r
-                * @return {tinymce.ui.Control} New control instance or null if no control was created.\r
-                */\r
-               createControl : function(n, cm) {\r
-                       return null;\r
-               },\r
-\r
-               /**\r
-                * Returns information about the plugin as a name/value array.\r
-                * The current keys are longname, author, authorurl, infourl and version.\r
-                *\r
-                * @return {Object} Name/value array containing information about the plugin.\r
-                */\r
-               getInfo : function() {\r
-                       return {\r
-                               longname : 'Moodle Dragmath plugin',\r
-                               author : 'Glen Davies',\r
-                               authorurl : 'http://www.canterbury.ac.nz',\r
-                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',\r
-                               version : "1.0"\r
-                       };\r
-               }\r
-       });\r
-\r
-       // Register plugin\r
-       tinymce.PluginManager.add('dragmath', tinymce.plugins.DragMathPlugin);\r
+(function() {
+       // Load plugin specific language pack
+       //tinymce.PluginManager.requireLangPack('example');
+
+       tinymce.create('tinymce.plugins.DragMathPlugin', {
+               /**
+                * Initializes the plugin, this will be executed after the plugin has been created.
+                * This call is done before the editor instance has finished it's initialization so use the onInit event
+                * of the editor instance to intercept that event.
+                *
+                * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
+                * @param {string} url Absolute URL to where the plugin is located.
+                */
+               init : function(ed, url) {
+                       // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
+                       lang = tinyMCE.activeEditor.getParam('language');
+                       
+                       ed.addCommand('mceDragMath', function() {
+                               ed.windowManager.open({
+                                       
+                                       file : url + '/dragmath.php?elanguage=' + lang,
+                                       width : 540,
+                                       height : 380,
+                                       inline : 1
+                               }, {
+                                       plugin_url : url, // Plugin absolute URL
+                                       some_custom_arg : 'custom arg' // Custom argument
+                               });
+                       });
+
+                       // Register example button
+                       ed.addButton('dragmath', {
+                               title : 'dragmath.dragmath_desc',
+                               cmd : 'mceDragMath',
+                               image : url + '/img/dragmath.gif'
+                       });
+                       
+
+                       // Add a node change handler, selects the button in the UI when a image is selected
+                       ed.onNodeChange.add(function(ed, cm, n) {
+                               cm.setActive('dragmath', n.nodeName == 'IMG');
+                       });
+               },
+
+               /**
+                * Creates control instances based in the incomming name. This method is normally not
+                * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
+                * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
+                * method can be used to create those.
+                *
+                * @param {String} n Name of the control to create.
+                * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
+                * @return {tinymce.ui.Control} New control instance or null if no control was created.
+                */
+               createControl : function(n, cm) {
+                       return null;
+               },
+
+               /**
+                * Returns information about the plugin as a name/value array.
+                * The current keys are longname, author, authorurl, infourl and version.
+                *
+                * @return {Object} Name/value array containing information about the plugin.
+                */
+               getInfo : function() {
+                       return {
+                               longname : 'Moodle Dragmath plugin',
+                               author : 'Glen Davies',
+                               authorurl : 'http://www.canterbury.ac.nz',
+                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',
+                               version : "1.0"
+                       };
+               }
+       });
+
+       // Register plugin
+       tinymce.PluginManager.add('dragmath', tinymce.plugins.DragMathPlugin);
 })();
\ No newline at end of file