Skip to content

Commit

Permalink
MDL-35645 make the emoticon and tex filter dependency optional in our…
Browse files Browse the repository at this point in the history
… TinyMCE plugins
  • Loading branch information
skodak committed Oct 6, 2012
1 parent ccd90e7 commit f4b9800
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 12 deletions.
Expand Up @@ -24,6 +24,8 @@

$string['javaneeded'] = 'To use this page you need a Java-enabled browser. Download the latest Java plug-in from {$a}.';
$string['pluginname'] = 'Insert equation';
$string['requiretex'] = 'Require TeX filter';
$string['requiretex_desc'] = 'If enabled the Dragmath button is visible only when the TeX filter is enabled in the editor context. Disable if you have a custom TeX filter that is enabled in global scope.';
$string['title'] = 'DragMath Equation Editor';

/* All lang strings used from TinyMCE JavaScript code must be named 'pluginname:stringname', no need to create langs/en_dlg.js */
Expand Down
10 changes: 6 additions & 4 deletions lib/editor/tinymce/plugins/dragmath/lib.php
Expand Up @@ -30,10 +30,12 @@ class tinymce_dragmath extends editor_tinymce_plugin {
protected function update_init_params(array &$params, context $context,
array $options = null) {

// If TeX filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/tex', $filters)) {
return;
if ($this->get_config('requiretex', 1)) {
// If TeX filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/tex', $filters)) {
return;
}
}

// Add button before 'nonbreaking' in advancedbuttons3.
Expand Down
30 changes: 30 additions & 0 deletions lib/editor/tinymce/plugins/dragmath/settings.php
@@ -0,0 +1,30 @@
<?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/>.

/**
* DragMath integration settings.
*
* @package tinymce_dragmath
* @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) {
$settings->add(new admin_setting_configcheckbox('tinymce_dragmath/requiretex',
get_string('requiretex', 'tinymce_dragmath'), get_string('requiretex_desc', 'tinymce_dragmath'), 1));
}
4 changes: 2 additions & 2 deletions lib/editor/tinymce/plugins/dragmath/version.php
Expand Up @@ -25,8 +25,8 @@
defined('MOODLE_INTERNAL') || die();

// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012051700;
$plugin->version = 2012100200;
// Required Moodle version.
$plugin->requires = 2011112900;
$plugin->requires = 2012092700;
// Full name of the plugin (used for diagnostics).
$plugin->component = 'tinymce_dragmath';
Expand Up @@ -23,6 +23,8 @@
*/

$string['pluginname'] = 'Insert emoticon';
$string['requireemoticon'] = 'Require emoticon filter';
$string['requireemoticon_desc'] = 'If enabled the emoticon button is visible only when the emoticon filter is enabled in the editor context.';

/* All lang strings used from TinyMCE JavaScript code must be named 'pluginname:stringname', no need to create langs/en_dlg.js */
$string['moodleemoticon:desc'] = 'Insert emoticon';
10 changes: 6 additions & 4 deletions lib/editor/tinymce/plugins/moodleemoticon/lib.php
Expand Up @@ -31,10 +31,12 @@ protected function update_init_params(array &$params, context $context,
array $options = null) {
global $OUTPUT;

// If emoticon filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/emoticon', $filters)) {
return;
if ($this->get_config('requireemoticon', 1)) {
// If emoticon filter is disabled, do not add button.
$filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/emoticon', $filters)) {
return;
}
}

// Add button after 'image' in advancedbuttons3.
Expand Down
30 changes: 30 additions & 0 deletions lib/editor/tinymce/plugins/moodleemoticon/settings.php
@@ -0,0 +1,30 @@
<?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/>.

/**
* Emoticon integration settings.
*
* @package tinymce_moodleemoticon
* @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) {
$settings->add(new admin_setting_configcheckbox('tinymce_moodleemoticon/requireemoticon',
get_string('requireemoticon', 'tinymce_moodleemoticon'), get_string('requireemoticon_desc', 'tinymce_moodleemoticon'), 1));
}
4 changes: 2 additions & 2 deletions lib/editor/tinymce/plugins/moodleemoticon/version.php
Expand Up @@ -25,8 +25,8 @@
defined('MOODLE_INTERNAL') || die();

// The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012051700;
$plugin->version = 2012100200;
// Required Moodle version.
$plugin->requires = 2011112900;
$plugin->requires = 2012092700;
// Full name of the plugin (used for diagnostics).
$plugin->component = 'tinymce_moodleemoticon';

0 comments on commit f4b9800

Please sign in to comment.