Extension:AJAXDocumentViewer
|
AJAX Document Viewer Release status: beta |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | AJAX Document Viewer Extension. Embed documents using AJAX document viewer . | ||
| Author(s) | John Nidelc | ||
| Last version | 0.1 (2008-12-18) | ||
| License | No license specified | ||
| Download | Extension:AJAXDocumentViewer#Installation | ||
|
|||
| Check usage and version matrix | |||
Contents |
What can this extension do? [edit]
AJAX Document Viewer is a web based online document viewer that can embedded into any web page or be linked from any page. It is customizable and free, although the free version displays a banner ad.
Usage [edit]
<adv>Document Name</adv>
One can optionally set the width and height of the document viewer:
<adv width="the width you want" height="the height you want">Document Name</adv>
Document Name can be the name of a file you have already uploaded to MediaWiki, i.e. Report.doc.
Installation [edit]
extensions/AjaxDocumentViewer.php [edit]
Create a new file called "extensions/AjaxDocumentViewer.php" in your MediaWiki installation directory and populate it with the following:
<?php $wgExtensionFunctions[] = 'wfADV'; $wgHooks['LanguageGetMagic'][] = 'wfADVParserFunctionMagic'; $wgExtensionCredits['parserhook'][] = array( 'name' => 'ADV', 'version' => 0.1, 'description' => 'Display Documents using [http://www.ajaxdocumentviewer.com]', 'author' => '[http://www.ajaxdocumentviewer.com AJAXDocumentViewer]', 'url' => 'http://www.mediawiki.org/wiki/Extension:AJAXDocumentViewer' ); function wfADV() { global $wgParser; $wgParser->setHook('ADV', 'renderADV'); $wgParser->setFunctionHook('ADV', 'wfADVRender'); } function wfADVRender(&$parser, $file = '') { return $parser->insertStripItem(renderADV($file, array()), $parser->mStripState); } function wfADVParserFunctionMagic( &$magicWords, $langCode ) { $magicWords['ADV'] = array( 0, 'ADV' ); return true; } # The callback function for converting the input text to HTML output function renderADV($input, $args) { global $wgADVKey; global $wgServer; $input = htmlspecialchars($input); $width = $args['width']; $height = $args['height']; if($width <= 0) { $width = 510; } if($height <= 0) { $height = 660; } /* is this a URL or an internal file? */ if(strpos($input, "http://") == FALSE) { /* try and treat this like an internal file */ $input = $wgServer . Image::imageUrl($input); } $output = '<iframe name="ajaxdocumentviewer" src="http://www.ajaxdocumentviewer.com/embed.asp?key='.$wgADVKey.'&document='.$input.'&viewerheight='.$height.'&viewerwidth='.$width.'" border="0" height="'.$height.'" width="'.$width.'" scrolling="no" align="center" frameborder="0" marginwidth="1" marginheight="1">Your browser does not support inline frames or is currently configured not to display inline frames.</iframe>'; return $output; } ?>
LocalSettings.php [edit]
To enable the extension add the following to your "LocalSettings.php" file:
require_once("$IP/extensions/AjaxDocumentViewer.php"); $wgADVKey = 'XXXXXXXX';
where 'XXXXXXXX' is the free AJAX Document Viewer key that can be obtained from http://www.ajaxdocumentviewer.com/linkit.asp#key.
Acknowledgments [edit]
This plugin was (badly) adapted from the Google Calendar extensions.