Extension:AJAXDocumentViewer
From MediaWiki.org
|
Release status: beta |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | AJAX Document Viewer Extension. Embed documents using AJAX document viewer . | ||
| Author(s) | John Nidelc | ||
| Last Version | 0.1 (12/18/2008) | ||
| License | No license specified | ||
| Download | Extension:AJAXDocumentViewer#Installation | ||
|
|||
|
check usage (experimental) |
|||
Contents |
[edit] What can this extension do?
AJAX Document Viewer is a web based online document viewer and can embedded into any web page or linked from any page. It is fast, customizable and FREE.
[edit] Usage
<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.
[edit] Installation
[edit] extensions/ajaxdocumentviewer.php
Create a new file called "extensions/ajaxdocumentviewer.php" in your MediaWiki installation directory and populate it with the following:
$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; }
[edit] LocalSettings.php
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 you have obtained from here [1].
[edit] Acknowledgments
This plugin was (badly) adapted from the Google Calendar extensions.