English: Converts Video-Links in your forum posts to embedded Video-Players.
Deutsch: Wandelt Video-Links in den Forenbeiträgen in Video-Player um.
Supports: Youtube, Dailymotion, MyVideo Google Video and many more ... Author: Naden Badalgogtapeh Author URI: http://www.naden.de/blog Version: 0.24 */ /** * class BBPressBBVideo */ class BBPressPluginBBVideo { /** * list of supported video providers */ var $provider; /** * plugin version */ var $version; /** * plugin options */ var $options; /** * plugin id for filter hooks */ var $wp_filter_id; /** * global index for embedding */ var $index; /** * public constructor */ function BBPressPluginBBVideo() { $this->version = '0.24'; $this->wp_filter_id = 'bbvideo'; $this->index = 0; $this->options = bb_get_option( 'bbvideo_options' ); if( is_null( $this->options ) ) { $this->SaveOptions( array( 'embed' => 1 ), false ); } if( !array_key_exists( 'download', $this->options ) ) { $this->options[ 'download' ] = 1; $this->SaveOptions( $this->options, false ); } $this->provider = array(); // include list of video providers if( @include_once( dirname( __FILE__ ) . '/provider.inc.php' ) ) { // content filter only on topics if( is_topic() ) { // header stuff add_action( 'bb_head', array( &$this, 'AddHeader' ) ); // add content filter add_filter( 'post_text', array( &$this, 'ContentFilter' ), 9 ); } else { /// add admin panel add_action( 'bb_admin_menu_generator', array( &$this, 'AddAdminPage' ) ); } } } function SaveOptions( $options, $verbose = true ) { foreach( $options as $key => $value ) { $this->options[ $key ] = $value; } bb_update_option( 'bbvideo_options', $this->options ); if( $verbose ) { print( __( '
Settings Saved
' ) ); } } function AdminPage() { global $bbdb, $bb, $bb_table_prefix; @include_once( dirname( __FILE__ ) . '/admin.php' ); } function AddHeader() { if( $this->options[ 'embed' ] == 1 ) { $code = <<version} - http://www.naden.de/blog/bbvideo-bbpress-video-plugin --> DATA; print( $code ); unset( $code ); } } function AddAdminPage() { global $bb_menu; $bb_menu[ 60 ] = array( __( 'bbVideo' ), 'use_keys', 'BBPressPluginBBVideoAdminPage' ); } function DisplayProvider( $mask = '%s', $pre = '

', $post = '

' ) { printf( $pre . $mask . $post, implode( ', ', array_keys( $this->provider ) ) ); } function GetTitle( $s ) { $magic = 0; for( $k=0; $kprovider as $k => $provider ) { @preg_match( '|' . $provider[ 'pattern' ] . '|i', $link, $matches ); if( count( $matches ) > 0 ) { /// build embed-code $code = str_replace( array( '[ID]', '[HEIGHT]', '[WIDTH]' ), array( $matches[ $provider[ 'index' ] ], $provider[ 'height' ], $provider[ 'width' ] ), $provider[ 'code' ] ); $url = sprintf( '%s', $this->GetTitle( get_topic_title() ) ); if( $this->options[ 'download' ] == 1 ) { $download = sprintf( 'Video Download', urlencode( $link ) ); } if( $this->options[ 'embed' ] == 1 ) { $post_title = str_replace( "'", '', get_topic_title() ); $post_link = get_topic_link(); if( $bb->mod_rewrite ) { list( $post_link, ) = explode( '?', get_topic_link() ); } if( isset( $download ) ) { $download = ' | ' . $download; } $code = <<version} - http://www.naden.de/blog/bbvideo-bbpress-video-plugin -->
{$code}
[+] Embed the video{$download}Get the {$url}
DATA; } else { if( isset( $download ) ) { $download = '' . $download . ''; } $code = <<{$code} {$download}
Get the {$url}
DATA; } /// replace link w/ embed-code $buffer = str_replace( $link, $code, $buffer ); unset( $code ); break; } } $this->index ++; reset( $this->provider ); } return( $buffer ); } } // end class BBPressPluginBBVideo /** * dirty hack, because it seems to be impossible to call an class method over uri */ function BBPressPluginBBVideoAdminPage( ) { global $BBPressPluginBBVideo; $BBPressPluginBBVideo->AdminPage(); } /// end func /// init plugin if( !isset( $BBPressPluginBBVideo ) || is_null( $BBPressPluginBBVideo ) ) { $BBPressPluginBBVideo = new BBPressPluginBBVideo(); } ?>