Skip to content

Commit fc4daf2

Browse files
committed
fix: Move filter to /classes for 4.5 compat
1 parent f054713 commit fc4daf2

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

filter.php renamed to classes/text_filter.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

17+
namespace filter_smartmedia;
18+
1719
use local_smartmedia\conversion;
1820
use core\plugininfo\media;
1921
use core\url;
@@ -22,6 +24,13 @@
2224
use core\context\course;
2325
use local_smartmedia\aws_api;
2426
use local_smartmedia\aws_elastic_transcoder;
27+
use core_media_manager;
28+
use core_media_player_native;
29+
use media_videojs_plugin;
30+
use DOMDocument;
31+
use DOMXPath;
32+
use stdClass;
33+
use core\output\single_button;
2534

2635
/**
2736
* Automatic smart media embedding filter class.
@@ -30,7 +39,7 @@
3039
* @copyright 2019 Matt Porritt <mattp@catalyst-au.net>
3140
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3241
*/
33-
class filter_smartmedia extends moodle_text_filter {
42+
class text_filter extends \core_filters\text_filter {
3443

3544
/**
3645
* Video.js plugin enabled status not set.
@@ -126,7 +135,7 @@ class filter_smartmedia extends moodle_text_filter {
126135
* @param array $localconfig Any context-specific configuration for this filter.
127136
* @param conversion|null $conversion
128137
*/
129-
public function __construct($context, array $localconfig, conversion $conversion = null) {
138+
public function __construct($context, array $localconfig, ?conversion $conversion = null) {
130139
parent::__construct($context, $localconfig);
131140

132141
if (!empty($conversion)) {
@@ -576,7 +585,7 @@ public function filter($text, array $options = []) {
576585
// Add a wrapping div so DOMDocument doesnt mangle the structure.
577586
$loadtext = '<div>' . $text . '</div>';
578587
// Ensure the encoding can be loaded by the domdoc.
579-
$loadtext = mb_convert_encoding($loadtext, 'HTML-ENTITIES', 'UTF-8');
588+
$loadtext = htmlspecialchars($loadtext);
580589

581590
// Supress warnings. HTML5 nodes currently throw warnings.
582591
// Use flags to prevent html and body tags from being included.
@@ -653,7 +662,7 @@ public function filter($text, array $options = []) {
653662
if ($link->isSameNode($newlink)) {
654663
$exists = true;
655664
}
656-
} catch (Throwable $e) {
665+
} catch (\Throwable $e) {
657666
// Some error, likely when the $link is no longer a valid DOMElement.
658667
continue;
659668
}

version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
$plugin->component = 'filter_smartmedia';
28-
$plugin->release = 2025061300;
29-
$plugin->version = 2025061300;
28+
$plugin->release = 2025061301;
29+
$plugin->version = 2025061301;
3030
$plugin->supported = [405, 405];
3131
$plugin->requires = 2024100700; // 4.5
3232
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)