MDL-35661 Loading of plugin settings for editor plugins (plugininfo_editor)

This commit is contained in:
Marina Glancy
2012-10-09 09:57:57 +08:00
parent 79c5c3fa96
commit 087001ee42
3 changed files with 51 additions and 13 deletions
+2 -12
View File
@@ -91,19 +91,9 @@ if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('editorsettings', new lang_string('editors', 'editor')));
$temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
$temp->add(new admin_setting_manageeditors());
$htmleditors = editors_get_available();
$ADMIN->add('editorsettings', $temp);
$editors_available = editors_get_available();
foreach ($editors_available as $editor=>$editorstr) {
if (file_exists($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php')) {
$settings = new admin_settingpage('editorsettings'.$editor, new lang_string('pluginname', 'editor_'.$editor), 'moodle/site:config');
// settings.php may create a subcategory or unset the settings completely
include($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php');
if ($settings) {
$ADMIN->add('editorsettings', $settings);
}
}
foreach ($allplugins['editor'] as $editor) {
$editor->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
}
/// License types
+1 -1
View File
@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('editorsettings', new admin_category('editortinymce', new lang_string('pluginname', 'editor_tinymce')));
$ADMIN->add('editorsettings', new admin_category('editortinymce', $editor->displayname, $editor->is_enabled() === false));
$settings = new admin_settingpage('editorsettingstinymce', new lang_string('settings', 'editor_tinymce'));
if ($ADMIN->fulltree) {
+48
View File
@@ -2669,3 +2669,51 @@ class plugininfo_local extends plugininfo_base {
}
}
}
/**
* Class for HTML editors
*/
class plugininfo_editor extends plugininfo_base {
public function get_settings_section_name() {
return 'editorsettings' . $this->name;
}
public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
global $CFG, $USER, $DB, $OUTPUT, $PAGE; // in case settings.php wants to refer to them
$ADMIN = $adminroot; // may be used in settings.php
$editor = $this; // also can be used inside settings.php
$section = $this->get_settings_section_name();
$settings = null;
if ($hassiteconfig && file_exists($this->full_path('settings.php'))) {
$settings = new admin_settingpage($section, $this->displayname,
'moodle/site:config', $this->is_enabled() === false);
include($this->full_path('settings.php')); // this may also set $settings to null
}
if ($settings) {
$ADMIN->add($parentnodename, $settings);
}
}
/**
* Returns the information about plugin availability
*
* True means that the plugin is enabled. False means that the plugin is
* disabled. Null means that the information is not available, or the
* plugin does not support configurable availability or the availability
* can not be changed.
*
* @return null|bool
*/
public function is_enabled() {
global $CFG;
if (empty($CFG->texteditors)) {
$CFG->texteditors = 'tinymce,textarea';
}
if (in_array($this->name, explode(',', $CFG->texteditors))) {
return true;
}
return false;
}
}