Skip to content

Commit

Permalink
MDL-66954 filter_displayh5p: Rename filter_h5p to filter_displayh5p
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Amaia Anabitarte committed Oct 18, 2019
1 parent aaff669 commit 826e76e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 32 deletions.
Expand Up @@ -15,19 +15,19 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Privacy Subsystem implementation for filter_h5p.
* Privacy Subsystem implementation for filter_displayh5p.
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @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 <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down
12 changes: 6 additions & 6 deletions filter/h5p/filter.php → filter/displayh5p/filter.php
Expand Up @@ -14,25 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* H5P filter
* Display H5P filter
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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 <victor@moodle.com>
* @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.
Expand All @@ -57,7 +57,7 @@ public function filter($text, array $options = array()) {
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;
Expand Down
Expand Up @@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Strings for filter_h5p
* Strings for filter_displayh5p
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -30,5 +30,5 @@
<b>[id]</b> is a placeholder for the H5P content id in the external source.
<b>*</b> 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.';
11 changes: 7 additions & 4 deletions filter/h5p/settings.php → filter/displayh5p/settings.php
Expand Up @@ -15,17 +15,20 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* H5P filter settings
* Display H5P filter settings
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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]"));
}
Expand Up @@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Unit tests for the filter_h5p
* Unit tests for the filter_displayh5p
*
* @package filter_h5p
* @package filter_displayh5p
* @category test
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -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 <victor@moodle.com>
* @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);
Expand Down
8 changes: 4 additions & 4 deletions filter/h5p/version.php → filter/displayh5p/version.php
Expand Up @@ -15,15 +15,15 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Version of filter_h5p.
* Version of filter_displayh5p.
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @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';

0 comments on commit 826e76e

Please sign in to comment.