Extension:WikiScript
From MediaWiki.org
|
Release status: beta |
|
|---|---|
| Implementation | Tag |
| Description | WikiScript allows you to embed a external javascripts src using <script src="..." type="text/javascript"></script> tags, to embed various kinds of inline scripts like Google Gadgets, Google Analytics etc.
Please make sure that the external script you include is something you trust. Use this extension at your own risk. |
| Author(s) | Siddique Hameed, Peter Tandler |
| Last Version | 2.0 (05/21/2009) |
| License | No license specified |
| Download | see below |
|
check usage (experimental) |
|
WikiScript allows you to embed a external javascripts src using
- <script src="..." type="text/javascript"></script>
tags, to embed various kinds of inline scripts like Google Gadgets, Google Analytics etc.
Please make sure that the external script you include is something you trust. Use this extension at your own risk.
Contents |
[edit] php.ini
For the extension to work output buffering must be enabled in php.ini with a line like:
output_buffering = 4096
It maybe necessary to restart HTTPD to activate.
[edit] Example
<wikiscript src="http://gmodules.com/ig/ifr?url=http://www.therandomhomepage.com/google/gadgets/randomwiki/RandomWikiModule.xml &up_moduletitle=&up_language=en&synd=open&w=320&h=350 &title=&lang=en&country=ALL&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"> </wikiscript>
[edit] Source Code
Source code of "extensions/wikiscript.php".
Modification by PTandler: also allow inline javascript and allow to set language and type
<?php # WikiScript extension # Usage: # <wikiscript src="http://gmodules.com/ig/ifr? #url=http://www.therandomhomepage.com/google/gadgets/randomwiki/RandomWikiModule.xml #&up_moduletitle=&up_language=en&synd=open&w=320&h=350&title= #&lang=en&country=ALL&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"> #</wikiscript> # you can now also use the arguments language and type, and also # include embedded scripts -- 2009-05-21-ptandler http://www.teambits.de # <wikiscript language="..." type="..."> #...some script code ... #</wikiscript> # To install it put this file in the extensions directory # To activate the extension, include it from your LocalSettings.php # with: require("extensions/wikiscript.php"); $wgExtensionFunctions[] = "wfWikiScript"; function wfWikiScript() { global $wgParser; # registers the <wikiscript> extension with the WikiText parser $wgParser->setHook( "wikiscript", "renderWikiScript" ); } # The callback function for converting the input text to HTML output function renderWikiScript( $input, $argv ) { $output = '<script '; if( $argv["src"] ) { $output .= 'src="'.$argv["src"].'" '; } if( $argv["language"] ) { $output .= 'language="'.$argv["language"].'" '; } else { $output .= 'language="javascript" '; } $type=$argv["type"]; if( !$type ) { $type = "text/javascript"; } $output .= 'type="'.$type.'" '; $output .= '>'; $output .= $input; $output .= '</script>'; return $output; } ?>