Extension:EmailPage

From Organic Design wiki
Revision as of 22:00, 24 May 2007 by Nad (talk | contribs) (may as well get this one back in the pipeline too)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<?php

  1. Extension:EmailArticle
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.

{{#Security:*|dev}}{{#Security:view|*}}Template:Php

  1. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  2. - Author: User:NadCategory:Extensions created with Template:SpecialPage

if (!defined('MEDIAWIKI')) die('Not an entry point.');

define('EMAILARTICLE_VERSION','0.0.0, 2007-05-25');

$wgExtensionFunctions[] = 'wfSetupEmailArticle';

$wgExtensionCredits['specialpage'][] = array( 'name' => 'Special:EmailArticle', 'author' => 'User:Nad', 'description' => 'Send rendered article to an email address or list of addresses', 'url' => 'http://www.organicdesign.co.nz/Extension:SpecialPage', 'version' => EMAILARTICLE_VERSION );

require_once "$IP/includes/SpecialPage.php";

  1. Define a new class based on the SpecialPage class

class SpecialEmailArticle extends SpecialPage {

# Constructor function SpecialSearchLog() { SpecialPage::SpecialPage( 'EmailArticle', # 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() wfSpecialEmailArticle($param,&$specialpage) { global $wgOut; $title = Title::makeTitle(NS_SPECIAL,'EmailArticle'); $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 wfSetupEmailArticle() { global $wgLanguageCode,$wgMessageCache;

# Add the messages used by the specialpage if ($wgLanguageCode == 'en') { $wgMessageCache->addMessages(array( 'emailarticle' => 'Example Specialpage', # The friendly page title 'exampleMessage' => "Example message: $1", )); }

# Add the specialpage to the environment SpecialPage::addPage(new SpecialEmailArticle()); } ?>