Extension:SuperGallery

From Organic Design wiki
Revision as of 20:42, 28 November 2008 by Jack (talk | contribs) (Template code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<?php

  1. Extension:SuperGallery
Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.

Template:PhpCategory:Extensions created with Template:SpecialPage

  1. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  2. - 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";

  1. 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>' ); }

}

  1. 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()); }