Difference between revisions of "Extension:EmailToWiki"

From Organic Design wiki
m (removed from wrong bit)
m
Line 24: Line 24:
 
$wgCustomVariables = array('EMAILTOWIKI');
 
$wgCustomVariables = array('EMAILTOWIKI');
 
   
 
   
$wgHooks['MagicWordMagicWords'][]          = 'wfAddCustomVariable';
+
$wgHooks['MagicWordMagicWords'][]          = 'wfETWAddCustomVariable';
$wgHooks['MagicWordwgVariableIDs'][]      = 'wfAddCustomVariableID';
+
$wgHooks['MagicWordwgVariableIDs'][]      = 'wfETWAddCustomVariableID';
$wgHooks['LanguageGetMagic'][]            = 'wfAddCustomVariableLang';
+
$wgHooks['LanguageGetMagic'][]            = 'wfETWAddCustomVariableLang';
$wgHooks['ParserGetVariableValueSwitch'][] = 'wfGetCustomVariable';
+
$wgHooks['ParserGetVariableValueSwitch'][] = 'wfETWGetCustomVariable';
 
   
 
   
function wfAddCustomVariable(&$magicWords) {
+
function wfETWAddCustomVariable(&$magicWords) {
 
foreach($GLOBALS['wgCustomVariables'] as $var) $magicWords[] = "MAG_$var";
 
foreach($GLOBALS['wgCustomVariables'] as $var) $magicWords[] = "MAG_$var";
 
return true;
 
return true;
 
}
 
}
 
   
 
   
function wfAddCustomVariableID(&$variables) {
+
function wfETWAddCustomVariableID(&$variables) {
 
foreach($GLOBALS['wgCustomVariables'] as $var) $variables[] = constant("MAG_$var");
 
foreach($GLOBALS['wgCustomVariables'] as $var) $variables[] = constant("MAG_$var");
 
return true;
 
return true;
 
}
 
}
 
   
 
   
function wfAddCustomVariableLang(&$langMagic, $langCode = 0) {
+
function wfETWAddCustomVariableLang(&$langMagic, $langCode = 0) {
 
foreach($GLOBALS['wgCustomVariables'] as $var) {
 
foreach($GLOBALS['wgCustomVariables'] as $var) {
 
$magic = "MAG_$var";
 
$magic = "MAG_$var";
Line 47: Line 47:
 
}
 
}
 
   
 
   
function wfGetCustomVariable(&$parser,&$cache,&$index,&$ret) {
+
function wfETWGetCustomVariable(&$parser,&$cache,&$index,&$ret) {
 
if ($index == MAG_EMAILTOWIKI) {
 
if ($index == MAG_EMAILTOWIKI) {
 
global $wgTitle,$wgServer;
 
global $wgTitle,$wgServer;

Revision as of 04:05, 15 June 2007

<?php

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

  1. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  2. - Author: User:Nad
  3. - Started: 2007-05-25
  4. - See http://www.mediawiki.org/wiki/Extension:EmailToWiki for installation and usage details
  1. NOTE: This script just adds the version and extension information to Special:version,
  2. the actual work is done by EmailToWiki.pl which should be run from the crontab

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

define('EMAILTOWIKI_VERSION','1.0.1, 2007-06-15');

$wgExtensionCredits['other'][] = array( 'name' => 'EmailToWiki', 'author' => 'User:Nad', 'description' => 'Allows emails to be sent to the wiki and added to an existing or new article', 'url' => 'http://www.mediawiki.org/wiki/Extension:EmailToWiki', 'version' => EMAILTOWIKI_VERSION );

  1. Add a MediaWiki variable to get the page's email address

$wgCustomVariables = array('EMAILTOWIKI');

$wgHooks['MagicWordMagicWords'][] = 'wfETWAddCustomVariable'; $wgHooks['MagicWordwgVariableIDs'][] = 'wfETWAddCustomVariableID'; $wgHooks['LanguageGetMagic'][] = 'wfETWAddCustomVariableLang'; $wgHooks['ParserGetVariableValueSwitch'][] = 'wfETWGetCustomVariable';

function wfETWAddCustomVariable(&$magicWords) { foreach($GLOBALS['wgCustomVariables'] as $var) $magicWords[] = "MAG_$var"; return true; }

function wfETWAddCustomVariableID(&$variables) { foreach($GLOBALS['wgCustomVariables'] as $var) $variables[] = constant("MAG_$var"); return true; }

function wfETWAddCustomVariableLang(&$langMagic, $langCode = 0) { foreach($GLOBALS['wgCustomVariables'] as $var) { $magic = "MAG_$var"; $langMagic[defined($magic) ? constant($magic) : $magic] = array(0,$var); } return true; }

function wfETWGetCustomVariable(&$parser,&$cache,&$index,&$ret) { if ($index == MAG_EMAILTOWIKI) { global $wgTitle,$wgServer; $url = parse_url($wgServer); $host = ereg_replace('^www.',,$url['host']); $ret = $wgTitle->getPrefixedURL(); $ret = str_replace(':','&3A',$ret); $ret = eregi_replace('%([0-9a-z]{2})','&$1',$ret); $ret = "$ret@".$url['host']; $ret = "$ret"; } return true; } ?>