MDL-34877 add tinymce subplugin setting support

Includes migration of spell related settings to spellchecker plugin.
This commit is contained in:
Petr Škoda 2012-08-18 15:21:37 +02:00
parent d71c486507
commit 116ad39b7a
11 changed files with 243 additions and 15 deletions

View file

@ -27,8 +27,11 @@ require('../../../../../config.php');
@error_reporting(E_ALL ^ E_NOTICE); // Hide notices even if Moodle is configured to show them.
// General settings
$config['general.engine'] = get_config('editor_tinymce', 'spellengine') ?
get_config('editor_tinymce', 'spellengine') : 'GoogleSpell';
$engine = get_config('tinymce_spellchecker', 'spellengine');
if (!$engine) {
$engine = 'GoogleSpell';
}
$config['general.engine'] = $engine;
// GoogleSpell settings
$config['GoogleSpell.proxyhost'] = isset($CFG->proxyhost) ? $CFG->proxyhost : '';

View file

@ -0,0 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Spellchecker post install script.
*
* @package tinymce_spellchecker
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
function xmldb_tinymce_spellchecker_install() {
global $CFG, $DB;
require_once(__DIR__.'/upgradelib.php');
tinymce_spellchecker_migrate_settings();
}

View file

@ -0,0 +1,40 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Spellchecker upgrade script.
*
* @package tinymce_spellchecker
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
function xmldb_tinymce_spellchecker_upgrade($oldversion) {
global $CFG, $DB;
require_once(__DIR__.'/upgradelib.php');
$dbman = $DB->get_manager();
if ($oldversion < 2012051800) {
tinymce_spellchecker_migrate_settings();
upgrade_plugin_savepoint(true, 2012051800, 'tinymce', 'spellchecker');
}
return true;
}

View file

@ -0,0 +1,41 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Spellchecker upgrade script.
*
* @package tinymce_spellchecker
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Migrate spell related settings from tinymce.
*/
function tinymce_spellchecker_migrate_settings() {
$engine = get_config('editor_tinymce', 'spellengine');
if ($engine !== false) {
set_config('spellengine', $engine, 'tinymce_spellchecker');
unset_config('spellengine', 'editor_tinymce');
}
$list = get_config('editor_tinymce', 'spelllanguagelist');
if ($list !== false) {
set_config('spelllanguagelist', $list, 'tinymce_spellchecker');
unset_config('spelllanguagelist', 'editor_tinymce');
}
}

View file

@ -30,8 +30,7 @@ class tinymce_spellchecker extends editor_tinymce_plugin {
global $CFG;
// Check at least one language is supported.
$config = $params['moodle_config'];
$spelllanguagelist = empty($config->spelllanguagelist) ? '' : $config->spelllanguagelist;
$spelllanguagelist = $this->get_config('spelllanguagelist', '');
if ($spelllanguagelist !== '') {
// Add button after code button in advancedbuttons3.
$added = $this->add_button_after($params, 3, 'spellchecker', 'code', false);

View file

@ -0,0 +1,38 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Spellchecker settings.
*
* @package tinymce_spellchecker
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$options = array(
'PSpell'=>'PSpell',
'GoogleSpell'=>'Google Spell',
'PSpellShell'=>'PSpellShell');
$settings->add(new admin_setting_configselect('tinymce_spellchecker/spellengine',
get_string('spellengine', 'admin'), '', 'GoogleSpell', $options));
$settings->add(new admin_setting_configtextarea('tinymce_spellchecker/spelllanguagelist',
get_string('spelllanguagelist', 'admin'), '',
'+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,' .
'Portuguese=pt,Spanish=es,Swedish=sv', PARAM_RAW));
}

View file

@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012051701;
$plugin->version = 2012051800;
// Required Moodle version.
$plugin->requires = 2011112900;
// Full name of the plugin (used for diagnostics).