Extension:Docstoc
From MediaWiki.org
|
Release status: experimental |
|
|---|---|
| Implementation | Media |
| Description | Embed a Docstoc Document |
| Author(s) | MorderTalk |
| Last Version | 0.1 (2009/2/23) |
| MediaWiki | 1.5. X |
| License | No license specified |
| Download | Download |
|
check usage (experimental) |
|
Rendering a Docstoc Document within MediaWiki
- syntax
- "
<docstoc docid='1675844' memid='248689'></docstoc>"
Use Extension talk:Docstoc for feedback
[edit] Code
<?php // MediaWiki Docstoc Extension Ver .1 (http://wwww.mediawiki.org/wiki/Extension:Docstoc) //useage //<docstoc docid='1675844' memid='248689' height='300' width='300'></docstoc> //optional: height, width, embed //valid embed types: object, embed (default object) $wgExtensionCredits['parserhook'][] = array( 'name' => 'Docstoc', 'author' => 'Morder', 'url' => 'http://www.mediawiki.org/wiki/Extension:Docstoc', 'description' => 'Renders a Docstoc Document' ); // register the "<docstoc>" tag $wgExtensionFunctions[] = "wfDocstoc"; // register the hook function wfDocstoc() { global $wgParser; $wgParser->setHook("docstoc", "OutputDocstoc"); } // respond to <docstoc> tag function OutputDocstoc($input, $args) { //optional height/width $height = $args['height'] == '' ? '550' : $args['height']; $width = $args['width'] == '' ? '670' : $args['width']; //required $docid = $args['docid']; //required for preview $memid = $args['memid']; //do we have required variables if ($docid == '' || $memid == '') { return 'Invalid docid or memid'; } $embedtype = $args['embed'] == '' ? 'object' : 'embed'; $output = ''; switch ($embedtype) { //output object type embed case 'object': $output .= '<object id="_ds_'.$docid.'" name="_ds_'.$docid.'" width="'.$width.'" height="'.$height; $output .= '" type="application/x-shockwave-flash" data="http://viewer.docstoc.com/">'; $output .= '<param name="FlashVars" value="doc_id='.$docid.'&mem_id='.$memid.'&doc_type=pdf&fullscreen=0" />'; $output .= '<param name="movie" value="http://viewer.docstoc.com/"/>'; $output .= '<param name="allowScriptAccess" value="always" />'; $output .= '<param name="allowFullScreen" value="true" />'; $output .= '</object>'; break; //output embed type embed case 'embed': $output .= '<embed id="_ds_'.$docid.'" name="_ds_'.$docid.'" width="'.$width.'" height="'.$height; $output .= '" type="application/x-shockwave-flash" src="http://viewer.docstoc.com/" + FlashVars="doc_id='.$docid; $output .= '&mem_id='.$memid.'&doc_type=pdf&fullscreen=0" allowScriptAccess="always" allowFullScreen="true"></embed>'; break; //user specified invalid embed type default: $output .= 'Invalid embed type'; } return $output; } ?>
[edit] Installation
- Copy the code into a file (e.g. docstoc.php)
- Save the file in the extensions/docstoc directory of your MediaWiki folder
- Add the line
require_once('extensions/docstoc/docstoc.php');to the end of your LocalSettings.php file
Now you can use the extension with <docstoc docid='1675844' memid='248689'></docstoc> in the wiki