From 7a856a933025ca4dd0c42155249d9742483fe447 Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Tue, 23 Mar 2010 08:47:05 +0000 Subject: [PATCH] "MDL-16639, enable spellchecker plugin, and added config pages" --- admin/editors.php | 38 +++++++++++++++++++++++++++- admin/settings/plugins.php | 8 ++++++ lang/en_utf8/admin.php | 1 + lib/adminlib.php | 4 +-- lib/editor/tinymce/lib.php | 5 ++-- lib/editor/tinymce/readme_moodle.txt | 5 +--- lib/editor/tinymce/settings.php | 22 ++++++++++++++++ lib/editorlib.php | 15 +++++++++++ 8 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 lib/editor/tinymce/settings.php diff --git a/admin/editors.php b/admin/editors.php index e63dc2ef258..da8b0a8540c 100644 --- a/admin/editors.php +++ b/admin/editors.php @@ -17,6 +17,7 @@ $action = optional_param('action', '', PARAM_ACTION); $editor = optional_param('editor', '', PARAM_SAFEDIR); // get currently installed and enabled auth plugins +$settingsurl = "$CFG->wwwroot/$CFG->admin/editors.php?sesskey=".sesskey()."&action=edit&editor=$editor"; $available_editors = get_available_editors(); if (!empty($editor) and empty($available_editors[$editor])) { redirect ($returnurl); @@ -36,6 +37,8 @@ if (!confirm_sesskey()) { redirect($returnurl); } + +$return = true; switch ($action) { case 'disable': // remove from enabled list @@ -77,6 +80,37 @@ switch ($action) { } break; + case 'edit': + + $form_file = $CFG->dirroot . '/lib/editor/'.$editor.'/settings.php'; + if (file_exists($form_file)) { + require_once($form_file); + $classname = 'editor_settings_' . $editor; + $pagename = 'editorsettings' . $editor; + admin_externalpage_setup($pagename); + $form = new $classname(); + $data = $form->get_data(); + // $form->addElement('hidden', 'action', 'edit'); + if ($form->is_cancelled()){ + } else if (!empty($data)) { + foreach ($data as $key=>$value) { + if (strpos($key, 'editor_') === 0) { + set_config($key, $value, 'editor'); + } + } + } else { + $form->set_data(array('editor_tinymce_spellengine'=>get_config('editor', 'editor_tinymce_spellengine'))); + $PAGE->set_pagetype('admin-editors-' . $editor); + admin_externalpage_print_header(); + echo $OUTPUT->heading(get_string('modulename', 'editor_'.$editor)); + $OUTPUT->box_start(); + $form->display(); + $OUTPUT->box_end(); + echo $OUTPUT->footer(); + $return = false; + } + } + break; default: break; } @@ -88,4 +122,6 @@ if (empty($active_editors)) { set_config('texteditors', implode(',', $active_editors)); -redirect ($returnurl); +if ($return) { + redirect ($returnurl); +} diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index 9b0d056187d..029beac7a8c 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -75,6 +75,14 @@ if ($hassiteconfig) { $temp->add(new admin_setting_manageeditors()); $ADMIN->add('editorsettings', $temp); + $editors_available = get_available_editors(); + $url = $CFG->wwwroot.'/'.$CFG->admin.'/editors.php?sesskey='.sesskey(); + foreach ($editors_available as $editor=>$editorstr) { + if (file_exists($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php')) { + $editor_setting = new admin_externalpage('editorsettings'.$editor, $editorstr, $url.'&action=edit&editor='.$editor); + $ADMIN->add('editorsettings', $editor_setting); + } + } /// Filter plugins $ADMIN->add('modules', new admin_category('filtersettings', get_string('managefilters'))); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index d10e5ce5027..f70701aa49e 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -834,6 +834,7 @@ $string['smtpmaxbulk'] = 'SMTP session limit'; $string['smtppass'] = 'SMTP password'; $string['smtpuser'] = 'SMTP username'; $string['soaprecommended'] = 'Installing the optional soap extension is useful for web services and some contrib modules.'; +$string['spellengine'] = 'Spell engine'; $string['stats'] = 'Statistics'; $string['statscatdepth'] = 'Maximum parent categories'; $string['statsfirstrun'] = 'Maximum processing interval'; diff --git a/lib/adminlib.php b/lib/adminlib.php index d0237e8e973..a5c5d72e887 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -4992,8 +4992,8 @@ class admin_setting_manageeditors extends admin_setting { } // settings link - if (file_exists($CFG->dirroot.'/editor/'.$editor.'/settings.php')) { - $settings = "{$txt->settings}"; + if (file_exists($CFG->dirroot.'/lib/editor/'.$editor.'/settings.php')) { + $settings = "{$txt->settings}"; } else { $settings = ''; } diff --git a/lib/editor/tinymce/lib.php b/lib/editor/tinymce/lib.php index 908f781db5f..aae9df27fed 100644 --- a/lib/editor/tinymce/lib.php +++ b/lib/editor/tinymce/lib.php @@ -112,7 +112,7 @@ class tinymce_texteditor extends texteditor { 'apply_source_formatting' => true, 'remove_script_host' => false, 'entity_encoding' => "raw", - 'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak", + 'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak,spellchecker", 'theme_advanced_font_sizes' => "1,2,3,4,5,6,7", 'theme_advanced_layout_manager' => "SimpleLayout", 'theme_advanced_toolbar_align' => "left", @@ -121,12 +121,13 @@ class tinymce_texteditor extends texteditor { 'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,cite,abbr,acronym", 'theme_advanced_buttons2_add' => "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl", 'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,image,{$xmedia},emotions,{$xdragmath}advhr,nonbreaking,charmap", - 'theme_advanced_buttons3_add' => "|,table,insertlayer,styleprops,visualchars,|,code,preview", + 'theme_advanced_buttons3_add' => "|,table,insertlayer,styleprops,visualchars,|,code,preview,spellchecker", 'theme_advanced_fonts' => "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;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", 'theme_advanced_resize_horizontal' => true, 'theme_advanced_resizing' => true, 'theme_advanced_toolbar_location' => "top", 'theme_advanced_statusbar_location' => "bottom", + 'spellchecker_rpc_url' => $CFG->wwwroot."/lib/editor/tinymce/plugins/spellchecker/rpc.php" ); if (empty($options['legacy'])) { diff --git a/lib/editor/tinymce/readme_moodle.txt b/lib/editor/tinymce/readme_moodle.txt index 6f5c5433d5b..80753ca2c74 100644 --- a/lib/editor/tinymce/readme_moodle.txt +++ b/lib/editor/tinymce/readme_moodle.txt @@ -25,6 +25,7 @@ Added: * plugins/gragmath/* * plugins/moodlenolink/* * plugins/moodlemedia/* + * plugins/spellchecker/* Modified: * Popup.js --> compressed into tiny_mce_popup.js (extra/patches/tinymce_strings.patch) @@ -32,7 +33,3 @@ Modified: Removed: * - -TODO: - * reimplement spellchecker support in plugins/spellchecker/* - diff --git a/lib/editor/tinymce/settings.php b/lib/editor/tinymce/settings.php new file mode 100644 index 00000000000..845a2c5f475 --- /dev/null +++ b/lib/editor/tinymce/settings.php @@ -0,0 +1,22 @@ +_form; + $options = array( + 'PSpell'=>'PSpell', + 'GoogleSpell'=>'Google Spell', + 'PSpellShell'=>'PSpellShell'); + // options must be started with editor_ to get stored + $mform->addElement('select', 'editor_tinymce_spellengine', get_string('spellengine', 'admin'), $options); + $mform->addElement('hidden', 'editor', 'tinymce'); + + parent::definition(); + } +} diff --git a/lib/editorlib.php b/lib/editorlib.php index 59e81904c7e..383824f4237 100644 --- a/lib/editorlib.php +++ b/lib/editorlib.php @@ -184,7 +184,22 @@ abstract class texteditor { } } +require_once($CFG->libdir.'/formslib.php'); +/** + * Editor settings moodle form class. + * + * @copyright 2010 Dongsheng Cai + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package moodlecore + */ +class editor_settings_form extends moodleform { + public function definition() { + $mform =& $this->_form; + $mform->addElement('hidden', 'action', 'edit'); + $this->add_action_buttons(true, get_string('savechanges')); + } +} //=== DEPRECATED ===================== /**