Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / Filter / YouTube.php
blob433f17cf47e4ba934d562aad9f2e84c342de55f3
1 <?php
3 require_once 'HTMLPurifier/Filter.php';
5 class HTMLPurifier_Filter_YouTube extends HTMLPurifier_Filter
8 var $name = 'YouTube preservation';
10 function preFilter($html, $config, &$context) {
11 $pre_regex = '#<object[^>]+>.+?'.
12 'http://www.youtube.com/v/([A-Za-z0-9\-_]+).+?</object>#s';
13 $pre_replace = '<span class="youtube-embed">\1</span>';
14 return preg_replace($pre_regex, $pre_replace, $html);
17 function postFilter($html, $config, &$context) {
18 $post_regex = '#<span class="youtube-embed">([A-Za-z0-9\-_]+)</span>#';
19 $post_replace = '<object width="425" height="350" '.
20 'data="http://www.youtube.com/v/\1">'.
21 '<param name="movie" value="http://www.youtube.com/v/\1"></param>'.
22 '<param name="wmode" value="transparent"></param>'.
23 '<!--[if IE]>'.
24 '<embed src="http://www.youtube.com/v/\1"'.
25 'type="application/x-shockwave-flash"'.
26 'wmode="transparent" width="425" height="350" />'.
27 '<![endif]-->'.
28 '</object>';
29 return preg_replace($post_regex, $post_replace, $html);