Extension:ModalBox
From MediaWiki.org
|
Release status: stable |
|
|---|---|
| Implementation | Parser function, Skin |
| Description | Creates a Grey, Drop Down Modal Box |
| Author(s) | Oliver Baker (ocbakerTalk) |
| Last Version | 2.00 (29 April 2009) |
| MediaWiki | works on 1.14 |
| License | MIT |
| Download | Get Latest Version Here |
|
check usage (experimental) |
|
Contents |
[edit] What does it do?
It creates a Grey dropdown box on the page, Dimming out the rest of the page to display the ModalBox.
[edit] Version Information
[edit] Version 1 - OBSOLETE
This can use ALL HTML
I have not fully figured out how to disable use of the extension on unprotected or partially-protected pages (except when being imported from a protected template)
[edit] Version 2
This version parses ALL user inputs through Mediawiki, only HTML mediawiki accepts will be included
This is currently the default release.
Unfortunately all the bugs have not been removed, and the Link text is always created on a new line.
[edit] How to use
Add the following line below to the bottom of LocalSettings.php
require_once( "$IP/extensions/modalbox/modalbox.php" );
Copy the ModalBox folder into the extensions folder.
Done.
[edit] Example
{{#modalbox:Title|Content|Link on Article (Can be anything, even the whole article)}}
[edit] Code
The Main PHP file was created by myself. All the files in the Includes folder was created by WildBit That code has been unedited by myself and therefore, do not ask me about it.
Finally,
This extension does not make full use of ModalBox, if you want full usage of modalbox you will have to add it to your own PHP file yourself, I am 50% sure that I will not be including any other functionallity from ModalBox in this extension.
<?php # Don't forget to add require_once( "$IP/extensions/modalbox/modalbox.php" ); $wgExtensionCredits['other'][] = array( 'name' => 'ModalBox', 'version' => '2.00', 'author' => 'Oliver Baker', 'description' => 'Creates an in-built ModalBox which cant be block by popup blockers {{#modalbox:Examples | <nowiki>{{#modalbox:TITLE | MESSAGE | Link Object }}</nowiki> | Example }}', 'url' => 'http://mediawiki.org/wiki/Extension:popup' ); # Define a setup function $wgExtensionFunctions[] = "efModalBoxFunction_Setup"; # Add a hook to initialise the magic word $wgHooks['LanguageGetMagic'][] = 'efModalBoxFunction_Magic'; function efModalBoxFunction_Setup() { global $wgParser; $wgParser->setFunctionHook( 'modalbox', 'efModalBoxFunction_Render' ); addScriptFile('prototype.js'); addScriptFile('scriptaculous.js?load=effects'); addScriptFile('modalbox.js'); addScriptFile('builder.js'); addExtensionStyle('modalbox.css'); } function efModalBoxFunction_Magic( &$magicWords, $langCode ) { $magicWords['modalbox'] = array( 0, 'modalbox' ); return true; } // {{#modalbox:TITLE | MESSAGE | Link Object }} // {{#modalbox:Warning | This was a success | Click Me}} function efModalBoxFunction_Render( &$parser, $title = '', $content = '', $link = '' ) { global $wgOut ; $contentSanitized = Wiki_2_Html($content); $titleSanitized = Wiki_2_Html($title); $linkSanitized = Wiki_2_Html($link); $output = '<a href="#" onclick="Modalbox.show(\''.$contentSanitized.'\', {title: \''.$titleSanitized.'\'}); return false;" alt="">'.$linkSanitized.'</a>'; return array($output, 'noparse' => true, 'isHTML' => true, 'nowiki' => true); } function Wiki_2_Html( $wikiText ) { global $wgTitle, $wgUser; $myParser = new Parser(); $myParserOptions = new ParserOptions(); $myParserOptions->initialiseFromUser($wgUser); $result = $myParser->parse($wikiText, $wgTitle, $myParserOptions); $output = $result->getText(); $output = preg_replace("/[\n\r]/","",$output); $output = eregi_replace("<!--[^>]*-->","",$output); $output = eregi_replace("\"","\\'",$output); return $output; } function addScriptFile( $file ) { global $wgJsMimeType, $wgOut; if( substr( $file, 0, 1 ) == '/' ) { $path = $file; } else { $path = "/wiki/extensions/modalbox/includes/{$file}"; } $wgOut->addScript( Xml::element( 'script', array( 'type' => $wgJsMimeType, 'src' => "$path", ), '', false ) ); } function addExtensionStyle( $url ) { global $wgOut; $linkarr = array( 'rel' => 'stylesheet', 'href' => '/wiki/extensions/modalbox/includes/'.$url, 'type' => 'text/css', 'media' => 'screen' ); array_push( $wgOut->mExtStyles, $linkarr ); } ?>