Skip to content
Snippets Groups Projects
Commit 782db1ae authored by Tamara Gunkel's avatar Tamara Gunkel
Browse files

allow filtering for multiple URLs

parent 2fb46dd8
No related branches found
No related tags found
No related merge requests found
...@@ -56,11 +56,15 @@ class filter_opencast extends moodle_text_filter ...@@ -56,11 +56,15 @@ class filter_opencast extends moodle_text_filter
} }
foreach (\tool_opencast\local\settings_api::get_ocinstances() as $ocinstance) { foreach (\tool_opencast\local\settings_api::get_ocinstances() as $ocinstance) {
$episodeurl = get_config('filter_opencast', 'episodeurl_' . $ocinstance->id); $episodeurls = get_config('filter_opencast', 'episodeurl_' . $ocinstance->id);
if (!$episodeurl) {
if (!$episodeurls) {
continue; continue;
} }
foreach (explode("\n", $episodeurls) as $episodeurl) {
$episodeurl = trim($episodeurl);
$urlparts = parse_url($episodeurl); $urlparts = parse_url($episodeurl);
$baseurl = $urlparts['scheme'] . '://' . $urlparts['host']; $baseurl = $urlparts['scheme'] . '://' . $urlparts['host'];
if (isset($urlparts['port'])) { if (isset($urlparts['port'])) {
...@@ -115,6 +119,10 @@ class filter_opencast extends moodle_text_filter ...@@ -115,6 +119,10 @@ class filter_opencast extends moodle_text_filter
$data = paella_transform::get_paella_data_json($ocinstance->id, $episodeid[1][0]); $data = paella_transform::get_paella_data_json($ocinstance->id, $episodeid[1][0]);
if (!$data) {
continue;
}
// Collect the needed data being submitted to the template. // Collect the needed data being submitted to the template.
$mustachedata = new stdClass(); $mustachedata = new stdClass();
$mustachedata->playerid = 'ocplayer_' . $i++; $mustachedata->playerid = 'ocplayer_' . $i++;
...@@ -159,6 +167,7 @@ class filter_opencast extends moodle_text_filter ...@@ -159,6 +167,7 @@ class filter_opencast extends moodle_text_filter
} }
} }
} }
}
// Return the same string except processed by the above. // Return the same string except processed by the above.
return $text; return $text;
......
...@@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die();
$string['filtername'] = 'Opencast'; $string['filtername'] = 'Opencast';
$string['pluginname'] = 'Opencast Filter'; $string['pluginname'] = 'Opencast Filter';
$string['privacy:metadata'] = 'The Opencast filter plugin does not store any personal data.'; $string['privacy:metadata'] = 'The Opencast filter plugin does not store any personal data.';
$string['setting_episodeurl'] = 'URL template for filtering'; $string['setting_episodeurl'] = 'URL templates for filtering';
$string['setting_episodeurl_desc'] = 'URLs matching this template are replaced with the Opencast player. You must use the placeholder [EPISODEID] to indicate where the episode ID is contained in the URL e.g. http://stable.opencast.de/play/[EPISODEID]'; $string['setting_episodeurl_desc'] = 'URLs matching this template are replaced with the Opencast player. You must use the placeholder [EPISODEID] to indicate where the episode ID is contained in the URL e.g. http://stable.opencast.de/play/[EPISODEID]. If you want to filter for multiple URLs, enter each URL in a new line.';
$string['setting_configurl'] = 'URL to Paella config.json'; $string['setting_configurl'] = 'URL to Paella config.json';
$string['setting_configurl_desc'] = 'URL of the config.json used by Paella Player. Can either be a absolute URL or a URL relative to the wwwroot.'; $string['setting_configurl_desc'] = 'URL of the config.json used by Paella Player. Can either be a absolute URL or a URL relative to the wwwroot.';
...@@ -27,9 +27,9 @@ if ($ADMIN->fulltree) { ...@@ -27,9 +27,9 @@ if ($ADMIN->fulltree) {
$ocinstances = \tool_opencast\local\settings_api::get_ocinstances(); $ocinstances = \tool_opencast\local\settings_api::get_ocinstances();
foreach ($ocinstances as $instance) { foreach ($ocinstances as $instance) {
$settings->add(new admin_setting_configtext('filter_opencast/episodeurl_' . $instance->id, $settings->add(new admin_setting_configtextarea('filter_opencast/episodeurl_' . $instance->id,
get_string('setting_episodeurl', 'filter_opencast'), get_string('setting_episodeurl', 'filter_opencast'),
get_string('setting_episodeurl_desc', 'filter_opencast'), '')); get_string('setting_episodeurl_desc', 'filter_opencast'), '', PARAM_RAW_TRIMMED, '30', '4'));
$settings->add(new admin_setting_configtext('filter_opencast/configurl_' . $instance->id, $settings->add(new admin_setting_configtext('filter_opencast/configurl_' . $instance->id,
new lang_string('setting_configurl', 'filter_opencast'), new lang_string('setting_configurl', 'filter_opencast'),
......
...@@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die();
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->release = 'v3.11-r1'; $plugin->release = 'v3.11-r1';
$plugin->version = 2021101900; // The current plugin version (Date: YYYYMMDDXX). $plugin->version = 2021101901; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2020061500; // Requires this Moodle version. $plugin->requires = 2020061500; // Requires this Moodle version.
$plugin->component = 'filter_opencast'; // Full name of the plugin. $plugin->component = 'filter_opencast'; // Full name of the plugin.
$plugin->dependencies = array( $plugin->dependencies = array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment