From e3d84fb05d6630b3c990ae23ca60d6b91af34a6f Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 16 Jun 2009 10:23:27 +0000 Subject: [PATCH] MDL-19522 dragmath plugin now fully supports localization --- lang/en_utf8/editor_tinymce.php | 4 +- .../tinymce/extra/tools/compress_dragmath.cmd | 1 + .../tinymce/plugins/dragmath/dragmath.php | 37 +++-- .../tinymce/plugins/dragmath/editor_plugin.js | 2 +- .../plugins/dragmath/editor_plugin_src.js | 154 +++++++++--------- 5 files changed, 109 insertions(+), 89 deletions(-) create mode 100644 lib/editor/tinymce/extra/tools/compress_dragmath.cmd diff --git a/lang/en_utf8/editor_tinymce.php b/lang/en_utf8/editor_tinymce.php index 152b832c9a..134513e17a 100644 --- a/lang/en_utf8/editor_tinymce.php +++ b/lang/en_utf8/editor_tinymce.php @@ -1,9 +1,11 @@ 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'); ?> -"DragMath Equation Editor +<?php print_string('dragmath:dragmath_title', 'editor_tinymce')?> @@ -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" > - + - To use this page you need a Java-enabled browser. - Download the latest Java plug-in from - Java.com + Java.com')?>
- - + +
diff --git a/lib/editor/tinymce/plugins/dragmath/editor_plugin.js b/lib/editor/tinymce/plugins/dragmath/editor_plugin.js index 96c5c639a8..437c97fb44 100644 --- a/lib/editor/tinymce/plugins/dragmath/editor_plugin.js +++ b/lib/editor/tinymce/plugins/dragmath/editor_plugin.js @@ -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 diff --git a/lib/editor/tinymce/plugins/dragmath/editor_plugin_src.js b/lib/editor/tinymce/plugins/dragmath/editor_plugin_src.js index 1ae22fbac2..be68393e5d 100644 --- a/lib/editor/tinymce/plugins/dragmath/editor_plugin_src.js +++ b/lib/editor/tinymce/plugins/dragmath/editor_plugin_src.js @@ -1,78 +1,78 @@ -(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'); - 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, // Plugin absolute URL - some_custom_arg : 'custom arg' // Custom argument - }); - }); - - // Register example button - ed.addButton('dragmath', { - title : 'Insert Equation', - 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); +(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 -- 2.39.5