Extension:Vuzit

From MediaWiki.org

Jump to: navigation, search

             

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
Vuzit

Release status: beta

Implementation  Tag
Description Embed documents using Vuzit's AJAX-based document viewer.
Author(s)  Evan Sultanik
Last Version  0.4 (09/02/2008)
MediaWiki  Tested on 1.12.0
License No license specified
Download Extension:Vuzit#Installation
Example  http://www.sultanik.com/CV

check usage (experimental)

Contents

[edit] What can this extension do?

vuzit is a free online document viewer implemented using ajax. For an example, see my CV.

[edit] Usage

<vuzit>Document URL</vuzit>

One can optionally set the width and height of the document viewer:

<vuzit width="the width you want" height="the height you want">Document URL</vuzit>

The extension can also be called as a parser function:

{{#vuzit:Document URL}}

As of version 0.4, Document URL may be either an absolute URL (i.e. "http://foo.com/bar.pdf") or a PDF that has been uploaded (as an image) to the wiki (e.g. "Image:Bar.pdf").

[edit] Installation

Create a new file called "extensions/vuzit.php" in your MediaWiki installation directory and populate it with the following:

<?php
$wgExtensionFunctions[] = 'wfVuzit';
$wgHooks['LanguageGetMagic'][] = 'wfVuzitParserFunctionMagic';
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'vuzit',
        'version' => 0.4,
        'description' => 'Display Documents using [http://www.vuzit.com/ vuzit]',
        'author' => '[http://www.sultanik.com Evan Sultanik]',
        'url' => 'http://www.sultanik.com/vuzit_MediaWiki_extension'
);
 
function wfVuzit() {
        global $wgParser;
        $wgParser->setHook('vuzit', 'renderVuzit');
        $wgParser->setFunctionHook('vuzit', 'wfVuzitRender');
}
 
function wfVuzitRender(&$parser, $file = '') {
        return $parser->insertStripItem(renderVuzit($file, array()), $parser->mStripState);
}
 
function wfVuzitParserFunctionMagic( &$magicWords, $langCode ) {
        $magicWords['vuzit'] = array( 0, 'vuzit' );
        return true;
}
 
# The callback function for converting the input text to HTML output
function renderVuzit($input, $args) {
        global $wgVuzitKey;
        $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 type="text/html" width="'.$width.'px" height="'.$height.'px" src="http://vuzit.com/view/?url='.$input.'&output=embed&z=0&key='.$wgVuzitKey.'" frameborder="0" ></iframe>';
 
        return $output;
}
?>

Then, in your "LocalSettings.php" file, add:

require_once("$IP/extensions/vuzit.php");
$wgVuzitKey = 'XXXX';

Where 'XXXX' should be replaced with your vuzit developer key (acquired from here).

[edit] Acknowledgments

This plugin was adapted from Kasper Souren's Google Calendar extension.