1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| <?php
/**
* MediaWiki Embed Document extension
* * @version 0.1 * @author S.Lohse
* @link http://www.mediawiki.org/wiki/Extension:Embed_Document
*/
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Embed Document',
'author' => 'SLohse, DrTrigon',
'version' => '0.12',
'url' => 'http://www.mediawiki.org/wiki/Extension:Embed_Document',
'description' => 'Allows embedding *.pdf, *.doc and *.wav files on a wiki page',
);
$wgExtensionFunctions[] = 'registerEmbedDocumentHandler';
function registerEmbedDocumentHandler() {
global $wgParser;
$wgParser->setHook( 'embed_document', 'embedDocumentHandler' );
}
function embedDocumentHandler( $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',
'_', '/', '.', '-', ':');
$w = '100%';
$h = '680';
foreach( $argv as $name => $value )
{
if ($name == 'width') $w = $value;
if ($name == 'height') $h = $value;
}
if( str_replace($allowedchars, '', $input) == '' ) { return "<iframe width=" . $w . " height=" . $h . " src=" . htmlspecialchars($input) . " frameborder=0 framebordercolor=#00000></iframe>";
}
else {
return "<font color=#aa0000>Error: invalid character sequence between <code>&lt;embed_document&gt;...&lt;/embed_document&gt;</code> markers, allowed are only<ul><li>a...z</li><li>A...Z</li><li>0...9</li><li>_</li><li>/</li><li>.</li><li>-</li><li>:</li></ul></font>";
}
}
?> |
Partager