Permalink
Browse files

MDL-33041 (4) Use new system for existing added TinyMCE plugins

AMOS BEGIN
  MOV [dragmath:dragmath_desc,editor_tinymce],[dragmath_desc,tinymce_dragmath]
  MOV [dragmath:dragmath_javaneeded,editor_tinymce],[dragmath_javaneeded,tinymce_dragmath]
  MOV [dragmath:dragmath_title,editor_tinymce],[dragmath_title,tinymce_dragmath]
  MOV [moodleemoticon:desc,editor_tinymce],[desc,tinymce_moodleemoticon]
  MOV [moodlenolink:desc,editor_tinymce],[desc,tinymce_moodlenolink]
  CPY [desc,tinymce_moodleemoticon],[pluginname,tinymce_moodleemoticon]
  CPY [desc,tinymce_moodlenolink],[pluginname,tinymce_moodlenolink]
AMOS END
  • Loading branch information...
1 parent fae9117 commit 204903363f923e9f280b18fad630b14e5ad66261 @sammarshallou sammarshallou committed with skodak May 16, 2012
Showing with 465 additions and 74 deletions.
  1. +0 −5 lib/editor/tinymce/lang/en/editor_tinymce.php
  2. +5 −29 lib/editor/tinymce/lib.php
  3. +6 −3 lib/editor/tinymce/{tiny_mce/3.5.4.1 → }/plugins/dragmath/dragmath.php
  4. +29 −0 lib/editor/tinymce/plugins/dragmath/lang/en/tinymce_dragmath.php
  5. +43 −0 lib/editor/tinymce/plugins/dragmath/lib.php
  6. +4 −4 ...ny_mce/3.5.4.1/plugins/dragmath/editor_plugin_src.js → plugins/dragmath/tinymce/editor_plugin.js}
  7. BIN lib/editor/tinymce/{tiny_mce/3.5.4.1/plugins/dragmath → plugins/dragmath/tinymce}/img/dragmath.gif
  8. 0 lib/editor/tinymce/{tiny_mce/3.5.4.1/plugins/dragmath → plugins/dragmath/tinymce}/js/dragmath.js
  9. 0 lib/editor/tinymce/{tiny_mce/3.5.4.1/plugins/dragmath → plugins/dragmath/tinymce}/langs/en_dlg.js
  10. +32 −0 lib/editor/tinymce/plugins/dragmath/version.php
  11. +7 −7 lib/editor/tinymce/{tiny_mce/3.5.4.1 → }/plugins/moodleemoticon/dialog.php
  12. +27 −0 lib/editor/tinymce/plugins/moodleemoticon/lang/en/tinymce_moodleemoticon.php
  13. +55 −0 lib/editor/tinymce/plugins/moodleemoticon/lib.php
  14. +1 −1 ....1/plugins/moodleemoticon/editor_plugin_src.js → plugins/moodleemoticon/tinymce/editor_plugin.js}
  15. BIN ...{tiny_mce/3.5.4.1/plugins/moodleemoticon → plugins/moodleemoticon/tinymce}/img/moodleemoticon.gif
  16. 0 ...r/tinymce/{tiny_mce/3.5.4.1/plugins/moodleemoticon → plugins/moodleemoticon/tinymce}/js/dialog.js
  17. +32 −0 lib/editor/tinymce/plugins/moodleemoticon/version.php
  18. +25 −0 lib/editor/tinymce/plugins/moodlemedia/lang/en/tinymce_moodlemedia.php
  19. +48 −0 lib/editor/tinymce/plugins/moodlemedia/lib.php
  20. +4 −4 lib/editor/tinymce/{tiny_mce/3.5.4.1 → }/plugins/moodlemedia/preview.php
  21. 0 ...editor/tinymce/{tiny_mce/3.5.4.1/plugins/moodlemedia → plugins/moodlemedia/tinymce}/css/media.css
  22. +2 −2 .../3.5.4.1/plugins/moodlemedia/editor_plugin_src.js → plugins/moodlemedia/tinymce/editor_plugin.js}
  23. BIN lib/editor/tinymce/{tiny_mce/3.5.4.1/plugins/moodlemedia → plugins/moodlemedia/tinymce}/img/icon.gif
  24. +1 −1 lib/editor/tinymce/{tiny_mce/3.5.4.1/plugins/moodlemedia → plugins/moodlemedia/tinymce}/js/media.js
  25. +14 −5 ...itor/tinymce/{tiny_mce/3.5.4.1/plugins/moodlemedia → plugins/moodlemedia/tinymce}/moodlemedia.htm
  26. +32 −0 lib/editor/tinymce/plugins/moodlemedia/version.php
  27. +27 −0 lib/editor/tinymce/plugins/moodlenolink/lang/en/tinymce_moodlenolink.php
  28. +37 −0 lib/editor/tinymce/plugins/moodlenolink/lib.php
  29. +2 −2 ....5.4.1/plugins/moodlenolink/editor_plugin_src.js → plugins/moodlenolink/tinymce/editor_plugin.js}
  30. BIN .../tinymce/{tiny_mce/3.5.4.1/plugins/moodlenolink → plugins/moodlenolink/tinymce}/img/ed_nolink.gif
  31. 0 ...editor/tinymce/{tiny_mce/3.5.4.1/plugins/moodlenolink → plugins/moodlenolink/tinymce}/langs/en.js
  32. +32 −0 lib/editor/tinymce/plugins/moodlenolink/version.php
  33. +0 −5 lib/editor/tinymce/readme_moodle.txt
  34. +0 −1 lib/editor/tinymce/tiny_mce/3.5.4.1/plugins/dragmath/editor_plugin.js
  35. +0 −2 lib/editor/tinymce/tiny_mce/3.5.4.1/plugins/moodleemoticon/editor_plugin.js
  36. +0 −1 lib/editor/tinymce/tiny_mce/3.5.4.1/plugins/moodlemedia/editor_plugin.js
  37. +0 −2 lib/editor/tinymce/tiny_mce/3.5.4.1/plugins/moodlenolink/editor_plugin.js
@@ -28,13 +28,8 @@
//== Custom Moodle strings that are not part of upstream TinyMCE ==
$string['common:browseimage'] = 'Find or upload an image...';
$string['common:browsemedia'] = 'Find or upload a sound, video or applet...';
-$string['dragmath:dragmath_desc'] = 'Insert 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['fontselectlist'] = 'Available fonts list';
$string['media_dlg:filename'] = 'Filename';
-$string['moodleemoticon:desc'] = 'Insert emoticon';
-$string['moodlenolink:desc'] = 'Prevent automatic linking';
$string['pluginname'] = 'TinyMCE HTML editor';
View
@@ -103,18 +103,6 @@ protected function get_init_params($elementid, array $options=null) {
$fontselectlist = empty($config->fontselectlist) ? '' : $config->fontselectlist;
$fontbutton = ($fontselectlist === '') ? '' : 'fontselect,';
- $filters = filter_get_active_in_context($context);
- if (array_key_exists('filter/tex', $filters)) {
- $xdragmath = 'dragmath,';
- } else {
- $xdragmath = '';
- }
- if (array_key_exists('filter/emoticon', $filters)) {
- $xemoticon = 'moodleemoticon,';
- } else {
- $xemoticon = '';
- }
-
$params = array(
'mode' => "exact",
'elements' => $elementid,
@@ -131,7 +119,10 @@ protected function get_init_params($elementid, array $options=null) {
'apply_source_formatting' => true,
'remove_script_host' => false,
'entity_encoding' => "raw",
- 'plugins' => "moodlemedia,advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xemoticon}{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak,spellchecker",
+ 'plugins' => 'advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,' .
+ 'searchreplace,paste,directionality,fullscreen,nonbreaking,contextmenu,' .
+ 'insertdatetime,save,iespell,preview,print,noneditable,visualchars,' .
+ 'xhtmlxtras,template,pagebreak,spellchecker',
'theme_advanced_font_sizes' => "1,2,3,4,5,6,7",
'theme_advanced_layout_manager' => "SimpleLayout",
'theme_advanced_toolbar_align' => "left",
@@ -141,9 +132,7 @@ protected function get_init_params($elementid, array $options=null) {
'justifyleft,justifycenter,justifyright,|,' .
'cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl',
'theme_advanced_buttons3' => 'bullist,numlist,outdent,indent,|,' .
- 'link,unlink,moodlenolink,|,' .
- "image,{$xemoticon}moodlemedia,{$xdragmath}nonbreaking,charmap,table,|," .
- 'code' . $spellbutton,
+ 'link,unlink,|,image,nonbreaking,charmap,table,|,code' . $spellbutton,
'theme_advanced_fonts' => $fontselectlist,
'theme_advanced_resize_horizontal' => true,
'theme_advanced_resizing' => true,
@@ -155,19 +144,6 @@ protected function get_init_params($elementid, array $options=null) {
'spellchecker_languages' => $spelllanguagelist
);
- if ($xemoticon) {
- $manager = get_emoticon_manager();
- $emoticons = $manager->get_emoticons();
- $imgs = array();
- // see the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used :-S
- $index = 0;
- foreach ($emoticons as $emoticon) {
- $imgs[$emoticon->text] = $OUTPUT->render(
- $manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-'.$index++)));
- }
- $params['moodleemoticon_emoticons'] = json_encode($imgs);
- }
-
if (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted'])) {
// now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
// but they scream even more when we strip all tags that are not strict :-(
@@ -2,7 +2,7 @@
define('NO_MOODLE_COOKIES', true);
-require("../../../../../../../config.php");
+require("../../../../../config.php");
$lang = required_param('elanguage', PARAM_SAFEDIR);
@@ -22,6 +22,9 @@
$lang = 'en';
}
+$editor = get_texteditor('tinymce');
+$plugin = $editor->get_plugin('dragmath');
+
@header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -30,8 +33,8 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<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>
+<script type="text/javascript" src="../../tiny_mce/<?php echo $editor->version ?>/tiny_mce_popup.js"></script>
+<script type="text/javascript" src="<?php echo $plugin->get_tinymce_file_url('js/dragmath.js'); ?>"></script>
</head>
<body>
@@ -0,0 +1,29 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for dragmath editor plugin.
+ *
+ * @package tinymce_dragmath
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['pluginname'] = 'Insert equation';
+
+$string['dragmath_desc'] = 'Insert equation';
+$string['dragmath_javaneeded'] = 'To use this page you need a Java-enabled browser. Download the latest Java plug-in from {$a}.';
+$string['dragmath_title'] = 'DragMath Equation Editor';
@@ -0,0 +1,43 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Plugin for 'dragmath' equation editor (for use with TeX filter).
+ *
+ * @package tinymce_dragmath
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class tinymce_dragmath extends editor_tinymce_plugin {
+ protected function update_init_params(array &$params, context $context,
+ array $options = null) {
+ global $OUTPUT;
+
+ // If TeX filter is disabled, do not add button.
+ $filters = filter_get_active_in_context($context);
+ if (!array_key_exists('filter/tex', $filters)) {
+ return;
+ }
+
+ // Add button before 'nonbreaking' in advancedbuttons3.
+ $this->add_button_before($params, 3, 'dragmath', 'nonbreaking');
+
+ // Add JS file, which uses default name.
+ $this->add_js_plugin($params);
+ }
+}
@@ -14,11 +14,11 @@
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,
+
+ file : url + '/../../../dragmath/dragmath.php?elanguage=' + lang,
width : 540,
height : 380,
inline : 1
@@ -34,7 +34,7 @@
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) {
@@ -0,0 +1,32 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * TinyMCE dragmath plugin version details.
+ *
+ * @package tinymce_dragmath
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+// The current plugin version (Date: YYYYMMDDXX).
+$plugin->version = 2012051700;
+// Required Moodle version.
+$plugin->requires = 2011112900;
+// Full name of the plugin (used for diagnostics).
+$plugin->component = 'tinymce_dragmath';
@@ -18,31 +18,31 @@
/**
* Displays the TinyMCE popup window to insert a Moodle emoticon
*
- * @package tinymceplugin
- * @subpackage moodleemoticon
- * @copyright 2010 David Mudrak <david@moodle.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package tinymce_moodleemoticon
+ * @copyright 2010 David Mudrak <david@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_MOODLE_COOKIES', true); // Session not used here
define('NO_UPGRADE_CHECK', true); // Ignore upgrade check
-require_once(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/config.php');
+require_once(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/config.php');
$PAGE->set_context(get_system_context());
$emoticonmanager = get_emoticon_manager();
$stringmanager = get_string_manager();
$editor = get_texteditor('tinymce');
+$plugin = $editor->get_plugin('moodleemoticon');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php print_string('moodleemoticon:desc', 'editor_tinymce'); ?></title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?v=<?php echo $editor->version ?>"></script>
- <script type="text/javascript" src="js/dialog.js?v=<?php echo $editor->version ?>"></script>
+ <script type="text/javascript" src="../../tiny_mce/<?php echo $editor->version ?>/tiny_mce_popup.js"></script>
+ <script type="text/javascript" src="<?php echo $plugin->get_tinymce_file_url('js/dialog.js'); ?>"></script>
</head>
<body>
@@ -0,0 +1,27 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for Moodle emoticon plugin.
+ *
+ * @package tinymce_moodleemoticon
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['pluginname'] = 'Insert emoticon';
+
+$string['desc'] = 'Insert emoticon';
@@ -0,0 +1,55 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Plugin for Moodle emoticons.
+ *
+ * @package tinymce_moodleemoticon
+ * @copyright 2012 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class tinymce_moodleemoticon extends editor_tinymce_plugin {
+ protected function update_init_params(array &$params, context $context,
+ array $options = null) {
+ global $OUTPUT;
+
+ // If emoticon filter is disabled, do not add button.
+ $filters = filter_get_active_in_context($context);
+ if (!array_key_exists('filter/emoticon', $filters)) {
+ return;
+ }
+
+ // Add button after 'image' in advancedbuttons3.
+ $this->add_button_after($params, 3, 'moodleemoticon', 'image');
+
+ // Add JS file, which uses default name.
+ $this->add_js_plugin($params);
+
+ // Extra params specifically for emoticon plugin.
+ $manager = get_emoticon_manager();
+ $emoticons = $manager->get_emoticons();
+ $imgs = array();
+ // See the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used.
+ $index = 0;
+ foreach ($emoticons as $emoticon) {
+ $imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon(
+ $emoticon, array('class' => 'emoticon emoticon-index-'.$index++)));
+ }
+ $params['moodleemoticon_emoticons'] = json_encode($imgs);
+ }
+}
@@ -30,7 +30,7 @@
ed.addCommand('mceMoodleEmoticon', function() {
lang = ed.getParam('language');
ed.windowManager.open({
- file : url + '/dialog.php?lang=' + lang ,
+ file : url + '/../../../moodleemoticon/dialog.php?lang=' + lang ,
width : 250 + parseInt(ed.getLang('moodleemoticon.delta_width', 0)),
height : 400 + parseInt(ed.getLang('moodleemoticon.delta_height', 0)),
inline : 1
Oops, something went wrong.

0 comments on commit 2049033

Please sign in to comment.