MDL-19522 dragmath plugin now fully supports localization

This commit is contained in:
skodak
2009-06-16 10:23:27 +00:00
parent 70f01544e1
commit e3d84fb05d
5 changed files with 109 additions and 89 deletions
+3 -1
View 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'] = '';
@@ -0,0 +1 @@
java -jar yuicompressor.jar --line-break 1000 ..\..\plugins\dragmath\editor_plugin_src.js -o ..\..\plugins\dragmath\editor_plugin.js
@@ -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);
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';
}
require_course_login($id);
@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>
@@ -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);})();
(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)})();
@@ -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);
})();