From OrganicDesign Wiki
<?php
# Extension:{{{name}}}{{Category:Extensions}}{{php}}{{Category:Extensions created with Template:SpecialPage}}
# - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
# - Author: {{{author}}}
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('{{{NAME}}}_VERSION','{{{version}}}');
$wgExtensionFunctions[] = 'wfSetup{{{name}}}';
$wgExtensionCredits['specialpage'][] = array(
'name' => 'Special:{{{name}}}',
'author' => 'Unknown',
'description' => '',
'url' => 'http://www.organicdesign.co.nz/Template:Extension',
'version' => {{{NAME}}}_VERSION
);
require_once "$IP/includes/SpecialPage.php";
# Define a new class based on the SpecialPage class
class Special{{{name}}} extends SpecialPage {
# Constructor
function __construct() {
SpecialPage::SpecialPage(
'{{{name}}}', # name as seen in links etc
'sysop', # user rights required
true, # listed in special:specialpages
false, # function called by execute() - defaults to wfSpecial{$name}
false, # file included by execute() - defaults to Special{$name}.php, only used if no function
false # includable
);
}
# Override SpecialPage::execute()
# - $param is from the URL, eg Special:{{{name}}}/param
function execute($param) {
global $wgOut, $wgRequest;
$this->setHeaders();
$title = Title::makeTitle(NS_SPECIAL,'{{{name}}}');
# Extract any posted data
$posted = $wgRequest->getText('wpSubmit', false);
$target = $wgRequest->getText('wpTarget', "Enter some text");
# Render the form with values filled in from any posted values
$wgOut->addWikiText(wfMsg('example-message', 'exampleParameter'));
$wgOut->addHTML(
wfElement('form', array('action' => $title->getLocalURL('action=submit'), 'method' => 'post'), null)
. "<textarea name='wpTarget' cols='25' rows='10'>$target</textarea>"
. wfElement('input', array('name' => 'wpSubmit', 'type' => 'submit'))
. "</form>"
);
# Process results if data posted
if ($posted) {
$wgOut->addWikiText("\n\nResults for '$target'...");
}
}
}
# Called from $wgExtensionFunctions array when initialising extensions
function wfSetup{{{name}}}() {
global $wgLanguageCode, $wgMessageCache;
# Add the messages used by the specialpage
if ($wgLanguageCode == 'en') {
$wgMessageCache->addMessages(array(
'{{{name}}}' => 'Example Specialpage', # The friendly page title
'exampleMessage' => "Example message: <tt>$1</tt>",
));
}
# Add the specialpage to the environment
SpecialPage::addPage(new Special{{{name}}}());
}