From 826e76edc95842e4203389807a4b1f73148e2b35 Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Fri, 18 Oct 2019 12:19:56 +0200 Subject: [PATCH] MDL-66954 filter_displayh5p: Rename filter_h5p to filter_displayh5p We are renaming existing h5p_filter in 3.8dev to h5p_displayh5p to avoid collisions with filter_h5p plugin in Moodle plugin directory. Everybody having a 3.8dev installation with filter_h5p plugin should drop the old filter or re-install from scratch. --- .../classes/privacy/provider.php | 8 +++---- filter/{h5p => displayh5p}/filter.php | 12 +++++----- .../lang/en/filter_displayh5p.php} | 6 ++--- filter/{h5p => displayh5p}/settings.php | 11 +++++---- .../{h5p => displayh5p}/tests/filter_test.php | 24 ++++++++++--------- filter/{h5p => displayh5p}/version.php | 8 +++---- 6 files changed, 37 insertions(+), 32 deletions(-) rename filter/{h5p => displayh5p}/classes/privacy/provider.php (86%) rename filter/{h5p => displayh5p}/filter.php (94%) rename filter/{h5p/lang/en/filter_h5p.php => displayh5p/lang/en/filter_displayh5p.php} (92%) rename filter/{h5p => displayh5p}/settings.php (76%) rename filter/{h5p => displayh5p}/tests/filter_test.php (81%) rename filter/{h5p => displayh5p}/version.php (86%) diff --git a/filter/h5p/classes/privacy/provider.php b/filter/displayh5p/classes/privacy/provider.php similarity index 86% rename from filter/h5p/classes/privacy/provider.php rename to filter/displayh5p/classes/privacy/provider.php index 215faccf3aa..26a482ecf9f 100644 --- a/filter/h5p/classes/privacy/provider.php +++ b/filter/displayh5p/classes/privacy/provider.php @@ -15,19 +15,19 @@ // along with Moodle. If not, see . /** - * Privacy Subsystem implementation for filter_h5p. + * Privacy Subsystem implementation for filter_displayh5p. * - * @package filter_h5p + * @package filter_displayh5p * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -namespace filter_h5p\privacy; +namespace filter_displayh5p\privacy; defined('MOODLE_INTERNAL') || die; /** - * Privacy Subsystem for filter_h5p implementing null_provider. + * Privacy Subsystem for filter_displayh5p implementing null_provider. * * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/filter/h5p/filter.php b/filter/displayh5p/filter.php similarity index 94% rename from filter/h5p/filter.php rename to filter/displayh5p/filter.php index fcb35ec4a88..e1b0cf74eaf 100644 --- a/filter/h5p/filter.php +++ b/filter/displayh5p/filter.php @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . /** - * H5P filter + * Display H5P filter * - * @package filter_h5p + * @package filter_displayh5p * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -24,15 +24,15 @@ defined('MOODLE_INTERNAL') || die; /** - * H5P filter + * Display H5P filter * * This filter will replace any occurrence of H5P URLs with the corresponding H5P content embed code * - * @package filter_h5p + * @package filter_displayh5p * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class filter_h5p extends moodle_text_filter { +class filter_displayh5p extends moodle_text_filter { /** * @var boolean $loadresizerjs This is whether to request the resize.js script. @@ -57,7 +57,7 @@ class filter_h5p extends moodle_text_filter { return $text; } - $allowedsources = get_config('filter_h5p', 'allowedsources'); + $allowedsources = get_config('filter_displayh5p', 'allowedsources'); $allowedsources = array_filter(array_map('trim', explode("\n", $allowedsources))); if (empty($allowedsources)) { return $text; diff --git a/filter/h5p/lang/en/filter_h5p.php b/filter/displayh5p/lang/en/filter_displayh5p.php similarity index 92% rename from filter/h5p/lang/en/filter_h5p.php rename to filter/displayh5p/lang/en/filter_displayh5p.php index 38f446044dc..6317fb63e6d 100644 --- a/filter/h5p/lang/en/filter_h5p.php +++ b/filter/displayh5p/lang/en/filter_displayh5p.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see . /** - * Strings for filter_h5p + * Strings for filter_displayh5p * - * @package filter_h5p + * @package filter_displayh5p * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -30,5 +30,5 @@ $string['allowedsourceslistdesc'] = 'List of sources from which users can embed [id] is a placeholder for the H5P content id in the external source. * wildcard is supported. For example, *.example.com will embed H5P content from any subdomain of example.com, but not from the example.com domain.'; -$string['filtername'] = 'H5P'; +$string['filtername'] = 'Display H5P'; $string['privacy:metadata'] = 'This H5P filter does not store any personal data.'; diff --git a/filter/h5p/settings.php b/filter/displayh5p/settings.php similarity index 76% rename from filter/h5p/settings.php rename to filter/displayh5p/settings.php index 6102eebbe38..ca5199009cd 100644 --- a/filter/h5p/settings.php +++ b/filter/displayh5p/settings.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see . /** - * H5P filter settings + * Display H5P filter settings * - * @package filter_h5p + * @package filter_displayh5p * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -25,7 +25,10 @@ defined('MOODLE_INTERNAL') || die; if ($ADMIN->fulltree) { - $settings->add(new admin_setting_configtextarea('filter_h5p/allowedsources', get_string('allowedsourceslist', 'filter_h5p'), - get_string('allowedsourceslistdesc', 'filter_h5p'), + $settings->add(new admin_setting_configtextarea( + 'filter_displayh5p/allowedsources', + get_string('allowedsourceslist', + 'filter_displayh5p'), + get_string('allowedsourceslistdesc', 'filter_displayh5p'), "https://h5p.org/h5p/embed/[id]\nhttps://*.h5p.com/content/[id]/embed\nhttps://*.h5p.com/content/[id]")); } diff --git a/filter/h5p/tests/filter_test.php b/filter/displayh5p/tests/filter_test.php similarity index 81% rename from filter/h5p/tests/filter_test.php rename to filter/displayh5p/tests/filter_test.php index 2e17c105ab0..2ac3aae1c7e 100644 --- a/filter/h5p/tests/filter_test.php +++ b/filter/displayh5p/tests/filter_test.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see . /** - * Unit tests for the filter_h5p + * Unit tests for the filter_displayh5p * - * @package filter_h5p + * @package filter_displayh5p * @category test * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -26,38 +26,40 @@ defined('MOODLE_INTERNAL') || die(); global $CFG; -require_once($CFG->dirroot.'/filter/h5p/filter.php'); +require_once($CFG->dirroot.'/filter/displayh5p/filter.php'); /** - * Unit tests for the H5P filter. + * Unit tests for the display H5P filter. * * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class filter_h5p_testcase extends advanced_testcase { +class filter_displayh5p_testcase extends advanced_testcase { public function setUp() { parent::setUp(); $this->resetAfterTest(true); - set_config('allowedsources', "https://h5p.org/h5p/embed/[id]\nhttps://*.h5p.com/content/[id]/embed\nhttps://*.h5p.com/content/[id] - \nhttps://generic.wordpress.soton.ac.uk/altc/wp-admin/admin-ajax.php?action=h5p_embed&id=[id]", 'filter_h5p'); - // Enable h5p filter at top level. - filter_set_global_state('h5p', TEXTFILTER_ON); + set_config('allowedsources', + "https://h5p.org/h5p/embed/[id]\nhttps://*.h5p.com/content/[id]/embed\nhttps://*.h5p.com/content/[id] + \nhttps://generic.wordpress.soton.ac.uk/altc/wp-admin/admin-ajax.php?action=h5p_embed&id=[id]", + 'filter_displayh5p'); + // Enable display h5p filter at top level. + filter_set_global_state('displayh5p', TEXTFILTER_ON); } /** * Check that h5p tags with urls from allowed domains are filtered. * * @param string $text Original text - * @param string $filteredtextpattern Text pattern after H5P filter + * @param string $filteredtextpattern Text pattern after display H5P filter * * @dataProvider texts_provider */ public function test_filter_urls($text, $filteredtextpattern) { - $filterplugin = new filter_h5p(null, array()); + $filterplugin = new filter_displayh5p(null, array()); $filteredtext = $filterplugin->filter($text); $this->assertRegExp($filteredtextpattern, $filteredtext); diff --git a/filter/h5p/version.php b/filter/displayh5p/version.php similarity index 86% rename from filter/h5p/version.php rename to filter/displayh5p/version.php index 343b5d2ffac..59766e78d95 100644 --- a/filter/h5p/version.php +++ b/filter/displayh5p/version.php @@ -15,15 +15,15 @@ // along with Moodle. If not, see . /** - * Version of filter_h5p. + * Version of filter_displayh5p. * - * @package filter_h5p + * @package filter_displayh5p * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2019092000; +$plugin->version = 2019101800; $plugin->requires = 2019092000; -$plugin->component = 'filter_h5p'; +$plugin->component = 'filter_displayh5p';