mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
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
This commit is contained in:
parent
fae911708e
commit
204903363f
37 changed files with 465 additions and 74 deletions
60
lib/editor/tinymce/plugins/dragmath/dragmath.php
Normal file
60
lib/editor/tinymce/plugins/dragmath/dragmath.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
|
||||
require("../../../../../config.php");
|
||||
|
||||
$lang = required_param('elanguage', PARAM_SAFEDIR);
|
||||
|
||||
if (!get_string_manager()->translation_exists($lang, false)) {
|
||||
$lang = 'en';
|
||||
}
|
||||
$SESSION->lang = $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';
|
||||
}
|
||||
|
||||
$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"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<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/<?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>
|
||||
|
||||
<applet
|
||||
name="dragmath"
|
||||
codebase="<?php echo $CFG->httpswwwroot.'/lib/dragmath/applet' ?>"
|
||||
code="Display/MainApplet.class"
|
||||
archive="DragMath.jar,lib/AbsoluteLayout.jar,lib/swing-layout-1.0.jar,lib/jdom.jar,lib/jep.jar"
|
||||
width="540" height="300"
|
||||
>
|
||||
<param name="language" value="<?php echo $lang; ?>" />
|
||||
<param name="outputFormat" value="MoodleTex" />
|
||||
<?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();"><?php print_string('common:insert', 'editor_tinymce'); ?></button>
|
||||
<button type="button" onclick="return tinyMCEPopup.close();"><?php print_string('cancel'); ?></button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -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';
|
43
lib/editor/tinymce/plugins/dragmath/lib.php
Normal file
43
lib/editor/tinymce/plugins/dragmath/lib.php
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
78
lib/editor/tinymce/plugins/dragmath/tinymce/editor_plugin.js
Normal file
78
lib/editor/tinymce/plugins/dragmath/tinymce/editor_plugin.js
Normal file
|
@ -0,0 +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');
|
||||
lang = tinyMCE.activeEditor.getParam('language');
|
||||
|
||||
ed.addCommand('mceDragMath', function() {
|
||||
ed.windowManager.open({
|
||||
|
||||
file : url + '/../../../dragmath/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);
|
||||
})();
|
BIN
lib/editor/tinymce/plugins/dragmath/tinymce/img/dragmath.gif
Normal file
BIN
lib/editor/tinymce/plugins/dragmath/tinymce/img/dragmath.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 166 B |
23
lib/editor/tinymce/plugins/dragmath/tinymce/js/dragmath.js
Normal file
23
lib/editor/tinymce/plugins/dragmath/tinymce/js/dragmath.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
var DragMathDialog = {
|
||||
init : function(ed) {
|
||||
},
|
||||
|
||||
insert : function(file, title) {
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var tex = document.dragmath.getMathExpression();
|
||||
|
||||
// convert < and > to entities
|
||||
tex = tex.replace('<', '<');
|
||||
tex = tex.replace('>', '>');
|
||||
|
||||
if (tinymce.isIE) {tinyMCEPopup.restoreSelection();}
|
||||
|
||||
ed.execCommand('mceInsertContent', false, tex);
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
};
|
||||
|
||||
tinyMCEPopup.onInit.add(DragMathDialog.init, DragMathDialog);
|
|
@ -0,0 +1,3 @@
|
|||
tinyMCE.addI18n('en.dragmath_dlg',{
|
||||
title:"Insert Equation"
|
||||
});
|
32
lib/editor/tinymce/plugins/dragmath/version.php
Normal file
32
lib/editor/tinymce/plugins/dragmath/version.php
Normal file
|
@ -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';
|
87
lib/editor/tinymce/plugins/moodleemoticon/dialog.php
Normal file
87
lib/editor/tinymce/plugins/moodleemoticon/dialog.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?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/>.
|
||||
|
||||
/**
|
||||
* Displays the TinyMCE popup window to insert a Moodle emoticon
|
||||
*
|
||||
* @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(__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/<?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>
|
||||
|
||||
<table border="0" align="center" style="width:100%;">
|
||||
<?php
|
||||
|
||||
$emoticons = $emoticonmanager->get_emoticons();
|
||||
// this is tricky - we must somehow include the information about the original
|
||||
// emoticon text so that we can replace the image back with it on editor save.
|
||||
// so we are going to encode the index of the emoticon. this will break when the
|
||||
// admin changes the mapping table while the user has the editor opened
|
||||
// but I am not able to come with better solution at the moment :-/
|
||||
$index = 0;
|
||||
foreach ($emoticons as $emoticon) {
|
||||
$txt = $emoticon->text;
|
||||
$img = $OUTPUT->render(
|
||||
$emoticonmanager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-'.$index)));
|
||||
if ($stringmanager->string_exists($emoticon->altidentifier, $emoticon->altcomponent)) {
|
||||
$alt = get_string($emoticon->altidentifier, $emoticon->altcomponent);
|
||||
} else {
|
||||
$alt = '';
|
||||
}
|
||||
echo html_writer::tag('tr',
|
||||
html_writer::tag('td', $img, array('style' => 'width:20%;text-align:center;')) .
|
||||
html_writer::tag('td', s($txt), array('style' => 'width:40%;text-align:center;font-family:monospace;')) .
|
||||
html_writer::tag('td', $alt),
|
||||
array(
|
||||
'class' => 'emoticoninfo emoticoninfo-index-'.$index,
|
||||
)
|
||||
);
|
||||
$index++;
|
||||
}
|
||||
|
||||
?>
|
||||
</table>
|
||||
|
||||
<div class="mceActionPanel">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -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';
|
55
lib/editor/tinymce/plugins/moodleemoticon/lib.php
Normal file
55
lib/editor/tinymce/plugins/moodleemoticon/lib.php
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* TinyMCE plugin MoodleEmoticon - provides GUI to insert emoticon images
|
||||
*
|
||||
* Based on the example plugin (c) 2009 Moxiecode Systems AB
|
||||
*
|
||||
* @author David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.MoodleEmoticon', {
|
||||
|
||||
/**
|
||||
* Holds the list of emoticons provided by emoticon_manager
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_emoticons : {},
|
||||
|
||||
/**
|
||||
* 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('mceMoodleEmoticon');
|
||||
ed.addCommand('mceMoodleEmoticon', function() {
|
||||
lang = ed.getParam('language');
|
||||
ed.windowManager.open({
|
||||
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
|
||||
}, {
|
||||
plugin_url : url // Plugin absolute URL
|
||||
});
|
||||
});
|
||||
|
||||
// Add an observer to the onInit event to convert emoticon texts to images
|
||||
ed.onInit.add(function(ed) {
|
||||
var data = ed.getContent();
|
||||
this._emoticons = tinymce.util.JSON.parse(ed.getParam('moodleemoticon_emoticons'));
|
||||
for (var emotxt in this._emoticons) {
|
||||
// escape the metacharacters so we can use it as regexp
|
||||
search = emotxt.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
// convert to regexp
|
||||
search = new RegExp(search, 'g');
|
||||
// and replace all occurrences of it with the image
|
||||
data = data.replace(search, this._emoticons[emotxt]);
|
||||
}
|
||||
ed.setContent(data);
|
||||
});
|
||||
|
||||
// Add an observer to the onPreProcess event to convert emoticon images to texts
|
||||
ed.onPreProcess.add(function(ed, o) {
|
||||
if (o.save) {
|
||||
tinymce.each(ed.dom.select('img.emoticon', o.node), function(image) {
|
||||
var emoticontxt = '';
|
||||
var matches = /^emoticon emoticon-index-([0-9]+)$/.exec(image.className);
|
||||
if (matches.length != 2) {
|
||||
// this is not valid emoticon image inserted via dialog
|
||||
// return true so that each() does not halt
|
||||
return true;
|
||||
}
|
||||
var index = matches[1];
|
||||
var search = new RegExp('class="emoticon emoticon-index-'.concat(index, '"'));
|
||||
for (var emotxt in this._emoticons) {
|
||||
if (search.test(this._emoticons[emotxt])) {
|
||||
emoticontxt = emotxt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (emoticontxt) {
|
||||
ed.dom.setOuterHTML(image, emoticontxt);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
|
||||
// Register moodleemoticon button
|
||||
ed.addButton('moodleemoticon', {
|
||||
title : 'moodleemoticon.desc',
|
||||
cmd : 'mceMoodleEmoticon',
|
||||
image : url + '/img/moodleemoticon.gif'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 Emoticon plugin',
|
||||
author : 'David Mudrak',
|
||||
authorurl : 'http://mudrak.name',
|
||||
infourl : 'http://moodle.org',
|
||||
version : "1.0"
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('moodleemoticon', tinymce.plugins.MoodleEmoticon);
|
||||
})();
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,54 @@
|
|||
var MoodleEmoticonDialog = {
|
||||
|
||||
init : function() {
|
||||
// register event handlers for the table rows
|
||||
tinymce.each(tinymce.DOM.select('tr.emoticoninfo', document), function(row) {
|
||||
|
||||
tinymce.dom.Event.add(row, 'mouseover', function(e) {
|
||||
this.style.backgroundColor = 'white';
|
||||
}, row);
|
||||
|
||||
tinymce.dom.Event.add(row, 'mouseout', function(e) {
|
||||
this.style.backgroundColor = 'transparent';
|
||||
}, row);
|
||||
|
||||
tinymce.dom.Event.add(row, 'click', function(e) {
|
||||
var matches = /^emoticoninfo emoticoninfo-index-([0-9]+)$/.exec(this.className);
|
||||
if (matches.length != 2) {
|
||||
// continue with the next row
|
||||
return true;
|
||||
}
|
||||
var index = matches[1];
|
||||
MoodleEmoticonDialog.insert(index);
|
||||
}, row);
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
insert : function(index) {
|
||||
emoticons = tinyMCEPopup.editor._emoticons;
|
||||
i = 0;
|
||||
for (var emoticon in emoticons) {
|
||||
if (i == index) {
|
||||
if (tinymce.isIE) {
|
||||
tinyMCEPopup.restoreSelection();
|
||||
}
|
||||
tinyMCEPopup.editor.execCommand('mceInsertContent', false, emoticons[emoticon]);
|
||||
tinyMCEPopup.close();
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
},
|
||||
|
||||
highlight : function(row) {
|
||||
row.style.backgroundColor="white";
|
||||
},
|
||||
|
||||
unhighlight : function(row) {
|
||||
row.style.backgroundColor="transparent";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
tinyMCEPopup.onInit.add(MoodleEmoticonDialog.init, MoodleEmoticonDialog);
|
32
lib/editor/tinymce/plugins/moodleemoticon/version.php
Normal file
32
lib/editor/tinymce/plugins/moodleemoticon/version.php
Normal file
|
@ -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 emoticon plugin version details.
|
||||
*
|
||||
* @package tinymce_moodleemoticon
|
||||
* @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_moodleemoticon';
|
|
@ -0,0 +1,25 @@
|
|||
<?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 Media plugin.
|
||||
*
|
||||
* @package tinymce_moodlemedia
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Insert media';
|
48
lib/editor/tinymce/plugins/moodlemedia/lib.php
Normal file
48
lib/editor/tinymce/plugins/moodlemedia/lib.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?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 media (audio/video) insertion dialog.
|
||||
*
|
||||
* @package tinymce_moodlemedia
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tinymce_moodlemedia extends editor_tinymce_plugin {
|
||||
protected function update_init_params(array &$params, context $context,
|
||||
array $options = null) {
|
||||
global $OUTPUT;
|
||||
|
||||
// Add button after emoticon button in advancedbuttons3.
|
||||
$added = $this->add_button_after($params, 3, 'moodlemedia', 'moodleemoticon', false);
|
||||
|
||||
// Note: We know that the emoticon button has already been added, if it
|
||||
// exists, because I set the sort order higher for this. So, if no
|
||||
// emoticon, add after 'image'.
|
||||
if (!$added) {
|
||||
$this->add_button_after($params, 3, 'moodlemedia', 'image');
|
||||
}
|
||||
|
||||
// Add JS file, which uses default name.
|
||||
$this->add_js_plugin($params);
|
||||
}
|
||||
|
||||
protected function get_sort_order() {
|
||||
return 110;
|
||||
}
|
||||
}
|
62
lib/editor/tinymce/plugins/moodlemedia/preview.php
Normal file
62
lib/editor/tinymce/plugins/moodlemedia/preview.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?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/>.
|
||||
|
||||
/**
|
||||
* Provides A/V preview features for the TinyMCE editor Moodle Media plugin.
|
||||
* The preview is included in an iframe within the popup dialog.
|
||||
*
|
||||
* @package tinymce_moodlemedia
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(dirname(__FILE__) . '/../../../../../config.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
require_once($CFG->libdir . '/editorlib.php');
|
||||
require_once($CFG->libdir . '/editor/tinymce/lib.php');
|
||||
|
||||
// Must be logged in
|
||||
require_login();
|
||||
|
||||
// Require path to draftfile.php file
|
||||
$path = required_param('path', PARAM_PATH);
|
||||
|
||||
$editor = new tinymce_texteditor();
|
||||
|
||||
// Now output this file which is super-simple
|
||||
$PAGE->set_pagelayout('embedded');
|
||||
$PAGE->set_url(new moodle_url('/lib/editor/tinymce/tiny_mce/' . $editor->version . '/plugins/moodlemedia/preview.php',
|
||||
array('path' => $path)));
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->add_body_class('core_media_preview');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$mediarenderer = $PAGE->get_renderer('core', 'media');
|
||||
|
||||
$path = '/'.trim($path, '/');
|
||||
|
||||
if (empty($CFG->slasharguments)) {
|
||||
$url = new moodle_url('/draftfile.php', array('file'=>$path));
|
||||
} else {
|
||||
$url = new moodle_url('/draftfile.php');
|
||||
$url->set_slashargument($path);
|
||||
}
|
||||
if ($mediarenderer->can_embed_url($url)) {
|
||||
echo $mediarenderer->embed_url($url);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
25
lib/editor/tinymce/plugins/moodlemedia/tinymce/css/media.css
Normal file
25
lib/editor/tinymce/plugins/moodlemedia/tinymce/css/media.css
Normal file
|
@ -0,0 +1,25 @@
|
|||
#id, #name, #hspace, #vspace, #class_name, #align { width: 100px }
|
||||
.moodlebutton {
|
||||
font-size: 1.5em;
|
||||
font-weight:bold;
|
||||
padding: 3px 3px 3px 1.5em;
|
||||
border:1px solid #ccc;
|
||||
text-decoration:none;
|
||||
background: url(../../../../../../../../pix/a/search.png) .2em .3em no-repeat;
|
||||
}
|
||||
.moodlebutton:hover {background: #ccc}
|
||||
#hspace, #vspace { width: 50px }
|
||||
#flash_quality, #flash_align, #flash_scale, #flash_salign, #flash_wmode { width: 100px }
|
||||
#flash_base, #flash_flashvars { width: 240px }
|
||||
#width, #height { width: 40px }
|
||||
#src, #media_type { width: 250px }
|
||||
#class { width: 120px }
|
||||
#prev {margin: 0; border: 1px solid black; width: 380px; height: 230px; overflow: hidden }
|
||||
.panel_wrapper div.current { height: 390px; overflow: auto }
|
||||
#flash_options, #shockwave_options, #qt_options, #wmp_options, #rmp_options { display: none }
|
||||
.mceAddSelectValue { background-color: #DDDDDD }
|
||||
#qt_starttime, #qt_endtime, #qt_fov, #qt_href, #qt_moveid, #qt_moviename, #qt_node, #qt_pan, #qt_qtsrc, #qt_qtsrcchokespeed, #qt_target, #qt_tilt, #qt_urlsubstituten, #qt_volume { width: 70px }
|
||||
#wmp_balance, #wmp_baseurl, #wmp_captioningid, #wmp_currentmarker, #wmp_currentposition, #wmp_defaultframe, #wmp_playcount, #wmp_rate, #wmp_uimode, #wmp_volume { width: 70px }
|
||||
#rmp_console, #rmp_numloop, #rmp_controls, #rmp_scriptcallbacks { width: 70px }
|
||||
#shockwave_swvolume, #shockwave_swframe, #shockwave_swurl, #shockwave_swstretchvalign, #shockwave_swstretchhalign, #shockwave_swstretchstyle { width: 90px }
|
||||
#qt_qtsrc { width: 200px }
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* @author Dongsheng Cai <dongsheng@moodle.com>
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var each = tinymce.each;
|
||||
|
||||
tinymce.PluginManager.requireLangPack('moodlemedia');
|
||||
|
||||
tinymce.create('tinymce.plugins.MoodlemediaPlugin', {
|
||||
init : function(ed, url) {
|
||||
var t = this;
|
||||
|
||||
t.editor = ed;
|
||||
t.url = url;
|
||||
|
||||
// Register commands
|
||||
ed.addCommand('mceMoodleMedia', function() {
|
||||
ed.windowManager.open({
|
||||
file : url + '/moodlemedia.htm',
|
||||
width : 430 + parseInt(ed.getLang('media.delta_width', 0)),
|
||||
height : 470 + parseInt(ed.getLang('media.delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
});
|
||||
|
||||
// Register buttons
|
||||
ed.addButton('moodlemedia', {
|
||||
title : 'Moodle Media',
|
||||
image : url + '/img/icon.gif',
|
||||
cmd : 'mceMoodleMedia'});
|
||||
|
||||
},
|
||||
|
||||
_parse : function(s) {
|
||||
return tinymce.util.JSON.parse('{' + s + '}');
|
||||
},
|
||||
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'Moodle media',
|
||||
author : 'Dongsheng Cai <dongsheng@moodle.com>',
|
||||
version : "1.0"
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('moodlemedia', tinymce.plugins.MoodlemediaPlugin);
|
||||
})();
|
BIN
lib/editor/tinymce/plugins/moodlemedia/tinymce/img/icon.gif
Normal file
BIN
lib/editor/tinymce/plugins/moodlemedia/tinymce/img/icon.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 910 B |
137
lib/editor/tinymce/plugins/moodlemedia/tinymce/js/media.js
Normal file
137
lib/editor/tinymce/plugins/moodlemedia/tinymce/js/media.js
Normal file
|
@ -0,0 +1,137 @@
|
|||
/**
|
||||
* @author Dongsheng Cai <dongsheng@moodle.com>
|
||||
*/
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
var oldWidth, oldHeight, ed, url;
|
||||
|
||||
if (url = tinyMCEPopup.getParam("media_external_list_url")) {
|
||||
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
||||
}
|
||||
|
||||
function init() {
|
||||
ed = tinyMCEPopup.editor;
|
||||
document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media');
|
||||
}
|
||||
|
||||
function insertMedia() {
|
||||
var f = document.forms[0];
|
||||
var url = f.filename.value;
|
||||
var linkname = url.substring(url.lastIndexOf('/')+1);
|
||||
var h = '<a href="'+f.src.value+'">'+linkname+'</a>';
|
||||
ed.execCommand('mceInsertContent', false, h);
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
function getType(v) {
|
||||
var fo, i, c, el, x, f = document.forms[0];
|
||||
|
||||
fo = ed.getParam("media_types", "flash=swf;flv=flv;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';');
|
||||
|
||||
// YouTube
|
||||
if (v.match(/watch\?v=(.+)(.*)/)) {
|
||||
f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1];
|
||||
return 'flash';
|
||||
} else if (v.match(/v\/(.+)(.*)/)) {
|
||||
return 'flash';
|
||||
}
|
||||
|
||||
// Google video
|
||||
if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) {
|
||||
f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en';
|
||||
return 'flash';
|
||||
}
|
||||
|
||||
for (i=0; i<fo.length; i++) {
|
||||
c = fo[i].split('=');
|
||||
|
||||
el = c[1].split(',');
|
||||
for (x=0; x<el.length; x++)
|
||||
if (v.indexOf('.' + el[x]) != -1)
|
||||
return c[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function serializeParameters() {
|
||||
var d = document, f = d.forms[0], s = '';
|
||||
s += getStr(null, 'src');
|
||||
s += 'width:300,';
|
||||
s += 'height:225,';
|
||||
|
||||
// delete the tail comma
|
||||
s = s.length > 0 ? s.substring(0, s.length - 1) : s;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
function getStr(p, n, d) {
|
||||
var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];
|
||||
var v = e.type == "hidden" ? e.value : e.options[e.selectedIndex].value;
|
||||
|
||||
if (n == 'src')
|
||||
v = tinyMCEPopup.editor.convertURL(v, 'src', null);
|
||||
|
||||
return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',");
|
||||
}
|
||||
|
||||
function jsEncode(s) {
|
||||
s = s.replace(new RegExp('\\\\', 'g'), '\\\\');
|
||||
s = s.replace(new RegExp('"', 'g'), '\\"');
|
||||
s = s.replace(new RegExp("'", 'g'), "\\'");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
function generatePreview(c) {
|
||||
var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh;
|
||||
|
||||
p.innerHTML = '<!-- x --->';
|
||||
var type = getType(f.src.value);
|
||||
var re = new RegExp("(.+)\#(.+)", "i");
|
||||
var result = f.src.value.match(re);
|
||||
if (result) {
|
||||
f.src.value = result[1];
|
||||
f.filename.value = result[2];
|
||||
} else {
|
||||
f.src.value = f.src.value;
|
||||
f.filename.value = f.src.value;
|
||||
}
|
||||
|
||||
// After constrain
|
||||
pl = serializeParameters();
|
||||
if (pl == '') {
|
||||
p.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
pl = tinyMCEPopup.editor.plugins.moodlemedia._parse(pl);
|
||||
|
||||
if (!pl.src) {
|
||||
p.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
pl.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(pl.src);
|
||||
pl.width = !pl.width ? 100 : pl.width;
|
||||
pl.height = !pl.height ? 100 : pl.height;
|
||||
pl.id = !pl.id ? 'moodlemediaid' : pl.id;
|
||||
pl.name = !pl.name ? 'moodlemedianame' : pl.name;
|
||||
pl.align = !pl.align ? '' : pl.align;
|
||||
|
||||
// Avoid annoying warning about insecure items
|
||||
if (!tinymce.isIE || document.location.protocol != 'https:') {
|
||||
// Include all the draftfile params after the ?
|
||||
var draftparams = pl.src.toString().replace(/^.*\/draftfile.php\//, '');
|
||||
h = '<iframe src="../../..//moodlemedia/preview.php?path=' +
|
||||
draftparams + '" width="100%" height="100%"></iframe>';
|
||||
}
|
||||
|
||||
// I don't know why the HTML comment is there, but leaving it just in case
|
||||
p.innerHTML = "<!-- x --->" + h;
|
||||
}
|
||||
|
||||
tinyMCEPopup.onInit.add(init);
|
|
@ -0,0 +1,58 @@
|
|||
<!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>{#media_dlg.title}</title>
|
||||
<script type="text/javascript">
|
||||
// Because there is no relative path to TinyMCE, we have to use JavaScript
|
||||
// to work out correct path from the .js files from TinyMCE. Only files
|
||||
// inside this plugin can be included with relative path (below).
|
||||
var editor_tinymce_include = function(path) {
|
||||
document.write('<script type="text/javascript" src="' +
|
||||
parent.tinyMCE.baseURL + '/' + path + '"></' + 'script>');
|
||||
};
|
||||
editor_tinymce_include('tiny_mce_popup.js');
|
||||
editor_tinymce_include('utils/mctabs.js');
|
||||
editor_tinymce_include('utils/validate.js');
|
||||
editor_tinymce_include('utils/form_utils.js');
|
||||
editor_tinymce_include('utils/editable_selects.js');
|
||||
</script>
|
||||
<script type="text/javascript" src="js/media.js"></script>
|
||||
<link href="css/media.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body style="display: none">
|
||||
<div class="tabs"></div>
|
||||
<form onsubmit="insertMedia();return false;" action="#">
|
||||
<div class="panel_wrapper">
|
||||
<div id="general_panel" class="panel current">
|
||||
<input id="src" name="src" type="hidden" value="" class="mceFocus" onchange="generatePreview();" />
|
||||
<input id="filename" name="filename" type="hidden" value="" />
|
||||
<fieldset>
|
||||
<legend>{#media_dlg.general}</legend>
|
||||
|
||||
<table align="center" border="0" cellpadding="4" cellspacing="0">
|
||||
<tr align="center">
|
||||
<td colspan='2' id="filebrowsercontainer"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>{#media_dlg.preview}</legend>
|
||||
<div id="prev"></div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mceActionPanel">
|
||||
<div style="float: left">
|
||||
<input type="submit" id="insert" name="insert" value="{#insert}" />
|
||||
</div>
|
||||
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
32
lib/editor/tinymce/plugins/moodlemedia/version.php
Normal file
32
lib/editor/tinymce/plugins/moodlemedia/version.php
Normal file
|
@ -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 media insert plugin version details.
|
||||
*
|
||||
* @package tinymce_moodlemedia
|
||||
* @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 = 2012051701;
|
||||
// Required Moodle version.
|
||||
$plugin->requires = 2011112900;
|
||||
// Full name of the plugin (used for diagnostics).
|
||||
$plugin->component = 'tinymce_moodlemedia';
|
|
@ -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 'no link' plugin.
|
||||
*
|
||||
* @package tinymce_moodlenolink
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Prevent automatic linking';
|
||||
|
||||
$string['desc'] = 'Prevent automatic linking';
|
37
lib/editor/tinymce/plugins/moodlenolink/lib.php
Normal file
37
lib/editor/tinymce/plugins/moodlenolink/lib.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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 'no link' button.
|
||||
*
|
||||
* @package tinymce_moodlenolink
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tinymce_moodlenolink extends editor_tinymce_plugin {
|
||||
protected function update_init_params(array &$params, context $context,
|
||||
array $options = null) {
|
||||
global $OUTPUT;
|
||||
|
||||
// Add button after 'unlink' in advancedbuttons3.
|
||||
$this->add_button_after($params, 3, 'moodlenolink', 'unlink');
|
||||
|
||||
// Add JS file, which uses default name.
|
||||
$this->add_js_plugin($params);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* $Id: editor_plugin_src.js,v 1.2 2008/07/30 08:14:53 scyrma Exp $
|
||||
*/
|
||||
|
||||
(function() {
|
||||
// Load plugin specific language pack
|
||||
tinymce.PluginManager.requireLangPack('moodlenolink');
|
||||
|
||||
tinymce.create('tinymce.plugins.moodlenolinkPlugin', {
|
||||
/**
|
||||
* 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('mcemoodlenolink');
|
||||
ed.addCommand('mcemoodlenolink', function() {
|
||||
var n, p;
|
||||
|
||||
n = ed.selection.getNode();
|
||||
p = ed.dom.getParent(n, function(t) {
|
||||
return ed.dom.getAttrib(t, 'class') == 'nolink';
|
||||
});
|
||||
|
||||
if (p) {
|
||||
ed.dom.remove(p, true);
|
||||
} else {
|
||||
ed.selection.setContent('<span class="nolink">' + ed.selection.getContent() + '</span>');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Register moodlenolink button
|
||||
ed.addButton('moodlenolink', {
|
||||
title : 'moodlenolink.desc',
|
||||
cmd : 'mcemoodlenolink',
|
||||
image : url + '/img/ed_nolink.gif'
|
||||
});
|
||||
|
||||
// Add a node change handler, selects the button in the UI when a image is selected
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
var p, c;
|
||||
c = cm.get('moodlenolink');
|
||||
p = ed.dom.getParent(n, 'SPAN');
|
||||
|
||||
c.setActive(p && ed.dom.hasClass(p, 'nolink'));
|
||||
|
||||
if (p && ed.dom.hasClass(p, 'nolink') || ed.selection.getContent()) {
|
||||
c.setDisabled(false);
|
||||
} else {
|
||||
c.setDisabled(true);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 : 'moodlenolink plugin',
|
||||
author : 'Mathieu Petit-Clair',
|
||||
authorurl : 'http://moodle.com/hq',
|
||||
infourl : 'http://docs.moodle.org/en/TinyMCE',
|
||||
version : "1.0"
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('moodlenolink', tinymce.plugins.moodlenolinkPlugin);
|
||||
})();
|
Binary file not shown.
After Width: | Height: | Size: 180 B |
|
@ -0,0 +1,3 @@
|
|||
tinyMCE.addI18n('en.moodlenolink',{
|
||||
desc : 'Prevent automatic linking'
|
||||
});
|
32
lib/editor/tinymce/plugins/moodlenolink/version.php
Normal file
32
lib/editor/tinymce/plugins/moodlenolink/version.php
Normal file
|
@ -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 no-link marker plugin version details.
|
||||
*
|
||||
* @package tinymce_moodlenolink
|
||||
* @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_moodlenolink';
|
Loading…
Add table
Add a link
Reference in a new issue