Extension:SuperGallery
<?php
- Extension:SuperGallery
Template:PhpCategory:Extensions created with Template:SpecialPage
- - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
- - Author: User:Jack
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('SUPERGALLERY_VERSION','1.0.0, 2008-11-28');
$wgExtensionFunctions[] = 'wfSetupSuperGallery';
$wgExtensionCredits['specialpage'][] = array( 'name' => 'Special:SuperGallery', 'author' => 'User:Jack', 'description' => 'An example special-page made with Template:SpecialPage.', 'url' => 'http://www.organicdesign.co.nz/Extension:SuperGallery', 'version' => SUPERGALLERY_VERSION );
require_once "$IP/includes/SpecialPage.php";
- Define a new class based on the SpecialPage class
class SpecialSuperGallery extends SpecialPage {
# Constructor function __construct() { SpecialPage::SpecialPage( 'SuperGallery', # 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:SuperGallery/param function execute($param) { global $wgOut; $this->setHeaders(); $title = Title::makeTitle(NS_SPECIAL,'SuperGallery'); $wgOut->addWikiText(wfMsg('example-message','exampleParameter')); $wgOut->addHTML( wfElement('form',array('action' => $title->getLocalURL('action=submit'),'method' => 'post'),null) . '<textarea name="target" cols=25 rows=10></textarea>' . wfElement('input',array('type' => 'submit')) . '</form>' ); }
}
- Called from $wgExtensionFunctions array when initialising extensions
function wfSetupSuperGallery() { global $wgLanguageCode,$wgMessageCache;
# Add the messages used by the specialpage if ($wgLanguageCode == 'en') { $wgMessageCache->addMessages(array( 'supergallery' => 'Example Specialpage', # The friendly page title 'exampleMessage' => "Example message: $1", )); }
# Add the specialpage to the environment SpecialPage::addPage(new SpecialSuperGallery()); }