diff options
| author | wjames5 <will@tekimaki.com> | 2009-05-27 17:11:06 +0000 |
|---|---|---|
| committer | wjames5 <will@tekimaki.com> | 2009-05-27 17:11:06 +0000 |
| commit | 8b8c53b6a821dc08b8562ac9a278d2f5b12bfdf9 (patch) | |
| tree | fd2d5878e62afa1c78ef8c002a0a41b954dabfc6 | |
| parent | ecc737d7ee3e706a0e7239dd00cf459bc8b46cfa (diff) | |
| download | util-8b8c53b6a821dc08b8562ac9a278d2f5b12bfdf9.tar.gz util-8b8c53b6a821dc08b8562ac9a278d2f5b12bfdf9.tar.bz2 util-8b8c53b6a821dc08b8562ac9a278d2f5b12bfdf9.zip | |
add filter for cnbc
| -rw-r--r-- | htmlpure/Filter/CNBC.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/htmlpure/Filter/CNBC.php b/htmlpure/Filter/CNBC.php new file mode 100644 index 0000000..f8bfdde --- /dev/null +++ b/htmlpure/Filter/CNBC.php @@ -0,0 +1,56 @@ +<?php
+
+require_once 'HTMLPurifier/Filter.php';
+
+class HTMLPurifier_Filter_CNBC extends HTMLPurifier_Filter
+{
+
+ public $name = 'CNBC';
+
+ public function preFilter($html, $config, &$context) {
+ $pre_regex = '#<object(.(?!<object))*?width="?([0-9]+)"?(.(?!<object))*?height="?([0-9]+)"?(.(?!</object))*?'.
+ 'http://plus.cnbc.com/rssvideosearch/action/player/id/([A-Za-z0-9\-_]+).+?</object>#s';
+ $pre_replace = '<span class="cnbc-embed w-\2 h-\4">\6</span>';
+ $ret = preg_replace($pre_regex, $pre_replace, $html);
+ return $ret;
+ }
+
+ public function postFilter($html, $config, &$context) {
+ $width = '\1';
+ $height = '\2';
+
+ /* the CNBC embed size may be fixed by the swf app and so it may never be possible to override
+ // @config->def->info['bitweaver']['CNBC'] params width and height will force the size of the video
+ if( !empty( $config->def->info['bitweaver']['CNBC'] ) ){
+ $moviesize = $config->def->info['bitweaver']['CNBC'];
+ $width = $moviesize['width'];
+ $height = $moviesize['height'];
+ }
+ */
+
+ $src_url='http://plus.cnbc.com/rssvideosearch/action/player/id/\3/code/cnbcplayershare';
+
+ $post_regex = '#<span class="cnbc-embed w-([0-9]+) h-([0-9]+)">([A-Za-z0-9\-_]+)</span>#';
+ $post_replace = '<div style="width:'.$width.'px; height:'.$height.'px;">
+ <object width="'.$width.'" height="'.$height.'" data="'.$src_url.'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash">
+ <param name="allowfullscreen" value="true" />
+ <param name="quality" value="best"/>
+ <param name="scale" value="noscale" />
+ <param name="wmode" value="transparent"/>
+ <param name="bgcolor" value="#000000"/>
+ <param name="salign" value="lt"/>
+ <param name="movie" value="'.$src_url.'"/>
+ <!--[if IE]>'.
+ '<embed src="'.$src_url.'" type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'"'.
+ 'name="cnbcplayer" pluginspage="http://www.macromedia.com/go/getflashplayer"'.
+ 'allowfullscreen="true" bgcolor="#000000" quality="best"'.
+ 'wmode="transparent" scale="noscale" salign="lt"></embed>'.
+ '<![endif]-->
+ </object>
+ </div>';
+ $ret = preg_replace($post_regex, $post_replace, $html);
+ return $ret;
+ }
+
+}
+
|
