MDL-35661 Loading of plugin settings for Tinymce plugins (plugininfo_tinymce)

This commit is contained in:
Marina Glancy
2012-10-09 09:57:57 +08:00
parent 087001ee42
commit 5827bf96ed
2 changed files with 21 additions and 19 deletions
+17 -6
View File
@@ -39,12 +39,23 @@ class plugininfo_tinymce extends plugininfo_base {
return new moodle_url('/lib/editor/tinymce/subplugins.php', array('delete' => $this->name, 'sesskey' => sesskey()));
}
public function get_settings_url() {
global $CFG;
if (file_exists("$CFG->dirroot/lib/editor/tinymce/plugins/$this->name/settings.php")) {
return new moodle_url('/admin/settings.php', array('section'=>'tinymce'.$this->name.'settings'));
} else {
return null;
public function get_settings_section_name() {
return 'tinymce'.$this->name.'settings';
}
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
$settings = null;
if ($hassiteconfig && file_exists($this->full_path('settings.php'))) {
$section = $this->get_settings_section_name();
$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);
}
}
+4 -13
View File
@@ -45,20 +45,11 @@ bullist,numlist,outdent,indent,|,link,unlink,|,image,nonbreaking,charmap,table,|
$ADMIN->add('editortinymce', $settings);
unset($settings);
$subplugins = get_plugin_list('tinymce');
$disabled = array(); // Disabling of subplugins to be implemented later.
foreach ($subplugins as $name=>$dir) {
if (file_exists("$dir/settings.php")) {
$settings = new admin_settingpage('tinymce'.$name.'settings', new lang_string('pluginname', 'tinymce_'.$name), 'moodle/site:config', in_array($name, $disabled));
// settings.php may create a subcategory or unset the settings completely.
include("$dir/settings.php");
if ($settings) {
$ADMIN->add('editortinymce', $settings);
}
}
require_once("$CFG->libdir/pluginlib.php");
$allplugins = plugin_manager::instance()->get_plugins();
foreach ($allplugins['tinymce'] as $plugin) {
$plugin->load_settings($ADMIN, 'editortinymce', $hassiteconfig);
}
unset($subplugins);
unset($disabled);
// TinyMCE does not have standard settings page.
$settings = null;