diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index b1ff88954d0..37123c4ac69 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -68,10 +68,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $temp->add(new admin_setting_configtext('editorfontsize', get_string('editorfontsize', 'admin'), get_string('edhelpfontsize'), '', PARAM_NOTAGS)); $temp->add(new admin_setting_special_editorfontlist()); $temp->add(new admin_setting_configcheckbox('editorkillword', get_string('editorkillword', 'admin'), get_string('edhelpcleanword'), 1)); - if (!empty($CFG->aspellpath)) { // make aspell settings disappear if path isn't set - $temp->add(new admin_setting_configcheckbox('editorspelling', get_string('editorspelling', 'admin'), get_string('editorspellinghelp', 'admin'), 0)); - $temp->add(new admin_setting_special_editordictionary()); - } $temp->add(new admin_setting_special_editorhidebuttons()); $ADMIN->add('htmleditor', $temp); */ diff --git a/lib/adminlib.php b/lib/adminlib.php index 297e16c081a..2bcac917010 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -3862,72 +3862,6 @@ class admin_setting_emoticons extends admin_setting { } -/** - * Setting for spellchecker language selection. - */ -class admin_setting_special_editordictionary extends admin_setting_configselect { - - function admin_setting_special_editordictionary() { - $name = 'editordictionary'; - $visiblename = get_string('editordictionary','admin'); - $description = get_string('configeditordictionary', 'admin'); - parent::admin_setting_configselect($name, $visiblename, $description, '', NULL); - } - - function load_choices() { - // function borrowed from the old moodle/admin/editor.php, slightly modified - // Get all installed dictionaries in the system - if (is_array($this->choices)) { - return true; - } - - $this->choices = array(); - - global $CFG; - - clearstatcache(); - - // If aspellpath isn't set don't even bother ;-) - if (empty($CFG->aspellpath)) { - $this->choices['error'] = 'Empty aspell path!'; - return true; - } - - // Do we have access to popen function? - if (!function_exists('popen')) { - $this->choices['error'] = 'Popen function disabled!'; - return true; - } - - $cmd = $CFG->aspellpath; - $output = ''; - $dictionaries = array(); - - if(!($handle = @popen(escapeshellarg($cmd).' dump dicts', 'r'))) { - $this->choices['error'] = 'Couldn\'t create handle!'; - } - - while(!feof($handle)) { - $output .= fread($handle, 1024); - } - @pclose($handle); - - $dictionaries = explode(chr(10), $output); - foreach ($dictionaries as $dict) { - if (empty($dict)) { - continue; - } - $this->choices[$dict] = $dict; - } - - if (empty($this->choices)) { - $this->choices['error'] = 'Error! Check your aspell installation!'; - } - return true; - } -} - - class admin_setting_special_editorhidebuttons extends admin_setting { var $items; diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index f40ac1fd7cf..8b70e7580d6 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -842,6 +842,14 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint($result, 2008091611); } + if ($result && $oldversion < 2008092300) { + unset_config('editorspelling'); + unset_config('editordictionary'); + /// Main savepoint reached + upgrade_main_savepoint($result, 2008092300); + } + + return $result; } diff --git a/lib/editor/tinymce/jscripts/tiny_mce/plugins/spellchecker/config.php b/lib/editor/tinymce/jscripts/tiny_mce/plugins/spellchecker/config.php index 646d1b84c8a..5097cfd385d 100644 --- a/lib/editor/tinymce/jscripts/tiny_mce/plugins/spellchecker/config.php +++ b/lib/editor/tinymce/jscripts/tiny_mce/plugins/spellchecker/config.php @@ -1,4 +1,7 @@ aspell see MDL-16639'); + // General settings $config['general.engine'] = 'GoogleSpell'; //$config['general.engine'] = 'PSpell'; diff --git a/lib/editor/tinymce/moodle_readme.txt b/lib/editor/tinymce/moodle_readme.txt new file mode 100644 index 00000000000..2ca28921a6f --- /dev/null +++ b/lib/editor/tinymce/moodle_readme.txt @@ -0,0 +1,6 @@ +Description of TinyMCE library import into Moodle + +Our changes: +* TODO: spellchecker integration in spellchecker/config.php (MDL-16639) + +skodak \ No newline at end of file diff --git a/lib/javascript.php b/lib/javascript.php index 12656abda63..793b8dc00a6 100644 --- a/lib/javascript.php +++ b/lib/javascript.php @@ -6,10 +6,6 @@ die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page } - if (!empty($CFG->aspellpath)) { // Enable global access to spelling feature. - echo ''."\n"; - } - if (!empty($CFG->editorsrc) ) { foreach ( $CFG->editorsrc as $scriptsource ) { echo ''."\n"; diff --git a/lib/speller/blank.html b/lib/speller/blank.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/speller/changes.txt b/lib/speller/changes.txt deleted file mode 100644 index 4e99bf76bb6..00000000000 --- a/lib/speller/changes.txt +++ /dev/null @@ -1,51 +0,0 @@ -Add $CFG->aspellpath = '/path/to/aspell' to config.php - -copy speller folder to /moodle/lib/ - -weblib.php -function use_html_editor($name="",$courseid=0) { - -/// Sets up the HTML editor on textareas in the current page. -/// If a field name is provided, then it will only be -/// applied to that field - otherwise it will be used -/// on every textarea in the page. -/// -/// In most cases no arguments need to be supplied - -// Modification by Ludo ( Marc Alier to provide Spell Checking to the -// html editor. August 2004 malier@lsi.upc.es -/// START LUDO - global $CFG; - if(!empty($CFG->aspellpath)) { - echo ""; - } - -/// END LUDO - - echo "\n"; -} \ No newline at end of file diff --git a/lib/speller/controlWindow.js b/lib/speller/controlWindow.js deleted file mode 100644 index db9ea4a3e22..00000000000 --- a/lib/speller/controlWindow.js +++ /dev/null @@ -1,86 +0,0 @@ -//////////////////////////////////////////////////// -// controlWindow object -//////////////////////////////////////////////////// -function controlWindow( controlForm ) { - // private properties - this._form = controlForm; - - // public properties - this.windowType = "controlWindow"; - this.noSuggestionSelection = "- No suggestions -"; - // set up the properties for elements of the given control form - this.suggestionList = this._form.sugg; - this.evaluatedText = this._form.misword; - this.replacementText = this._form.txtsugg; - this.undoButton = this._form.btnUndo; - - // public methods - this.addSuggestion = addSuggestion; - this.clearSuggestions = clearSuggestions; - this.selectDefaultSuggestion = selectDefaultSuggestion; - this.resetForm = resetForm; - this.setSuggestedText = setSuggestedText; - this.enableUndo = enableUndo; - this.disableUndo = disableUndo; -} - -function resetForm() { - if( this._form ) { - this._form.reset(); - } -} - -function setSuggestedText() { - var slct = this.suggestionList; - var txt = this.replacementText; - var str = ""; - if( (slct.options[0].text) && slct.options[0].text != this.noSuggestionSelection ) { - str = slct.options[slct.selectedIndex].text; - } - txt.value = str; -} - -function selectDefaultSuggestion() { - var slct = this.suggestionList; - var txt = this.replacementText; - if( slct.options.length == 0 ) { - this.addSuggestion( this.noSuggestionSelection ); - } else { - slct.options[0].selected = true; - } - this.setSuggestedText(); -} - -function addSuggestion( sugg_text ) { - var slct = this.suggestionList; - if( sugg_text ) { - var i = slct.options.length; - var newOption = new Option( sugg_text, 'sugg_text'+i ); - slct.options[i] = newOption; - } -} - -function clearSuggestions() { - var slct = this.suggestionList; - for( var j = slct.length - 1; j > -1; j-- ) { - if( slct.options[j] ) { - slct.options[j] = null; - } - } -} - -function enableUndo() { - if( this.undoButton ) { - if( this.undoButton.disabled == true ) { - this.undoButton.disabled = false; - } - } -} - -function disableUndo() { - if( this.undoButton ) { - if( this.undoButton.disabled == false ) { - this.undoButton.disabled = true; - } - } -} diff --git a/lib/speller/controls.html b/lib/speller/controls.html deleted file mode 100644 index 6f2831af81e..00000000000 --- a/lib/speller/controls.html +++ /dev/null @@ -1,153 +0,0 @@ - -
- - - - - - - - - - - - - diff --git a/lib/speller/lib.php b/lib/speller/lib.php deleted file mode 100644 index 9a655f8646d..00000000000 --- a/lib/speller/lib.php +++ /dev/null @@ -1,17 +0,0 @@ -httpswwwroot ."/lib/speller/spellchecker.html\";\n"; - echo "\tspeller.spellCheckScript = \"". $CFG->httpswwwroot ."/lib/speller/server-scripts/spellchecker.php?id=$courseid\";\n"; - echo "\tspeller._moogle_edit=1;\n"; - echo "\tspeller._editor=editor;\n"; - echo "\tspeller.openChecker();\n"; - echo "}\n"; - echo "config.registerButton(\"spell-check\", \"spell-check\", \"". $CFG->wwwroot ."/lib/speller/spell.gif\", false, spellClickHandler);\n"; - echo "config.toolbar.push([\"spell-check\"]);\n"; -} - -?> diff --git a/lib/speller/server-scripts/spellchecker.php b/lib/speller/server-scripts/spellchecker.php deleted file mode 100644 index 3747288fa9e..00000000000 --- a/lib/speller/server-scripts/spellchecker.php +++ /dev/null @@ -1,248 +0,0 @@ -aspellpath)) { - print_error('spellcheckernotconf'); -} - -header('Content-type: text/html; charset=utf-8'); - -// Speller pages script http://spellerpages.sourceforge.net/ -// Modified by Marc Alier on August 2004 for the integration with moodle - -$aspell_prog = escapeshellarg($CFG->aspellpath); -$spellercss = $CFG->wwwroot .'/lib/speller/spellerStyle.css'; -$word_win_src = $CFG->wwwroot .'/lib/speller/wordWindow.js'; - - -$textinputs = $_POST['textinputs']; // array - -if(!($lang = check_language($aspell_prog))) { - error_handler("No suitable dictionary found installed on your server!"); - exit; -} - -$aspell_opts = '-a -H --lang='. $lang .' --encoding=utf-8'; -if (!empty($CFG->aspellextradicts)) { // eg /usr/bin/.aspell.en.pws - $aspell_opts .= ' --add-extra-dicts='.$CFG->aspellextradicts; -} -$tempfiledir = $CFG->dataroot; // Use dataroot since it must be writable -$input_separator = 'A'; - -function check_language($cmd) { -/// return users current language if its -/// dictionary is found installed in system -/// and always return english if user's own -/// language is not in the list. If english dictionary -/// isn't found, then false is returned. - - global $CFG; - - clearstatcache(); - $current_lang = str_replace('_utf8', '', current_language()); - $output = ''; - - if(!($handle = popen($cmd .' dump dicts', 'r'))) { - error_handler("Couldn't create handle!"); - exit; - } - - while(!feof($handle)) { - $output .= fread($handle, 1024); - } - @pclose($handle); - - $dicts = explode(chr(10), strtolower($output)); - - if(is_array($dicts)) { - if(in_array($current_lang,$dicts)) { - return $current_lang; - } - } - - if (!empty($CFG->editordictionary)) { - return $CFG->editordictionary; - } - - return false; - -} - -// set the JavaScript variable to the submitted text. -// textinputs is an array, each element corresponding to the (url-encoded) -// value of the text control submitted for spell-checking -function print_textinputs_var() { - global $textinputs; - foreach( $textinputs as $key=>$val ) { - // $val = str_replace( "'", "%27", $val ); - echo "textinputs[$key] = decodeURIComponent(\"" . $val . "\");\n"; - } -} - -// make declarations for the text input index -function print_textindex_decl( $text_input_idx ) { - echo "words[$text_input_idx] = [];\n"; - echo "suggs[$text_input_idx] = [];\n"; -} - -// set an element of the JavaScript 'words' array to a misspelled word -function print_words_elem( $word, $index, $text_input_idx ) { - echo "words[$text_input_idx][$index] = '" . escape_quote( $word ) . "';\n"; -} - - -// set an element of the JavaScript 'suggs' array to a list of suggestions -function print_suggs_elem( $suggs, $index, $text_input_idx ) { - echo "suggs[$text_input_idx][$index] = ["; - foreach( $suggs as $key=>$val ) { - if( $val ) { - echo "'" . escape_quote( $val ) . "'"; - if ( $key+1 < count( $suggs )) { - echo ", "; - } - } - } - echo "];\n"; -} - -// escape single quote -function escape_quote( $str ) { - return preg_replace ( "/'/", "\\'", $str ); -} - - -// handle a server-side error. -function error_handler( $err ) { - echo "error = '" . escape_quote( $err ) . "';\n"; -} - -// get the list of misspelled words. Put the results in the javascript words array -// for each misspelled word, get suggestions and put in the javascript suggs array -function print_checker_results() { - - global $aspell_prog; - global $aspell_opts; - global $tempfiledir; - global $textinputs; - global $input_separator; - $aspell_err = ""; - // create temp file - $tempfile = tempnam( $tempfiledir, 'aspell_data_' ); - - // open temp file, add the submitted text. - if( $fh = fopen( $tempfile, 'w' )) { - for( $i = 0; $i < count( $textinputs ); $i++ ) { - $text = urldecode( $textinputs[$i] ); - $lines = explode( "\n", $text ); - fwrite ( $fh, "%\n" ); // exit terse mode - fwrite ( $fh, "^$input_separator\n" ); - fwrite ( $fh, "!\n" ); // enter terse mode - foreach( $lines as $key=>$value ) { - // use carat on each line to escape possible aspell commands - fwrite( $fh, "^$value\n" ); - } - } - fclose( $fh ); - - // exec aspell command - redirect STDERR to STDOUT - $cmd = "$aspell_prog $aspell_opts < $tempfile 2>&1"; - if( $aspellret = shell_exec( $cmd )) { - $linesout = explode( "\n", $aspellret ); - $index = 0; - $text_input_index = -1; - // parse each line of aspell return - foreach( $linesout as $key=>$val ) { - $chardesc = substr( $val, 0, 1 ); - // if '&', then not in dictionary but has suggestions - // if '#', then not in dictionary and no suggestions - // if '*', then it is a delimiter between text inputs - // if '@' then version info - if( $chardesc == '&' || $chardesc == '#' ) { - $line = explode( " ", $val, 5 ); - print_words_elem( $line[1], $index, $text_input_index ); - if( isset( $line[4] )) { - $suggs = explode( ", ", $line[4] ); - } else { - $suggs = array(); - } - print_suggs_elem( $suggs, $index, $text_input_index ); - $index++; - } elseif( $chardesc == '*' ) { - $text_input_index++; - print_textindex_decl( $text_input_index ); - $index = 0; - } elseif( $chardesc != '@' && $chardesc != "" ) { - // assume this is error output - $aspell_err .= $val; - } - } - if( $aspell_err ) { - $aspell_err = "Error executing `$cmd`\\n$aspell_err"; - error_handler( $aspell_err ); - } - } else { - error_handler( "System error: Aspell program execution failed (`$cmd`)" ); - } - } else { - error_handler( "System error: Could not open file '$tempfile' for writing" ); - } - - // close temp file, delete file - unlink( $tempfile ); -} - - -?> - - - - - - - - - - - - - - diff --git a/lib/speller/spell.gif b/lib/speller/spell.gif deleted file mode 100644 index 29bd11ae986..00000000000 Binary files a/lib/speller/spell.gif and /dev/null differ diff --git a/lib/speller/spellChecker.js b/lib/speller/spellChecker.js deleted file mode 100644 index 8e80a887e96..00000000000 --- a/lib/speller/spellChecker.js +++ /dev/null @@ -1,458 +0,0 @@ -//////////////////////////////////////////////////// -// spellChecker.js -// -// spellChecker object -// -// This file is sourced on web pages that have a textarea object to evaluate -// for spelling. It includes the implementation for the spellCheckObject. -// -// Modified by LUDO (Marc Alier) for integration with the moogle environment -// august 2004 malier@lsi.upc.es -// -//////////////////////////////////////////////////// - - -// constructor -function spellChecker( textObject) { - // public properties - configurable - //this.popUpUrl = '/moodle/lib/speller/spellchecker.html'; - this.popUpName = 'spellchecker'; - this.popUpProps = "menu=no,width=440,height=350,top=70,left=120,resizable=yes,status=yes"; - //this.spellCheckScript = '/moodle/lib/speller/server-scripts/spellchecker.php'; - //this.spellCheckScript = '/cgi-bin/spellchecker.pl'; - - // values used to keep track of what happened to a word - this.replWordFlag = "R"; // single replace - this.ignrWordFlag = "I"; // single ignore - this.replAllFlag = "RA"; // replace all occurances - this.ignrAllFlag = "IA"; // ignore all occurances - this.fromReplAll = "~RA"; // an occurance of a "replace all" word - this.fromIgnrAll = "~IA"; // an occurance of a "ignore all" word - // properties set at run time - this.wordFlags = new Array(); - this.currentTextIndex = 0; - this.currentWordIndex = 0; - this.spellCheckerWin = null; - this.controlWin = null; - this.wordWin = null; - this.textArea = textObject; // deprecated - this.textInputs = arguments; - - this._editor=""; // BY LUDO - // private methods - this._spellcheck = _spellcheck; - this._getSuggestions = _getSuggestions; - this._setAsIgnored = _setAsIgnored; - this._getTotalReplaced = _getTotalReplaced; - this._setWordText = _setWordText; - this._getFormInputs = _getFormInputs; - - // public methods - this.openChecker = openChecker; - this.startCheck = startCheck; - this.checkTextBoxes = checkTextBoxes; - this.checkTextAreas = checkTextAreas; - this.spellCheckAll = spellCheckAll; - this.ignoreWord = ignoreWord; - this.ignoreAll = ignoreAll; - this.replaceWord = replaceWord; - this.replaceAll = replaceAll; - this.terminateSpell = terminateSpell; - this.undo = undo; - - // set the current window's "speller" property to the instance of this class. - // this object can now be referenced by child windows/frames. - window.speller = this; -} - -// call this method to check all text boxes (and only text boxes) in the HTML document -function checkTextBoxes() { - this.textInputs = this._getFormInputs( "^text$" ); - this.openChecker(); -} - -// call this method to check all textareas (and only textareas ) in the HTML document -function checkTextAreas() { - this.textInputs = this._getFormInputs( "^textarea$" ); - this.openChecker(); -} - -// call this method to check all text boxes and textareas in the HTML document -function spellCheckAll() { - this.textInputs = this._getFormInputs( "^text(area)?$" ); - this.openChecker(); -} - -// call this method to check text boxe(s) and/or textarea(s) that were passed in to the -// object's constructor or to the textInputs property -function openChecker() { - this.spellCheckerWin = window.open( this.popUpUrl, this.popUpName, this.popUpProps ); - if( !this.spellCheckerWin.opener ) { - this.spellCheckerWin.opener = window; - } -} - -function startCheck( wordWindowObj, controlWindowObj ) { - - // set properties from args - this.wordWin = wordWindowObj; - this.controlWin = controlWindowObj; - - // reset properties - this.wordWin.resetForm(); - this.controlWin.resetForm(); - this.currentTextIndex = 0; - this.currentWordIndex = 0; - // initialize the flags to an array - one element for each text input - this.wordFlags = new Array( this.wordWin.textInputs.length ); - // each element will be an array that keeps track of each word in the text - for( var i=0; i