Commit 2370875c authored by Richard Mansfield's avatar Richard Mansfield
Browse files

htmlpurifier filter for embedded SciVee videos

parent 0037c788
......@@ -38,7 +38,7 @@ $themeoptions = get_themes();
$yesno = array(true => get_string('yes'),
false => get_string('no'));
$allowedfilters = array('YouTube', 'GoogleVideo', 'TeacherTube');
$allowedfilters = array('YouTube', 'GoogleVideo', 'TeacherTube', 'SciVee');
$enabledfilters = get_config('filters');
if ($enabledfilters) {
$enabledfilters = unserialize($enabledfilters);
......@@ -188,6 +188,11 @@ $siteoptionform['elements']['filters'] = array(
'title' => 'http://www.teachertube.com',
'defaultvalue' => in_array('TeacherTube', $enabledfilters),
),
'SciVee' => array(
'type' => 'checkbox',
'title' => 'http://www.scivee.tv',
'defaultvalue' => in_array('SciVee', $enabledfilters),
),
),
);
......
<?php
class HTMLPurifier_Filter_SciVee extends HTMLPurifier_Filter
{
public $name = 'SciVee';
public function preFilter($html, $config, $context) {
$pre_regex = '#<object [^>]+>.*?<embed src="http://www.scivee.tv/flash/embedPlayer.swf"[^>]+\bflashvars="(id=\d+&(?:amp;)?type=\d+)"[^>]*>\s*</embed>\s*</object>#s';
$pre_replace = '<span class="scivee-embed">\1</span>';
return preg_replace($pre_regex, $pre_replace, $html);
}
public function postFilter($html, $config, $context) {
$post_regex = '#<span class="scivee-embed">(id=\d+&(?:amp;)?type=\d+)</span>#';
$post_replace = '<object width="480" height="400">'.
'<param name="movie" value="http://www.scivee.tv/flash/embedPlayer.swf" />'.
'<param name="allowscriptaccess" value="always" />'.
'<param name="flashvars" value="\1" />'.
'<embed src="http://www.scivee.tv/flash/embedPlayer.swf" width="480" height="400" flashvars="\1"></embed>'.
'</object>';
return preg_replace($post_regex, $post_replace, $html);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment