Location: PHPKode > projects > BusinessWiki > extensions/BusinessWikiWidgets/Scribd.php
<?php

$wgExtensionFunctions[] = 'wfScribd';
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'Scribd',
	'description' => 'Display Scribd document'
);
 
function wfScribd() {
	global $wgParser;
	$wgParser->setHook( 'scribd', 'renderScribd' );
}
 
function renderScribd( $input, $params ) {
	$id = $params['id'];
	$key = $params['key'];
	
	$width = !empty( $params['width'] ) ? $params['width'] : 425;
	$height = !empty( $params['height'] ) ? $params['height'] : 500;
 
	if ( preg_match('%[^A-Za-z0-9]%', $id ) ) {
		return 'Scribd : bad document ID !';
	}
 
	if ( preg_match('%[^A-Za-z0-9_\\-]%', $key ) ) {
		return 'Scribd : bad document access key !';
	}
	
	$url = "http://documents.scribd.com/ScribdViewer.swf?document_id={$id}&access_key={$key}";
	
	$output =
		Xml::openElement( 'object',
			array(
				'width' => $width,
				'height' => $height ) ) .
		Xml::openElement( 'param',
			array(
				'name' => 'movie',
				'value' => $url ) ) .
		'</param>' .
		Xml::openElement( 'embed',
			array(
				'src' => $url,
				'type' => 'application/x-shockwave-flash',
				'width' => $width,
				'height' => $height ) ) .
		'</embed>' .
		'</object>';
	
	return $output;
}
Return current item: BusinessWiki