Source of file YouTube.php
Size: 1,366 Bytes - Last Modified: 2021-12-23T10:07:55+00:00
/var/www/docs.ssmods.com/process/src/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Filter/YouTube.php
12345678910111213141516171819202122232425262728293031323334353637383940 | <?php class HTMLPurifier_Filter_YouTube extends HTMLPurifier_Filter { public $name = 'YouTube'; public function preFilter($html, $config, $context) { $pre_regex = '#<object[^>]+>.+?'. 'http://www.youtube.com/v/([A-Za-z0-9\-_]+).+?</object>#s'; $pre_replace = '<span class="youtube-embed">\1</span>'; return preg_replace($pre_regex, $pre_replace, $html); } public function postFilter($html, $config, $context) { $post_regex = '#<span class="youtube-embed">([A-Za-z0-9\-_]+)</span>#'; return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html); } protected function armorUrl($url) { return str_replace('--', '--', $url); } protected function postFilterCallback($matches) { $url = $this->armorUrl($matches[1]); return '<object width="425" height="350" type="application/x-shockwave-flash" '. 'data="http://www.youtube.com/v/'.$url.'">'. '<param name="movie" value="http://www.youtube.com/v/'.$url.'"></param>'. '<!--[if IE]>'. '<embed src="http://www.youtube.com/v/'.$url.'"'. 'type="application/x-shockwave-flash"'. 'wmode="transparent" width="425" height="350" />'. '<![endif]-->'. '</object>'; } } // vim: et sw=4 sts=4 |