Install websiteFrame Extension
From Zedomax Wiki
Contents |
[edit]
Description
This simple extension will allow you to post a website in an iFrame in your MediaWiki articles.
[edit]
Installation
To install this extension, save the following file as websiteFrame.php file in the wiki/extensions folder:
<?php
# to activate the extension, include it from your LocalSettings.php
# with: include("extensions/YourExtensionName.php");
$wgExtensionFunctions[] = "wfwebsiteFrame";
function wfwebsiteFrame() {
global $wgParser;
$wgParser->setHook( "websiteFrame", "websiteFrame" );
}
# the callback function for converting the input text to HTML output
function websiteFrame($input) {
# set default arguments
$allParams['height'] = 800;
$allParams['width'] = 800;
$allParams['scroll'] = "no";
$allParams['border'] = "0";
$allParams['name'] = "Page1";
$allParams['align'] = "middle";
# get input args
$aParams = explode("\n", $input); # ie 'website=http://www.whatever.com'
foreach($aParams as $sParam) {
$aParam = explode("=", $sParam); # ie $aParam[0] = 'website' and $aParam[1] = 'http://www.whatever.com'
if( count( $aParam ) < 2 ) # no arguments passed
continue;
$sType = $aParam[0]; # ie 'website'
$sArg = $aParam[1]; # ie 'http://www.whatever.com'
switch ($sType) {
case 'website':
# clean up
$sType = trim($sType);
$sArg = trim($sArg);
$allParams['website'] = $sArg; # http://www.whatever.com
break;
case 'height':
# clean up
$sType = trim($sType);
$sArg = trim($sArg);
$allParams['height'] = $sArg; # 80
break;
case 'width':
# clean up
$sType = trim($sType);
$sArg = trim($sArg);
$allParams['width'] = $sArg; # 100
break;
case 'scroll':
# clean up
$sType = trim($sType);
$sArg = trim($sArg);
$allParams['scroll'] = $sArg; # yes
break;
case 'border':
# clean up
$sType = trim($sType);
$sArg = trim($sArg);
$allParams['border'] = $sArg; # yes
break;
case 'name':
# clean up
$sType = trim($sType);
$sArg = trim($sArg);
$allParams['name'] = $sArg; # my iFrame
break;
case 'align':
# clean up
$sType = trim($sType);
$sArg = trim($sArg);
$allParams['align'] = $sArg; # my iFrame
break;
}
}
# build output
$output .= "<iframe src=\"".$allParams['website']."\" align=\"".$allParams['align']."\" name=\"".$allParams['name']."\" frameborder=\"".$allParams['border']."\" height=\"".$allParams['height']."\" scrolling=\"".$allParams['scroll']."\" width=\"".$allParams['width']."\"></iframe>";
# return the output
return $output;
}
?>
Finally, edit your LocalSettings.php file and add the following code to the bottom;
/* websiteFrame extension */
include("extensions/websiteFrame.php");
[edit]
Usage
Be sure to use the full URL to your website; http://fivedollarwiki.com
<websiteFrame> website=[website URL] name=[string] align=[top,middle,bottom,left,right] height=[number] width=[number] border=[number] scroll=[yes,no,auto] longdescription=[long description URI] </websiteFrame>
[edit]
Example
<websiteFrame> website=http://www.google.com height=800 width=800 border=0 scroll=yes </websiteFrame>