Enhancing editor settings.
This commit is contained in:
+45
-3
@@ -40,7 +40,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorspelling:</td>
|
||||
<td valign="top"><select name="spelling"<?php
|
||||
<td valign="top"><select onchange="change_state()" id="spelling" name="spelling"<?php
|
||||
if (empty($CFG->aspellpath)) {
|
||||
echo " disabled=\"disabled\"";
|
||||
$CFG->editorspelling = false;
|
||||
@@ -48,7 +48,28 @@
|
||||
?>>
|
||||
<option value="1"<?php print(!$CFG->editorspelling)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
|
||||
<option value="0"<?php print(!$CFG->editorspelling)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
|
||||
</select></td>
|
||||
</select>
|
||||
<select id="dictionary" name="dictionary"<?php
|
||||
if (empty($CFG->aspellpath)) {
|
||||
echo " disabled=\"disabled\"";
|
||||
$CFG->editordictionary = false;
|
||||
}
|
||||
?>>
|
||||
<?php
|
||||
if (is_array($dicts)) {
|
||||
foreach ($dicts as $dict) {
|
||||
echo "<option value=\"$dict\"";
|
||||
if (!empty($CFG->editordictionary)) {
|
||||
print ($CFG->editordictionary != $dict) ? "" : " selected=\"selected\"";
|
||||
}
|
||||
echo ">$dict</option>\n";
|
||||
}
|
||||
} else if (is_string($dicts)) {
|
||||
echo '<option value="">'. $dicts .'</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td valign="top"><?php print_string("edhelpenablespelling");?></td>
|
||||
</tr>
|
||||
<tr><td colspan="3"><br /><?php print_string("edhelpfontlist");?></td></tr>
|
||||
@@ -74,7 +95,10 @@
|
||||
<td valign="top" align="right">editorhidebuttons:</td>
|
||||
<td colspan="2">
|
||||
<?php
|
||||
$buttons = explode(chr(32), $CFG->editorhidebuttons);
|
||||
$buttons = array();
|
||||
if (!empty($CFG->editorhidebuttons)) {
|
||||
$buttons = explode(chr(32), $CFG->editorhidebuttons);
|
||||
}
|
||||
?>
|
||||
<table border="0" cellpadding="2" cellspacing="1">
|
||||
<tr>
|
||||
@@ -176,3 +200,21 @@
|
||||
<input type="submit" name="resettodefaults" value="<?php print_string('editorresettodefaults') ?>" />
|
||||
</center>
|
||||
</form>
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
|
||||
function change_state () {
|
||||
|
||||
var choice = document.forms[0].spelling;
|
||||
var speller = choice.options[choice.selectedIndex].value;
|
||||
|
||||
if (speller != 1) {
|
||||
document.forms[0].dictionary.disabled = true;
|
||||
} else {
|
||||
document.forms[0].dictionary.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
document.onload = change_state();
|
||||
-->
|
||||
</script>
|
||||
|
||||
+58
-2
@@ -31,6 +31,7 @@
|
||||
// Generate edit form
|
||||
|
||||
$fontlist = editor_convert_to_array($CFG->editorfontlist);
|
||||
$dicts = editor_get_dictionaries();
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
@@ -106,15 +107,15 @@ function editor_update_config ($data) {
|
||||
$updatedata['editorkillword'] = !empty($data->killword) ? $data->killword : "true";
|
||||
$updatedata['editorspelling'] = !empty($data->spelling) ? $data->spelling : 0;
|
||||
$updatedata['editorfontlist'] = $fontlist;
|
||||
$updatedata['editordictionary'] = !empty($data->dictionary) ? $data->dictionary : '';
|
||||
|
||||
$hidebuttons = '';
|
||||
if (!empty($data->buttons) && is_array($data->buttons)) {
|
||||
foreach ($data->buttons as $key => $value) {
|
||||
$hidebuttons .= $key . " ";
|
||||
}
|
||||
|
||||
$updatedata['editorhidebuttons'] = trim($hidebuttons);
|
||||
}
|
||||
$updatedata['editorhidebuttons'] = trim($hidebuttons);
|
||||
|
||||
foreach ($updatedata as $name => $value) {
|
||||
if (!(set_config($name, $value))) {
|
||||
@@ -140,6 +141,7 @@ function reset_to_defaults () {
|
||||
$updatedata['editorspelling'] = $defaults['editorspelling'];
|
||||
$updatedata['editorfontlist'] = $defaults['editorfontlist'];
|
||||
$updatedata['editorhidebuttons'] = $defaults['editorhidebuttons'];
|
||||
$updatedata['editordictionary'] = '';
|
||||
|
||||
foreach ($updatedata as $name => $value) {
|
||||
if (!(set_config($name, $value))) {
|
||||
@@ -148,4 +150,58 @@ function reset_to_defaults () {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function editor_get_dictionaries () {
|
||||
/// Get all installed dictionaries in the system
|
||||
|
||||
error_reporting(E_ALL); // for debug, final version shouldn't have this...
|
||||
clearstatcache();
|
||||
|
||||
$strerror = '';
|
||||
|
||||
if (!function_exists('popen')) {
|
||||
return $strerror = "Popen function disabled!";
|
||||
exit;
|
||||
}
|
||||
|
||||
global $CFG;
|
||||
|
||||
$cmd = $CFG->aspellpath;
|
||||
$output = '';
|
||||
$dictionaries = array();
|
||||
$dicts = array();
|
||||
|
||||
if(!($handle = @popen($cmd .' dump dicts', 'r'))) {
|
||||
return $strerror = "Couldn't create handle!";
|
||||
exit;
|
||||
}
|
||||
|
||||
while(!feof($handle)) {
|
||||
$output .= fread($handle, 1024);
|
||||
}
|
||||
@pclose($handle);
|
||||
|
||||
$dictionaries = explode(chr(10), $output);
|
||||
|
||||
// Get rid of possible empty values
|
||||
if (is_array($dictionaries)) {
|
||||
|
||||
$cnt = count($dictionaries);
|
||||
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
if (!empty($dictionaries[$i])) {
|
||||
$dicts[] = $dictionaries[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($dicts) >= 1) {
|
||||
return $dicts;
|
||||
}
|
||||
|
||||
$strerror = "Error! Check your aspell installation!";
|
||||
return $strerror;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -19,9 +19,9 @@ if(!($lang = check_language($aspell_prog))) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$aspell_opts = "-a -H --lang=$lang --encoding=utf-8";
|
||||
$tempfiledir = "./";
|
||||
$input_separator = "A";
|
||||
$aspell_opts = '-a -H --lang='. $lang .' --encoding=utf-8';
|
||||
$tempfiledir = './';
|
||||
$input_separator = 'A';
|
||||
|
||||
function check_language($cmd) {
|
||||
/// return users current language if its
|
||||
@@ -30,6 +30,8 @@ function check_language($cmd) {
|
||||
/// language is not in the list. If english dictionary
|
||||
/// isn't found, then false is returned.
|
||||
|
||||
global $CFG;
|
||||
|
||||
error_reporting(E_ALL); // for debug, final version shouldn't have this...
|
||||
clearstatcache();
|
||||
$current_lang = current_language();
|
||||
@@ -51,12 +53,14 @@ function check_language($cmd) {
|
||||
if(in_array($current_lang,$dicts)) {
|
||||
return $current_lang;
|
||||
}
|
||||
|
||||
if(in_array("en", $dicts)) {
|
||||
return "en";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($CFG->editordictionary)) {
|
||||
return $CFG->editordictionary;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// set the JavaScript variable to the submitted text.
|
||||
|
||||
Reference in New Issue
Block a user