]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-20603, added moodlemedia tinymce plugin"
authorDongsheng Cai <unoter@gmail.com>
Tue, 10 Nov 2009 08:51:42 +0000 (08:51 +0000)
committerDongsheng Cai <unoter@gmail.com>
Tue, 10 Nov 2009 08:51:42 +0000 (08:51 +0000)
15 files changed:
lang/en_utf8/editor_tinymce.php
lib/editor/tinymce/extra/patches/tinymce_form_utils.patch [new file with mode: 0644]
lib/editor/tinymce/extra/patches/tinymce_lang_string.patch [new file with mode: 0644]
lib/editor/tinymce/extra/tinymce_utils.js
lib/editor/tinymce/lib.php
lib/editor/tinymce/plugins/moodlemedia/css/media.css [new file with mode: 0755]
lib/editor/tinymce/plugins/moodlemedia/editor_plugin.js [new file with mode: 0755]
lib/editor/tinymce/plugins/moodlemedia/editor_plugin_src.js [new file with mode: 0755]
lib/editor/tinymce/plugins/moodlemedia/img/icon.gif [new file with mode: 0644]
lib/editor/tinymce/plugins/moodlemedia/js/dialog.js [new file with mode: 0755]
lib/editor/tinymce/plugins/moodlemedia/js/media.js [new file with mode: 0755]
lib/editor/tinymce/plugins/moodlemedia/moodlemedia.htm [new file with mode: 0755]
lib/editor/tinymce/readme_moodle.txt
lib/editor/tinymce/utils/form_utils.js
repository/repository.src.js

index 27484553855721fea4e5696011f3a4c171b60c23..746f86990cfe4767baea38da19a71c45c00f3ae6 100644 (file)
@@ -234,6 +234,8 @@ $string['advlink_dlg:url'] = 'Link URL';
 $string['autosave:unload_msg'] = 'The changes you made will be lost if you navigate away from this page.';
 $string['common:apply'] = 'Apply';
 $string['common:browse'] = 'Browse';
+$string['common:browsemedia'] = 'Find or upload a sound, video or applet';
+$string['common:browseimage'] = 'Find or upload an image';
 $string['common:cancel'] = 'Cancel';
 $string['common:class_name'] = 'Class';
 $string['common:clipboard_msg'] = 'Copy/Cut/Paste is not available in Mozilla and Firefox.\\nDo you want more information about this issue?';
@@ -414,6 +416,7 @@ $string['media_dlg:enabled'] = 'Enabled';
 $string['media_dlg:enablejavascript'] = 'Enable JavaScript';
 $string['media_dlg:endtime'] = 'End time';
 $string['media_dlg:file'] = 'File/URL';
+$string['media_dlg:filename'] = 'Filename';
 $string['media_dlg:flash_options'] = 'Flash options';
 $string['media_dlg:flashvars'] = 'Flashvars';
 $string['media_dlg:flv_autostart'] = 'Auto start';
diff --git a/lib/editor/tinymce/extra/patches/tinymce_form_utils.patch b/lib/editor/tinymce/extra/patches/tinymce_form_utils.patch
new file mode 100644 (file)
index 0000000..305add9
--- /dev/null
@@ -0,0 +1,41 @@
+Index: lib/editor/tinymce/utils/form_utils.js
+===================================================================
+RCS file: /cvsroot/moodle/moodle/lib/editor/tinymce/utils/form_utils.js,v
+retrieving revision 1.1
+diff -u -r1.1 form_utils.js
+--- lib/editor/tinymce/utils/form_utils.js     16 May 2009 20:54:46 -0000      1.1
++++ lib/editor/tinymce/utils/form_utils.js     10 Nov 2009 08:06:02 -0000
+@@ -48,9 +48,21 @@
+       if (!cb)\r
+               return "";\r
\r
+-      html = "";\r
+-      html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';\r
+-      html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';\r
++    html = "";\r
++    if (id=='filebrowser') {\r
++        // for moodlemedia plugin\r
++        html += '<a class="moodlebutton" id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';\r
++        html += tinyMCEPopup.getLang('browsemedia');\r
++        html += '</a>';\r
++    } else if (id=='srcbrowser') {\r
++        // for advimage plugin\r
++        html += '<a class="moodlebutton" id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';\r
++        html += tinyMCEPopup.getLang('browseimage');\r
++        html += '</a>';\r
++    } else {\r
++        html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';\r
++        html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';\r
++    }\r
\r
+       return html;\r
+ }\r
+@@ -58,7 +70,7 @@
+ function openBrowser(img_id, target_form_element, type, option) {\r
+       var img = document.getElementById(img_id);\r
\r
+-      if (img.className != "mceButtonDisabled")\r
++      if (!img || img.className != "mceButtonDisabled")\r
+               tinyMCEPopup.openBrowser(target_form_element, type, option);\r
+ }\r
\r
diff --git a/lib/editor/tinymce/extra/patches/tinymce_lang_string.patch b/lib/editor/tinymce/extra/patches/tinymce_lang_string.patch
new file mode 100644 (file)
index 0000000..defb040
--- /dev/null
@@ -0,0 +1,24 @@
+Index: lang/en_utf8/editor_tinymce.php
+===================================================================
+RCS file: /cvsroot/moodle/moodle/lang/en_utf8/editor_tinymce.php,v
+retrieving revision 1.7
+diff -u -r1.7 editor_tinymce.php
+--- lang/en_utf8/editor_tinymce.php    19 Jul 2009 13:05:24 -0000      1.7
++++ lang/en_utf8/editor_tinymce.php    10 Nov 2009 08:09:43 -0000
+@@ -234,6 +234,8 @@
+ $string['autosave:unload_msg'] = 'The changes you made will be lost if you navigate away from this page.';
+ $string['common:apply'] = 'Apply';
+ $string['common:browse'] = 'Browse';
++$string['common:browsemedia'] = 'Find or upload a sound, video or applet';
++$string['common:browseimage'] = 'Find or upload an image';
+ $string['common:cancel'] = 'Cancel';
+ $string['common:class_name'] = 'Class';
+ $string['common:clipboard_msg'] = 'Copy/Cut/Paste is not available in Mozilla and Firefox.\\nDo you want more information about this issue?';
+@@ -414,6 +416,7 @@
+ $string['media_dlg:enablejavascript'] = 'Enable JavaScript';
+ $string['media_dlg:endtime'] = 'End time';
+ $string['media_dlg:file'] = 'File/URL';
++$string['media_dlg:filename'] = 'Filename';
+ $string['media_dlg:flash_options'] = 'Flash options';
+ $string['media_dlg:flashvars'] = 'Flashvars';
+ $string['media_dlg:flv_autostart'] = 'Auto start';
index 9565fc68f8eb28700be8839a60fc7d3c0b638e7e..0b8b33c064ab63c84678ee1d216fca7bdd5549d2 100644 (file)
@@ -54,5 +54,5 @@ function mce_moodlefilemanager(field_name, url, type, win) {
     picker.id = 'file-picker-'+client_id;
     document.body.appendChild(picker);
     var el = win.document.getElementById(field_name);
-    eval('open_filepicker(client_id, {"env":"editor","target":el,"filetype":type, "savepath":"/"})');
+    open_filepicker(client_id, {"env":"editor","target":el,"filetype":type, "savepath":"/"});
 }
index 9cb5b5dea10802f15131edbccb3d41ef89899b58..a55ec42ec3edc37b8e2a209f635a31d28845dcf5 100644 (file)
@@ -79,16 +79,16 @@ class tinymce_texteditor extends texteditor {
 
         $context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context'];
         if (!empty($options['legacy'])) {
-            $xmedia = '';
+            $xmedia = 'moodlemedia,';
         } else {
             if (!empty($options['noclean']) or !empty($options['trusted'])) {
-                $xmedia = 'media,';
             } else {
                 $xmedia = '';
             }
         }
 
-        $xmedia = 'media, ';
+        // TODO: enabled moodlemedia
+        $xmedia = 'moodlemedia,';
         $filters = filter_get_active_in_context($context);
         if (array_key_exists('filter/tex', $filters)) {
             $xdragmath = 'dragmath,';
@@ -112,7 +112,7 @@ class tinymce_texteditor extends texteditor {
                     'apply_source_formatting' => true,
                     'remove_script_host' => false,
                     'entity_encoding' => "raw",
-                    'plugins' => "safari,table,style,layer,advhr,advimage,advlink,emotions,inlinepopups,{$xmedia}searchreplace,paste,directionality,fullscreen,moodlenolink,{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
+                    'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
                     'theme_advanced_font_sizes' => "1,2,3,4,5,6,7",
                     'theme_advanced_layout_manager' => "SimpleLayout",
                     'theme_advanced_toolbar_align' => "left",
@@ -120,7 +120,7 @@ class tinymce_texteditor extends texteditor {
                     'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen",
                     'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,cite,abbr,acronym",
                     'theme_advanced_buttons2_add' => "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
-                    'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,emotions,image,{$xmedia}{$xdragmath}advhr,nonbreaking,charmap",
+                    'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,image,{$xmedia},emotions,{$xdragmath}advhr,nonbreaking,charmap",
                     'theme_advanced_buttons3_add' => "|,table,insertlayer,styleprops,visualchars,|,code,preview",
                     'theme_advanced_fonts' => "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings",
                     'theme_advanced_resize_horizontal' => true,
diff --git a/lib/editor/tinymce/plugins/moodlemedia/css/media.css b/lib/editor/tinymce/plugins/moodlemedia/css/media.css
new file mode 100755 (executable)
index 0000000..ed33efd
--- /dev/null
@@ -0,0 +1,18 @@
+#id, #name, #hspace, #vspace, #class_name, #align {    width: 100px }\r
+.moodlebutton {font-size: 1.5em;font-weight:bold;padding: 3px;border:1px solid #ccc;text-decoration:none}\r
+.moodlebutton:hover {background: #ccc}\r
+#hspace, #vspace { width: 50px }\r
+#flash_quality, #flash_align, #flash_scale, #flash_salign, #flash_wmode { width: 100px }\r
+#flash_base, #flash_flashvars { width: 240px }\r
+#width, #height { width: 40px }\r
+#src, #media_type { width: 250px }\r
+#class { width: 120px }\r
+#prev {margin: 0; border: 1px solid black; width: 380px; height: 230px; overflow: hidden }\r
+.panel_wrapper div.current { height: 390px; overflow: auto }\r
+#flash_options, #shockwave_options, #qt_options, #wmp_options, #rmp_options { display: none }\r
+.mceAddSelectValue { background-color: #DDDDDD }\r
+#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 }\r
+#wmp_balance, #wmp_baseurl, #wmp_captioningid, #wmp_currentmarker, #wmp_currentposition, #wmp_defaultframe, #wmp_playcount, #wmp_rate, #wmp_uimode, #wmp_volume { width: 70px }\r
+#rmp_console, #rmp_numloop, #rmp_controls, #rmp_scriptcallbacks { width: 70px }\r
+#shockwave_swvolume, #shockwave_swframe, #shockwave_swurl, #shockwave_swstretchvalign, #shockwave_swstretchhalign, #shockwave_swstretchstyle { width: 90px }\r
+#qt_qtsrc { width: 200px }\r
diff --git a/lib/editor/tinymce/plugins/moodlemedia/editor_plugin.js b/lib/editor/tinymce/plugins/moodlemedia/editor_plugin.js
new file mode 100755 (executable)
index 0000000..f4f5a0a
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * @author Dongsheng Cai <dongsheng@moodle.com>
+ * @copyright 2009 Dongsheng Cai
+ */
+
+(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);
+})();
diff --git a/lib/editor/tinymce/plugins/moodlemedia/editor_plugin_src.js b/lib/editor/tinymce/plugins/moodlemedia/editor_plugin_src.js
new file mode 100755 (executable)
index 0000000..9de7454
--- /dev/null
@@ -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);
+})();
diff --git a/lib/editor/tinymce/plugins/moodlemedia/img/icon.gif b/lib/editor/tinymce/plugins/moodlemedia/img/icon.gif
new file mode 100644 (file)
index 0000000..8506072
Binary files /dev/null and b/lib/editor/tinymce/plugins/moodlemedia/img/icon.gif differ
diff --git a/lib/editor/tinymce/plugins/moodlemedia/js/dialog.js b/lib/editor/tinymce/plugins/moodlemedia/js/dialog.js
new file mode 100755 (executable)
index 0000000..fa83411
--- /dev/null
@@ -0,0 +1,19 @@
+tinyMCEPopup.requireLangPack();\r
+\r
+var ExampleDialog = {\r
+       init : function() {\r
+               var f = document.forms[0];\r
+\r
+               // Get the selected contents as text and place it in the input\r
+               f.someval.value = tinyMCEPopup.editor.selection.getContent({format : 'text'});\r
+               f.somearg.value = tinyMCEPopup.getWindowArg('some_custom_arg');\r
+       },\r
+\r
+       insert : function() {\r
+               // Insert the contents from the input into the document\r
+               tinyMCEPopup.editor.execCommand('mceInsertContent', false, document.forms[0].someval.value);\r
+               tinyMCEPopup.close();\r
+       }\r
+};\r
+\r
+tinyMCEPopup.onInit.add(ExampleDialog.init, ExampleDialog);\r
diff --git a/lib/editor/tinymce/plugins/moodlemedia/js/media.js b/lib/editor/tinymce/plugins/moodlemedia/js/media.js
new file mode 100755 (executable)
index 0000000..42ff3ae
--- /dev/null
@@ -0,0 +1,176 @@
+/**\r
+ * @author Dongsheng Cai <dongsheng@moodle.com>\r
+ */\r
+tinyMCEPopup.requireLangPack();\r
+\r
+var oldWidth, oldHeight, ed, url;\r
+\r
+if (url = tinyMCEPopup.getParam("media_external_list_url"))\r
+       document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');\r
+\r
+function init() {\r
+    ed = tinyMCEPopup.editor;\r
+       document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media');\r
+}\r
+\r
+function insertMedia() {\r
+       var f = document.forms[0];\r
+    var h = '<a href="'+f.src.value+'">'+f.filename.value+'</a>';\r
+    ed.execCommand('mceInsertContent', false, h);\r
+       tinyMCEPopup.close();\r
+}\r
+\r
+function getType(v) {\r
+       var fo, i, c, el, x, f = document.forms[0];\r
+\r
+       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(';');\r
+\r
+       // YouTube\r
+       if (v.match(/watch\?v=(.+)(.*)/)) {\r
+               f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1];\r
+               return 'flash';\r
+       } else if (v.match(/v\/(.+)(.*)/)) {\r
+               return 'flash';\r
+    }\r
+\r
+       // Google video\r
+       if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) {\r
+               f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en';\r
+               return 'flash';\r
+       }\r
+\r
+       for (i=0; i<fo.length; i++) {\r
+               c = fo[i].split('=');\r
+\r
+               el = c[1].split(',');\r
+               for (x=0; x<el.length; x++)\r
+               if (v.indexOf('.' + el[x]) != -1)\r
+                       return c[0];\r
+       }\r
+\r
+       return null;\r
+}\r
+\r
+\r
+function serializeParameters() {\r
+       var d = document, f = d.forms[0], s = '';\r
+       s += getStr(null, 'src');\r
+    s += 'width:300,';\r
+    s += 'height:225,';\r
+\r
+    // delete the tail comma\r
+       s = s.length > 0 ? s.substring(0, s.length - 1) : s;\r
+\r
+       return s;\r
+}\r
+\r
+\r
+function getStr(p, n, d) {\r
+       var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];\r
+       var v = e.type == "hidden" ? e.value : e.options[e.selectedIndex].value;\r
+\r
+       if (n == 'src')\r
+               v = tinyMCEPopup.editor.convertURL(v, 'src', null);\r
+\r
+       return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',");\r
+}\r
+\r
+function jsEncode(s) {\r
+       s = s.replace(new RegExp('\\\\', 'g'), '\\\\');\r
+       s = s.replace(new RegExp('"', 'g'), '\\"');\r
+       s = s.replace(new RegExp("'", 'g'), "\\'");\r
+\r
+       return s;\r
+}\r
+\r
+function generatePreview(c) {\r
+    var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh;\r
+\r
+    p.innerHTML = '<!-- x --->';\r
+    var type = getType(f.src.value);\r
+    var re = new RegExp("(.+)\#(.+)", "i");\r
+    var result = f.src.value.match(re);\r
+    f.src.value = result[1];\r
+    f.filename.value = result[2];\r
+\r
+       // After constrain\r
+       pl = serializeParameters();\r
+\r
+    switch (type) {\r
+        case 'flash':\r
+            cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';\r
+            codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';\r
+            type = 'application/x-shockwave-flash';\r
+            break;\r
+               case "shockwave":\r
+                       cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000';\r
+                       codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0';\r
+                       type = 'application/x-director';\r
+                       break;\r
+\r
+               case "qt":\r
+                       cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';\r
+                       codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';\r
+                       type = 'video/quicktime';\r
+                       break;\r
+\r
+               case "wmp":\r
+                       cls = ed.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6';\r
+                       codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';\r
+                       type = 'application/x-mplayer2';\r
+                       break;\r
+\r
+               case "rmp":\r
+                       cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA';\r
+                       codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';\r
+                       type = 'audio/x-pn-realaudio-plugin';\r
+                       break;\r
+    }\r
+\r
+       if (pl == '') {\r
+               p.innerHTML = '';\r
+               return;\r
+       }\r
+\r
+       pl = tinyMCEPopup.editor.plugins.moodlemedia._parse(pl);\r
+\r
+       if (!pl.src) {\r
+               p.innerHTML = '';\r
+               return;\r
+       }\r
+\r
+       pl.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(pl.src);\r
+       pl.width = !pl.width ? 100 : pl.width;\r
+       pl.height = !pl.height ? 100 : pl.height;\r
+    pl.id = !pl.id ? 'moodlemediaid' : pl.id;\r
+    pl.name = !pl.name ? 'moodlemedianame' : pl.name;\r
+       pl.align = !pl.align ? '' : pl.align;\r
+\r
+       // Avoid annoying warning about insecure items\r
+       if (!tinymce.isIE || document.location.protocol != 'https:') {\r
+               h += '<object classid="' + cls + '" codebase="' + codebase + '" width="' + pl.width + '" height="' + pl.height + '" id="' + pl.id + '" name="' + pl.name + '" align="' + pl.align + '">';\r
+\r
+               for (n in pl) {\r
+                       h += '<param name="' + n + '" value="' + pl[n] + '">';\r
+\r
+                       // Add extra url parameter if it's an absolute URL\r
+                       if (n == 'src' && pl[n].indexOf('://') != -1)\r
+                               h += '<param name="url" value="' + pl[n] + '" />';\r
+               }\r
+       }\r
+\r
+       h += '<embed type="' + type + '" ';\r
+\r
+       for (n in pl)\r
+               h += n + '="' + pl[n] + '" ';\r
+\r
+       h += '></embed>';\r
+\r
+       // Avoid annoying warning about insecure items\r
+       if (!tinymce.isIE || document.location.protocol != 'https:')\r
+               h += '</object>';\r
+\r
+       p.innerHTML = "<!-- x --->" + h;\r
+}\r
+\r
+tinyMCEPopup.onInit.add(init);\r
diff --git a/lib/editor/tinymce/plugins/moodlemedia/moodlemedia.htm b/lib/editor/tinymce/plugins/moodlemedia/moodlemedia.htm
new file mode 100755 (executable)
index 0000000..1916e1b
--- /dev/null
@@ -0,0 +1,52 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml">\r
+<head>\r
+       <title>{#media_dlg.title}</title>\r
+       <script type="text/javascript" src="../../tiny_mce_popup.js"></script>\r
+       <script type="text/javascript" src="js/media.js"></script>\r
+       <script type="text/javascript" src="../../utils/mctabs.js"></script>\r
+       <script type="text/javascript" src="../../utils/validate.js"></script>\r
+       <script type="text/javascript" src="../../utils/form_utils.js"></script>\r
+       <script type="text/javascript" src="../../utils/editable_selects.js"></script>\r
+       <link href="css/media.css" rel="stylesheet" type="text/css" />\r
+</head>\r
+<body style="display: none">\r
+    <div class="tabs"></div>\r
+    <form onsubmit="insertMedia();return false;" action="#">\r
+               <div class="panel_wrapper">\r
+                       <div id="general_panel" class="panel current">\r
+                <input id="src" name="src" type="hidden" value="" class="mceFocus" onchange="generatePreview();" />\r
+                               <fieldset>\r
+                                       <legend>{#media_dlg.general}</legend>\r
+\r
+                                       <table align="center" border="0" cellpadding="4" cellspacing="0">\r
+                        <tr align="center">\r
+                            <td colspan='2' id="filebrowsercontainer">&nbsp;</td>\r
+                        </tr>\r
+                        <tr>\r
+                                                       <td><label for="src">{#media_dlg.filename}</label></td>\r
+                            <td><input id="filename" name="filename" type="text" value="" class="mceFocus" /></td>\r
+                        </tr>\r
+                                       </table>\r
+                               </fieldset>\r
+\r
+                               <fieldset>\r
+                                       <legend>{#media_dlg.preview}</legend>\r
+                                       <div id="prev"></div>\r
+                               </fieldset>\r
+                       </div>\r
+\r
+               </div>\r
+\r
+               <div class="mceActionPanel">\r
+                       <div style="float: left">\r
+                               <input type="submit" id="insert" name="insert" value="{#insert}" />\r
+                       </div>\r
+\r
+                       <div style="float: right">\r
+                               <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />\r
+                       </div>\r
+               </div>\r
+       </form>\r
+</body>\r
+</html>\r
index 9699f8e994f5b86d0d31f8309c230ebab736cb1b..d7a8c57c085b917ce1c9f545b163166f2b7a3129 100644 (file)
@@ -12,23 +12,23 @@ Upgrade procedure:
  2/ replace tiny_mce*.* files, themes/*, utils/* and plugins/*
     (keep dragmath, moodlenolink, spellchecker)
  3/ copy tinymce/jscripts/tiny_mce/classes/Popup.js to Popup.js
- 4/ apply plugins/media/* (extra/tinymce_plugin_media.patch) - MDL-16650
- 5/ apply strings patch
- 6/ copy yuicompressor.jar from dev package into extra/tools/, use shell
+ 4/ apply strings & form_utils.js patch
+ 5/ copy yuicompressor.jar from dev package into extra/tools/, use shell
     script extra/tools/compress.sh to compress modified files
- 7/ download all TinyMCE lang files (extra/tools/download_langs.sh)
- 8/ update moodle lang string files (extra/tools/update_lang_files.php)
+ 6/ download all TinyMCE lang files (extra/tools/download_langs.sh)
+ 7/ update moodle lang string files (extra/tools/update_lang_files.php)
+ 8/ apply tinymce_lang_string.patch which contains language string for moodlemedia plugin
 
 =========================================================================================
 Added:
  * added Popup.js, copy of tinymce/jscripts/tiny_mce/classes/Popup.js from dev package 
  * plugins/gragmath/*
  * plugins/moodlenolink/*
+ * plugins/moodlemedia/*
 
 Modified:
  * Popup.js --> compressed into tiny_mce_popup.js (extra/patches/tinymce_strings.patch)
  * tiny_mce_src.js --> compressed into tiny_mce.js (extra/patches/tinymce_strings.patch)
- * plugins/media/js/media.js (extra/patches/tinymce_plugin_media.patch)
 
 Removed:
  *
index b8860b280ac87402b1f5ca71aa0ff148be2b6627..865b50aebf6f42680d665c343b6727327f8ff1b1 100644 (file)
@@ -48,9 +48,21 @@ function getBrowserHTML(id, target_form_element, type, prefix) {
        if (!cb)\r
                return "";\r
 \r
-       html = "";\r
-       html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';\r
-       html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';\r
+    html = "";\r
+    if (id=='filebrowser') {\r
+        // for moodlemedia plugin\r
+        html += '<a class="moodlebutton" id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';\r
+        html += tinyMCEPopup.getLang('browsemedia');\r
+        html += '</a>';\r
+    } else if (id=='srcbrowser') {\r
+        // for advimage plugin\r
+        html += '<a class="moodlebutton" id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';\r
+        html += tinyMCEPopup.getLang('browseimage');\r
+        html += '</a>';\r
+    } else {\r
+        html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';\r
+        html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';\r
+    }\r
 \r
        return html;\r
 }\r
@@ -58,7 +70,7 @@ function getBrowserHTML(id, target_form_element, type, prefix) {
 function openBrowser(img_id, target_form_element, type, option) {\r
        var img = document.getElementById(img_id);\r
 \r
-       if (img.className != "mceButtonDisabled")\r
+       if (!img || img.className != "mceButtonDisabled")\r
                tinyMCEPopup.openBrowser(target_form_element, type, option);\r
 }\r
 \r
index 4c69efaa52e692b53c4c299beedc0a6e237bf529..ca7639ee5a2a708500cc2eb911727151c43d86f3 100644 (file)
@@ -630,8 +630,18 @@ repository_client.select_file = function(oldname, url, icon, client_id, repo_id)
     html += '<p><label for="newname-'+client_id+'">'+fp_lang.saveas+'</label>';
     html += '<input type="text" id="newname-'+client_id+'" value="" /></p>';
 
+    var le_checked = '';
+    var le_style = '';
+    if (MOODLE.repository.listing[client_id][repo_id].return_types == 1) {
+        // support external links only
+        le_checked = 'checked';
+        le_style = ' style="display:none;"';
+    } else if(MOODLE.repository.listing[client_id][repo_id].return_types == 2) {
+        // support internal files only
+        le_style = ' style="display:none;"';
+    }
     if (fp_config.externallink && fp.env == 'editor') {
-        html += '<p><input type="checkbox" id="external_link-'+client_id+'" value="" />'+fp_lang.linkexternal+'</p>';
+        html += '<p'+le_style+'><input type="checkbox" id="external_link-'+client_id+'" value="" '+le_checked+' />'+fp_lang.linkexternal+'</p>';
     }
     html += '<p><input type="hidden" id="fileurl-'+client_id+'" value="'+url+'" />';
     html += '<input type="button" onclick="repository_client.download(\''+client_id+'\', \''+repo_id+'\')" value="'+fp_lang.downbtn+'" />';