Commit eb2042f6 authored by julmis's avatar julmis
Browse files

Add editor settings feature and Ludo's (Marc Alier) spellchecking functionality.

- Needs testing and should consider unstable.
parent 7a1efb69
......@@ -41,6 +41,9 @@
get_string("adminhelpbackup"));
}
$table->data[]= array("<b><a href=\"editor.php\">". get_string("editorsettings") ."</a></b>",
get_string("adminhelpeditorsettings"));
print_table($table);
print_footer($site);
......
<form method="post" action="<?php print($_SERVER['PHP_SELF']);?>">
<table border="0" cellpadding="4" cellspacing="2">
<tr><td colspan="3"><strong><?php print_string("editorcommonsettings");?></strong></td></tr>
<tr>
<td align="right" valign="top"><?php print_string("editorbgcolor");?>:</td>
<td valign="top"><input type="text" name="backgroundcolor" size="10" value="<?php print($CFG->editorbackgroundcolor);?>"></td>
<td valign="top"><?php print_string("edhelpbgcolor");?></td>
</tr>
<tr>
<td align="right" valign="top"><?php print_string("editordefaultfont");?>:</td>
<td valign="top"><input type="text" name="fontfamily" size="30" value="<?php print($CFG->editorfontfamily);?>"></td>
<td valign="top"><?php print_string("edhelpfontfamily");?></td>
</tr>
<tr>
<td align="right" valign="top"><?php print_string("editorfontsize");?>:</td>
<td valign="top"><input type="text" name="fontsize" size="10" value="<?php print($CFG->editorfontsize);?>"></td>
<td valign="top"><?php print_string("edhelpfontsize");?></td>
</tr>
<tr>
<td align="right" valign="top"><?php print_string("editorcleanonpaste");?>:</td>
<td valign="top"><select name="killword">
<option value="1"<?php print(!$CFG->editorkillword)?"":" selected=\"selected\"";?>>Yes</option>
<option value="0"<?php print(!$CFG->editorkillword)?" selected=\"selected\"":"";?>>No</option>
</select></td>
<td valign="top"><?php print_string("edhelpcleanword");?></td>
</tr>
<tr>
<td align="right" valign="top"><?php print_string("editorenablespelling");?>:</td>
<td valign="top"><select name="spelling"<?php
if(empty($CFG->aspellpath)) {
echo " disabled=\"disabled\"";
$CFG->editorspelling = false;
}
?>>
<option value="1"<?php print(!$CFG->editorspelling)?"":" selected=\"selected\"";?>>Yes</option>
<option value="0"<?php print(!$CFG->editorspelling)?" selected=\"selected\"":"";?>>No</option>
</select></td>
<td valign="top"><?php print_string("edhelpenablespelling");?></td>
</tr>
<tr><td colspan="2"><strong><?php print_string("editorfontlist");?></strong></td>
<td valign="top"><?php print_string("edhelpfontlist");?></td></tr>
<?php
foreach($fontlist as $fontkey => $fontvalue) {
?>
<tr>
<td align="right"><input type="text" name="fontname[]" size="15" value="<?php print($fontkey);?>"></td>
<td colspan="2"><input type="text" name="fontnamevalue[]" size="30" value="<?php print($fontvalue);?>"></td>
</tr>
<?php
}
?>
<tr>
<td align="right"><input type="text" name="fontname[]" size="15" value=""></td>
<td colspan="2"><input type="text" name="fontnamevalue[]" size="30" value=""></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges");?>"></td>
</tr>
</table>
</form>
\ No newline at end of file
<?php // $Id$
/// configuration routines for HTMLArea editor
require_once("../config.php");
require_login();
if (!isadmin()) {
error("Only admins can access this page");
}
if($data = data_submitted()) {
if(!(editor_update_config($data))) {
error("Editor settings could not be updated!");
}
redirect("$CFG->wwwroot/$CFG->admin/editor.php", get_string("changessaved"), 1);
} else {
// Generate edit form
$fontlist = editor_convert_to_array($CFG->editorfontlist);
$stradmin = get_string("administration");
$strconfiguration = get_string("configuration");
$streditorsettings = get_string("editorsettings");
$streditorsettingshelp = get_string("adminhelpeditorsettings");
print_header("Editor settings","Editor settings",
"<a href=\"index.php\">$stradmin</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> $streditorsettings");
print_heading($streditorsettings);
print_simple_box("<center>$streditorsettingshelp</center>","center","50%");
print("<br />\n");
print_simple_box_start("center", "", "$THEME->cellheading");
include("editor.html");
print_simple_box_end();
print_footer();
}
/// FUNCTIONS
function editor_convert_to_array ($string) {
/// Converts $CFG->editorfontlist to array
if(empty($string) || !is_string($string)) {
return false;
}
$fonts = array();
$lines = explode(";", $string);
foreach($lines as $line) {
if(!empty($line)) {
list($fontkey, $fontvalue) = explode(":", $line);
$fonts[$fontkey] = $fontvalue;
}
}
return $fonts;
}
function editor_update_config ($data) {
/// Updates the editor config values.
if(!is_object($data)) {
return false;
}
// make font string
for($i = 0; $i < count($data->fontname); $i++) {
if(!empty($data->fontname[$i])) {
$fontlist .= $data->fontname[$i] .":";
$fontlist .= $data->fontnamevalue[$i] .";";
}
}
// strip last semicolon
$fontlist = substr($fontlist, 0, strlen($fontlist) - 1);
// make array of values to update
$updatedata = array();
$updatedata['editorbackgroundcolor'] = $data->backgroundcolor;
$updatedata['editorfontfamily'] = $data->fontfamily;
$updatedata['editorfontsize'] = $data->fontsize;
$updatedata['editorkillword'] = $data->killword;
$updatedata['editorspelling'] = $data->spelling;
$updatedata['editorfontlist'] = $fontlist;
foreach($updatedata as $name => $value) {
if(!(set_config($name, $value))) {
return false;
}
}
return true;
}
?>
\ No newline at end of file
......@@ -288,6 +288,8 @@
$configdata .= "<font size=+1>&nbsp;</font><a href=\"backup.php\">".get_string("backup")."</a> - <font size=1>".
get_string("adminhelpbackup")."</font><br />";
}
$configdata .= "<font size=+1>&nbsp;</font><a href=\"editor.php\">". get_string("editorsettings") ."</a> - <font size=1>".
get_string("adminhelpeditorsettings")."</font><br />";
$table->data[] = array("<font size=+1><b><a href=\"configure.php\">".get_string("configuration")."</a></b>",
$configdata);
......
......@@ -45,26 +45,26 @@ unset($CFG); // Ignore this line
// A special case exists when using PostgreSQL databases via sockets. //
// Define dbhost as follows, leaving dbname, dbuser, dbpass BLANK!: //
// $CFG->dbhost = " user='muser' password='mpass' dbname='mdata'"; //
//
//
$CFG->dbtype = 'mysql'; // mysql or postgres7 (for now)
$CFG->dbhost = 'localhost'; // eg localhost or db.isp.com
$CFG->dbhost = 'localhost'; // eg localhost or db.isp.com
$CFG->dbname = 'moodle'; // database name, eg moodle
$CFG->dbuser = 'username'; // your database username
$CFG->dbpass = 'password'; // your database password
$CFG->prefix = 'mdl_'; // Prefix to use for all table names
$CFG->dbpersist = false; // Should database connections be reused?
// "false" is the most stable setting
// "true" can improve performance sometimes
// "false" is the most stable setting
// "true" can improve performance sometimes
//=========================================================================
// 2. WEB SITE LOCATION
//=========================================================================
// Now you need to tell Moodle where it is located. Specify the full
// web address to where moodle has been installed. If your web site
// is accessible via multiple URLs then choose the most natural one
// web address to where moodle has been installed. If your web site
// is accessible via multiple URLs then choose the most natural one
// that your students would use. Do not include a trailing slash
$CFG->wwwroot = 'http://example.com/moodle';
......@@ -87,8 +87,8 @@ $CFG->dirroot = '/home/example/public_html/moodle';
// 4. DATA FILES LOCATION
//=========================================================================
// Now you need a place where Moodle can save uploaded files. This
// directory should be readable AND WRITEABLE by the web server user
// (usually 'nobody' or 'apache'), but it should not be accessible
// directory should be readable AND WRITEABLE by the web server user
// (usually 'nobody' or 'apache'), but it should not be accessible
// directly via the web.
//
// - On hosting systems you might need to make sure that your "group" has
......@@ -103,9 +103,9 @@ $CFG->dataroot = '/home/example/moodledata';
// 5. DATA FILES PERMISSIONS
//=========================================================================
// The following parameter sets the permissions of new directories
// created by Moodle within the data directory. The format is in
// created by Moodle within the data directory. The format is in
// octal format (as used by the Unix utility chmod, for example).
// The default is usually OK, but you may want to change it to 0750
// The default is usually OK, but you may want to change it to 0750
// if you are concerned about world-access to the files (you will need
// to make sure the web server process (eg Apache) can access the files.
// NOTE: the prefixed 0 is important, and don't use quotes.
......@@ -116,10 +116,10 @@ $CFG->directorypermissions = 0777;
//=========================================================================
// 6. DIRECTORY LOCATION (most people can just ignore this setting)
//=========================================================================
// A very few webhosts use /admin as a special URL for you to access a
// control panel or something. Unfortunately this conflicts with the
// standard location for the Moodle admin pages. You can fix this by
// renaming the admin directory in your installation, and putting that
// A very few webhosts use /admin as a special URL for you to access a
// control panel or something. Unfortunately this conflicts with the
// standard location for the Moodle admin pages. You can fix this by
// renaming the admin directory in your installation, and putting that
// new name here. eg "moodleadmin". This will fix admin links in Moodle.
$CFG->admin = 'admin';
......@@ -133,7 +133,7 @@ $CFG->admin = 'admin';
//
//
// Prevent users from updating their profile images
// $CFG->disableuserimages = true;
// $CFG->disableuserimages = true;
//
// Prevent scheduled backups from operating (and hide the GUI for them)
// Useful for webhost operators who have alternate methods of backups
......@@ -144,8 +144,8 @@ $CFG->admin = 'admin';
// $CFG->restrictusers = 'teacher,fred,jim';
//
// Turning this on will make Moodle filter more than usual, including
// forum subjects, activity names and so on (in ADDITION to the normal
// texts like forum postings, journals etc). This is mostly only useful
// forum subjects, activity names and so on (in ADDITION to the normal
// texts like forum postings, journals etc). This is mostly only useful
// when using the multilang filter. This feature may not be complete.
// $CFG->filterall = true;
//
......@@ -157,17 +157,20 @@ $CFG->admin = 'admin';
// The names here should all be existing blocks in the "blocks" directory.
// $CFG->defaultblocks = "participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity";
//
// This setting will put Moodle in Unicode mode. It's very new and
// This setting will put Moodle in Unicode mode. It's very new and
// most likely doesn't work yet. THIS IS FOR DEVELOPERS ONLY, IT IS
// NOT RECOMMENDED FOR PRODUCTION SITES
// $CFG->unicode = true;
//
// Turning this on will make Moodle use a https connection just for the
// login page (providing a secure login), and then afterwards revert
// back to the normal http URL. Requires https to be enabled on the
// Turning this on will make Moodle use a https connection just for the
// login page (providing a secure login), and then afterwards revert
// back to the normal http URL. Requires https to be enabled on the
// web server.
// $CFG->loginhttps = true;
//
// Aspell path. Required aspell installed on your server (0.50.1 or newer)
// $CFG->aspellpath '/usr/bin/aspell'; // *nix
// $CFG->aspellpath '"c:\path\to\aspell\aspell.exe"'; // Windows
//=========================================================================
......@@ -186,6 +189,6 @@ if (file_exists("$CFG->dirroot/lib/setup.php")) { // Do not edit
}
die;
}
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
?>
<?PHP // $Id$
<?PHP // $Id$
// moodle.php - created with Moodle 1.2 development (2004013101)
$string['action'] = 'Action';
......@@ -347,7 +347,7 @@ $string['emailformat'] = 'Email format';
$string['emailmustbereal'] = 'Note: your email address must be a real one';
$string['emailpasswordconfirmation'] = 'Hi $a->firstname,
Someone (probably you) has requested a new password for your
Someone (probably you) has requested a new password for your
account on \'$a->sitename\'.
To confirm this and have a new password sent to you via email,
......@@ -386,7 +386,7 @@ $string['enrolmentnotyet'] = 'Sorry, you can not access this course until <br />
$string['enrolments'] = 'Enrolments';
$string['enrolperiod'] = 'Enrolment period';
$string['entercourse'] = 'Click to enter this course';
$string['enteremailaddress'] = 'Enter in your email address to reset your
$string['enteremailaddress'] = 'Enter in your email address to reset your
password and have the new password sent to you via email.';
$string['entries'] = 'Entries';
$string['error'] = 'Error';
......@@ -564,7 +564,7 @@ $string['login'] = 'Login';
$string['loginas'] = 'Login as';
$string['loginguest'] = 'Login as a guest';
$string['loginsite'] = 'Login to the site';
$string['loginsteps'] = 'Hi! For full access to courses you\'ll need to take
$string['loginsteps'] = 'Hi! For full access to courses you\'ll need to take
a minute to create a new account for yourself on this web site.
Each of the individual courses may also have a one-time
&quot;enrolment key&quot;, which you won\'t need until later. Here are
......@@ -786,10 +786,10 @@ $string['refreshingevents'] = 'Refreshing events';
$string['registration'] = 'Moodle Registration';
$string['registrationemail'] = 'Email notifications';
$string['registrationinfo'] = '<p>This page allows you to register your Moodle site with moodle.org. Registration is free.
The main benefit of registering is that you will be added to a low-volume mailing list
The main benefit of registering is that you will be added to a low-volume mailing list
for important notifications such as security alerts and new releases of Moodle.
<p>By default, your information will be kept private, and will never be sold or passed on to anyone else. The only
reason for collecting this information is for support purposes, and to help build up a statistical
<p>By default, your information will be kept private, and will never be sold or passed on to anyone else. The only
reason for collecting this information is for support purposes, and to help build up a statistical
picture of the Moodle community as a whole.
<p>If you choose, you can allow your site name, country and URL to be added to the public list of Moodle Sites.
<p>All new registrations are verified manually before they are added to the list, but once you are added you can update your registration (and your entry on the public list) at any time by resubmitting this form.';
......@@ -1019,5 +1019,19 @@ $string['yourlastlogin'] = 'Your last login was';
$string['yourself'] = 'yourself';
$string['yourteacher'] = 'your $a';
$string['zippingbackup'] = 'Zipping backup';
$string['editorsettings'] = 'Editor settings';
$string['adminhelpeditorsettings'] = 'Define basic settings for HTML editor';
$string['editorcommonsettings'] = 'Common settings';
$string['editorbgcolor'] = 'Background-color';
$string['editordefaultfont'] = 'Default font';
$string['editorfontsize'] = 'Default font-size';
$string['editorcleanonpaste'] = 'Clean Word HTML on paste';
$string['editorenablespelling'] = 'Enable spellchecking';
$string['editorfontlist'] = 'Fontlist';
$string['edhelpbgcolor'] = 'Define editarea\'s background-color.<br />Valid values are for example: #ffffff or white';
$string['edhelpfontfamily'] = 'The font-family property is a list of font family names and/or generic family names. Family names must be seperated with comma.';
$string['edhelpfontsize'] = 'The default font-size sets the size of a font. <br />Valid values are for example: medium, large, smaller, larger, 10pt, 11px.';
$string['edhelpcleanword'] = 'This setting enables or disables Word specific format filtering.';
$string['edhelpenablespelling'] = 'Enable or disable spellchecking. When enabled, <strong>aspell</strong> must be installed on the server.';
$string['edhelpfontlist'] = 'Define the fonts used on editors dropdown menu.';
?>
......@@ -17,6 +17,12 @@
"enablerssfeeds" => 0,
"enrol" => 'internal',
"extendedusernamechars" => false,
"editorbackgroundcolor" => '#ffffff',
"editorfontfamily" => 'Times New Roman, Times',
"editorfontsize" => '',
"editorkillword" => 1,
"editorspelling" => 0,
"editorfontlist" => "Arial:arial,helvetica,sans-serif;Courier New:courier new,courier,monospace;Georgia:georgia,times new roman,times,serif;Tahoma:tahoma,arial,helvetica,sans-serif;Times New Roman:times new roman,times,serif;Verdana:verdana,arial,helvetica,sans-serif;Impact:impact;Wingdings:wingdings;",
"filteruploadedfiles" => true,
"forcelogin" => false,
"forceloginforprofiles" => false,
......
<script language="JavaScript" type="text/javascript"
src="<?php echo "$CFG->wwwroot/lib/overlib.js" ?>"></script>
<script language="JavaScript">
<!-- //hide
function popUpProperties(inobj) {
op = window.open();
op.document.open('text/plain');
for (objprop in inobj) {
op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
}
op.document.close();
}
function fillmessagebox(text) {
document.form.message.value = text;
}
function openpopup(url,name,options,fullscreen) {
fullurl = "<?php echo $CFG->wwwroot ?>" + url;
windowobj = window.open(fullurl,name,options);
if (fullscreen) {
windowobj.moveTo(0,0);
windowobj.resizeTo(screen.availWidth,screen.availHeight);
}
windowobj.focus();
return false;
}
function copyrichtext(textname) {
/// Legacy stub for old editor - to be removed soon
return true;
}
function checkall() {
void(d=document);
void(el=d.getElementsByTagName('INPUT'));
for(i=0;i<el.length;i++)
void(el[i].checked=1)
}
function inserttext(text) {
<?php
if (!empty($SESSION->inserttextform)) {
$insertfield = "opener.document.forms['$SESSION->inserttextform'].$SESSION->inserttextfield";
} else {
$insertfield = "opener.document.forms['theform'].message";
}
echo " text = ' ' + text + ' ';\n";
echo " if ( $insertfield.createTextRange && $insertfield.caretPos) {\n";
echo " var caretPos = $insertfield.caretPos;\n";
echo " caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;\n";
echo " } else {\n";
echo " $insertfield.value += text;\n";
echo " }\n";
echo " $insertfield.focus();\n";
?>
}
function lockoptions(form, master, subitems) {
// subitems is an array of names of sub items
// requires that each item in subitems has a
// companion hidden item in the form with the
// same name but prefixed by "h"
if (eval("document."+form+"."+master+".checked")) {
for (i=0; i<subitems.length; i++) {
unlockoption(form, subitems[i]);
}
} else {
for (i=0; i<subitems.length; i++) {
lockoption(form, subitems[i]);
}
}
return(true);
}
function lockoption(form,item) {
eval("document."+form+"."+item+".disabled=true");/* IE thing */
eval("document."+form+".h"+item+".value=1");
}
function unlockoption(form,item) {
eval("document."+form+"."+item+".disabled=false");/* IE thing */
eval("document."+form+".h"+item+".value=0");
}
<?php if ($focus) { echo "function setfocus() { document.$focus.focus() }\n"; } ?>
// done hiding -->
</script>
<script language="JavaScript" type="text/javascript"
src="<?php echo "$CFG->wwwroot/lib/overlib.js" ?>"></script>
<?php
// Enable global access to spelling feature.
if(!empty($CFG->aspellpath)) {
echo "<script src=\"".$CFG->wwwroot."/lib/speller/spellChecker.js\"></script>\n";
}
?>
<script language="JavaScript">
<!-- //hide
function popUpProperties(inobj) {
op = window.open();
op.document.open('text/plain');
for (objprop in inobj) {
op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
}
op.document.close();
}
function fillmessagebox(text) {
document.form.message.value = text;
}
function openpopup(url,name,options,fullscreen) {
fullurl = "<?php echo $CFG->wwwroot ?>" + url;
windowobj = window.open(fullurl,name,options);
if (fullscreen) {
windowobj.moveTo(0,0);
windowobj.resizeTo(screen.availWidth,screen.availHeight);
}
windowobj.focus();
return false;
}
function copyrichtext(textname) {
/// Legacy stub for old editor - to be removed soon
return true;
}
function checkall() {
void(d=document);
void(el=d.getElementsByTagName('INPUT'));
for(i=0;i<el.length;i++)
void(el[i].checked=1)
}
function inserttext(text) {
<?php
if (!empty($SESSION->inserttextform)) {
$insertfield = "opener.document.forms['$SESSION->inserttextform'].$SESSION->inserttextfield";
} else {
$insertfield = "opener.document.forms['theform'].message";
}
echo " text = ' ' + text + ' ';\n";
echo " if ( $insertfield.createTextRange && $insertfield.caretPos) {\n";
echo " var caretPos = $insertfield.caretPos;\n";
echo " caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;\n";
echo " } else {\n";
echo " $insertfield.value += text;\n";
echo " }\n";
echo " $insertfield.focus();\n";
?>
}
function lockoptions(form, master, subitems) {
// subitems is an array of names of sub items
// requires that each item in subitems has a
// companion hidden item in the form with the
// same name but prefixed by "h"
if (eval("document."+form+"."+master+".checked")) {
for (i=0; i<subitems.length; i++) {
unlockoption(form, subitems[i]);
}
} else {
for (i=0; i<subitems.length; i++) {
lockoption(form, subitems[i]);
}
}
return(true);
}
function lockoption(form,item) {
eval("document."+form+"."+item+".disabled=true");/* IE thing */