MDL-16629 removed legacy unfinished multiple editors code
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
<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$
|
||||
@@ -1,138 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
function toggleEditor(id) {
|
||||
var elm = document.getElementById(id);
|
||||
|
||||
if (tinyMCE.getInstanceById(id) == null)
|
||||
tinyMCE.execCommand('mceAddControl', false, id);
|
||||
else
|
||||
tinyMCE.execCommand('mceRemoveControl', false, id);
|
||||
}
|
||||
function tsetup() {
|
||||
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 : "fontselect,fontsizeselect,formatselect,|",
|
||||
theme_standard_buttons1_add : "styleselect,selectall,pastetext,pasteword,insertlayer",
|
||||
theme_standard_buttons2 : "bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,sub,sup,undo,redo,cleanup,removeformat,code,|",
|
||||
theme_standard_buttons2_add : "styleprops,ltr,rtl,table,nonbreaking",
|
||||
theme_standard_buttons3 : "bullist,numlist,outdent,indent,forecolor,backcolor,link,unlink,anchor,image,charmap,|",
|
||||
theme_standard_buttons3_add : "media,emotions,emoticons,charmap,dragmath,spellchecker,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.'",';
|
||||
}
|
||||
?>
|
||||
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;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<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
|
||||
$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.'",';
|
||||
}
|
||||
?>
|
||||
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;
|
||||
}
|
||||
</script>
|
||||
@@ -1,820 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// Manage all uploaded files in a course file area
|
||||
|
||||
// This file is a hack to files/index.php that removes
|
||||
// the headers and adds some controls so that images
|
||||
// can be selected within the Richtext editor.
|
||||
|
||||
// All the Moodle-specific stuff is in this top section
|
||||
// Configuration and access control occurs here.
|
||||
// Must define: USER, basedir, baseweb, html_header and html_footer
|
||||
// USER is a persistent variable using sessions
|
||||
|
||||
require("../../../config.php");
|
||||
require_once($CFG->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</body>\n</html>";
|
||||
}
|
||||
|
||||
function html_header($course, $wdir, $formfield=""){
|
||||
|
||||
global $CFG;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title>coursefiles</title>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
||||
|
||||
function set_value(params) {
|
||||
/// function's argument is an object containing necessary values
|
||||
/// to export parent window (url,isize,itype,iwidth,iheight, imodified)
|
||||
/// set values when user click's an image name.
|
||||
var upper = window.parent;
|
||||
var insimg = upper.document.getElementById('f_url');
|
||||
|
||||
try {
|
||||
if(insimg != null) {
|
||||
if(params.itype.indexOf("image/gif") == -1 && params.itype.indexOf("image/jpeg") == -1 && params.itype.indexOf("image/png") == -1) {
|
||||
alert("<?php print_string("notimage","editor");?>");
|
||||
return false;
|
||||
}
|
||||
for(field in params) {
|
||||
var value = params[field];
|
||||
switch(field) {
|
||||
case "url" : upper.document.getElementById('f_url').value = value;
|
||||
upper.ipreview.location.replace('preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ value);
|
||||
break;
|
||||
case "isize" : upper.document.getElementById('isize').value = value; break;
|
||||
case "itype" : upper.document.getElementById('itype').value = value; break;
|
||||
case "iwidth": upper.document.getElementById('f_width').value = value; break;
|
||||
case "iheight": upper.document.getElementById('f_height').value = value; break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(field in params) {
|
||||
var value = params[field];
|
||||
switch(field) {
|
||||
case "url" :
|
||||
//upper.document.getElementById('f_href').value = value;
|
||||
//upper.opener.document.getElementById('f_href').value = value;
|
||||
//upper.close();
|
||||
upper.FileBrowserDialogue.mySubmit(value);
|
||||
break;
|
||||
//case "imodified" : upper.document.getElementById('imodified').value = value; break;
|
||||
//case "isize" : upper.document.getElementById('isize').value = value; break;
|
||||
//case "itype" : upper.document.getElementById('itype').value = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
if ( window.tinyMCE != "undefined" || window.TinyMCE != "undefined" ) {
|
||||
//upper.opener.Dialog._return(params.url);
|
||||
//upper.close();
|
||||
} else {
|
||||
alert("Something odd just occurred!!!");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function set_dir(strdir) {
|
||||
// sets wdir values
|
||||
var upper = window.parent.document;
|
||||
if(upper) {
|
||||
for(var i = 0; i < upper.forms.length; i++) {
|
||||
var f = upper.forms[i];
|
||||
try {
|
||||
f.wdir.value = strdir;
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function set_rename(strfile) {
|
||||
var upper = window.parent.document;
|
||||
upper.getElementById('irename').value = strfile;
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset_value() {
|
||||
var upper = window.parent.document;
|
||||
//for(var i = 0; i < upper.forms.length; i++) {
|
||||
//var f = upper.forms[i];
|
||||
//for(var j = 0; j < f.elements.length; j++) {
|
||||
//var e = f.elements[j];
|
||||
//if(e.type != "submit" && e.type != "button" && e.type != "hidden") {
|
||||
// try {
|
||||
// e.value = "";
|
||||
//} catch (e) {
|
||||
//}
|
||||
//}
|
||||
// }
|
||||
//}
|
||||
upper.getElementById('irename').value = 'xx';
|
||||
|
||||
var prev = window.parent.ipreview;
|
||||
if(prev != null) {
|
||||
//prev.location.replace('about:blank');
|
||||
}
|
||||
var uploader = window.parent.document.forms['uploader'];
|
||||
if(uploader != null) {
|
||||
uploader.reset();
|
||||
}
|
||||
set_dir('<?php print($wdir);?>');
|
||||
return true;
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: white;
|
||||
margin-top: 2px;
|
||||
margin-left: 4px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
body,p,table,td,input,select,a {
|
||||
font-family: Tahoma, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
select {
|
||||
position: absolute;
|
||||
top: -20px;
|
||||
left: 0px;
|
||||
}
|
||||
img.icon {
|
||||
vertical-align:middle;
|
||||
margin-right:4px;
|
||||
width:16px;
|
||||
height:16px;
|
||||
border:0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="reset_value();">
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
if (! $basedir = make_upload_directory("$course->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 "<p>$struploadafile ($strmaxsize) --> <strong>$wdir</strong>";
|
||||
echo "<table border=\"0\"><tr><td colspan=\"2\">\n";
|
||||
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"coursefiles.php\">\n";
|
||||
upload_print_form_fragment(1,array('userfile'),null,false,null,$course->maxbytes,0,false);
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
|
||||
echo " </td><tr><td align=\"right\">";
|
||||
echo " <input type=\"submit\" name=\"save\" value=\"$struploadthisfile\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td>\n<td>\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"get\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
|
||||
echo " <input type=\"submit\" value=\"$strcancel\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td>\n</tr>\n</table>\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 "<br />Error: Could not delete: $fullfile";
|
||||
}
|
||||
}
|
||||
clearfilelist();
|
||||
displaydir($wdir);
|
||||
html_footer();
|
||||
|
||||
} else {
|
||||
html_header($course, $wdir);
|
||||
if (setfilelist($_POST)) {
|
||||
echo "<p align=center>".get_string("deletecheckwarning").":</p>";
|
||||
print_simple_box_start("center");
|
||||
printfilelist($USER->filelist);
|
||||
print_simple_box_end();
|
||||
echo "<br />";
|
||||
$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 "<p align=\"center\">";
|
||||
print_string("selectednowmove", "moodle", $count);
|
||||
echo "</p>";
|
||||
}
|
||||
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 "<p>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 "<p>$strrenamefileto:";
|
||||
echo "<table border=\"0\">\n<tr>\n<td>\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"post\" id=\"form\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"rename\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"oldname\" value=\"$file\" />\n";
|
||||
echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"$file\" />\n";
|
||||
echo " <input type=\"submit\" value=\"$strrename\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td><td>\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"get\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
|
||||
echo " <input type=\"submit\" value=\"$strcancel\" />\n";
|
||||
echo "</form>";
|
||||
echo "</td></tr>\n</table>\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 "<p>$strcreatefolder:";
|
||||
echo "<table border=\"0\">\n<tr><td>\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"mkdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
|
||||
echo " <input type=\"text\" name=\"name\" size=\"35\" />\n";
|
||||
echo " <input type=\"submit\" value=\"$strcreate\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td><td>\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"get\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
|
||||
echo " <input type=\"submit\" value=\"$strcancel\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td>\n</tr>\n</table>\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", "", "<strong>$file</strong>");
|
||||
$fileptr = fopen($basedir.$file, "r");
|
||||
$contents = fread($fileptr, filesize($basedir.$file));
|
||||
fclose($fileptr);
|
||||
|
||||
print_heading("$streditfile");
|
||||
|
||||
echo "<table><tr><td colspan=\"2\">\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\" $onsubmit>\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=file value=\"$file\" />";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"edit\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
|
||||
print_textarea(false, 25, 80, 680, 400, "text", $contents);
|
||||
echo "</td>\n</tr>\n<tr>\n<td>\n";
|
||||
echo " <input type=\"submit\" value=\"".get_string("savechanges")."\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td>\n<td>\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"get\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
|
||||
echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td></tr></table>\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 "<p align=\"center\">".get_string("youareabouttocreatezip").":</p>";
|
||||
print_simple_box_start("center");
|
||||
printfilelist($USER->filelist);
|
||||
print_simple_box_end();
|
||||
echo "<br />";
|
||||
echo "<p align=\"center\">".get_string("whattocallzip");
|
||||
echo "<table border=\"0\">\n<tr>\n<td>\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"zip\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
|
||||
echo " <INPUT type=\"text\" name=\"name\" size=\"35\" value=\"new.zip\" />\n";
|
||||
echo " <input type=\"submit\" value=\"".get_string("createziparchive")."\" />";
|
||||
echo "</form>\n";
|
||||
echo "</td>\n<td>\n";
|
||||
echo "<form action=\"coursefiles.php\" method=\"get\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
|
||||
echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td>\n</tr>\n</table>\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 "<p align=\"center\">$strunpacking:</p>";
|
||||
|
||||
$file = basename($file);
|
||||
|
||||
if (!unzip_file("$basedir/$wdir/$file")) {
|
||||
print_error("unzipfileserror", "error");
|
||||
}
|
||||
|
||||
echo "<center><form action=\"coursefiles.php\" method=\"get\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
|
||||
echo " <input type=\"submit\" value=\"$strok\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</center>\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 "<p align=\"center\">$strlistfiles:</p>";
|
||||
$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 "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\">\n";
|
||||
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>";
|
||||
foreach ($list as $item) {
|
||||
echo "<tr>";
|
||||
print_cell("left", $item['filename']);
|
||||
if (! $item['folder']) {
|
||||
print_cell("right", display_size($item['size']));
|
||||
} else {
|
||||
echo "<td> </td>\n";
|
||||
}
|
||||
$filedate = userdate($item['mtime'], get_string("strftimedatetime"));
|
||||
print_cell("right", $filedate);
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo "<br /><center><form action=\"coursefiles.php\" method=\"get\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
|
||||
echo " <input type=\"submit\" value=\"$strok\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</center>\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 "<img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"".get_string('folder')."\" /> $file<br />";
|
||||
$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 "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" /> $file<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function print_cell($alignment="center", $text=" ") {
|
||||
echo "<td align=\"$alignment\" nowrap=\"nowrap\">\n";
|
||||
echo "$text";
|
||||
echo "</td>\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 "<form action=\"coursefiles.php\" method=\"post\" name=\"dirform\">\n";
|
||||
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">\n";
|
||||
|
||||
if ($wdir == "/") {
|
||||
$wdir = "";
|
||||
} else {
|
||||
$bdir = str_replace("/".basename($wdir),"",$wdir);
|
||||
if($bdir == "/") {
|
||||
$bdir = "";
|
||||
}
|
||||
print "<tr>\n<td colspan=\"5\">";
|
||||
print "<a href=\"coursefiles.php?id=$id&wdir=$bdir&usecheckboxes=$usecheckboxes\" onclick=\"return reset_value();\">";
|
||||
print "<img src=\"$CFG->wwwroot/lib/editor/htmlarea/images/folderup.gif\" height=\"14\" width=\"24\" border=\"0\" alt=\"".get_string('parentfolder')."\" />";
|
||||
print "</a></td>\n</tr>\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 "<tr>";
|
||||
|
||||
if ($usecheckboxes) {
|
||||
print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" onclick=\"return set_rename('$dir');\" />");
|
||||
}
|
||||
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>");
|
||||
print_cell("right", " ");
|
||||
print_cell("right", $filedate);
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 "<tr>\n";
|
||||
|
||||
if ($usecheckboxes) {
|
||||
print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" onclick=\";return set_rename('$file');\" />");
|
||||
}
|
||||
echo "<td align=\"left\" nowrap=\"nowrap\">";
|
||||
if ($CFG->slasharguments) {
|
||||
$ffurl = "/file.php/$id$fileurl";
|
||||
} else {
|
||||
$ffurl = "/file.php?file=/$id$fileurl";
|
||||
}
|
||||
link_to_popup_window ($ffurl, "display",
|
||||
"<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" />",
|
||||
480, 640);
|
||||
$file_size = filesize($filename);
|
||||
|
||||
echo "<a onclick=\"return set_value(info = {url: '".$CFG->wwwroot.$ffurl."',";
|
||||
echo " isize: '".$file_size."', itype: '".$imgtype."', iwidth: '".$imgwidth."',";
|
||||
echo " iheight: '".$imgheight."', imodified: '".$filedate."' })\" href=\"#\">$file</a>";
|
||||
echo "</td>\n";
|
||||
|
||||
if ($icon == "zip.gif") {
|
||||
$edittext = "<a href=\"coursefiles.php?id=$id&wdir=$wdir&file=$fileurl&action=unzip&sesskey=$USER->sesskey\">$strunzip</a> ";
|
||||
$edittext .= "<a href=\"coursefiles.php?id=$id&wdir=$wdir&file=$fileurl&action=listzip&sesskey=$USER->sesskey\">$strlist</a> ";
|
||||
} else {
|
||||
$edittext = " ";
|
||||
}
|
||||
print_cell("right", "$edittext ");
|
||||
print_cell("right", $filedate);
|
||||
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
if (empty($wdir)) {
|
||||
$wdir = "/";
|
||||
}
|
||||
|
||||
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n";
|
||||
echo "<tr>\n<td>";
|
||||
echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->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 "<form action=\"coursefiles.php\" method=\"get\">\n";
|
||||
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"paste\" />\n";
|
||||
echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
|
||||
echo " <input type=\"submit\" value=\"$strmovefilestohere\" />\n";
|
||||
echo "</form>";
|
||||
}
|
||||
echo "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
}
|
||||
?>
|
||||
@@ -1,183 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,109 +0,0 @@
|
||||
<?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='') {
|
||||
global $THEME;
|
||||
}
|
||||
|
||||
function use_admin_editor($name='', $editorhidebuttons='', $id='') {
|
||||
global $THEME;
|
||||
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">
|
||||
document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');
|
||||
</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->wwwroot ?>/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
|
||||
<?php
|
||||
if (($COURSE->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');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -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;
|
||||
}
|
||||
*/
|
||||
@@ -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();
|
||||
};
|
||||
@@ -1,70 +0,0 @@
|
||||
<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>
|
||||
@@ -1,53 +0,0 @@
|
||||
<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>
|
||||
@@ -1,370 +0,0 @@
|
||||
<?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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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 = <<<EOF
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
@@ -7788,19 +7788,6 @@ function custom_script_path($urlpath='') {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
Reference in New Issue
Block a user