From: skodak Date: Tue, 23 Sep 2008 14:34:58 +0000 (+0000) Subject: MDL-16629 removed legacy unfinished multiple editors code X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=09af05ba196f8b2bcf72dbf8c3532b03059cc342;p=moodle.git MDL-16629 removed legacy unfinished multiple editors code --- diff --git a/lib/editor/htmlEditor.class.php b/lib/editor/htmlEditor.class.php index 4afdc97bef..877723161f 100644 --- a/lib/editor/htmlEditor.class.php +++ b/lib/editor/htmlEditor.class.php @@ -45,7 +45,7 @@ class htmlEditor { $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; diff --git a/lib/editor/neweditor_readme.txt b/lib/editor/neweditor_readme.txt deleted file mode 100644 index 995c58684c..0000000000 --- a/lib/editor/neweditor_readme.txt +++ /dev/null @@ -1,192 +0,0 @@ - -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 - 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$ diff --git a/lib/editor/tinymce/adminscr.php b/lib/editor/tinymce/adminscr.php deleted file mode 100644 index baa5801aa3..0000000000 --- a/lib/editor/tinymce/adminscr.php +++ /dev/null @@ -1,138 +0,0 @@ - - diff --git a/lib/editor/tinymce/coursefiles.php b/lib/editor/tinymce/coursefiles.php deleted file mode 100644 index 1faf836109..0000000000 --- a/lib/editor/tinymce/coursefiles.php +++ /dev/null @@ -1,820 +0,0 @@ -libdir.'/filelib.php'); - -error('Not reimplemented yet, sorry'); - - $id = required_param('id', PARAM_INT); - $file = optional_param('file', '', PARAM_PATH); - $wdir = optional_param('wdir', '', PARAM_PATH); - $action = optional_param('action', '', PARAM_ACTION); - $name = optional_param('name', '', PARAM_FILE); - $oldname = optional_param('oldname', '', PARAM_FILE); - $usecheckboxes = optional_param('usecheckboxes', 1, PARAM_INT); - $save = optional_param('save', 0, PARAM_BOOL); - $text = optional_param('text', '', PARAM_RAW); - $confirm = optional_param('confirm', 0, PARAM_BOOL); - - - if (! $course = $DB->get_record("course", array("id"=>$id))) { - print_error("invalidcourseid"); - } - - require_login($course); - require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id)); - - function html_footer() { - echo "\n\n\n"; - } - - function html_header($course, $wdir, $formfield=""){ - - global $CFG; - - ?> - - - - - coursefiles - - - - - - id")) { - print_error("cannotcreateuploaddir"); - } - - $baseweb = $CFG->wwwroot; - -// End of configuration and access control - - - if ($wdir == '') { - $wdir='/'; - } - - switch ($action) { - - case "upload": - html_header($course, $wdir); - require_once($CFG->dirroot.'/lib/uploadlib.php'); - - if ($save and confirm_sesskey()) { - $um = new upload_manager('userfile',false,false,$course,false,0); - $dir = "$basedir$wdir"; - if ($um->process_file_uploads($dir)) { - notify(get_string('uploadedfile')); - } - // um will take care of error reporting. - displaydir($wdir); - } else { - $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); - $filesize = display_size($upload_max_filesize); - - $struploadafile = get_string("uploadafile"); - $struploadthisfile = get_string("uploadthisfile"); - $strmaxsize = get_string("maxsize", "", $filesize); - $strcancel = get_string("cancel"); - - echo "

$struploadafile ($strmaxsize) --> $wdir"; - echo "\n\n\n
\n"; - echo "
\n"; - upload_print_form_fragment(1,array('userfile'),null,false,null,$course->maxbytes,0,false); - echo " \n"; - echo " \n"; - echo " \n"; - echo " sesskey\" />\n"; - echo "
"; - echo " \n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - } - html_footer(); - break; - - case "delete": - if ($confirm and confirm_sesskey()) { - html_header($course, $wdir); - foreach ($USER->filelist as $file) { - $fullfile = $basedir.$file; - if (! fulldelete($fullfile)) { - echo "
Error: Could not delete: $fullfile"; - } - } - clearfilelist(); - displaydir($wdir); - html_footer(); - - } else { - html_header($course, $wdir); - if (setfilelist($_POST)) { - echo "

".get_string("deletecheckwarning").":

"; - print_simple_box_start("center"); - printfilelist($USER->filelist); - print_simple_box_end(); - echo "
"; - $frameold = $CFG->framename; - $CFG->framename = "ibrowser"; - notice_yesno (get_string("deletecheckfiles"), - "coursefiles.php?id=$id&wdir=$wdir&action=delete&confirm=1&sesskey=$USER->sesskey", - "coursefiles.php?id=$id&wdir=$wdir&action=cancel"); - $CFG->framename = $frameold; - } else { - displaydir($wdir); - } - html_footer(); - } - break; - - case "move": - html_header($course, $wdir); - if ($count = setfilelist($_POST) and confirm_sesskey()) { - $USER->fileop = $action; - $USER->filesource = $wdir; - echo "

"; - print_string("selectednowmove", "moodle", $count); - echo "

"; - } - displaydir($wdir); - html_footer(); - break; - - case "paste": - html_header($course, $wdir); - if (isset($USER->fileop) and $USER->fileop == "move" and confirm_sesskey()) { - foreach ($USER->filelist as $file) { - $shortfile = basename($file); - $oldfile = $basedir.$file; - $newfile = $basedir.$wdir."/".$shortfile; - if (!rename($oldfile, $newfile)) { - echo "

Error: $shortfile not moved"; - } - } - } - clearfilelist(); - displaydir($wdir); - html_footer(); - break; - - case "rename": - if (!empty($name) and confirm_sesskey()) { - html_header($course, $wdir); - $name = clean_filename($name); - if (file_exists($basedir.$wdir."/".$name)) { - echo "Error: $name already exists!"; - } else if (!@rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) { - echo "Error: could not rename $oldname to $name"; - } - displaydir($wdir); - - } else { - $strrename = get_string("rename"); - $strcancel = get_string("cancel"); - $strrenamefileto = get_string("renamefileto", "moodle", $file); - html_header($course, $wdir, "form.name"); - echo "

$strrenamefileto:"; - echo "\n\n\n
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " sesskey\" />\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
"; - echo "
\n"; - } - html_footer(); - break; - - case "mkdir": - if (!empty($name) and confirm_sesskey()) { - html_header($course, $wdir); - $name = clean_filename($name); - if (file_exists("$basedir$wdir/$name")) { - echo "Error: $name already exists!"; - } else if (! make_upload_directory("$course->id/$wdir/$name")) { - echo "Error: could not create $name"; - } - displaydir($wdir); - - } else { - $strcreate = get_string("create"); - $strcancel = get_string("cancel"); - $strcreatefolder = get_string("createfolder", "moodle", $wdir); - html_header($course, $wdir, "form.name"); - echo "

$strcreatefolder:"; - echo "\n\n\n
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " sesskey\" />\n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - } - html_footer(); - break; - - case "edit": - html_header($course, $wdir); - if (($text != '') and confirm_sesskey()) { - $fileptr = fopen($basedir.$file,"w"); - fputs($fileptr, $text); - fclose($fileptr); - displaydir($wdir); - - } else { - $streditfile = get_string("edit", "", "$file"); - $fileptr = fopen($basedir.$file, "r"); - $contents = fread($fileptr, filesize($basedir.$file)); - fclose($fileptr); - - print_heading("$streditfile"); - - echo "\n\n\n\n
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " "; - echo " \n"; - echo " sesskey\" />\n"; - print_textarea(false, 25, 80, 680, 400, "text", $contents); - echo "
\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - - if ($usehtmleditor) { - use_html_editor("text"); - } - - - } - html_footer(); - break; - - case "zip": - if (!empty($name) and confirm_sesskey()) { - html_header($course, $wdir); - $name = clean_filename($name); - - $files = array(); - foreach ($USER->filelist as $file) { - $files[] = "$basedir/$file"; - } - - if (!zip_files($files,"$basedir/$wdir/$name")) { - print_error("zipfileserror", "error"); - } - - clearfilelist(); - displaydir($wdir); - - } else { - html_header($course, $wdir, "form.name"); - - if (setfilelist($_POST)) { - echo "

".get_string("youareabouttocreatezip").":

"; - print_simple_box_start("center"); - printfilelist($USER->filelist); - print_simple_box_end(); - echo "
"; - echo "

".get_string("whattocallzip"); - echo "\n\n\n\n\n
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " sesskey\" />\n"; - echo " \n"; - echo " "; - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - } else { - displaydir($wdir); - clearfilelist(); - } - } - html_footer(); - break; - - case "unzip": - html_header($course, $wdir); - if (!empty($file) and confirm_sesskey()) { - $strok = get_string("ok"); - $strunpacking = get_string("unpacking", "", $file); - - echo "

$strunpacking:

"; - - $file = basename($file); - - if (!unzip_file("$basedir/$wdir/$file")) { - print_error("unzipfileserror", "error"); - } - - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - } else { - displaydir($wdir); - } - html_footer(); - break; - - case "listzip": - html_header($course, $wdir); - if (!empty($file) and confirm_sesskey()) { - $strname = get_string("name"); - $strsize = get_string("size"); - $strmodified = get_string("modified"); - $strok = get_string("ok"); - $strlistfiles = get_string("listfiles", "", $file); - - echo "

$strlistfiles:

"; - $file = basename($file); - - require_once($CFG->libdir.'/pclzip/pclzip.lib.php'); - $archive = new PclZip("$basedir/$wdir/$file"); - if (!$list = $archive->listContent("$basedir/$wdir")) { - notify($archive->errorInfo(true)); - - } else { - echo "\n"; - echo "\n"; - foreach ($list as $item) { - echo ""; - print_cell("left", $item['filename']); - if (! $item['folder']) { - print_cell("right", display_size($item['size'])); - } else { - echo "\n"; - } - $filedate = userdate($item['mtime'], get_string("strftimedatetime")); - print_cell("right", $filedate); - echo "\n"; - } - echo "
$strname$strsize$strmodified
 
\n"; - } - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " sesskey\" />\n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - } else { - displaydir($wdir); - } - html_footer(); - break; - - case "cancel": - clearfilelist(); - - default: - html_header($course, $wdir); - displaydir($wdir); - html_footer(); - break; -} - - -/// FILE FUNCTIONS /////////////////////////////////////////////////////////// - - -function setfilelist($VARS) { - global $USER; - - $USER->filelist = array (); - $USER->fileop = ""; - - $count = 0; - foreach ($VARS as $key => $val) { - if (substr($key,0,4) == "file") { - $count++; - $val = rawurldecode($val); - if (!detect_munged_arguments($val, 0)) { - $USER->filelist[] = $val; - } - } - } - return $count; -} - -function clearfilelist() { - global $USER; - - $USER->filelist = array (); - $USER->fileop = ""; -} - - -function printfilelist($filelist) { - global $basedir, $CFG; - - foreach ($filelist as $file) { - if (is_dir($basedir.$file)) { - echo "pixpath/f/folder.gif\" class=\"icon\" alt=\"".get_string('folder')."\" /> $file
"; - $subfilelist = array(); - $currdir = opendir($basedir.$file); - while (false !== ($subfile = readdir($currdir))) { - if ($subfile <> ".." && $subfile <> ".") { - $subfilelist[] = $file."/".$subfile; - } - } - printfilelist($subfilelist); - - } else { - $icon = mimeinfo("icon", $file); - echo "pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" /> $file
"; - } - } -} - - -function print_cell($alignment="center", $text=" ") { - echo "\n"; - echo "$text"; - echo "\n"; -} - -function get_image_size($filepath) { -/// This function get's the image size - - /// Check if file exists - if(!file_exists($filepath)) { - return false; - } else { - /// Get the mime type so it really an image. - if(mimeinfo("icon", basename($filepath)) != "image.gif") { - return false; - } else { - $array_size = getimagesize($filepath); - return $array_size; - } - } - unset($filepath,$array_size); -} - -function displaydir ($wdir) { -// $wdir == / or /a or /a/b/c/d etc - - global $basedir; - global $usecheckboxes; - global $id; - global $USER, $CFG; - - $fullpath = $basedir.$wdir; - - $directory = opendir($fullpath); // Find all files - while (false !== ($file = readdir($directory))) { - if ($file == "." || $file == "..") { - continue; - } - - if (is_dir($fullpath."/".$file)) { - $dirlist[] = $file; - } else { - $filelist[] = $file; - } - } - closedir($directory); - - $strfile = get_string("file"); - $strname = get_string("name"); - $strsize = get_string("size"); - $strmodified = get_string("modified"); - $straction = get_string("action"); - $strmakeafolder = get_string("makeafolder"); - $struploadafile = get_string("uploadafile"); - $strwithchosenfiles = get_string("withchosenfiles"); - $strmovetoanotherfolder = get_string("movetoanotherfolder"); - $strmovefilestohere = get_string("movefilestohere"); - $strdeletecompletely = get_string("deletecompletely"); - $strcreateziparchive = get_string("createziparchive"); - $strrename = get_string("rename"); - $stredit = get_string("edit"); - $strunzip = get_string("unzip"); - $strlist = get_string("list"); - $strchoose = get_string("choose"); - - - echo "
\n"; - echo "\n"; - - if ($wdir == "/") { - $wdir = ""; - } else { - $bdir = str_replace("/".basename($wdir),"",$wdir); - if($bdir == "/") { - $bdir = ""; - } - print "\n\n\n"; - } - - $count = 0; - - if (!empty($dirlist)) { - asort($dirlist); - foreach ($dirlist as $dir) { - - $count++; - - $filename = $fullpath."/".$dir; - $fileurl = $wdir."/".$dir; - $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); - - echo ""; - - if ($usecheckboxes) { - print_cell("center", ""); - } - print_cell("left", "pixpath/f/folder.gif\" class=\"icon\" alt=\"".get_string('folder')."\" />".htmlspecialchars($dir).""); - print_cell("right", " "); - print_cell("right", $filedate); - - echo ""; - } - } - - - if (!empty($filelist)) { - asort($filelist); - foreach ($filelist as $file) { - - $icon = mimeinfo("icon", $file); - $imgtype = mimeinfo("type",$file); - - $count++; - $filename = $fullpath."/".$file; - $fileurl = "$wdir/$file"; - $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); - - $dimensions = get_image_size($filename); - if($dimensions) { - $imgwidth = $dimensions[0]; - $imgheight = $dimensions[1]; - } else { - $imgwidth = "Unknown"; - $imgheight = "Unknown"; - } - unset($dimensions); - echo "\n"; - - if ($usecheckboxes) { - print_cell("center", ""); - } - echo "\n"; - - if ($icon == "zip.gif") { - $edittext = "sesskey\">$strunzip "; - $edittext .= "sesskey\">$strlist "; - } else { - $edittext = " "; - } - print_cell("right", "$edittext "); - print_cell("right", $filedate); - - echo "\n"; - } - } - echo "
"; - print ""; - print "wwwroot/lib/editor/htmlarea/images/folderup.gif\" height=\"14\" width=\"24\" border=\"0\" alt=\"".get_string('parentfolder')."\" />"; - print "
"; - if ($CFG->slasharguments) { - $ffurl = "/file.php/$id$fileurl"; - } else { - $ffurl = "/file.php?file=/$id$fileurl"; - } - link_to_popup_window ($ffurl, "display", - "pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" />", - 480, 640); - $file_size = filesize($filename); - - echo "wwwroot.$ffurl."',"; - echo " isize: '".$file_size."', itype: '".$imgtype."', iwidth: '".$imgwidth."',"; - echo " iheight: '".$imgheight."', imodified: '".$filedate."' })\" href=\"#\">$file"; - echo "
\n"; - - if (empty($wdir)) { - $wdir = "/"; - } - - echo "\n"; - echo "\n\n"; - echo "
"; - echo "\n"; - echo "\n"; - echo "sesskey\" />\n"; - $options = array ( - "move" => "$strmovetoanotherfolder", - "delete" => "$strdeletecompletely", - "zip" => "$strcreateziparchive" - ); - if (!empty($count)) { - choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:getElementById('dirform').submit()"); - } - if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) { - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " sesskey\" />\n"; - echo " \n"; - echo ""; - } - echo "
\n"; - echo "\n"; -} -?> diff --git a/lib/editor/tinymce/messages.php b/lib/editor/tinymce/messages.php deleted file mode 100644 index f4406280fd..0000000000 --- a/lib/editor/tinymce/messages.php +++ /dev/null @@ -1,183 +0,0 @@ -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 ''; -} - -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 .= '
'."\n"; - $toggle_ed = ''; - $str .= "".$toggle_ed." "; - $str .= ''; - } else { - $str .= ''."\n"; - } - if ($return) { - return $str; - } - echo $str; -} -?> - - diff --git a/lib/editor/tinymce/meta.php b/lib/editor/tinymce/meta.php deleted file mode 100644 index e414a86866..0000000000 --- a/lib/editor/tinymce/meta.php +++ /dev/null @@ -1,109 +0,0 @@ -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='') { - global $THEME; -} - -function use_admin_editor($name='', $editorhidebuttons='', $id='') { - global $THEME; - echo ''; -} - -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 .= '
'."\n"; - $toggle_ed = ''.get_string('toggleeditor','editor').''; - $str .= "".$toggle_ed." "; - $str .= ''; - } - else - { - $str .= ''."\n"; - } - if ($return) { - return $str; - } - echo $str; -} -?> - -id < 2) and has_capability('moodle/site:doanything', get_context_instance(CONTEXT_COURSE, $COURSE->id))) { - include_once('adminscr.php'); -} else { - if (!empty($COURSE->id) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))) { - include_once('staff.php'); - } else { - include_once('student.php'); - } -} -?> diff --git a/lib/editor/tinymce/moodlecontent.css b/lib/editor/tinymce/moodlecontent.css deleted file mode 100644 index 66dcc985d4..0000000000 --- a/lib/editor/tinymce/moodlecontent.css +++ /dev/null @@ -1,56 +0,0 @@ -/* 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; -} -*/ diff --git a/lib/editor/tinymce/moodledialog.js b/lib/editor/tinymce/moodledialog.js deleted file mode 100644 index ef02dda570..0000000000 --- a/lib/editor/tinymce/moodledialog.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* $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(); -}; diff --git a/lib/editor/tinymce/staff.php b/lib/editor/tinymce/staff.php deleted file mode 100644 index cf1436c4c3..0000000000 --- a/lib/editor/tinymce/staff.php +++ /dev/null @@ -1,70 +0,0 @@ - diff --git a/lib/editor/tinymce/student.php b/lib/editor/tinymce/student.php deleted file mode 100644 index 04f6c299a8..0000000000 --- a/lib/editor/tinymce/student.php +++ /dev/null @@ -1,53 +0,0 @@ - diff --git a/lib/editor/tinymce/tinymce.class.php b/lib/editor/tinymce/tinymce.class.php deleted file mode 100644 index bf56dc6df5..0000000000 --- a/lib/editor/tinymce/tinymce.class.php +++ /dev/null @@ -1,370 +0,0 @@ -","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_","theme_advanced_container__class", - "theme_advanced_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 ''."\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("cfg->wwwroot) ?>/lib/editor/htmlarea/popups/link.php?id=courseid) ?>", 470, 400, function (param) { - - if ( !param ) { - return false; - } - - win.document.forms[0].elements[field_name].value = param; - - },null); - } - - 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; - - } - -} - -?> diff --git a/lib/editor/tinymce.js.php b/lib/editor/tinymce/tinymce.js.php similarity index 99% rename from lib/editor/tinymce.js.php rename to lib/editor/tinymce/tinymce.js.php index a1b0702c0a..0b770a6889 100644 --- a/lib/editor/tinymce.js.php +++ b/lib/editor/tinymce/tinymce.js.php @@ -2,7 +2,7 @@ define('NO_MOODLE_COOKIES', true); -require_once('../../config.php'); +require_once('../../../config.php'); $editorlanguage = optional_param('editorlanguage', 'en_utf8', PARAM_ALPHANUMEXT); @@ -192,7 +192,7 @@ $output = <<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.