]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14795: initial commit of the code sent in by Mauno Korpelainen, after reformatting.
authorscyrma <scyrma>
Mon, 12 May 2008 09:02:17 +0000 (09:02 +0000)
committerscyrma <scyrma>
Mon, 12 May 2008 09:02:17 +0000 (09:02 +0000)
lib/editor/tinymce/adminscr.php [new file with mode: 0644]
lib/editor/tinymce/coursefiles.php [new file with mode: 0644]
lib/editor/tinymce/jscripts/tiny_mce/plugins/moodleimage/insert_image.php
lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php
lib/editor/tinymce/langlist.php [new file with mode: 0644]
lib/editor/tinymce/messages.php [new file with mode: 0644]
lib/editor/tinymce/meta.php [new file with mode: 0644]
lib/editor/tinymce/staff.php [new file with mode: 0644]
lib/editor/tinymce/student.php [new file with mode: 0644]
lib/editor/tinymce/xhtml_ruleset.txt [new file with mode: 0644]

diff --git a/lib/editor/tinymce/adminscr.php b/lib/editor/tinymce/adminscr.php
new file mode 100644 (file)
index 0000000..baa5801
--- /dev/null
@@ -0,0 +1,138 @@
+<script type="text/javascript">\r
+function toggleEditor(id) {\r
+    var elm = document.getElementById(id);\r
+\r
+    if (tinyMCE.getInstanceById(id) == null)\r
+        tinyMCE.execCommand('mceAddControl', false, id);\r
+    else\r
+        tinyMCE.execCommand('mceRemoveControl', false, id);\r
+}\r
+function tsetup() { \r
+    tinyMCE.init({\r
+        relative_urls : false,\r
+        remove_script_host : false,\r
+        document_base_url : "<?php echo $CFG->wwwroot; ?>",\r
+        editor_selector : "form-textarea",\r
+        mode : "textareas",\r
+        theme : "standard",\r
+<?php \r
+if (!empty($USER->id)) {\r
+    if ($CFG->defaulthtmleditor == 'tinymce') {\r
+        echo 'skin : "o2k7",';\r
+    } else {\r
+        echo 'skin : "default",';\r
+    }\r
+} \r
+?>\r
+        entity_encoding : "raw",\r
+        theme_standard_statusbar_location : "bottom",\r
+        language : "<?php echo str_replace("_utf8", "", current_language()) ?>",\r
+<?php \r
+    include_once('langlist.php');\r
+    echo "\n";\r
+    include_once('xhtml_ruleset.txt');\r
+?>\r
+        plugins : "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emotions,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodleimage,moodlelink,dragmath,nonbreaking",         \r
+        theme_standard_buttons1 : "fontselect,fontsizeselect,formatselect,|",\r
+        theme_standard_buttons1_add : "styleselect,selectall,pastetext,pasteword,insertlayer",\r
+        theme_standard_buttons2 : "bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,sub,sup,undo,redo,cleanup,removeformat,code,|",\r
+        theme_standard_buttons2_add : "styleprops,ltr,rtl,table,nonbreaking",\r
+        theme_standard_buttons3 : "bullist,numlist,outdent,indent,forecolor,backcolor,link,unlink,anchor,image,charmap,|",\r
+        theme_standard_buttons3_add : "media,emotions,emoticons,charmap,dragmath,spellchecker,search,code,fullscreen",\r
+<?php \r
+    $hidbut = $CFG->editorhidebuttons;\r
+    if ($hidbut) {\r
+        $hidbut = str_replace(" ",",",$hidbut);\r
+        echo '        theme_standard_disable : "'.$hidbut.'",';\r
+    } \r
+    $tinyfts = $CFG->editorfontlist;\r
+    if ($tinyfts) {\r
+        $tinyfts = str_replace(":","=",$tinyfts);\r
+        echo '        theme_standard_fonts : "'.$tinyfts.'",';\r
+    } \r
+?> \r
+        spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",\r
+        moodleimage_course_id: <?php echo $COURSE->id; ?>,\r
+        theme_standard_resize_horizontal : true,\r
+        theme_standard_resizing : true,\r
+        file_browser_callback : "moodlefilemanager",\r
+        apply_source_formatting : true\r
+    });\r
+    function moodlefilemanager(field_name, url, type, win) {\r
+        tinyMCE.activeEditor.windowManager.open({\r
+            file : "<?php echo $CFG->wwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id=<?php echo $COURSE->id; ?>",\r
+            width : 480,  \r
+            height : 380,\r
+            resizable : "yes",\r
+            inline : "yes",  \r
+            close_previous : "no"\r
+        }, {\r
+            window : win,\r
+            input : field_name\r
+        });\r
+        return false;\r
+    }\r
+}\r
+</script>\r
+<script type="text/javascript"> \r
+tinyMCE.init({\r
+    relative_urls : false,\r
+    remove_script_host : false,\r
+    document_base_url : "<?php echo $CFG->wwwroot; ?>",\r
+    editor_selector : "form-textarea",\r
+    mode : "textareas",\r
+    theme : "standard",\r
+<?php \r
+if (!empty($USER->id)) {\r
+    if ($CFG->defaulthtmleditor == 'tinymce') {\r
+        echo 'skin : "o2k7",';\r
+    } else {\r
+        echo 'skin : "default",';\r
+    }\r
+}\r
+?>\r
+    entity_encoding : "raw",\r
+    theme_standard_statusbar_location : "bottom",\r
+    language : "<?php echo str_replace("_utf8", "", current_language()) ?>",\r
+<?php \r
+    include_once('langlist.php'); \r
+    echo "\n";\r
+    include_once('xhtml_ruleset.txt'); \r
+?>\r
+    plugins : "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emotions,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodleimage,moodlelink,dragmath,nonbreaking",             \r
+    theme_standard_buttons1_add : "styleselect,selectall,pastetext,pasteword,insertlayer",\r
+    theme_standard_buttons2_add : "styleprops,ltr,rtl,table,nonbreaking,media,advhr,emotions,emoticons,charmap,dragmath,spellchecker,search,code,fullscreen",\r
+<?php \r
+    $hidbut = $CFG->editorhidebuttons;\r
+if ($hidbut) {\r
+    $hidbut = str_replace(" ",",",$hidbut);\r
+    echo 'theme_standard_disable : "'.$hidbut.'",';\r
+} \r
+$tinyfts = $CFG->editorfontlist;\r
+if ($tinyfts) {\r
+    $tinyfts = str_replace(":","=",$tinyfts);\r
+    echo 'theme_standard_fonts : "'.$tinyfts.'",';\r
+} \r
+?> \r
+    spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",\r
+       moodleimage_course_id: <?php echo $COURSE->id; ?>,\r
+       theme_standard_resize_horizontal : true,\r
+       theme_standard_resizing : true,\r
+       file_browser_callback : "moodlefilemanager",\r
+       apply_source_formatting : true\r
+});\r
+function moodlefilemanager(field_name, url, type, win) {\r
+    tinyMCE.activeEditor.windowManager.open({\r
+        file : "<?php echo $CFG->wwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id=<?php echo $COURSE->id; ?>",\r
+        width : 480,  \r
+        height : 380,\r
+        resizable : "yes",\r
+        inline : "yes",  \r
+        close_previous : "no"\r
+    }, {\r
+        window : win,\r
+        input : field_name\r
+    });\r
+    return false;\r
+}\r
+</script>\r
diff --git a/lib/editor/tinymce/coursefiles.php b/lib/editor/tinymce/coursefiles.php
new file mode 100644 (file)
index 0000000..358a568
--- /dev/null
@@ -0,0 +1,818 @@
+<?php // $Id$\r
+\r
+//  Manage all uploaded files in a course file area\r
+\r
+//  This file is a hack to files/index.php that removes\r
+//  the headers and adds some controls so that images\r
+//  can be selected within the Richtext editor.\r
+\r
+//  All the Moodle-specific stuff is in this top section\r
+//  Configuration and access control occurs here.\r
+//  Must define:  USER, basedir, baseweb, html_header and html_footer\r
+//  USER is a persistent variable using sessions\r
+\r
+    require("../../../config.php");\r
+    require_once($CFG->libdir.'/filelib.php');\r
+\r
+    $id      = required_param('id', PARAM_INT);\r
+    $file    = optional_param('file', '', PARAM_PATH);\r
+    $wdir    = optional_param('wdir', '', PARAM_PATH);\r
+    $action  = optional_param('action', '', PARAM_ACTION);\r
+    $name    = optional_param('name', '', PARAM_FILE);\r
+    $oldname = optional_param('oldname', '', PARAM_FILE);\r
+    $usecheckboxes  = optional_param('usecheckboxes', 1, PARAM_INT);\r
+    $save    = optional_param('save', 0, PARAM_BOOL);\r
+    $text    = optional_param('text', '', PARAM_RAW);\r
+    $confirm = optional_param('confirm', 0, PARAM_BOOL);\r
+\r
+\r
+    if (! $course = get_record("course", "id", $id) ) {\r
+        print_error("That's an invalid course id");\r
+    }\r
+\r
+    require_login($course);\r
+    require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id));\r
+\r
+    function html_footer() {\r
+        echo "\n\n</body>\n</html>";\r
+    }\r
+\r
+    function html_header($course, $wdir, $formfield=""){\r
+\r
+        global $CFG;\r
+\r
+        ?>\r
+        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\r
+            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+        <html>\r
+        <head>\r
+        <meta http-equiv="content-type" content="text/html; charset=utf-8" />\r
+        <title>coursefiles</title>\r
+        <script type="text/javascript">\r
+//<![CDATA[\r
+\r
+\r
+        function set_value(params) {\r
+            /// function's argument is an object containing necessary values\r
+            /// to export parent window (url,isize,itype,iwidth,iheight, imodified)\r
+            /// set values when user click's an image name.\r
+            var upper = window.parent;\r
+            var insimg = upper.document.getElementById('f_url');\r
+\r
+            try {\r
+                if(insimg != null) {\r
+                    if(params.itype.indexOf("image/gif") == -1 && params.itype.indexOf("image/jpeg") == -1 && params.itype.indexOf("image/png") == -1) {\r
+                        alert("<?php print_string("notimage","editor");?>");\r
+                        return false;\r
+                    }\r
+                    for(field in params) {\r
+                        var value = params[field];\r
+                        switch(field) {\r
+                            case "url"   :   upper.document.getElementById('f_url').value = value;\r
+                                     upper.ipreview.location.replace('preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ value);\r
+                                break;\r
+                            case "isize" :   upper.document.getElementById('isize').value = value; break;\r
+                            case "itype" :   upper.document.getElementById('itype').value = value; break;\r
+                            case "iwidth":    upper.document.getElementById('f_width').value = value; break;\r
+                            case "iheight":   upper.document.getElementById('f_height').value = value; break;\r
+                        }\r
+                    }\r
+                } else {\r
+                    for(field in params) {\r
+                        var value = params[field];\r
+                        switch(field) {\r
+                            case "url" :\r
+                                //upper.document.getElementById('f_href').value = value;\r
+                                //upper.opener.document.getElementById('f_href').value = value;\r
+                                //upper.close();\r
+                                upper.FileBrowserDialogue.mySubmit(value);\r
+                                break;\r
+                            //case "imodified" : upper.document.getElementById('imodified').value = value; break;\r
+                            //case "isize" : upper.document.getElementById('isize').value = value; break;\r
+                            //case "itype" : upper.document.getElementById('itype').value = value; break;\r
+                        }\r
+                    }\r
+                }\r
+            } catch(e) {\r
+                if ( window.tinyMCE != "undefined" || window.TinyMCE != "undefined" ) {\r
+                    //upper.opener.Dialog._return(params.url);\r
+                    //upper.close();\r
+                } else {\r
+                    alert("Something odd just occurred!!!");\r
+                }\r
+            }\r
+            return false;\r
+        }\r
+\r
+        function set_dir(strdir) {\r
+            // sets wdir values\r
+            var upper = window.parent.document;\r
+            if(upper) {\r
+                for(var i = 0; i < upper.forms.length; i++) {\r
+                    var f = upper.forms[i];\r
+                    try {\r
+                        f.wdir.value = strdir;\r
+                    } catch (e) {\r
+\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        function set_rename(strfile) {\r
+            var upper = window.parent.document;\r
+            upper.getElementById('irename').value = strfile;\r
+            return true;\r
+        }\r
+\r
+        function reset_value() {\r
+            var upper = window.parent.document;\r
+            //for(var i = 0; i < upper.forms.length; i++) {\r
+                //var f = upper.forms[i];\r
+                //for(var j = 0; j < f.elements.length; j++) {\r
+                    //var e = f.elements[j];\r
+                    //if(e.type != "submit" && e.type != "button" && e.type != "hidden") {\r
+                       // try {\r
+                           // e.value = "";\r
+                        //} catch (e) {\r
+                        //}\r
+                    //}\r
+               // }\r
+            //}\r
+            upper.getElementById('irename').value = 'xx';\r
+\r
+            var prev = window.parent.ipreview;\r
+            if(prev != null) {\r
+                //prev.location.replace('about:blank');\r
+            }\r
+            var uploader = window.parent.document.forms['uploader'];\r
+            if(uploader != null) {\r
+                uploader.reset();\r
+            }\r
+            set_dir('<?php print($wdir);?>');\r
+            return true;\r
+        }\r
+//]]>\r
+        </script>\r
+        <style type="text/css">\r
+        body {\r
+            background-color: white;\r
+            margin-top: 2px;\r
+            margin-left: 4px;\r
+            margin-right: 4px;\r
+        }\r
+        body,p,table,td,input,select,a {\r
+            font-family: Tahoma, sans-serif;\r
+            font-size: 11px;\r
+        }\r
+        select {\r
+            position: absolute;\r
+            top: -20px;\r
+            left: 0px;\r
+        }\r
+        img.icon {\r
+          vertical-align:middle;\r
+          margin-right:4px;\r
+          width:16px;\r
+          height:16px;\r
+          border:0px;\r
+        }\r
+        </style>\r
+        </head>\r
+        <body onload="reset_value();">\r
+\r
+        <?php\r
+    }\r
+\r
+    if (! $basedir = make_upload_directory("$course->id")) {\r
+        print_error("The site administrator needs to fix the file permissions");\r
+    }\r
+\r
+    $baseweb = $CFG->wwwroot;\r
+\r
+//  End of configuration and access control\r
+\r
+\r
+    if ($wdir == '') {\r
+        $wdir='/';\r
+    }\r
+\r
+    switch ($action) {\r
+\r
+        case "upload":\r
+            html_header($course, $wdir);\r
+            require_once($CFG->dirroot.'/lib/uploadlib.php');\r
+\r
+            if ($save and confirm_sesskey()) {\r
+                $um = new upload_manager('userfile',false,false,$course,false,0);\r
+                $dir = "$basedir$wdir";\r
+                if ($um->process_file_uploads($dir)) {\r
+                    notify(get_string('uploadedfile'));\r
+                }\r
+                // um will take care of error reporting.\r
+                displaydir($wdir);\r
+            } else {\r
+                $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);\r
+                $filesize = display_size($upload_max_filesize);\r
+\r
+                $struploadafile = get_string("uploadafile");\r
+                $struploadthisfile = get_string("uploadthisfile");\r
+                $strmaxsize = get_string("maxsize", "", $filesize);\r
+                $strcancel = get_string("cancel");\r
+\r
+                echo "<p>$struploadafile ($strmaxsize) --> <strong>$wdir</strong>";\r
+                echo "<table border=\"0\"><tr><td colspan=\"2\">\n";\r
+                echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"coursefiles.php\">\n";\r
+                upload_print_form_fragment(1,array('userfile'),null,false,null,$course->maxbytes,0,false);\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />\n";\r
+                echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";\r
+                echo " </td><tr><td align=\"right\">";\r
+                echo " <input type=\"submit\" name=\"save\" value=\"$struploadthisfile\" />\n";\r
+                echo "</form>\n";\r
+                echo "</td>\n<td>\n";\r
+                echo "<form action=\"coursefiles.php\" method=\"get\">\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";\r
+                echo " <input type=\"submit\" value=\"$strcancel\" />\n";\r
+                echo "</form>\n";\r
+                echo "</td>\n</tr>\n</table>\n";\r
+            }\r
+            html_footer();\r
+            break;\r
+\r
+        case "delete":\r
+            if ($confirm and confirm_sesskey()) {\r
+                html_header($course, $wdir);\r
+                foreach ($USER->filelist as $file) {\r
+                    $fullfile = $basedir.$file;\r
+                    if (! fulldelete($fullfile)) {\r
+                        echo "<br />Error: Could not delete: $fullfile";\r
+                    }\r
+                }\r
+                clearfilelist();\r
+                displaydir($wdir);\r
+                html_footer();\r
+\r
+            } else {\r
+                html_header($course, $wdir);\r
+                if (setfilelist($_POST)) {\r
+                    echo "<p align=center>".get_string("deletecheckwarning").":</p>";\r
+                    print_simple_box_start("center");\r
+                    printfilelist($USER->filelist);\r
+                    print_simple_box_end();\r
+                    echo "<br />";\r
+                    $frameold = $CFG->framename;\r
+                    $CFG->framename = "ibrowser";\r
+                    notice_yesno (get_string("deletecheckfiles"),\r
+                                "coursefiles.php?id=$id&amp;wdir=$wdir&amp;action=delete&amp;confirm=1&amp;sesskey=$USER->sesskey",\r
+                                "coursefiles.php?id=$id&amp;wdir=$wdir&amp;action=cancel");\r
+                    $CFG->framename = $frameold;\r
+                } else {\r
+                    displaydir($wdir);\r
+                }\r
+                html_footer();\r
+            }\r
+            break;\r
+\r
+        case "move":\r
+            html_header($course, $wdir);\r
+            if ($count = setfilelist($_POST) and confirm_sesskey()) {\r
+                $USER->fileop     = $action;\r
+                $USER->filesource = $wdir;\r
+                echo "<p align=\"center\">";\r
+                print_string("selectednowmove", "moodle", $count);\r
+                echo "</p>";\r
+            }\r
+            displaydir($wdir);\r
+            html_footer();\r
+            break;\r
+\r
+        case "paste":\r
+            html_header($course, $wdir);\r
+            if (isset($USER->fileop) and $USER->fileop == "move" and confirm_sesskey()) {\r
+                foreach ($USER->filelist as $file) {\r
+                    $shortfile = basename($file);\r
+                    $oldfile = $basedir.$file;\r
+                    $newfile = $basedir.$wdir."/".$shortfile;\r
+                    if (!rename($oldfile, $newfile)) {\r
+                        echo "<p>Error: $shortfile not moved";\r
+                    }\r
+                }\r
+            }\r
+            clearfilelist();\r
+            displaydir($wdir);\r
+            html_footer();\r
+            break;\r
+\r
+        case "rename":\r
+            if (!empty($name) and confirm_sesskey()) {\r
+                html_header($course, $wdir);\r
+                $name    = clean_filename($name);\r
+                if (file_exists($basedir.$wdir."/".$name)) {\r
+                    echo "Error: $name already exists!";\r
+                } else if (!@rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) {\r
+                    echo "Error: could not rename $oldname to $name";\r
+                }\r
+                displaydir($wdir);\r
+\r
+            } else {\r
+                $strrename = get_string("rename");\r
+                $strcancel = get_string("cancel");\r
+                $strrenamefileto = get_string("renamefileto", "moodle", $file);\r
+                html_header($course, $wdir, "form.name");\r
+                echo "<p>$strrenamefileto:";\r
+                echo "<table border=\"0\">\n<tr>\n<td>\n";\r
+                echo "<form action=\"coursefiles.php\" method=\"post\" id=\"form\">\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"rename\" />\n";\r
+                echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";\r
+                echo " <input type=\"hidden\" name=\"oldname\" value=\"$file\" />\n";\r
+                echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"$file\" />\n";\r
+                echo " <input type=\"submit\" value=\"$strrename\" />\n";\r
+                echo "</form>\n";\r
+                echo "</td><td>\n";\r
+                echo "<form action=\"coursefiles.php\" method=\"get\">\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";\r
+                echo " <input type=\"submit\" value=\"$strcancel\" />\n";\r
+                echo "</form>";\r
+                echo "</td></tr>\n</table>\n";\r
+            }\r
+            html_footer();\r
+            break;\r
+\r
+        case "mkdir":\r
+            if (!empty($name) and confirm_sesskey()) {\r
+                html_header($course, $wdir);\r
+                $name = clean_filename($name);\r
+                if (file_exists("$basedir$wdir/$name")) {\r
+                    echo "Error: $name already exists!";\r
+                } else if (! make_upload_directory("$course->id/$wdir/$name")) {\r
+                    echo "Error: could not create $name";\r
+                }\r
+                displaydir($wdir);\r
+\r
+            } else {\r
+                $strcreate = get_string("create");\r
+                $strcancel = get_string("cancel");\r
+                $strcreatefolder = get_string("createfolder", "moodle", $wdir);\r
+                html_header($course, $wdir, "form.name");\r
+                echo "<p>$strcreatefolder:";\r
+                echo "<table border=\"0\">\n<tr><td>\n";\r
+                echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"mkdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";\r
+                echo " <input type=\"text\" name=\"name\" size=\"35\" />\n";\r
+                echo " <input type=\"submit\" value=\"$strcreate\" />\n";\r
+                echo "</form>\n";\r
+                echo "</td><td>\n";\r
+                echo "<form action=\"coursefiles.php\" method=\"get\">\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";\r
+                echo " <input type=\"submit\" value=\"$strcancel\" />\n";\r
+                echo "</form>\n";\r
+                echo "</td>\n</tr>\n</table>\n";\r
+            }\r
+            html_footer();\r
+            break;\r
+\r
+        case "edit":\r
+            html_header($course, $wdir);\r
+            if (($text != '') and confirm_sesskey()) {\r
+                $fileptr = fopen($basedir.$file,"w");\r
+                fputs($fileptr, stripslashes($text));\r
+                fclose($fileptr);\r
+                displaydir($wdir);\r
+\r
+            } else {\r
+                $streditfile = get_string("edit", "", "<strong>$file</strong>");\r
+                $fileptr  = fopen($basedir.$file, "r");\r
+                $contents = fread($fileptr, filesize($basedir.$file));\r
+                fclose($fileptr);\r
+\r
+                print_heading("$streditfile");\r
+\r
+                echo "<table><tr><td colspan=\"2\">\n";\r
+                echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\" $onsubmit>\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=file value=\"$file\" />";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"edit\" />\n";\r
+                echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";\r
+                print_textarea(false, 25, 80, 680, 400, "text", $contents);\r
+                echo "</td>\n</tr>\n<tr>\n<td>\n";\r
+                echo " <input type=\"submit\" value=\"".get_string("savechanges")."\" />\n";\r
+                echo "</form>\n";\r
+                echo "</td>\n<td>\n";\r
+                echo "<form action=\"coursefiles.php\" method=\"get\">\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";\r
+                echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />\n";\r
+                echo "</form>\n";\r
+                echo "</td></tr></table>\n";\r
+\r
+                if ($usehtmleditor) {\r
+                    use_html_editor("text");\r
+                }\r
+\r
+\r
+            }\r
+            html_footer();\r
+            break;\r
+\r
+        case "zip":\r
+            if (!empty($name) and confirm_sesskey()) {\r
+                html_header($course, $wdir);\r
+                $name = clean_filename($name);\r
+\r
+                $files = array();\r
+                foreach ($USER->filelist as $file) {\r
+                   $files[] = "$basedir/$file";\r
+                }\r
+\r
+                if (!zip_files($files,"$basedir/$wdir/$name")) {\r
+                    print_error("zipfileserror","error");\r
+                }\r
+\r
+                clearfilelist();\r
+                displaydir($wdir);\r
+\r
+            } else {\r
+                html_header($course, $wdir, "form.name");\r
+\r
+                if (setfilelist($_POST)) {\r
+                    echo "<p align=\"center\">".get_string("youareabouttocreatezip").":</p>";\r
+                    print_simple_box_start("center");\r
+                    printfilelist($USER->filelist);\r
+                    print_simple_box_end();\r
+                    echo "<br />";\r
+                    echo "<p align=\"center\">".get_string("whattocallzip");\r
+                    echo "<table border=\"0\">\n<tr>\n<td>\n";\r
+                    echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n";\r
+                    echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                    echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                    echo " <input type=\"hidden\" name=\"action\" value=\"zip\" />\n";\r
+                    echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";\r
+                    echo " <INPUT type=\"text\" name=\"name\" size=\"35\" value=\"new.zip\" />\n";\r
+                    echo " <input type=\"submit\" value=\"".get_string("createziparchive")."\" />";\r
+                    echo "</form>\n";\r
+                    echo "</td>\n<td>\n";\r
+                    echo "<form action=\"coursefiles.php\" method=\"get\">\n";\r
+                    echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                    echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                    echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";\r
+                    echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />\n";\r
+                    echo "</form>\n";\r
+                    echo "</td>\n</tr>\n</table>\n";\r
+                } else {\r
+                    displaydir($wdir);\r
+                    clearfilelist();\r
+                }\r
+            }\r
+            html_footer();\r
+            break;\r
+\r
+        case "unzip":\r
+            html_header($course, $wdir);\r
+            if (!empty($file) and confirm_sesskey()) {\r
+                $strok = get_string("ok");\r
+                $strunpacking = get_string("unpacking", "", $file);\r
+\r
+                echo "<p align=\"center\">$strunpacking:</p>";\r
+\r
+                $file = basename($file);\r
+\r
+                if (!unzip_file("$basedir/$wdir/$file")) {\r
+                    print_error("unzipfileserror","error");\r
+                }\r
+\r
+                echo "<center><form action=\"coursefiles.php\" method=\"get\">\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";\r
+                echo " <input type=\"submit\" value=\"$strok\" />\n";\r
+                echo "</form>\n";\r
+                echo "</center>\n";\r
+            } else {\r
+                displaydir($wdir);\r
+            }\r
+            html_footer();\r
+            break;\r
+\r
+        case "listzip":\r
+            html_header($course, $wdir);\r
+            if (!empty($file) and confirm_sesskey()) {\r
+                $strname = get_string("name");\r
+                $strsize = get_string("size");\r
+                $strmodified = get_string("modified");\r
+                $strok = get_string("ok");\r
+                $strlistfiles = get_string("listfiles", "", $file);\r
+\r
+                echo "<p align=\"center\">$strlistfiles:</p>";\r
+                $file = basename($file);\r
+\r
+                require_once($CFG->libdir.'/pclzip/pclzip.lib.php');\r
+                $archive = new PclZip("$basedir/$wdir/$file");\r
+                if (!$list = $archive->listContent("$basedir/$wdir")) {\r
+                    notify($archive->errorInfo(true));\r
+\r
+                } else {\r
+                    echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\">\n";\r
+                    echo "<tr>\n<th align=\"left\" scope=\"col\">$strname</th><th align=\"right\" scope=\"col\">$strsize</th><th align=\"right\" scope=\"col\">$strmodified</th></tr>";\r
+                    foreach ($list as $item) {\r
+                        echo "<tr>";\r
+                        print_cell("left", $item['filename']);\r
+                        if (! $item['folder']) {\r
+                            print_cell("right", display_size($item['size']));\r
+                        } else {\r
+                            echo "<td>&nbsp;</td>\n";\r
+                        }\r
+                        $filedate  = userdate($item['mtime'], get_string("strftimedatetime"));\r
+                        print_cell("right", $filedate);\r
+                        echo "</tr>\n";\r
+                    }\r
+                    echo "</table>\n";\r
+                }\r
+                echo "<br /><center><form action=\"coursefiles.php\" method=\"get\">\n";\r
+                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+                echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";\r
+                echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";\r
+                echo " <input type=\"submit\" value=\"$strok\" />\n";\r
+                echo "</form>\n";\r
+                echo "</center>\n";\r
+            } else {\r
+                displaydir($wdir);\r
+            }\r
+            html_footer();\r
+            break;\r
+\r
+        case "cancel":\r
+            clearfilelist();\r
+\r
+        default:\r
+            html_header($course, $wdir);\r
+            displaydir($wdir);\r
+            html_footer();\r
+            break;\r
+}\r
+\r
+\r
+/// FILE FUNCTIONS ///////////////////////////////////////////////////////////\r
+\r
+\r
+function setfilelist($VARS) {\r
+    global $USER;\r
+\r
+    $USER->filelist = array ();\r
+    $USER->fileop = "";\r
+\r
+    $count = 0;\r
+    foreach ($VARS as $key => $val) {\r
+        if (substr($key,0,4) == "file") {\r
+            $count++;\r
+            $val = rawurldecode($val);\r
+            if (!detect_munged_arguments($val, 0)) {\r
+                $USER->filelist[] = $val;\r
+            }\r
+        }\r
+    }\r
+    return $count;\r
+}\r
+\r
+function clearfilelist() {\r
+    global $USER;\r
+\r
+    $USER->filelist = array ();\r
+    $USER->fileop = "";\r
+}\r
+\r
+\r
+function printfilelist($filelist) {\r
+    global $basedir, $CFG;\r
+\r
+    foreach ($filelist as $file) {\r
+        if (is_dir($basedir.$file)) {\r
+            echo "<img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"".get_string('folder')."\" /> $file<br />";\r
+            $subfilelist = array();\r
+            $currdir = opendir($basedir.$file);\r
+            while (false !== ($subfile = readdir($currdir))) {\r
+                if ($subfile <> ".." && $subfile <> ".") {\r
+                    $subfilelist[] = $file."/".$subfile;\r
+                }\r
+            }\r
+            printfilelist($subfilelist);\r
+\r
+        } else {\r
+            $icon = mimeinfo("icon", $file);\r
+            echo "<img src=\"$CFG->pixpath/f/$icon\"  class=\"icon\" alt=\"".get_string('file')."\" /> $file<br />";\r
+        }\r
+    }\r
+}\r
+\r
+\r
+function print_cell($alignment="center", $text="&nbsp;") {\r
+    echo "<td align=\"$alignment\" nowrap=\"nowrap\">\n";\r
+    echo "$text";\r
+    echo "</td>\n";\r
+}\r
+\r
+function get_image_size($filepath) {\r
+/// This function get's the image size\r
+\r
+    /// Check if file exists\r
+    if(!file_exists($filepath)) {\r
+        return false;\r
+    } else {\r
+        /// Get the mime type so it really an image.\r
+        if(mimeinfo("icon", basename($filepath)) != "image.gif") {\r
+            return false;\r
+        } else {\r
+            $array_size = getimagesize($filepath);\r
+            return $array_size;\r
+        }\r
+    }\r
+    unset($filepath,$array_size);\r
+}\r
+\r
+function displaydir ($wdir) {\r
+//  $wdir == / or /a or /a/b/c/d  etc\r
+\r
+    global $basedir;\r
+    global $usecheckboxes;\r
+    global $id;\r
+    global $USER, $CFG;\r
+\r
+    $fullpath = $basedir.$wdir;\r
+\r
+    $directory = opendir($fullpath);             // Find all files\r
+    while (false !== ($file = readdir($directory))) {\r
+        if ($file == "." || $file == "..") {\r
+            continue;\r
+        }\r
+\r
+        if (is_dir($fullpath."/".$file)) {\r
+            $dirlist[] = $file;\r
+        } else {\r
+            $filelist[] = $file;\r
+        }\r
+    }\r
+    closedir($directory);\r
+\r
+    $strfile = get_string("file");\r
+    $strname = get_string("name");\r
+    $strsize = get_string("size");\r
+    $strmodified = get_string("modified");\r
+    $straction = get_string("action");\r
+    $strmakeafolder = get_string("makeafolder");\r
+    $struploadafile = get_string("uploadafile");\r
+    $strwithchosenfiles = get_string("withchosenfiles");\r
+    $strmovetoanotherfolder = get_string("movetoanotherfolder");\r
+    $strmovefilestohere = get_string("movefilestohere");\r
+    $strdeletecompletely = get_string("deletecompletely");\r
+    $strcreateziparchive = get_string("createziparchive");\r
+    $strrename = get_string("rename");\r
+    $stredit   = get_string("edit");\r
+    $strunzip  = get_string("unzip");\r
+    $strlist   = get_string("list");\r
+    $strchoose   = get_string("choose");\r
+\r
+\r
+    echo "<form action=\"coursefiles.php\" method=\"post\" name=\"dirform\">\n";\r
+    echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">\n";\r
+\r
+    if ($wdir == "/") {\r
+        $wdir = "";\r
+    } else {\r
+        $bdir = str_replace("/".basename($wdir),"",$wdir);\r
+        if($bdir == "/") {\r
+            $bdir = "";\r
+        }\r
+        print "<tr>\n<td colspan=\"5\">";\r
+        print "<a href=\"coursefiles.php?id=$id&amp;wdir=$bdir&amp;usecheckboxes=$usecheckboxes\" onclick=\"return reset_value();\">";\r
+        print "<img src=\"$CFG->wwwroot/lib/editor/htmlarea/images/folderup.gif\" height=\"14\" width=\"24\" border=\"0\" alt=\"".get_string('parentfolder')."\" />";\r
+        print "</a></td>\n</tr>\n";\r
+    }\r
+\r
+    $count = 0;\r
+\r
+    if (!empty($dirlist)) {\r
+        asort($dirlist);\r
+        foreach ($dirlist as $dir) {\r
+\r
+            $count++;\r
+\r
+            $filename = $fullpath."/".$dir;\r
+            $fileurl  = $wdir."/".$dir;\r
+            $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");\r
+\r
+            echo "<tr>";\r
+\r
+            if ($usecheckboxes) {\r
+                print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" onclick=\"return set_rename('$dir');\" />");\r
+            }\r
+            print_cell("left", "<a href=\"coursefiles.php?id=$id&amp;wdir=$fileurl\" onclick=\"return reset_value();\"><img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"".get_string('folder')."\" /></a> <a href=\"coursefiles.php?id=$id&amp;wdir=$fileurl&amp;usecheckboxes=$usecheckboxes\" onclick=\"return reset_value();\">".htmlspecialchars($dir)."</a>");\r
+            print_cell("right", "&nbsp;");\r
+            print_cell("right", $filedate);\r
+\r
+            echo "</tr>";\r
+        }\r
+    }\r
+\r
+\r
+    if (!empty($filelist)) {\r
+        asort($filelist);\r
+        foreach ($filelist as $file) {\r
+\r
+            $icon = mimeinfo("icon", $file);\r
+            $imgtype = mimeinfo("type",$file);\r
+\r
+            $count++;\r
+            $filename    = $fullpath."/".$file;\r
+            $fileurl     = "$wdir/$file";\r
+            $filedate    = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");\r
+\r
+            $dimensions = get_image_size($filename);\r
+            if($dimensions) {\r
+                $imgwidth = $dimensions[0];\r
+                $imgheight = $dimensions[1];\r
+            } else {\r
+                $imgwidth = "Unknown";\r
+                $imgheight = "Unknown";\r
+            }\r
+            unset($dimensions);\r
+            echo "<tr>\n";\r
+\r
+            if ($usecheckboxes) {\r
+                print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" onclick=\";return set_rename('$file');\" />");\r
+            }\r
+            echo "<td align=\"left\" nowrap=\"nowrap\">";\r
+            if ($CFG->slasharguments) {\r
+                $ffurl = "/file.php/$id$fileurl";\r
+            } else {\r
+                $ffurl = "/file.php?file=/$id$fileurl";\r
+            }\r
+            link_to_popup_window ($ffurl, "display",\r
+                                  "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" />",\r
+                                  480, 640);\r
+            $file_size = filesize($filename);\r
+\r
+            echo "<a onclick=\"return set_value(info = {url: '".$CFG->wwwroot.$ffurl."',";\r
+            echo " isize: '".$file_size."', itype: '".$imgtype."', iwidth: '".$imgwidth."',";\r
+            echo " iheight: '".$imgheight."', imodified: '".$filedate."' })\" href=\"#\">$file</a>";\r
+            echo "</td>\n";\r
+\r
+            if ($icon == "zip.gif") {\r
+                $edittext = "<a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$fileurl&amp;action=unzip&amp;sesskey=$USER->sesskey\">$strunzip</a>&nbsp;";\r
+                $edittext .= "<a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$fileurl&amp;action=listzip&amp;sesskey=$USER->sesskey\">$strlist</a> ";\r
+            } else {\r
+                $edittext = "&nbsp;";\r
+            }\r
+            print_cell("right", "$edittext ");\r
+            print_cell("right", $filedate);\r
+\r
+            echo "</tr>\n";\r
+        }\r
+    }\r
+    echo "</table>\n";\r
+\r
+    if (empty($wdir)) {\r
+        $wdir = "/";\r
+    }\r
+\r
+    echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n";\r
+    echo "<tr>\n<td>";\r
+    echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+    echo "<input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+    echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";\r
+    $options = array (\r
+                   "move" => "$strmovetoanotherfolder",\r
+                   "delete" => "$strdeletecompletely",\r
+                   "zip" => "$strcreateziparchive"\r
+               );\r
+    if (!empty($count)) {\r
+        choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:getElementById('dirform').submit()");\r
+    }\r
+    if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) {\r
+        echo "<form action=\"coursefiles.php\" method=\"get\">\n";\r
+        echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";\r
+        echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";\r
+        echo " <input type=\"hidden\" name=\"action\" value=\"paste\" />\n";\r
+        echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";\r
+        echo " <input type=\"submit\" value=\"$strmovefilestohere\" />\n";\r
+        echo "</form>";\r
+    }\r
+    echo "</td></tr>\n";\r
+    echo "</table>\n";\r
+    echo "</form>\n";\r
+}\r
+?>\r
index c3fb9aebce26165853edd279b7d2249022332fff..bf1e0a9e40c7dea73eeaa9aef54fbeb152316c4a 100644 (file)
@@ -218,7 +218,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
       <td width="55%" valign="top"><?php\r
           print_string("filebrowser","editor");\r
           echo "<br />";\r
-          echo "<iframe id=\"ibrowser\" name=\"ibrowser\" src=\"{$CFG->wwwroot}/lib/editor/tinymce/jscripts/tiny_mce/coursefiles.php?usecheckboxes=1&id=$id\" style=\"width: 100%; height: 200px;\"></iframe>";\r
+          echo "<iframe id=\"ibrowser\" name=\"ibrowser\" src=\"{$CFG->wwwroot}/lib/editor/tinymce/coursefiles.php?usecheckboxes=1&id=$id\" style=\"width: 100%; height: 200px;\"></iframe>";\r
       ?>\r
       </td>\r
       <td width="45%" valign="top"><?php print_string("preview","editor");?>:<br />\r
@@ -238,7 +238,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
           <input name="btnMove" type="submit" id="btnMove" value="<?php print_string("move","editor");?>" onclick="return submit_form('move');" /></td>\r
           <td><form id="izip">\r
           <input name="btnZip" type="submit" id="btnZip" value="<?php print_string("zip","editor");?>" onclick="return submit_form('zip');" /></form></td>\r
-          <td><form method="post" action="../coursefiles.php" target="ibrowser">\r
+          <td><form method="post" action="../../../coursefiles.php" target="ibrowser">\r
           <input type="hidden" name="id" value="<?php print($id);?>" />\r
           <input type="hidden" name="wdir" value="" />\r
           <input type="hidden" id="irename" name="file" value="" />\r
@@ -265,7 +265,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
     </tr>\r
     <tr>\r
       <td height="22">\r
-          <form id="cfolder" action="<?php echo $CFG->wwwroot;?>/lib/editor/tinymce/jscripts/tiny_mce/coursefiles.php" method="post" target="ibrowser">\r
+          <form id="cfolder" action="<?php echo $CFG->wwwroot;?>/lib/editor/tinymce/coursefiles.php" method="post" target="ibrowser">\r
           <input type="hidden" name="id" value="<?php print($id);?>" />\r
           <input type="hidden" name="wdir" value="" />\r
           <input type="hidden" name="action" value="mkdir" />\r
@@ -276,7 +276,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
           \r
           </form>\r
           <div class="space"></div>\r
-          <form action="<?php echo $CFG->wwwroot;?>/lib/editor/tinymce/jscripts/tiny_mce/coursefiles.php?id=<?php print($id);?>" method="post" enctype="multipart/form-data" target="ibrowser" id="uploader">\r
+          <form action="<?php echo $CFG->wwwroot;?>/lib/editor/tinymce/coursefiles.php?id=<?php print($id);?>" method="post" enctype="multipart/form-data" target="ibrowser" id="uploader">\r
           <input type="hidden" name="MAX_FILE_SIZE" value="<?php print($upload_max_filesize);?>" />\r
           <input type="hidden" name="id" VALUE="<?php print($id);?>" />\r
           <input type="hidden" name="wdir" value="" />\r
index d255af8fd30e3989396a2f0ea97cc1030c0aae50..67f9ae7950e447c2ce871319001ff12a25e54021 100644 (file)
@@ -112,7 +112,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
 \r
         <div class="space"></div>\r
         <?php print(has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id)))?\r
-        "<iframe id=\"fbrowser\" name=\"fbrowser\" src=\"../../coursefiles.php?id=".$id."\" width=\"420\" height=\"180\"></iframe>":\r
+        "<iframe id=\"fbrowser\" name=\"fbrowser\" src=\"../../../../coursefiles.php?id=".$id."\" width=\"420\" height=\"180\"></iframe>":\r
         ""; ?>\r
         <p>\r
         </p>\r
@@ -131,7 +131,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
           <input name="btnMove" type="submit" id="btnMove" value="<?php print_string("move","editor");?>" onclick="return submit_form('move');" /></form></td>\r
           <td><form id="izip">\r
           <input name="btnZip" type="submit" id="btnZip" value="<?php print_string("zip","editor");?>" onclick="return submit_form('zip');" /></form></td>\r
-          <td><form id="irename" method="post" action="../../coursefiles.php" target="fbrowser">\r
+          <td><form id="irename" method="post" action="../../../../coursefiles.php" target="fbrowser">\r
           <input type="hidden" name="id" value="<?php print($id);?>" />\r
           <input type="hidden" name="wdir" value="" />\r
           <input type="hidden" name="file" value="" />\r
@@ -150,7 +150,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
     <tr>\r
       <td height="22"><?php\r
       if(has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id))) { ?>\r
-          <form id="cfolder" action="../../coursefiles.php" method="post" target="fbrowser">\r
+          <form id="cfolder" action="../../../../coursefiles.php" method="post" target="fbrowser">\r
           <input type="hidden" name="id" value="<?php print($id);?>" />\r
           <input type="hidden" name="wdir" value="" />\r
           <input type="hidden" name="action" value="mkdir" />\r
@@ -158,7 +158,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
           <input name="name" type="text" id="foldername" size="35" />\r
           <input name="btnCfolder" type="submit" id="btnCfolder" value="<?php print_string("createfolder","editor");?>" onclick="return checkvalue('foldername','cfolder');" />\r
           </form>\r
-          <form action="../../coursefiles.php?id=<?php print($id);?>" method="post" enctype="multipart/form-data" target="fbrowser" id="uploader">\r
+          <form action="../../../../coursefiles.php?id=<?php print($id);?>" method="post" enctype="multipart/form-data" target="fbrowser" id="uploader">\r
           <input type="hidden" name="MAX_FILE_SIZE" value="<?php print($upload_max_filesize);?>" />\r
           <input type="hidden" name="id" VALUE="<?php print($id);?>" />\r
           <input type="hidden" name="wdir" value="" />\r
diff --git a/lib/editor/tinymce/langlist.php b/lib/editor/tinymce/langlist.php
new file mode 100644 (file)
index 0000000..45dca6f
--- /dev/null
@@ -0,0 +1 @@
+theme_standard_styles : "aa=aa;ab=ab;ae=ae;af=af;am=am;ar=ar;as=as;ay=ay;az=az;ba=ba;be=be;bg=bg;bh=bh;bi=bi;bn=bn;bo=bo;br=br;bs=bs;ca=ca;ce=ce;ch=ch;co=co;cs=cs;cu=cu;cv=cv;cy=cy;da=da;de=de;dz=dz;el=el;en=en;eo=eo;es=es;et=et;eu=eu;fa=fa;fi=fi;fj=fj;fo=fo;fr=fr;fy=fy;ga=ga;gd=gd;gl=gl;gn=gn;gu=gu;gv=gv;ha=ha;he=he;hi=hi;ho=ho;hr=hr;hu=hu;hy=hy;hz=hz;ia=ia;id=id;ie=ie;ik=ik;is=is;it=it;iu=iu;ja=ja;jw=jw;ka=ka;ki=ki;kj=kj;kk=kk;kl=kl;km=km;kn=kn;ko=ko;ks=ks;ku=ku;kv=kv;kw=kw;ky=ky;la=la;lb=lb;ln=ln;lo=lo;lt=lt;lv=lv;mg=mg;mh=mh;mi=mi;mk=mk;ml=ml;mn=mn;mo=mo;mr=mr;ms=ms;mt=mt;my=my;na=na;nb=nb;nd=nd;ne=ne;ng=ng;nl=nl;nn=nn;no=no;nr=nr;nv=nv;ny=ny;oc=oc;om=om;or=or;os=os;pa=pa;ph=ph;pi=pi;pl=pl;ps=ps;pt=pt;pt-br=pt-br;qu=qu;rm=rm;rn=rn;ro=ro;ru=ru;rw=rw;sa=sa;sc=sc;sd=sd;se=se;sg=sg;si=si;sk=sk;sl=sl;sm=sm;sn=sn;so=so;sq=sq;sr=sr;ss=ss;st=st;su=su;sv=sv;sw=sw;ta=ta;te=te;tg=tg;th=th;tk=tk;tl=tl;tn=tn;tr=tr;ts=ts;tt=tt;tw=tw;ty=ty;ug=ug;uk=uk;ur=ur;uz=uz;vi=vi;vo=vo;wo=wo;xh=xh;yi=yi;za=za;zh=zh;zu=zu;multi=multi;aa_ml=aa_ML;ab_ml=ab_ML;ae_ml=ae_ML;af_ml=af_ML;am_ml=am_ML;ar_ml=ar_ML;as_ml=as_ML;ay_ml=ay_ML;az_ml=az_ML;ba_ml=ba_ML;be_ml=be_ML;bg_ml=bg_ML;bh_ml=bh_ML;bi_ml=bi_ML;bn_ml=bn_ML;bo_ml=bo_ML;br_ml=br_ML;bs_ml=bs_ML;ca_ml=ca_ML;ce_ml=ce_ML;ch_ml=ch_ML;co_ml=co_ML;cs_ml=cs_ML;cu_ml=cu_ML;cv_ml=cv_ML;cy_ml=cy_ML;da_ml=da_ML;de_ml=de_ML;dz_ml=dz_ML;el_ml=el_ML;en_ml=en_ML;eo_ml=eo_ML;es_ml=es_ML;et_ml=et_ML;eu_ml=eu_ML;fa_ml=fa_ML;fi_ml=fi_ML;fj_ml=fj_ML;fo_ml=fo_ML;fr_ml=fr_ML;fy_ml=fy_ML;ga_ml=ga_ML;gd_ml=gd_ML;gl_ml=gl_ML;gn_ml=gn_ML;gu_ml=gu_ML;gv_ml=gv_ML;ha_ml=ha_ML;he_ml=he_ML;hi_ml=hi_ML;ho_ml=ho_ML;hr_ml=hr_ML;hu_ml=hu_ML;hy_ml=hy_ML;hz_ml=hz_ML;ia_ml=ia_ML;id_ml=id_ML;ie_ml=ie_ML;ik_ml=ik_ML;is_ml=is_ML;it_ml=it_ML;iu_ml=iu_ML;ja_ml=ja_ML;jw_ml=jw_ML;ka_ml=ka_ML;ki_ml=ki_ML;kj_ml=kj_ML;kk_ml=kk_ML;kl_ml=kl_ML;km_ml=km_ML;kn_ml=kn_ML;ko_ml=ko_ML;ks_ml=ks_ML;ku_ml=ku_ML;kv_ml=kv_ML;kw_ml=kw_ML;ky_ml=ky_ML;la_ml=la_ML;lb_ml=lb_ML;ln_ml=ln_ML;lo_ml=lo_ML;lt_ml=lt_ML;lv_ml=lv_ML;mg_ml=mg_ML;mh_ml=mh_ML;mi_ml=mi_ML;mk_ml=mk_ML;ml_ml=ml_ML;mn_ml=mn_ML;mo_ml=mo_ML;mr_ml=mr_ML;ms_ml=ms_ML;mt_ml=mt_ML;my_ml=my_ML;na_ml=na_ML;nb_ml=nb_ML;nd_ml=nd_ML;ne_ml=ne_ML;ng_ml=ng_ML;nl_ml=nl_ML;nn_ml=nn_ML;no_ml=no_ML;nr_ml=nr_ML;nv_ml=nv_ML;ny_ml=ny_ML;oc_ml=oc_ML;om_ml=om_ML;or_ml=or_ML;os_ml=os_ML;pa_ml=pa_ML;ph_ml=ph_ML;pi_ml=pi_ML;pl_ml=pl_ML;ps_ml=ps_ML;pt_ml=pt_ML;pt-br_ml=pt-br_ML;qu_ml=qu_ML;rm_ml=rm_ML;rn_ml=rn_ML;ro_ml=ro_ML;ru_ml=ru_ML;rw_ml=rw_ML;sa_ml=sa_ML;sc_ml=sc_ML;sd_ml=sd_ML;se_ml=se_ML;sg_ml=sg_ML;si_ml=si_ML;sk_ml=sk_ML;sl_ml=sl_ML;sm_ml=sm_ML;sn_ml=sn_ML;so_ml=so_ML;sq_ml=sq_ML;sr_ml=sr_ML;ss_ml=ss_ML;st_ml=st_ML;su_ml=su_ML;sv_ml=sv_ML;sw_ml=sw_ML;ta_ml=ta_ML;te_ml=te_ML;tg_ml=tg_ML;th_ml=th_ML;tk_ml=tk_ML;tl_ml=tl_ML;tn_ml=tn_ML;tr_ml=tr_ML;ts_ml=ts_ML;tt_ml=tt_ML;tw_ml=tw_ML;ty_ml=ty_ML;ug_ml=ug_ML;uk_ml=uk_ML;ur_ml=ur_ML;uz_ml=uz_ML;vi_ml=vi_ML;vo_ml=vo_ML;wo_ml=wo_ML;xh_ml=xh_ML;yi_ml=yi_ML;za_ml=za_ML;zh_ml=zh_ML;zu_ml=zu_ML",
\ No newline at end of file
diff --git a/lib/editor/tinymce/messages.php b/lib/editor/tinymce/messages.php
new file mode 100644 (file)
index 0000000..6f8621e
--- /dev/null
@@ -0,0 +1,183 @@
+<?php \r
+function print_editor_config($editorhidebuttons='', $return=false) {\r
+    global $CFG;\r
+\r
+    $str = "config.pageStyle = \"body {";\r
+\r
+    if (!(empty($CFG->editorbackgroundcolor))) {\r
+        $str .= " background-color: $CFG->editorbackgroundcolor;";\r
+    }\r
+\r
+    if (!(empty($CFG->editorfontfamily))) {\r
+        $str .= " font-family: $CFG->editorfontfamily;";\r
+    }\r
+\r
+    if (!(empty($CFG->editorfontsize))) {\r
+        $str .= " font-size: $CFG->editorfontsize;";\r
+    }\r
+\r
+    $str .= " }\";\n";\r
+    $str .= "config.killWordOnPaste = ";\r
+    $str .= (empty($CFG->editorkillword)) ? "false":"true";\r
+    $str .= ';'."\n";\r
+    $str .= 'config.fontname = {'."\n";\r
+\r
+    $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();\r
+    $i = 1;                     // Counter is used to get rid of the last comma.\r
+\r
+    foreach ($fontlist as $fontline) {\r
+        if (!empty($fontline)) {\r
+            if ($i > 1) {\r
+                $str .= ','."\n";\r
+            }\r
+            list($fontkey, $fontvalue) = split(':', $fontline);\r
+            $str .= '"'. $fontkey ."\":\t'". $fontvalue ."'";\r
+\r
+            $i++;\r
+        }\r
+    }\r
+    $str .= '};';\r
+\r
+    if (!empty($editorhidebuttons)) {\r
+        $str .= "\nconfig.hideSomeButtons(\" ". $editorhidebuttons ." \");\n";\r
+    } else if (!empty($CFG->editorhidebuttons)) {\r
+        $str .= "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n";\r
+    }\r
+\r
+    if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {\r
+        $str .= print_speller_code($CFG->htmleditor, true);\r
+    }\r
+\r
+    if ($return) {\r
+        return $str;\r
+    }\r
+    echo $str;\r
+}\r
+\r
+function use_html_editor($name='', $editorhidebuttons='', $id='') {\r
+}\r
+\r
+function use_admin_editor($name='', $editorhidebuttons='', $id='') {\r
+    echo '<script type="text/javascript">tsetup();</script>';\r
+}\r
+\r
+function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') {\r
+    global $CFG, $COURSE, $HTTPSPAGEREQUIRED;\r
+    $str = '';\r
+    if ($id === '') {\r
+        $id = 'edit-'.$name;\r
+    }\r
+    if (empty($courseid)) {\r
+        $courseid = $COURSE->id;\r
+    }\r
+    if ($usehtmleditor) {\r
+        $str .= '<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';\r
+        $str .= htmlspecialchars($value); \r
+        $str .= '</textarea><br />'."\n";\r
+        $toggle_ed = '<img width="50" height="17" src="'.$CFG->wwwroot.'/lib/editor/tinymce/images/toggle.gif" '.\r
+            'alt="'.get_string('toggleeditor','editor').'" title="'.get_string('toggleeditor','editor').'" />';\r
+        $str .= "<a href=\"javascript:toggleEditor('".$id."');\">".$toggle_ed."</a> ";\r
+        $str .= '<script type="text/javascript">'."\n".\r
+            'document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');'."\n".\r
+            '</script>';\r
+    } else {\r
+        $str .= '<textarea class="alltext" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';  \r
+        $str .= s($value);\r
+        $str .= '</textarea>'."\n";\r
+    }\r
+    if ($return) {\r
+        return $str;\r
+    }\r
+    echo $str;\r
+}\r
+?>\r
+<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>\r
+<script type="text/javascript">\r
+function tsetup() { \r
+<?php\r
+if (!empty($COURSE->id) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {\r
+?>\r
+       tinyMCE.init({\r
+               relative_urls : false,\r
+        remove_script_host : false,\r
+        document_base_url : "<?php echo $CFG->wwwroot; ?>",\r
+               editor_selector : "form-textarea",\r
+               mode : "textareas",\r
+               theme : "standard",\r
+<?php \r
+if (!empty($USER->id)) {\r
+    if ($CFG->usehtmleditor == 'tinymce') {\r
+        echo 'skin : "o2k7",';\r
+    } else {\r
+        echo 'skin : "default",';\r
+    }\r
+} \r
+?>\r
+        entity_encoding : "raw",\r
+               plugins : "safari,emoticons,searchreplace,fullscreen,advimage,advlink,moodleimage,moodlelink",\r
+               \r
+               theme_standard_buttons1 : "fontselect,fontsizeselect,formatselect",\r
+               theme_standard_buttons2 : "bold,italic,underline,forecolor,backcolor,link,unlink,image,emoticons,charmap,code,fullscreen",\r
+        theme_standard_buttons3 : "",\r
+               theme_standard_toolbar_location : "top",\r
+               theme_standard_toolbar_align : "left",\r
+               theme_standard_statusbar_location : "bottom",\r
+               moodleimage_course_id: <?php echo $COURSE->id; ?>,\r
+               theme_standard_resize_horizontal : true,\r
+               theme_standard_resizing : true,\r
+               file_browser_callback : "moodlefilemanager",\r
+               apply_source_formatting : true          \r
+       \r
+       });\r
+    function moodlefilemanager(field_name, url, type, win) {\r
+                       \r
+           tinyMCE.activeEditor.windowManager.open({\r
+            file : "<?php echo $CFG->httpswwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id=<?php echo $COURSE->id; ?>",\r
+            width : 480,  \r
+            height : 380,\r
+            resizable : "yes",\r
+            inline : "yes",  \r
+            close_previous : "no"\r
+        }, {\r
+            window : win,\r
+            input : field_name\r
+        });\r
+        return false;\r
+    }\r
+<?php\r
+} else {\r
+?>\r
+    tinyMCE.init({\r
+        relative_urls : false,\r
+        remove_script_host : false,\r
+        document_base_url : "<?php echo $CFG->httpswwwroot; ?>",\r
+        editor_selector : "form-textarea",\r
+        mode : "textareas",\r
+        entity_encoding : "raw",\r
+        theme : "standard",\r
+        plugins : "safari,emoticons,searchreplace,fullscreen,advimage,advlink",\r
+        theme_standard_buttons1 : "fontselect,fontsizeselect,formatselect",\r
+        theme_standard_buttons2 : "bold,italic,underline,forecolor,backcolor,link,unlink,image,emoticons,charmap,code,fullscreen",\r
+        theme_standard_buttons3 : "",\r
+        theme_standard_toolbar_location : "top",\r
+        theme_standard_toolbar_align : "left",\r
+        theme_standard_statusbar_location : "bottom",\r
+        moodleimage_course_id: <?php echo $COURSE->id; ?>,\r
+        theme_standard_resize_horizontal : true,\r
+        theme_standard_resizing : true,\r
+        apply_source_formatting : true\r
+    });\r
+\r
+<?php\r
+}\r
+?>\r
+} /* end of tsetup() */\r
+function toggleEditor(id) {\r
+       var elm = document.getElementById(id);\r
+\r
+       if (tinyMCE.getInstanceById(id) == null)\r
+               tinyMCE.execCommand('mceAddControl', false, id);\r
+       else\r
+               tinyMCE.execCommand('mceRemoveControl', false, id);\r
+}\r
+</script>\r
diff --git a/lib/editor/tinymce/meta.php b/lib/editor/tinymce/meta.php
new file mode 100644 (file)
index 0000000..e414a86
--- /dev/null
@@ -0,0 +1,109 @@
+<?php \r
+function print_editor_config($editorhidebuttons='', $return=false) {\r
+    global $CFG;\r
+\r
+    $str = "config.pageStyle = \"body {";\r
+\r
+    if (!(empty($CFG->editorbackgroundcolor))) {\r
+        $str .= " background-color: $CFG->editorbackgroundcolor;";\r
+    }\r
+\r
+    if (!(empty($CFG->editorfontfamily))) {\r
+        $str .= " font-family: $CFG->editorfontfamily;";\r
+    }\r
+\r
+    if (!(empty($CFG->editorfontsize))) {\r
+        $str .= " font-size: $CFG->editorfontsize;";\r
+    }\r
+\r
+    $str .= " }\";\n";\r
+    $str .= "config.killWordOnPaste = ";\r
+    $str .= (empty($CFG->editorkillword)) ? "false":"true";\r
+    $str .= ';'."\n";\r
+    $str .= 'config.fontname = {'."\n";\r
+\r
+    $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();\r
+    $i = 1;                     // Counter is used to get rid of the last comma.\r
+\r
+    foreach ($fontlist as $fontline) {\r
+        if (!empty($fontline)) {\r
+            if ($i > 1) {\r
+                $str .= ','."\n";\r
+            }\r
+            list($fontkey, $fontvalue) = split(':', $fontline);\r
+            $str .= '"'. $fontkey ."\":\t'". $fontvalue ."'";\r
+\r
+            $i++;\r
+        }\r
+    }\r
+    $str .= '};';\r
+\r
+    if (!empty($editorhidebuttons)) {\r
+        $str .= "\nconfig.hideSomeButtons(\" ". $editorhidebuttons ." \");\n";\r
+    } else if (!empty($CFG->editorhidebuttons)) {\r
+        $str .= "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n";\r
+    }\r
+\r
+    if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {\r
+        $str .= print_speller_code($CFG->htmleditor, true);\r
+    }\r
+\r
+    if ($return) {\r
+        return $str;\r
+    }\r
+    echo $str;\r
+}\r
+\r
+function use_html_editor($name='', $editorhidebuttons='', $id='') {\r
+    global $THEME;\r
+}\r
+\r
+function use_admin_editor($name='', $editorhidebuttons='', $id='') {\r
+    global $THEME;\r
+    echo '<script type="text/javascript">tsetup();</script>';\r
+}\r
+\r
+function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') {\r
+    global $CFG, $COURSE, $HTTPSPAGEREQUIRED;\r
+    \r
+    $str = '';\r
+    if ($id === '') {\r
+        $id = 'edit-'.$name;\r
+    }\r
+    if (empty($courseid)) {\r
+        $courseid = $COURSE->id;\r
+    }\r
+    if ($usehtmleditor) {\r
+        $str .= '<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';\r
+        $str .= htmlspecialchars($value); \r
+        $str .= '</textarea><br />'."\n";\r
+        $toggle_ed = '<img width="50" height="17" src="'.$CFG->wwwroot.'/lib/editor/tinymce/images/toggle.gif" alt="'.get_string('toggleeditor','editor').'" title="'.get_string('toggleeditor','editor').'" />';\r
+        $str .= "<a href=\"javascript:toggleEditor('".$id."');\">".$toggle_ed."</a> ";\r
+        $str .= '<script type="text/javascript">\r
+            document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');\r
+        </script>';\r
+    }\r
+    else\r
+    {\r
+        $str .= '<textarea class="alltext" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';  \r
+        $str .= s($value);\r
+        $str .= '</textarea>'."\n";\r
+    }\r
+    if ($return) {\r
+        return $str;\r
+    }\r
+    echo $str;\r
+}\r
+?>\r
+<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>\r
+<?php \r
+if (($COURSE->id < 2) and has_capability('moodle/site:doanything', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {\r
+    include_once('adminscr.php');\r
+} else {\r
+    if (!empty($COURSE->id) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {\r
+        include_once('staff.php');\r
+    } else {\r
+        include_once('student.php');\r
+    }\r
+}\r
+?>\r
diff --git a/lib/editor/tinymce/staff.php b/lib/editor/tinymce/staff.php
new file mode 100644 (file)
index 0000000..f079716
--- /dev/null
@@ -0,0 +1,70 @@
+<script type="text/javascript"> \r
+    tinyMCE.init({\r
+       relative_urls : false,\r
+        remove_script_host : false,\r
+        document_base_url : "<?php echo $CFG->wwwroot; ?>",\r
+           editor_selector : "form-textarea",\r
+       mode : "textareas",\r
+           theme : "standard", \r
+<?php \r
+if (!empty($USER->id)) {\r
+    if ($CFG->defaulthtmleditor == 'tinymce') {\r
+        echo = 'skin : "o2k7",';\r
+    } else {\r
+        echo = 'skin : "default",';\r
+    } \r
+}\r
+?>\r
+        entity_encoding : "raw",\r
+        theme_standard_statusbar_location : "bottom",\r
+        language : "<?php echo str_replace("_utf8", "", current_language()) ?>",\r
+<?php \r
+    include_once('langlist.php');\r
+    echo "\n";\r
+    include_once('xhtml_ruleset.txt');\r
+?>\r
+        plugins : "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emotions,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodleimage,moodlelink,dragmath,nonbreaking",\r
+           theme_standard_buttons1_add : "styleselect,selectall,pastetext,pasteword,insertlayer",\r
+        theme_standard_buttons2_add : "styleprops,ltr,rtl,table,nonbreaking,media,advhr,emotions,emoticons,charmap,dragmath,spellchecker,search,code,fullscreen",\r
+<?php \r
+$hiddenbuttons = $CFG->editorhidebuttons;\r
+if (!empty($hiddenbuttons)) {\r
+    $hiddenbuttons = str_replace(" ", ",", $hiddenbuttons);\r
+    echo 'theme_standard_disable : "'. $hiddenbuttons .'",';\r
+} \r
+$tinyfts = $CFG->editorfontlist;\r
+if ($tinyfts) {\r
+    $tinyfts = str_replace(":", "=", $tinyfts);\r
+    echo 'theme_standard_fonts : "'. $tinyfts .'",';\r
+} \r
+?> \r
+        spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",\r
+           moodleimage_course_id: <?php echo $COURSE->id; ?>,\r
+       theme_standard_resize_horizontal : true,\r
+           theme_standard_resizing : true,\r
+        file_browser_callback : "moodlefilemanager",\r
+       apply_source_formatting : true\r
+    });\r
+    function moodlefilemanager(field_name, url, type, win) {\r
+                       \r
+        tinyMCE.activeEditor.windowManager.open({\r
+            file : "<?php echo $CFG->wwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id=<?php echo $COURSE->id; ?>",\r
+            width : 480,  \r
+            height : 380,\r
+            resizable : "yes",\r
+            inline : "yes",  \r
+            close_previous : "no"\r
+        }, {\r
+            window : win,\r
+            input : field_name\r
+        });\r
+        return false;\r
+    }\r
+    function toggleEditor(id) {\r
+           var elm = document.getElementById(id);\r
+       if (tinyMCE.getInstanceById(id) == null)\r
+               tinyMCE.execCommand('mceAddControl', false, id);\r
+       else\r
+               tinyMCE.execCommand('mceRemoveControl', false, id);\r
+    }\r
+</script>\r
diff --git a/lib/editor/tinymce/student.php b/lib/editor/tinymce/student.php
new file mode 100644 (file)
index 0000000..d207fa6
--- /dev/null
@@ -0,0 +1,53 @@
+<script type="text/javascript"> \r
+    tinyMCE.init({\r
+        relative_urls : false,\r
+        remove_script_host : false,\r
+        document_base_url : "<?php echo $CFG->httpswwwroot; ?>",\r
+        editor_selector : "form-textarea",\r
+        mode : "textareas",\r
+        theme : "standard",\r
+<?php \r
+if (!empty($USER->id)) {\r
+    if ($CFG->defaulthtmleditor == 'tinymce') {\r
+        echo 'skin : "o2k7",';\r
+    } else {\r
+        echo 'skin : "default",';\r
+    }\r
+}\r
+?>\r
+        entity_encoding : "raw",\r
+        theme_standard_statusbar_location : "bottom",\r
+        language : "<?php echo str_replace("_utf8", "", current_language()) ?>",\r
+<?php \r
+    include_once('langlist.php');\r
+    echo "\n";\r
+    include_once('xhtml_ruleset.txt'); \r
+?> \r
+        plugins : "safari,spellchecker,table,style,advhr,advimage,advlink,emotions,emoticons,inlinepopups,searchreplace,standardmenu,paste,directionality,fullscreen,dragmath,nonbreaking",    \r
+        theme_standard_buttons1_add : "styleselect,pastetext,pasteword,selectall",\r
+        theme_standard_buttons2_add : "ltr,rtl,table,nonbreaking,advhr,emotions,emoticons,charmap,dragmath,search,code,fullscreen",\r
+<?php \r
+$hidbut = $CFG->editorhidebuttons;\r
+if ($hidbut) {\r
+    $hidbut = str_replace(" ",",",$hidbut);\r
+    echo 'theme_standard_disable : "'.$hidbut.'",';\r
+} \r
+$tinyfts = $CFG->editorfontlist;\r
+if ($tinyfts) {\r
+    $tinyfts = str_replace(":","=",$tinyfts);\r
+    echo 'theme_standard_fonts : "'.$tinyfts.'",';\r
+} \r
+?>\r
+        moodleimage_course_id: <?php echo $COURSE->id; ?>,\r
+       theme_standard_resize_horizontal : true,\r
+       theme_standard_resizing : true,\r
+           apply_source_formatting : true\r
+    });\r
+    function toggleEditor(id) {\r
+           var elm = document.getElementById(id);\r
+       if (tinyMCE.getInstanceById(id) == null)\r
+               tinyMCE.execCommand('mceAddControl', false, id);\r
+       else\r
+               tinyMCE.execCommand('mceRemoveControl', false, id);\r
+    }\r
+</script>\r
diff --git a/lib/editor/tinymce/xhtml_ruleset.txt b/lib/editor/tinymce/xhtml_ruleset.txt
new file mode 100644 (file)
index 0000000..f444c71
--- /dev/null
@@ -0,0 +1,90 @@
+    valid_elements : ""\r
++"a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|shape<circle?default?poly?rect|style|tabindex|title|target|type],"\r
+    +"abbr[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"acronym[class|dir<ltr?rtl|id|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"address[class|align|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"applet[align<bottom?left?middle?right?top|alt|archive|class|code|codebase|height|hspace|id|name|object|style|title|vspace|width],"\r
++"area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|shape<circle?default?poly?rect|style|tabindex|title|target],"\r
++"base[href|target],"\r
++"basefont[color|face|id|size],"\r
++"bdo[class|dir<ltr?rtl|id|lang|style|title],"\r
++"big[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"blockquote[cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"body[alink|background|bgcolor|class|dir<ltr?rtl|id|lang|link|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onunload|style|title|text|vlink],"\r
++"br[class|clear<all?left?none?right|id|style|title],"\r
++"button[accesskey|class|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex|title|type|value],"\r
++"caption[align<bottom?left?right?top|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"center[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"cite[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"code[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"col[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|span|style|title|valign<baseline?bottom?middle?top|width],"\r
++"colgroup[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|span|style|title|valign<baseline?bottom?middle?top|width],"\r
++"dd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"del[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"dfn[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"dir[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"div[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"dl[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"dt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"em/i[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"fieldset[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"font[class|color|dir<ltr?rtl|face|id|lang|size|style|title],"\r
++"form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit|style|title|target],"\r
++"frame[class|frameborder|id|longdesc|marginheight|marginwidth|name|noresize<noresize|scrolling<auto?no?yes|src|style|title],"\r
++"frameset[class|cols|id|onload|onunload|rows|style|title],"\r
++"h1[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"h2[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"h3[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"h4[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"h5[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"h6[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"head[dir<ltr?rtl|lang|profile],"\r
++"hr[align<center?left?right|class|dir<ltr?rtl|id|lang|noshade<noshade|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style|title|width],"\r
++"html[dir<ltr?rtl|lang|version],"\r
++"iframe[align<bottom?left?middle?right?top|class|frameborder|height|id|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style|title|width],"\r
++"img[align<bottom?left?middle?right?top|alt|border|class|dir<ltr?rtl|height|hspace|id|ismap<ismap|lang|longdesc|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|src|style|title|usemap|vspace|width],"\r
++"input[accept|accesskey|align<bottom?left?middle?right?top|alt|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|size|src|style|tabindex|title|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text|usemap|value],"\r
++"ins[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"isindex[class|dir<ltr?rtl|id|lang|prompt|style|title],"\r
++"kbd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"li[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type|value],"\r
++"link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|style|title|target|type],"\r
++"map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"menu[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"meta[content|dir<ltr?rtl|http-equiv|lang|name|scheme],"\r
++"noframes[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"noscript[class|dir<ltr?rtl|id|lang|style|title],"\r
++"object[align<bottom?left?middle?right?top|archive|border|class|classid|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap|vspace|width],"\r
++"ol[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|start|style|title|type],"\r
++"optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"option[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|selected<selected|style|title|value],"\r
++"p[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"param[id|name|type|value|valuetype<DATA?OBJECT?REF],"\r
++"pre/listing/plaintext/xmp[align|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|width],"\r
++"q[cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"s[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"samp[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"script[charset|defer|language|src|type],"\r
++"select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name|onblur|onchange|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style|tabindex|title],"\r
++"small[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"span[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"strike[class|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"strong/b[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"style[dir<ltr?rtl|lang|media|title|type],"\r
++"sub[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"sup[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"table[align<center?left?right|bgcolor|border|cellpadding|cellspacing|class|dir<ltr?rtl|frame|height|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rules|style|summary|title|width],"\r
++"tbody[align<center?char?justify?left?right|char|class|charoff|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],"\r
++"td[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup|style|title|valign<baseline?bottom?middle?top|width],"\r
++"textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|rows|style|tabindex|title],"\r
++"tfoot[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],"\r
++"th[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup|style|title|valign<baseline?bottom?middle?top|width],"\r
++"thead[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],"\r
++"title[dir<ltr?rtl|lang],"\r
++"tr[abbr|align<center?char?justify?left?right|bgcolor|char|charoff|class|rowspan|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],"\r
++"tt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"u[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"\r
++"ul[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type],"\r
++"var[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title]",\r