Extension:Embed Document

Purpose
Will show a document like *.pdf, *.doc, *.wav embedded inside a MediaWiki page.

"Here is my sugestion on dealing with pdf files and an answer from a coleague:

-- MarcioCarneiro? - 23-10-2007 16:09

Is it possible to develop a plugin to read a pdf file and write a wiki file? I have clients who need to read a pdf file with legal newspaper every day and I am trying to build a legal document management system inside a wiki engine.

About wiki files, could be a native xml database the management of wiki files such as sedna, eXist or xindice? "

And here is the answer:

"Hi Marcio!

Altough you will need some engineering efforts, yes, it's possible (and after, you can publish your own piece of software, better if free software!). Such flux can be stated as:

PDF -> PDF filter -> Wiki format converter -> Input

Well, the PDF block is your newspaper (um Diário Oficial da União, I think),

The PDF can be parsed/manipulated via Perl, for instance (look at http://search.cpan.org/~antro/PDF-111/PDF.pm). That's your filter block.

The Wiki format converter can even be part of the lst module, embedded into the same perl (convertin keywords/tags into wiki tags).

And the insert can be made also via Perl using DBI.

-- MauricioMauad - 23 Oct 2007"

Usage
/my/path/myfilename.pdf

Note: The path has to be in your Wiki's root-dir

Installation

 * 1) Copy the code into
 * 2) add a line in

Parameters
none

Changes to LocalSettings.php
require_once("$IP/extensions/embed_document.php");

Code
setHook( "embed_document", "embed_document_handler" ); }

function embed_document_handler( $input, $argv ) {   $allowedchars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',                          'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',                          'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',                          'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',                          '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',                          '_', '/', '.');

if( str_replace($allowedchars, , $input) ==  ) {      return " "; }   else {      return "Error: invalid character sequence between   markers, allowed are onlya...zA...Z_/.</ul> "; } } ?>