$editorlanguage = current_language();
$configuration[] = $CFG->httpswwwroot ."/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js";
//$configuration[] = $CFG->httpswwwroot ."/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce_src.js";
- $configuration[] = $CFG->httpswwwroot ."/lib/editor/tinymce.js.php?course=$courseid&editorlanguage=$editorlanguage";
+ $configuration[] = $CFG->httpswwwroot ."/lib/editor/tinymce/tinymce.js.php?course=$courseid&editorlanguage=$editorlanguage";
$configured['tinymce'] = true;
break;
+++ /dev/null
-
-Last update: March 6, 2006
-
-editorObject README
-===================
-
-Quick specs
-===========
-
-Quick specs for new editor integration class.
-This new integration method lets user choose which editor to use if
-user chooses to use WYSIWYG editor (HTMLArea or TinyMCE).
-
-There are legacy code for backward compatibilty in case that modules are not
-upgraded for both editors. In such case only HTMLArea is available.
-Structure implemented with factory design pattern:
-
- * /lib
- o editorlib.php
- * /lib/editor
- o htmlarea
- + htmlarea.class.php
- o tinymce
- + tinymce.class.php
-
-Usage:
-
-Editor scripts must be loaded before print_header() function call and
-only required variable is course id. To load editor you can use wrapper
-function located in moodlelib.php called loadeditor().
-
- if ( $usehtmleditor = can_use_html_editor() ) {
- $editor = loadeditor($course->id);
- }
-
-This will push needed scripts to global $CFG->editorsrc array which will be
-printed out in /lib/javascript.php.
-And at the bottom of the page before print_footer() function,
-we'll startup the editor almost as usual:
-
- if ( $usehtmleditor ) {
- $editor->use_html_editor();
- }
-
-After $editor->use_html_editor() -method is called $CFG->editorsrc array is cleared,
-so these scripts are loaded only when necessary.
-
-Special usage
-=============
-
-In some rare cases programmer needs to force certain settings. If you don't want to
-take care of both editor's settings you can force your module to use one editor only.
-In that case you'll have to pass an associative array as an argument
-for loadeditor function:
-
-
- $args = array('courseid' => $course->id, 'name' => 'tinymce');
- $editor = loadeditor($args);
-
-Then you can define settings for the editor that you wish to use. For setting up new
-settings use setconfig() method:
-
- Tiny example1:
-
- $editor->setconfig('mode','exact');
- $editor->setconfig('elements','mytextarea');
- $editor->setconfig('plugins','advhr,table,flash');
-
- // Merge config to defaults and startup the editor.
- $editor->starteditor('merge');
-
- Tiny example2:
-
- $args['mode'] = 'exact';
- $args['elements'] = 'mytextarea';
-
- $args['plugins'] = 'advhr,table,flash';
-
- // merge config to defaults and startup the editor.
- $editor->starteditor('merge');
-
- HTMLArea example1:
-
- $toolbar = array(
- array("fontname","fontsize","separator","undo","redo"),
- array("cut","copy","paste","separator","fullscreen")
- );
- $editor->setconfig('toolbar', $toolbar);
- $editor->setconfig('killWordOnPaste', false);
- $editor->starteditor('merge');
-
- HTMLArea example2:
-
- $args['toolbar'] = array(
- array("fontname","fontsize","separator","undo","redo"),
- array("cut","copy","paste","separator","fullscreen")
- );
- $args['killWordOnPaste'] = false;
- $args['pageStyle'] = "body { font-family: Verdana; font-size: 10pt; }";
-
- $editor->setconfig($args);
-
- // Print only these settings and start up the editor.
- $editor->starteditor();
-
-There are three possible arguments for starteditor method. Which are:
-append, merge and default.
-
- append: Leave default values untouched if overlapping settings are found.
- merge: Override default values if same configuration settings are found.
-default: Use only default settings.
-
-If none of these options is present then only those settings are used what
-you've set with setsetting method.
-
-
-
-TinyMCE configuration options
-=============================
-
-You can find full list of configuration options and possible values
-at http://tinymce.moxiecode.com/tinymce/docs/reference_configuration.html
-
-HTMLArea configuration options
-==============================
-
-Possible configuration options for HTMLArea are:
-
- width (string)
- **************
- Width of the editor as a string. Example: "100%" or "250px".
-
- height (string)
- ***************
- Height of the editor as a string. Example: "100%" or "150px".
-
- statusBar (boolean)
- *******************
- Print out statusbar or not. Example: true or false.
-
- undoSteps (integer)
- *******************
- Amount of undo steps to hold in memory. Default is 20.
-
- undoTimeout (integer)
- *********************
- The time interval at which undo samples are taken. Default 500 (1/2 sec).
-
- sizeIncludesToolbar (boolean)
- *****************************
- Specifies whether the toolbar should be included in the size or not.
- Default is true.
-
- fullPage (boolean)
- ******************
- If true then HTMLArea will retrieve the full HTML, starting with the
- <HTML> tag. Default is false.
-
- pageStyle (string)
- ******************
- Style included in the iframe document.
- Example: "body { background-color: #fff; font-family: 'Times New Roman', Times; }".
-
- killWordOnPaste (boolean)
- *************************
- Set to true if you want Word code to be cleaned upon Paste. Default is true.
-
- toolbar (array of arrays)
- *************************
- Buttons to print in toolbar. Must be array of arrays.
- Example: array(array("Fontname","fontsize"), array("cut","copy","paste"));
- Will print toolbar with two rows.
-
- fontname (associative array)
- ****************************
- Fontlist for fontname drowdown list.
- Example: array("Arial" => "arial, sans-serif", "Tahoma", "tahoma,sans-serif");
-
- fontsize (associative array)
- ****************************
- Fontsizes for fontsize dropdown list.
- Example: array("1 (8pt)" => "1", "2 (10pt)" => "2");
-
- formatblock (associative array)
- *******************************
- An associative array of formatting options for formatblock dropdown list.
- Example: array("Heading 1" => "h1", "Heading 2" => "h2");
-
-
-To be continue...
-
-$Id$
+++ /dev/null
-<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
+++ /dev/null
-<?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
-error('Not reimplemented yet, sorry');\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 = $DB->get_record("course", array("id"=>$id))) {\r
- print_error("invalidcourseid");\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("cannotcreateuploaddir");\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&wdir=$wdir&action=delete&confirm=1&sesskey=$USER->sesskey",\r
- "coursefiles.php?id=$id&wdir=$wdir&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, $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> </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=" ") {\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&wdir=$bdir&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&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&wdir=$fileurl&usecheckboxes=$usecheckboxes\" onclick=\"return reset_value();\">".htmlspecialchars($dir)."</a>");\r
- print_cell("right", " ");\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&wdir=$wdir&file=$fileurl&action=unzip&sesskey=$USER->sesskey\">$strunzip</a> ";\r
- $edittext .= "<a href=\"coursefiles.php?id=$id&wdir=$wdir&file=$fileurl&action=listzip&sesskey=$USER->sesskey\">$strlist</a> ";\r
- } else {\r
- $edittext = " ";\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
+++ /dev/null
-<?php
-function print_editor_config($editorhidebuttons='', $return=false) {
- global $CFG;
-
- $str = "config.pageStyle = \"body {";
-
- if (!(empty($CFG->editorbackgroundcolor))) {
- $str .= " background-color: $CFG->editorbackgroundcolor;";
- }
-
- if (!(empty($CFG->editorfontfamily))) {
- $str .= " font-family: $CFG->editorfontfamily;";
- }
-
- if (!(empty($CFG->editorfontsize))) {
- $str .= " font-size: $CFG->editorfontsize;";
- }
-
- $str .= " }\";\n";
- $str .= "config.killWordOnPaste = ";
- $str .= (empty($CFG->editorkillword)) ? "false":"true";
- $str .= ';'."\n";
- $str .= 'config.fontname = {'."\n";
-
- $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();
- $i = 1; // Counter is used to get rid of the last comma.
-
- foreach ($fontlist as $fontline) {
- if (!empty($fontline)) {
- if ($i > 1) {
- $str .= ','."\n";
- }
- list($fontkey, $fontvalue) = split(':', $fontline);
- $str .= '"'. $fontkey ."\":\t'". $fontvalue ."'";
-
- $i++;
- }
- }
- $str .= '};';
-
- if (!empty($editorhidebuttons)) {
- $str .= "\nconfig.hideSomeButtons(\" ". $editorhidebuttons ." \");\n";
- } else if (!empty($CFG->editorhidebuttons)) {
- $str .= "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n";
- }
-
- if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {
- $str .= print_speller_code($CFG->htmleditor, true);
- }
-
- if ($return) {
- return $str;
- }
- echo $str;
-}
-
-function use_html_editor($name='', $editorhidebuttons='', $id='') {
-}
-
-function use_admin_editor($name='', $editorhidebuttons='', $id='') {
- echo '<script type="text/javascript">tsetup();</script>';
-}
-
-function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') {
- global $CFG, $COURSE, $HTTPSPAGEREQUIRED;
- $str = '';
- if ($id === '') {
- $id = 'edit-'.$name;
- }
- if (empty($courseid)) {
- $courseid = $COURSE->id;
- }
- if ($usehtmleditor) {
- $str .= '<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
- $str .= htmlspecialchars($value);
- $str .= '</textarea><br />'."\n";
- $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').'" />';
- $str .= "<a href=\"javascript:toggleEditor('".$id."');\">".$toggle_ed."</a> ";
- $str .= '<script type="text/javascript">'."\n".
- 'document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');'."\n".
- '</script>';
- } else {
- $str .= '<textarea class="alltext" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
- $str .= s($value);
- $str .= '</textarea>'."\n";
- }
- if ($return) {
- return $str;
- }
- echo $str;
-}
-?>
-<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
-<script type="text/javascript">
-function tsetup() {
-<?php
-if (!empty($COURSE->id) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
-?>
- tinyMCE.init({
- relative_urls : false,
- remove_script_host : false,
- document_base_url : "<?php echo $CFG->wwwroot; ?>",
- editor_selector : "form-textarea",
- mode : "textareas",
- theme : "standard",
-<?php
-if (!empty($USER->id)) {
- if ($CFG->usehtmleditor == 'tinymce') {
- echo 'skin : "o2k7",';
- } else {
- echo 'skin : "default",';
- }
-}
-?>
- entity_encoding : "raw",
- plugins : "safari,emoticons,searchreplace,fullscreen,advimage,advlink,moodleimage,moodlelink",
-
- theme_standard_buttons1 : "fontselect,fontsizeselect,formatselect",
- theme_standard_buttons2 : "bold,italic,underline,forecolor,backcolor,link,unlink,image,emoticons,charmap,code,fullscreen",
- theme_standard_buttons3 : "",
- theme_standard_toolbar_location : "top",
- theme_standard_toolbar_align : "left",
- theme_standard_statusbar_location : "bottom",
- moodleimage_course_id: <?php echo $COURSE->id; ?>,
- theme_standard_resize_horizontal : true,
- theme_standard_resizing : true,
- file_browser_callback : "moodlefilemanager",
- apply_source_formatting : true
-
- });
- function moodlefilemanager(field_name, url, type, win) {
-
- tinyMCE.activeEditor.windowManager.open({
- file : "<?php echo $CFG->httpswwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id=<?php echo $COURSE->id; ?>",
- width : 480,
- height : 380,
- resizable : "yes",
- inline : "yes",
- close_previous : "no"
- }, {
- window : win,
- input : field_name
- });
- return false;
- }
-<?php
-} else {
-?>
- tinyMCE.init({
- relative_urls : false,
- remove_script_host : false,
- document_base_url : "<?php echo $CFG->httpswwwroot; ?>",
- editor_selector : "form-textarea",
- mode : "textareas",
- entity_encoding : "raw",
- theme : "standard",
- plugins : "safari,emoticons,searchreplace,fullscreen,advimage,advlink",
- theme_standard_buttons1 : "fontselect,fontsizeselect,formatselect",
- theme_standard_buttons2 : "bold,italic,underline,forecolor,backcolor,link,unlink,image,emoticons,charmap,code,fullscreen",
- theme_standard_buttons3 : "",
- theme_standard_toolbar_location : "top",
- theme_standard_toolbar_align : "left",
- theme_standard_statusbar_location : "bottom",
- moodleimage_course_id: <?php echo $COURSE->id; ?>,
- theme_standard_resize_horizontal : true,
- theme_standard_resizing : true,
- apply_source_formatting : true
- });
-
-<?php
-}
-?>
-} /* end of tsetup() */
-function toggleEditor(id) {
- var elm = document.getElementById(id);
-
- if (tinyMCE.getInstanceById(id) == null)
- tinyMCE.execCommand('mceAddControl', false, id);
- else
- tinyMCE.execCommand('mceRemoveControl', false, id);
-}
-</script>
+++ /dev/null
-<?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
+++ /dev/null
-/* This file contains the CSS data for the editable area(iframe) of TinyMCE */
-/* You can extend this CSS by adding your own CSS file with the the content_css option */
-
-body {
- background-color: #FFFFFF;
- margin: 5px;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: small;
- scrollbar-3dlight-color: #F0F0EE;
- scrollbar-arrow-color: #676662;
- scrollbar-base-color: #F0F0EE;
- scrollbar-darkshadow-color: #DDDDDD;
- scrollbar-face-color: #E0E0DD;
- scrollbar-highlight-color: #F0F0EE;
- scrollbar-shadow-color: #F0F0EE;
- scrollbar-track-color: #F5F5F5;
-}
-
-td {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: small;
-}
-
-pre {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: small;
-}
-
-.mceVisualAid {
- border: 1px dashed #BBBBBB !important;
-}
-
-.mceItemAnchor {
- width: 12px;
- line-height: 6px;
- overflow: hidden;
- padding-left: 12px;
- background-image: url('../images/anchor_symbol.gif');
- background-position: bottom;
- background-repeat: no-repeat;
-}
-
-/* Important is needed in Gecko browsers inorder to style links */
-/*
-a {
- color: green !important;
-}
-*/
-
-/* Style selection range colors in Gecko browsers */
-/*
-::-moz-selection {
- background-color: red;
- color: green;
-}
-*/
+++ /dev/null
-/**
-* $Id$
-*
-* Though "Dialog" looks like an object, it isn't really an object. Instead
-* it's just namespace for protecting global symbols.
-**/
-
-function Dialog(url, width, height, action, init) {
- if (typeof init == "undefined") {
- init = window; // pass this window object by default
- }
- Dialog._geckoOpenModal(url, width, height, action, init);
-};
-
-Dialog._addEvent = function (el, evname, func) {
- if ( document.all ) {
- el.attachEvent("on" + evname, func);
- } else {
- el.addEventListener(evname, func, true);
- }
-};
-
-Dialog._removeEvent = function (el, evname, func) {
- if ( document.all ) {
- el.detachEvent("on" + evname, func);
- } else {
- el.removeEventListener(evname, func, true);
- }
-};
-
-Dialog._stopEvent = function (ev) {
- if ( document.all ) {
- ev.cancelBubble = true;
- ev.returnValue = false;
- } else {
- ev.preventDefault();
- ev.stopPropagation();
- }
-};
-
-Dialog._parentEvent = function(ev) {
- if (Dialog._modal && !Dialog._modal.closed) {
- Dialog._modal.focus();
- Dialog._stopEvent(ev);
- }
-};
-
-// should be a function, the return handler of the currently opened dialog.
-Dialog._return = null;
-
-// constant, the currently opened dialog
-Dialog._modal = null;
-
-// the dialog will read it's args from this variable
-Dialog._arguments = null;
-
-Dialog._geckoOpenModal = function(url, width, height, action, init) {
-
- var file = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
- var x,y;
- x = width;
- y = height;
-
- var lx = (screen.width - x) / 2;
- var tx = (screen.height - y) / 2;
- var dlg = window.open(url, "ha_dialog", "toolbar=no,menubar=no,personalbar=no, width="+ x +",height="+ y +",scrollbars=no,resizable=no, left="+ lx +", top="+ tx +"");
- Dialog._modal = dlg;
- Dialog._arguments = init;
-
- // capture some window's events
- function capwin(w) {
- Dialog._addEvent(w, "click", Dialog._parentEvent);
- Dialog._addEvent(w, "mousedown", Dialog._parentEvent);
- Dialog._addEvent(w, "focus", Dialog._parentEvent);
- };
- // release the captured events
- function relwin(w) {
- Dialog._removeEvent(w, "click", Dialog._parentEvent);
- Dialog._removeEvent(w, "mousedown", Dialog._parentEvent);
- Dialog._removeEvent(w, "focus", Dialog._parentEvent);
- };
- capwin(window);
- // capture other frames, note the exception trapping, this is because
- // we are not permitted to add events to frames outside of the current
- // window's domain.
- for (var i = 0; i < window.frames.length; i++) {try { capwin(window.frames[i]); } catch(e) { } };
- // make up a function to be called when the Dialog ends.
- Dialog._return = function (val) {
- if (val && action) {
- action(val);
- }
- relwin(window);
- // capture other frames
- for (var i = 0; i < window.frames.length; i++) { try { relwin(window.frames[i]); } catch(e) { } };
- Dialog._modal = null;
- };
- Dialog._modal.focus();
-};
+++ /dev/null
-<script type="text/javascript">
- tinyMCE.init({
- relative_urls : false,
- remove_script_host : false,
- document_base_url : "<?php echo $CFG->wwwroot; ?>",
- editor_selector : "form-textarea",
- mode : "textareas",
- theme : "standard",
-<?php
-if (!empty($USER->id)) {
- if ($CFG->defaulthtmleditor == 'tinymce') {
- echo 'skin : "o2k7",';
- } else {
- echo 'skin : "default",';
- }
-}
-?>
- entity_encoding : "raw",
- theme_standard_statusbar_location : "bottom",
- language : "<?php echo str_replace("_utf8", "", current_language()) ?>",
-<?php
- include_once('langlist.php');
- echo "\n";
- include_once('xhtml_ruleset.txt');
-?>
- plugins : "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emotions,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodleimage,moodlelink,dragmath,nonbreaking",
- theme_standard_buttons1_add : "styleselect,selectall,pastetext,pasteword,insertlayer",
- theme_standard_buttons2_add : "styleprops,ltr,rtl,table,nonbreaking,media,advhr,emotions,emoticons,charmap,dragmath,spellchecker,search,code,fullscreen",
-<?php
-$hiddenbuttons = $CFG->editorhidebuttons;
-if (!empty($hiddenbuttons)) {
- $hiddenbuttons = str_replace(" ", ",", $hiddenbuttons);
- echo 'theme_standard_disable : "'. $hiddenbuttons .'",';
-}
-$tinyfts = $CFG->editorfontlist;
-if ($tinyfts) {
- $tinyfts = str_replace(":", "=", $tinyfts);
- echo 'theme_standard_fonts : "'. $tinyfts .'",';
-}
-?>
- spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",
- moodleimage_course_id: <?php echo $COURSE->id; ?>,
- theme_standard_resize_horizontal : true,
- theme_standard_resizing : true,
- file_browser_callback : "moodlefilemanager",
- apply_source_formatting : true
- });
- function moodlefilemanager(field_name, url, type, win) {
-
- tinyMCE.activeEditor.windowManager.open({
- file : "<?php echo $CFG->wwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id=<?php echo $COURSE->id; ?>",
- width : 480,
- height : 380,
- resizable : "yes",
- inline : "yes",
- close_previous : "no"
- }, {
- window : win,
- input : field_name
- });
- return false;
- }
- function toggleEditor(id) {
- var elm = document.getElementById(id);
- if (tinyMCE.getInstanceById(id) == null)
- tinyMCE.execCommand('mceAddControl', false, id);
- else
- tinyMCE.execCommand('mceRemoveControl', false, id);
- }
-</script>
+++ /dev/null
-<script type="text/javascript">
- tinyMCE.init({
- relative_urls : false,
- remove_script_host : false,
- document_base_url : "<?php echo $CFG->httpswwwroot; ?>",
- editor_selector : "form-textarea",
- mode : "textareas",
- theme : "standard",
-<?php
-if (!empty($USER->id)) {
- if ($CFG->defaulthtmleditor == 'tinymce') {
- echo 'skin : "o2k7",';
- } else {
- echo 'skin : "default",';
- }
-}
-?>
- entity_encoding : "raw",
- theme_standard_statusbar_location : "bottom",
- language : "<?php echo str_replace("_utf8", "", current_language()) ?>",
-<?php
- include_once('langlist.php');
- echo "\n";
- include_once('xhtml_ruleset.txt');
-?>
- plugins : "safari,spellchecker,table,style,advhr,advimage,advlink,emotions,emoticons,inlinepopups,searchreplace,standardmenu,paste,directionality,fullscreen,dragmath,nonbreaking",
- theme_standard_buttons1_add : "styleselect,pastetext,pasteword,selectall",
- theme_standard_buttons2_add : "ltr,rtl,table,nonbreaking,advhr,emotions,emoticons,charmap,dragmath,search,code,fullscreen",
-<?php
-$hidbut = $CFG->editorhidebuttons;
-if ($hidbut) {
- $hidbut = str_replace(" ",",",$hidbut);
- echo 'theme_standard_disable : "'.$hidbut.'",';
-}
-$tinyfts = $CFG->editorfontlist;
-if ($tinyfts) {
- $tinyfts = str_replace(":","=",$tinyfts);
- echo 'theme_standard_fonts : "'.$tinyfts.'",';
-}
-?>
- moodleimage_course_id: <?php echo $COURSE->id; ?>,
- theme_standard_resize_horizontal : true,
- theme_standard_resizing : true,
- apply_source_formatting : true
- });
- function toggleEditor(id) {
- var elm = document.getElementById(id);
- if (tinyMCE.getInstanceById(id) == null)
- tinyMCE.execCommand('mceAddControl', false, id);
- else
- tinyMCE.execCommand('mceRemoveControl', false, id);
- }
-</script>
+++ /dev/null
-<?php // $Id$
-
-/**
- * This file contains the tinymce subclass for moodle editorObject.
- *
- * @author Janne Mikkonen
- * @version $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package editorObject
- */
-class tinymce extends editorObject {
-
- /**
- * The tinyconf variable holds custom variable keys and values pairs in array.
- * @var array $tinyconf
- */
- var $tinyconf = array();
-
- /**
- * Internal tinyconfkeys is an array of valid configuration keys.
- * @var array $tinyconfkeys
- */
- var $tinyconfkeys = array(
- "mode","theme","plugins","language","ask","textarea_trigger",
- "editor_selector","editor_deselector","elements","docs_language",
- "debug","focus_alert","directionality","auto_reset_designmode",
- "auto_focus","nowrap","button_tile_map","auto_resize","browsers",
- "dialog_type","accessibility_warnings","accessibility_focus",
- "event_elements","table_inline_editing","object_resizing","custom_shortcuts",
- "cleanup","valid_elements","extended_valid_elements","invalid_elements",
- "verify_css_classes","verify_html","preformatted","encoding","cleanup_on_startup",
- "fix_content_duplication","inline_styles","convert_newlines_to_brs","force_br_newlines",
- "force_p_newlines","entities","entity_encoding","remove_linebreaks","convert_fonts_to_spans",
- "font_size_classes","font_size_style_values","merge_styles_invalid_parents",
- "force_hex_style_colors","apply_source_formatting","trim_span_elements","doctype",
- "convert_urls","relative_urls","remove_script_host","document_base_url",
- "urlconverter_callback","insertlink_callback","insertimage_callback","setupcontent_callback",
- "save_callback","onchange_callback","init_instance_callback","file_browser_callback",
- "cleanup_callback","handle_event_callback","execcommand_callback","oninit","onpageload",
- "content_css","popups_css","editor_css","width","height","visual","visual_table_class",
- "custom_undo_redo","custom_undo_redo_levels","custom_undo_redo_keyboard_shortcuts",
- "custom_undo_redo_restore_selection","external_link_list_url","external_image_list_url",
- "add_form_submit_trigger","add_unload_trigger","submit_patch");
-
- /**
- * Array of valid advanced theme configuration keys.
- * @var array $tinythemekeys
- */
- var $tinythemekeys = array(
- "theme_advanced_layout_manager","theme_advanced_blockformats","theme_advanced_styles",
- "theme_advanced_source_editor_width","theme_advanced_source_editor_height",
- "theme_advanced_toolbar_location","theme_advanced_toolbar_align",
- "theme_advanced_statusbar_location","theme_advanced_buttons<1-n>","theme_advanced_buttons<1-n>_add",
- "theme_advanced_buttons<1-n>_add_before","theme_advanced_disable","theme_advanced_containers",
- "theme_advanced_containers_default_class","theme_advanced_containers_default_align",
- "theme_advanced_container_<container>","theme_advanced_container_<container>_class",
- "theme_advanced_container_<container>_align","theme_advanced_custom_layout",
- "theme_advanced_link_targets","theme_advanced_resizing","theme_advanced_resizing_use_cookie",
- "theme_advanced_resize_horizontal","theme_advanced_path","theme_advanced_fonts");
-
- /**
- * The defaults configuration array for internal use.
- * @var array $defaults
- */
- var $defaults = array();
-
- /**
- * For internal usage variable which holds the information
- * should dialogs script be printed after configuration.
- * @var bool $printdialogs
- */
- var $printdialogs = false;
-
- /**
- * PHP5 style class constructor.
- *
- * @param int $courseid
- */
- function __construct($courseid) {
- parent::editorObject();
- $this->courseid = clean_param($courseid, PARAM_INT);
-
- $isteacher = isteacher($courseid);
-
- $this->defaults = array(
- "mode" => "textareas",
- "theme" => $this->cfg->tinymcetheme,
- "language" => $this->__get_language(),
- "width" => "100%",
- "plugins" => !empty($this->cfg->tinymceplugins) ?
- $this->cfg->tinymceplugins : '',
- "content_css" => !empty($this->cfg->tinymcecontentcss) ?
- $this->cfg->tinymcecontentcss : '',
- "popup_css" => !empty($this->cfg->tinymcepopupcss) ?
- $this->cfg->tinymcepopupcss : '',
- "editor_css" => !empty($this->cfg->tinymceeditorcss) ?
- $this->cfg->tinymceeditorcss : '',
- "file_browser_callback" => has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $courseid)) ? 'moodleFileBrowser' : '',
- "convert_urls" => false,
- "relative_urls" => false);
-
- if ( $this->cfg->tinymcetheme == 'advanced' ) {
- $this->defaults['theme_advanced_buttons1_add'] = "fontselect,fontsizeselect";
- $this->defaults['theme_advanced_buttons2_add'] = "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor,liststyle";
- $this->defaults['theme_advanced_buttons2_add_before'] = "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator";
- $this->defaults['theme_advanced_buttons3_add_before'] = "tablecontrols,separator";
- $this->defaults['theme_advanced_buttons3_add'] = "emotions,iespell,flash,advhr,separator,print,separator,ltr,rtl,separator,fullscreen";
- $this->defaults['theme_advanced_toolbar_location'] = "top";
- $this->defaults['theme_advanced_toolbar_align'] = "left";
- $this->defaults['theme_advanced_statusbar_location'] = "bottom";
- $this->defaults['theme_advanced_resizing'] = true;
- $this->defaults['theme_advanced_resize_horizontal'] = true;
- }
-
- $this->printdialogs = has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $courseid)) ? true : false;
- }
-
- /**
- * Checks configuration key validity.
- * @param string $key Configuration key to check.
- * @return bool Returns true if key is valid. Otherwise false is returned.
- */
- function __is_valid_key($key) {
-
- if ( is_array($key) ) {
- return false;
- }
-
- if ( strstr($key, "theme_advanced_") ) { // Search in theme keys.
-
- foreach ( $this->tinythemekeys as $value ) {
- if ( strstr($key, "<1-n>") ) {
- $value = preg_replace("/<(.*)>/", "([0-9]+)", $value);
- } else {
- $value = preg_replace("/<(.*)>/", "([a-z0-9]+)", $value);
- }
-
- if ( preg_match("/^(". $value .")$/i", $key) ) {
- return true;
- }
- }
-
- } else {
- if ( in_array($key, $this->tinyconfkeys) ) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Sets configuration key and value pairs.
- * Passed parameters can be key and value pair or
- * an associative array of keys and values.
- * @todo code example
- */
- function setconfig () {
-
- $numargs = func_num_args();
-
- if ( $numargs > 2 ) {
- $this->error("Too many arguments!");
- exit;
- }
-
- if ( $numargs < 1 ) {
- $this->error("No arguments passed!");
- exit;
- }
-
- switch ( $numargs ) {
- case 1: // Must be an array.
-
- $arg = func_get_arg(0);
- if ( is_array($arg) ) {
- foreach ( $arg as $key => $value ) {
- if ( !is_string($key) ) {
- $this->error("Array is not associative array!");
- exit;
- }
- if ( !$this->__is_valid_key($key) ) {
- $this->error("Invalid configuration key: '$key'");
- }
-
- $this->tinyconf[$key] = $value;
- }
- } else {
- $this->error("Given argument is not an array!!!");
- }
-
- break;
- case 2: // Key, Value pair.
-
- $key = func_get_arg(0);
- $value = func_get_arg(1);
-
- if ( !$this->__is_valid_key($key) ) {
- $this->error("Invalid configuration key: $key");
- }
- $this->tinyconf[$key] = $value;
-
- break;
- }
-
- }
-
- /**
- * For internal usage. Print out configuration arrays.
- * @param string $conftype Type of configuration.
- * @return void
- */
- function __printconfig ($conftype='') {
-
- switch ( $conftype ) {
- case 'merge': // New config overrides defaults if found.
- $conf = array_merge($this->defaults,$this->tinyconf);
- break;
- case 'append': // Append mode leave default value if found.
- $conf = $this->defaults;
- $keys = array_keys($this->defaults);
- foreach ( $this->tinyconf as $key => $value ) {
- if ( in_array($key, $keys) ) {
- continue;
- } else {
- $conf[$key] = $value;
- }
- }
- break;
- case 'default':
- $conf = $this->defaults;
- break;
- default:
- $conf = $this->tinyconf;
- }
-
- echo "\n";
- echo '<script type="text/javascript">'."\n";
- echo '//<![CDATA['."\n";
- echo ' tinyMCE.init({'."\n";
-
- if ( !empty($conf) ) {
- $max = count($conf);
- $cnt = 1;
- foreach ( $conf as $key => $value ) {
-
- if ( empty($value) ) {
- continue;
- }
-
- if ( $cnt > 1 ) {
- echo ',' ."\n";
- }
-
- echo "\t" . $key .' : ';
-
- if ( is_bool($value) ) {
- echo ($value) ? 'true' : 'false';
- } else {
- echo '"'. $value .'"';
- }
-
- $cnt++;
- }
- }
-
- echo ' });'."\n";
-
- if ( $this->printdialogs ) {
- $this->__dialogs();
- }
- echo '//]]>'."\n";
- echo '</script>'."\n";
-
- }
-
- /**
- * Print out code that start up the editor.
- * @param string $conftype Configuration type to print.
- */
- function starteditor($conftype='default') {
- $this->__printconfig($conftype);
- }
-
- /**
- * For backward compatibility only.
- * @param string $name
- * @param string $editorhidesomebuttons
- */
- function use_html_editor($name='', $editorhidesomebuttons='') {
- if ( empty($this->tinyconf) ) {
- $this->__printconfig('default');
- }
-
- if ( !empty($this->cfg->editorsrc) ) {
- unset($this->cfg->editorsrc);
- }
- }
-
- /**
- * Print out needed script for custom dialog which is
- * needed to provide access to Moodle's files and folders.
- * For internal use only.
- */
- function __dialogs() {
- ?>
-
- function moodleFileBrowser (field_name, url, type, win) {
- Dialog("<?php p($this->cfg->wwwroot) ?>/lib/editor/htmlarea/popups/link.php?id=<?php p($this->courseid) ?>", 470, 400, function (param) {
-
- if ( !param ) {
- return false;
- }
-
- win.document.forms[0].elements[field_name].value = param;
-
- },null);
- }
-
- <?php
- }
-
- /**
- * Try to generate TinyMCE compatible language string from
- * current users language. If not successful return default
- * language which is english.
- * For internal use only.
- */
- function __get_language() {
-
- $tinylangdir = $this->cfg->libdir .'/editor/tinymce/jscripts/tiny_mce/langs';
- $currentlanguage = current_language();
- $defaultlanguage = 'en';
-
- if ( !$fp = opendir($tinylangdir) ) {
- return $defaultlanguage;
- exit;
- }
-
- $languages = array();
-
- while ( ($file = readdir($fp)) !== false ) {
- if ( preg_match("/\.js$/i", $file) ) {
- array_push($languages, basename($file, '.js'));
- }
- }
-
- if ( $fp ) {
- closedir($fp);
- }
-
- // If language is found in array.
- if ( in_array($currentlanguage, $languages) ) {
- return $currentlanguage;
- }
-
- // Check if two character country code is found (eg. fi, de, sv etc.)
- // then return that.
- $currentlanguage = str_replace("_utf8", "", $currentlanguage);
-
- if ( in_array($currentlanguage, $languages) ) {
- return $currentlanguage;
- }
-
- return $defaultlanguage;
-
- }
-
-}
-
-?>
define('NO_MOODLE_COOKIES', true);
-require_once('../../config.php');
+require_once('../../../config.php');
$editorlanguage = optional_param('editorlanguage', 'en_utf8', PARAM_ALPHANUMEXT);
EOF;
// the xhtml ruleset must be the last one - no comma at the end of the file
-$output .= file_get_contents('tinymce/xhtml_ruleset.txt');
+$output .= file_get_contents('xhtml_ruleset.txt');
$output .= <<<EOF
});
}
}
-/**
- * Wrapper function to load necessary editor scripts
- * to $CFG->editorsrc array. Params can be coursei id
- * or associative array('courseid' => value, 'name' => 'editorname').
- * @uses $CFG
- * @param mixed $args Courseid or associative array.
- */
-function loadeditor($args) {
- global $CFG;
- include($CFG->libdir .'/editorlib.php');
- return editorObject::loadeditor($args);
-}
-
/**
* Returns whether or not the user object is a remote MNET user. This function
* is in moodlelib because it does not rely on loading any of the MNET code.