. /** * H5P filter * * @package filter_h5p * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; /** * H5P filter * * This filter will replace any occurrence of H5P URLs with the corresponding H5P content embed code * * @package filter_h5p * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class filter_h5p extends moodle_text_filter { /** * @var boolean $loadresizerjs This is whether to request the resize.js script. */ private static $loadresizerjs = true; /** * Function filter replaces any h5p-sources. * * @param string $text HTML content to process * @param array $options options passed to the filters * @return string */ public function filter($text, array $options = array()) { if (!is_string($text) or empty($text)) { // Non string data can not be filtered anyway. return $text; } if (stripos($text, 'http') === false) { return $text; } $allowedsources = get_config('filter_h5p', 'allowedsources'); $allowedsources = array_filter(array_map('trim', explode("\n", $allowedsources))); if (empty($allowedsources)) { return $text; } $params = array( 'tagbegin' => "