http://www.my-url.com/
# http://www.my-url.com/{width=640}{height=480}
#
$wgExtensionFunctions[] = "wfEmbedURL";
$wgExtensionCredits['parserhook'][] = array(
'name' => 'EmbedURL',
'author' => 'Unknown author, modified by UCSC',
'url' => 'http://www.mediawiki.org/wiki/Extension:EmbedURL',
'description' => '<embedurl> parser tag for embedding other websites into a wiki page, modified by UCSC'
);
function wfEmbedURL() {
global $wgParser;
$wgParser->setHook( "embedurl", "renderEmbedURL" );
}
# The callback function for converting the input text to HTML output
function renderEmbedURL( $input ) {
global $width;
global $height;
$width = false;
$height = false;
global $scrolling;
$scrolling = "no";
global $frameborder;
$frameborder = "0";
global $marginwidth;
$marginwidth = "0";
global $marginheight;
$marginheight = "0";
# Building the code
$pos = strpos($input, "{");
if ($pos == false) {
$url = $input;
} else {
$url = substr($input, 0, $pos);
}
$pos = strpos($input, "{width=");
if ($pos != false) {
$width = substr($input, $pos+7);
$pos1 = strpos($width, "}");
if ($pos1 != false) {
$width = substr($width, 0, $pos1);
}
}
$pos = strpos($input, "{height=");
if ($pos != false) {
$height = substr($input, $pos+8);
$pos1 = strpos($height, "}");
if ($pos1 != false) {
$height = substr($height, 0, $pos1);
}
}
$pos = strpos($input, "{scrolling=");
if ($pos != false) {
$scrolling = substr($input, $pos+11);
$pos1 = strpos($scrolling, "}");
if ($pos1 != false) {
$scrolling = substr($scrolling, 0, $pos1);
} else {
$scrolling="no";
}
}
$pos = strpos($input, "{frameborder=");
if ($pos != false) {
$frameborder = substr($input, $pos+13);
$pos1 = strpos($frameborder, "}");
if ($pos1 != false) {
$frameborder = substr($frameborder, 0, $pos1);
} else {
$frameborder="0";
}
}
$pos = strpos($input, "{marginwidth=");
if ($pos != false) {
$marginwidth = substr($input, $pos+13);
$pos1 = strpos($marginwidth, "}");
if ($pos1 != false) {
$marginwidth = substr($marginwidth, 0, $pos1);
} else {
$marginwidth="0";
}
}
$pos = strpos($input, "{marginheight=");
if ($pos != false) {
$marginheight = substr($input, $pos+14);
$pos1 = strpos($marginheight, "}");
if ($pos1 != false) {
$marginheight = substr($marginheight, 0, $pos1);
} else {
$marginheight="0";
}
}
if ($url == false ) {
$url = "http://www.mediawiki.org/wiki/Extension:EmbedURL";
}
if ($width == false ) {
$width = "100%";
}
if ($height == false ) {
$height = "500";
}
$height = preg_match('/\%$/',$height) ?
"height:$height" : "height:${height}px";
$width = preg_match('/\%$/',$width) ?
"width:$width" : "width:${width}px";
$output = "";
return $output;
}