Sedang Disiapkan

564822 MediaWiki EmbedVideo Simplification

Currently I have EmbedVideo extension of Mediawiki.

[url removed, login to view]

The extension requires to type

{{#ev:youtube|dMH0bHeiRNg}}

to embed a video.

I want to simplify this.

There are various ways to simplify this.

I don't need these all. I just want at least one of these ways implemented.

1. Simplify copying and pasting the url of the video page will embed the vidio. For example,

[url removed, login to view]

2. Writing

ev1|dMH0bHeiRNg

will embed the embed. ev1 stands for youtube, and ev2 for other, ev3 or other video services.

Either 1 or 2 is OK, or maybe you can think of another way to simplify.

There is a similar plugin for bbpress. So I attach the code of the plugin.

====================================================

There is a bbpress plugin bbvideo

[url removed, login to view]

This plugin allows users to embed videos from numerous sources including Youtube just by copying and pasting the address of page.

For example, copying and pasting [url removed, login to view] will show visitors the embedded video.

An example website with this plugin is [url removed, login to view]

=========================================================

[[[url removed, login to view]]]

<?php

/*

Plugin Name: BBVideo

Plugin URI: [url removed, login to view]

Description: <strong>English:</strong> Converts Video-Links in your forum posts to embedded Video-Players.<br /><strong>Deutsch:</strong> Wandelt Video-Links in den Forenbeiträgen in Video-Player um.<br /><em>Supports: Youtube, Dailymotion, MyVideo Google Video and many <a href="[url removed, login to view]" target="_blank">more ...</a></em>

Author: Naden Badalgogtapeh

Author URI: [url removed, login to view]

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__ ) . '/[url removed, login to view]' ) )

{

// 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( __( '<div class="updated">Settings Saved</div>' ) );

}

}

function AdminPage()

{

global $bbdb, $bb, $bb_table_prefix;

@include_once( dirname( __FILE__ ) . '/[url removed, login to view]' );

}

function AddHeader()

{

if( $this->options[ 'embed' ] == 1 )

{

$code = <<<DATA

<!-- bbVideo Plugin v{$this->version} - [url removed, login to view] -->

<script type="text/javascript">

function bbvideo_embed( sender ) {

var area = [url removed, login to view]( [url removed, login to view] + 'embed' );

if( area ) {

if( [url removed, login to view] == 'normal' || [url removed, login to view] == 'block' ) {

[url removed, login to view] = [url removed, login to view]( /-/, '+' );

[url removed, login to view] = 'none';

}

else {

[url removed, login to view] = [url removed, login to view]( /\+/, '-' );

[url removed, login to view] = 'block';

}

}

return( false );

}

</script>

<!-- // bbVideo Plugin -->

DATA;

print( $code );

unset( $code );

}

}

function AddAdminPage()

{

global $bb_menu;

$bb_menu[ 60 ] = array( __( 'bbVideo' ), 'use_keys', 'BBPressPluginBBVideoAdminPage' );

}

function DisplayProvider( $mask = '<small><a href="[url removed, login to view]">%s</a></small>', $pre = '<p>', $post = '</p>' )

{

printf( $pre . $mask . $post, implode( ', ', array_keys( $this->provider ) ) );

}

function GetTitle( $s )

{

$magic = 0;

for( $k=0; $k<strlen( $s ); $k++ )

{

$magic += ord( $s[ $k ] );

}

$titles = array( 'video plugin', 'video plugins', 'video widget', 'video player', 'flash video', 'flash videos' );

return( @ucwords( $titles[ $magic % count( $titles ) ] ) );

}

function ContentFilter( $buffer )

{

/// detect all links in the current topic

@preg_match_all( '|http([s]?)\://(.*)|i', $buffer, $links, PREG_PATTERN_ORDER );

$count = count( $links[ 0 ] );

foreach( $links[ 0 ] as $link )

{

foreach( $this->provider 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( '<a href="[url removed, login to view]" style="color:#aaa;text-decoration:underline;">%s</a>', $this->GetTitle( get_topic_title() ) );

if( $this->options[ 'download' ] == 1 )

{

$download = sprintf( '<a style="color: #000;" href="[url removed, login to view]" target="_blank">Video Download</a>', 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 = <<<DATA

<!-- bbVideo Plugin v{$this->version} - [url removed, login to view] -->

<div style="width:{$provider[ 'width' ]}px;">{$code}<div>

<table width="100%" cellpadding="0" cellspacing="0" border="0">

<tr><td><a href="" id="bbvideo{$this->index}" onclick="javascript:return(bbvideo_embed(this));" style="color: #000;">[+] Embed the video</a>{$download}</td><td align="right" style="color:#aaa;font-size:80%;">Get the {$url}</td></tr></table>

<div id="bbvideo{$this->index}embed" style="display:none;">

<table width="100%" cellpadding="0" cellspacing="0" border="0">

<tr><td width="80">Text-Link:</td><td><input type="text" value="{$post_link}" onclick="javascript:[url removed, login to view]();[url removed, login to view]();" style="width:100%;" /></td></tr>

<tr><td width="80">HTML-Link:</td><td><input type="text" value='<a href="{$post_link}">{$post_title}</a>' onclick="javascript:[url removed, login to view]();[url removed, login to view]();" style="width:100%;" /></td></tr>

<tr><td width="80">BB-Code:</td><td><input type="text" value="[url={$post_link}]{$post_title}[/url]" onclick="javascript:[url removed, login to view]();[url removed, login to view]();" style="width:100%;" /></td></tr>

<tr><td width="80">Embed:</td><td><input type="text" value='<div style="width:{$provider[ 'width' ]}px;">{$code}<div align="right" style="color:#aaa;font-size:80%;">Get the {$url}</div></div>' onclick="javascript:[url removed, login to view]();[url removed, login to view]();" style="width:100%;" /></td></tr>

</table>

</div></div></div>

<!-- // bbVideo Plugin -->

DATA;

}

else

{

if( isset( $download ) )

{

$download = '<td>' . $download . '</td>';

}

$code = <<<DATA

<div style="width:{$provider[ 'width' ]}px;">{$code}

<table width="100%" cellpadding="0" cellspacing="0" border="0">

<tr>{$download}<td align="right" style="color:#aaa;font-size:80%;">Get the {$url}</td></tr>

</table>

</div>

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();

}

?>

=============================================

[[[url removed, login to view]]]

<?php

/*

BBVideo Plugin [url removed, login to view] admin template

[url removed, login to view]

*/

if( isset( $_POST[ 'cmd' ] ) )

{

$this->SaveOptions(

array(

'embed' => intval( $_POST[ 'embed' ] ),

'download' => intval( $_POST[ 'download' ] )

)

);

}

?>

<h2>bbVideo v<?php print( $this->version ); ?> - <?php _e( 'Settings' ) ?></h2>

<div>

<strong><a href="[url removed, login to view]">Plugin Homepage</a></strong>

</div>

<form method="post" action="">

<p>

<h4>Embed:</h4>

<label for="embed">Zeige Embed Optionen unter den Videos. / Show embed field below the videos.</label>

<p>

<input type="radio" name="embed" value="1" <?php print( $this->options[ 'embed' ] == 1 ? ' checked="checked"' : '' ); ?>/> Ja

<input type="radio" name="embed" value="0" <?php print( $this->options[ 'embed' ] == 0 ? ' checked="checked"' : '' ); ?>/> Nein

</p>

</p>

<p>

<h4>Download:</h4>

<label for="download">Zeige Download-Link unter den Videos. / Show download link field below the videos.</label>

<p>

<input type="radio" name="download" value="1" <?php print( $this->options[ 'download' ] == 1 ? ' checked="checked"' : '' ); ?>/> Ja

<input type="radio" name="download" value="0" <?php print( $this->options[ 'download' ] == 0 ? ' checked="checked"' : '' ); ?>/> Nein

</p>

</p>

<p class="submit"><input type="submit" name="cmd" value="speichern / save" /></p>

</form>

<p>

<h4>Supported Video-Portals (<?php print( count( $this->provider ) ); ?>):</h4>

<ul>

<?php

foreach( $this->provider as $k => $provider )

{

printf( '<li><a href="%s" target="_blank">%s</a></li>', $provider[ 'page_url' ], ucfirst( $k ) );

}

?>

</ul>

</p>

<div align="center">

<strong><a href="[url removed, login to view]">Plugin Homepage</a></strong>

</div>

============================================

[[[url removed, login to view]]]

<?php

/*

BBVideo Plugin [url removed, login to view] definition file

[url removed, login to view]

*/

/*

Support for:

+ myvideo

+ funnyordie

+ collegehumor

+ redtube

+ dailymotion

+ sevenload

+ glumbert

+ youtube

+ googlevideo

+ liveleak

+ metacafe

+ clipfish

+ gametrailers

+ vimeo

*/

$this->provider = array(

'youtube' => array(

'width' => '425',

'height' => '350',

'pattern' => 'youtube\.(.*)/watch\?v=([a-zA-Z0-9_-]*)',

'index' => 2,

'code' => '<object width="[WIDTH]" height="[HEIGHT]"><param name="movie" value="[url removed, login to view][ID]&rel=1"></param><param name="wmode" value="transparent"></param><embed src="[url removed, login to view][ID]&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="[WIDTH]" height="[HEIGHT]"></embed></object>',

'page_url' => '[url removed, login to view]'

),

'myvideo' => array(

'width' => '425',

'height' => '350',

'pattern' => 'myvideo\.de/watch/([a-zA-Z0-9_-]*)',

'index' => 1,

'code' => '<object width="[WIDTH]" height="[HEIGHT]" type="application/x-shockwave-flash" data="[url removed, login to view][ID]"><param name="movie" value="[url removed, login to view][ID]"></param><param name="AllowFullscreen" value="true" /></object>',

'page_url' => '[url removed, login to view]'

),

'funnyordie' => array(

'width' => '425',

'height' => '350',

'pattern' => 'funnyordie\.com/videos/([0-9a-fA-F]*)',

'index' => 1,

'code' => '<embed type="application/x-shockwave-flash" src="[url removed, login to view]" scale="noScale" salign="TL" flashvars="&ratename=IMMORTAL&rating=5.0&ratedby=12&canrate=no&VID=7417&file=[url removed, login to view][ID].flv&autoStart=false&key=[ID]" allowfullscreen="true" height="[HEIGHT]" width="[WIDTH]"></embed>',

'page_url' => '[url removed, login to view]'

),

'gametrailers' => array(

'width' => '425',

'height' => '350',

'pattern' => 'gametrailers\.com/player/([0-9].*)\.html(.*)',

'index' => 1,

'code' => '<object id="gtembed" width="[WIDTH]" height="[HEIGHT]"><param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="[url removed, login to view][ID]"/> <param name="quality" value="high" /><embed src="[url removed, login to view][ID]" swLiveConnect="true" name="gtembed" align="middle" allowScriptAccess="sameDomain" quality="high" type="application/x-shockwave-flash" width="[WIDTH]" height="[HEIGHT]"></embed></object>',

'page_url' => '[url removed, login to view]'

),

'collegehumor' => array(

'width' => '425',

'height' => '350',

'pattern' => 'collegehumor\.com/video:([0-9]*)',

'index' => 1,

'code' => '<embed src="[url removed, login to view][ID]" quality="best" width="[WIDTH]" height="[HEIGHT]" type="application/x-shockwave-flash"></embed>',

'page_url' => '[url removed, login to view]'

),

'dailymotion' => array(

'width' => '425',

'height' => '350',

'pattern' => 'dailymotion\.com/(.*)video/(.*?)_',

'index' => 2,

'code' => '<object width="[WIDTH]" height="[HEIGHT]"><param name="movie" value="[url removed, login to view][ID]"></param><param name="allowfullscreen" value="true"></param><embed src="[url removed, login to view][ID]" type="application/x-shockwave-flash" width="[WIDTH]" height="[HEIGHT]" allowfullscreen="true"></embed></object>',

'page_url' => '[url removed, login to view]'

),

'glumbert' => array(

'width' => '425',

'height' => '350',

'pattern' => 'glumbert\.com\/media\/(.*?)$',

'index' => 1,

'code' => '<object width="[WIDTH]" height="[HEIGHT]"><param name="movie" value="[url removed, login to view][ID]"></param><param name="wmode" value="transparent"></param><embed src="[url removed, login to view][ID]" type="application/x-shockwave-flash" wmode="transparent" width="[WIDTH]" height="[HEIGHT]"></embed></object>',

'page_url' => '[url removed, login to view]'

),

'liveleak' => array(

'width' => '425',

'height' => '350',

'pattern' => '[url removed, login to view][?]i=([0-9a-zA-Z_]*)',

'index' => 1,

'code' => '<embed src="[url removed, login to view]" width="[WIDTH]" height="[HEIGHT]" type="application/x-shockwave-flash" flashvars="autostart=false&token=[ID]" scale="showall" name="index"></embed>',

'page_url' => '[url removed, login to view]'

),

'redtube' => array(

'width' => '434',

'height' => '344',

'pattern' => '[url removed, login to view]([0-9].*)',

'index' => 1,

'code' => '<object height="[HEIGHT]" width="[WIDTH]"><param name="movie" value="[url removed, login to view]"><param name="FlashVars" value="id=[ID]&style=redtube"><embed src="[url removed, login to view][ID]&style=redtube" type="application/x-shockwave-flash" height="[HEIGHT]" width="[WIDTH]"></object>',

'page_url' => '[url removed, login to view]'

),

'googlevideo' => array(

'width' => '425',

'height' => '350',

'pattern' => 'video\.google\.(.*)/(videoplay)?(url)?\?docid=([a-zA-Z0-9_-]*)',

'index' => 1,

'code' => '<embed style="width:[WIDTH]px; height:[HEIGHT]px;" id="VideoPlayback" type="application/x-shockwave-flash" src="[url removed, login to view][ID]&hl=de" flashvars=""></embed>',

'page_url' => '[url removed, login to view]'

),

'sevenload' => array(

'width' => '425',

'height' => '350',

'pattern' => 'sevenload\.com/videos\/([a-zA-Z0-9_-]*)',

'index' => 1,

'code' => '<object width="[WIDTH]" height="[HEIGHT]"><param name="FlashVars" value="slxml=[url removed, login to view]"/><param name="movie" value="[url removed, login to view][ID]/[WIDTH]x[HEIGHT]/swf" /><embed src="[url removed, login to view][ID]/[WIDTH]x[HEIGHT]/swf" type="application/x-shockwave-flash" width="[WIDTH]" height="[HEIGHT]" FlashVars="slxml=[url removed, login to view]"></embed></object>',

'page_url' => '[url removed, login to view]'

),

'metacafe' => array(

'width' => '425',

'height' => '350',

'pattern' => 'metacafe\.com/watch/([0-9].*?)/',

'index' => 1,

'code' => '<embed flashVars="altServerURL=http://www.metacafe.com&playerVars=showStats=yes|autoPlay=no|blogName=[url removed, login to view]|blogURL=[url removed, login to view]" src="[url removed, login to view][ID]/[url removed, login to view]" width="[WIDTH]" height="[HEIGHT]" wmode="transparent"></embed>',

'page_url' => '[url removed, login to view]'

),

'clipfish' => array(

'width' => '425',

'height' => '350',

'pattern' => 'clipfish\.de/player\.php\?videoid=([a-zA-z0-9]*)',

'index' => 1,

'code' => '<embed src="[url removed, login to view][ID]&r=1" quality="high" bgcolor="#cacaca" width="[WIDTH]" height="[HEIGHT]" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed>',

'page_url' => '[url removed, login to view]'

),

'vimeo' => array(

'width' => '425',

'height' => '350',

'pattern' => 'vimeo\.com/([0-9]*)',

'index' => 1,

'code' => '<object width="[WIDTH]" height="[HEIGHT]"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="[url removed, login to view][ID]&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /><embed src="[url removed, login to view][ID]&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="[WIDTH]" height="[HEIGHT]"></embed></object>',

'page_url' => '[url removed, login to view]'

)

);

?>

Kemahiran: Semua Boleh, WIKI, Youtube

Lihat lagi: youtube html 5, x videos similar, www vidio post com, www bb&t.com, writing style definition, writing magic, writing hooks, writing height, writing dirty, writing deutsch, writing block, writing a movie script, writing a javascript class, wiki services, website decoration, vid post, vidio post.com, vidio post com, vidio post, video script writing services

Tentang Majikan:
( 39 ulasan ) Seoul, Korea, Republic of

ID Projek: #2310780