Megavideo.plugin

From FUDforum Wiki
Jump to: navigation, search

Megavideo.plugin is plugin that makes a new [megavideo] BBcode tag available for embedding MegaVideo videos into forum posts.

Contents

Prerequisites

None, this plugin can be uploaded and activated as-is on any forum.

Usage

If this plugin is active, you can use the [megavideo]VIDEO_ID[/megavideo] tag to embed videos into forum posts. Example:

[megavideo]OWHNICB0[/megavideo]

Code

File megavideo.plugin:

<?php
// Initialize plugin
plugin_add_hook("BBCODE2HTML", "plugin_megavideo_tag_to_html");
plugin_add_hook("HTML2BBCODE", "plugin_megavideo_html_to_tag");

// Convert [megavideo] to html code (post message)
function plugin_megavideo_tag_to_html($array) {
	list($bbcode) = $array;

	$bbcode = preg_replace('#\[MEGAVIDEO\]([0-9a-zA-Z_\-]+)\[/MEGAVIDEO\]#si', '<object width="640" height="480"><param name="movie" value="http://wwwstatic.megavideo.com/mv_player.swf?v=\\1"></param><embed src="http://wwwstatic.megavideo.com/mv_player.swf?v=\\1" type="application/x-shockwave-flash" allowfullscreen="true" width="640" height="480"></embed></object>', $bbcode);
	return array($bbcode);
}

// Convert html to [MEGAVIDEO] tag (edit message)
function plugin_megavideo_html_to_tag($array) {
	list($bbcode) = $array;

	$bbcode = preg_replace('#<object width="640" height="480"><param name="movie" value="http://wwwstatic.megavideo.com/mv_player.swf\?v=([0-9a-zA-Z_\-]+)"></param><embed src="http://wwwstatic.megavideo.com/mv_player.swf\?v=([0-9a-zA-Z_\-]+)" type="application/x-shockwave-flash" allowfullscreen="true" width="640" height="480"></embed></object>#si', '[MEGAVIDEO]\\1[/MEGAVIDEO]', $bbcode);
	return array($bbcode);
}

Also see

Languages
Personal tools