diff --git a/admin/editor.html b/admin/editor.html
index 1b8508e798f..f0cb124cb39 100644
--- a/admin/editor.html
+++ b/admin/editor.html
@@ -40,7 +40,7 @@
| editorspelling: |
- |
+
+ aspellpath)) {
+ echo " disabled=\"disabled\"";
+ $CFG->editordictionary = false;
+ }
+ ?>>
+ editordictionary)) {
+ print ($CFG->editordictionary != $dict) ? "" : " selected=\"selected\"";
+ }
+ echo ">$dict\n";
+ }
+ } else if (is_string($dicts)) {
+ echo '' . "\n";
+ }
+ ?>
+
+
|
|
@@ -74,7 +95,10 @@
editorhidebuttons: |
editorhidebuttons);
+ $buttons = array();
+ if (!empty($CFG->editorhidebuttons)) {
+ $buttons = explode(chr(32), $CFG->editorhidebuttons);
+ }
?>
@@ -176,3 +200,21 @@
+
diff --git a/admin/editor.php b/admin/editor.php
index 33502699fc8..d50b394bb20 100644
--- a/admin/editor.php
+++ b/admin/editor.php
@@ -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;
+
+}
+
?>
diff --git a/lib/speller/server-scripts/spellchecker.php b/lib/speller/server-scripts/spellchecker.php
index 184adcf90a9..0ad2bebdeb8 100644
--- a/lib/speller/server-scripts/spellchecker.php
+++ b/lib/speller/server-scripts/spellchecker.php
@@ -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.
|