MDL-67063 h5p: new h5plib plugintype for supporting multi coreAPI

A new plugintype has been created for having more than one installed
third-party H5P libraries. Existing libraries have been moved from
lib/h5p to the new h5plib_v124 plugin.
This commit is contained in:
Sara Arjona
2020-03-11 08:46:16 +01:00
parent 32a05b5625
commit 08fda3e0f8
76 changed files with 625 additions and 99 deletions
+41
View File
@@ -11208,3 +11208,44 @@ class admin_setting_configthemepreset extends admin_setting_configselect {
return true;
}
}
/**
* Selection of plugins that can work as H5P libraries handlers
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2020 Sara Arjona <sara@moodle.com>
*/
class admin_settings_h5plib_handler_select extends admin_setting_configselect {
/**
* Constructor
* @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting'
* for ones in config_plugins.
* @param string $visiblename localised
* @param string $description long localised info
* @param string $defaultsetting
*/
public function __construct($name, $visiblename, $description, $defaultsetting = '') {
parent::__construct($name, $visiblename, $description, $defaultsetting, null);
}
/**
* Lazy-load the available choices for the select box
*/
public function load_choices() {
if (during_initial_install()) {
return false;
}
if (is_array($this->choices)) {
return true;
}
$this->choices = \core_h5p\local\library\autoloader::get_all_handlers();
foreach ($this->choices as $name => $class) {
$this->choices[$name] = new lang_string('sitepolicyhandlerplugin', 'core_admin',
['name' => new lang_string('pluginname', $name), 'component' => $name]);
}
return true;
}
}