Commit 5cbcc34a authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow youtube iframe-based embed code (bug #708327)


Temporary htmlpurifier filter added - to be removed when SafeIframe option is available.
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent a6088f53
...@@ -2242,5 +2242,9 @@ function xmldb_core_upgrade($oldversion=0) { ...@@ -2242,5 +2242,9 @@ function xmldb_core_upgrade($oldversion=0) {
add_index($table, $index); add_index($table, $index);
} }
if ($oldversion < 2011012800) {
reload_html_filters();
}
return $status; return $status;
} }
<?php
class HTMLPurifier_Filter_YouTubeIframe extends HTMLPurifier_Filter
{
public $name = 'YouTubeIframe';
public function preFilter($html, $config, $context) {
$pre_regex = '#<iframe\b[a-zA-Z0-9/"=-\s]+?\bsrc="http://www.youtube.com/embed/([A-Za-z0-9]+)"[a-zA-Z0-9/"=-\s]*?></iframe>#';
$pre_replace = '<span class="youtube-iframe">\1</span>';
return preg_replace($pre_regex, $pre_replace, $html);
}
public function postFilter($html, $config, $context) {
$post_regex = '#<span class="youtube-iframe">([A-Za-z0-9]+)</span>#';
return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html);
}
protected function postFilterCallback($matches) {
return '<iframe title="YouTube video player" class="youtube-player" type="text/html"'.
'width="480" height="390" src="http://www.youtube.com/embed/'.$matches[1].
'" frameborder="0" allowFullScreen></iframe>';
}
}
\ No newline at end of file
...@@ -8,4 +8,8 @@ ...@@ -8,4 +8,8 @@
<filename>Twitter</filename> <filename>Twitter</filename>
<site>http://twitter.com</site> <site>http://twitter.com</site>
</filter> </filter>
<filter>
<filename>YouTubeIframe</filename>
<site>http://youtube.com (iframe code)</site>
</filter>
</filters> </filters>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
defined('INTERNAL') || die(); defined('INTERNAL') || die();
$config = new StdClass; $config = new StdClass;
$config->version = 2010122700; $config->version = 2011012800;
$config->release = '1.4.0dev'; $config->release = '1.4.0dev';
$config->minupgradefrom = 2008040200; $config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)'; $config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
...@@ -156,7 +156,7 @@ EOF; ...@@ -156,7 +156,7 @@ EOF;
tinyMCE.init({ tinyMCE.init({
button_tile_map: true, button_tile_map: true,
{$tinymce_config} {$tinymce_config}
extended_valid_elements : "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],script[src,type,language],+ul[id|type|compact]", extended_valid_elements : "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],script[src,type,language],+ul[id|type|compact],iframe[src|width|height|align|title|class|type|frameborder|allowfullscreen]",
urlconverter_callback : "custom_urlconvert", urlconverter_callback : "custom_urlconvert",
language: '{$language}', language: '{$language}',
directionality: "{$tinymce_langdir}", directionality: "{$tinymce_langdir}",
......
Supports Markdown
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