Difference between revisions of "Extension:EmailToWiki"

From Organic Design wiki
(remove www from domain portion of address in {{EMAILTOWIKI}})
m (Nad moved page Extension:EmailToWiki.php to Extension:EmailToWiki without leaving a redirect)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<?php
+
{{svn|extensions|MediaWiki/EmailToWiki/}}
# Extension:EmailToWiki{{Category:Extensions}}{{php}}{{Category:Extensions created with Template:Extension}}
 
# - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
 
# - Author:  [http://www.organicdesign.co.nz/nad User:Nad]
 
# - Started: 2007-05-25
 
# - See http://www.mediawiki.org/wiki/Extension:EmailToWiki for installation and usage details
 
  
# NOTE: This script just adds the version and extension information to Special:version,
+
{{info|The information page for this extension is at [[MW:Extension:EmailToWiki]]}}
#      the actual work is done by EmailToWiki.pl which should be run from the crontab
 
  
if (!defined('MEDIAWIKI')) die('Not an entry point.');
+
[[Category:Extensions|EmailToWiki]]
 
 
define('EMAILTOWIKI_VERSION','1.0.1, 2007-06-15');
 
 
 
$wgExtensionCredits['other'][] = array(
 
'name'        => 'EmailToWiki',
 
'author'      => '[http://www.organicdesign.co.nz/nad 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
 
);
 
 
 
# Add a MediaWiki variable to get the page's email address
 
$wgCustomVariables = array('EMAILTOWIKI');
 
 
$wgHooks['MagicWordMagicWords'][]          = 'wfAddCustomVariable';
 
$wgHooks['MagicWordwgVariableIDs'][]       = 'wfAddCustomVariableID';
 
$wgHooks['LanguageGetMagic'][]            = 'wfAddCustomVariableLang';
 
$wgHooks['ParserGetVariableValueSwitch'][] = 'wfGetCustomVariable';
 
 
function wfAddCustomVariable(&$magicWords) {
 
foreach($GLOBALS['wgCustomVariables'] as $var) $magicWords[] = "MAG_$var";
 
return true;
 
}
 
 
function wfAddCustomVariableID(&$variables) {
 
foreach($GLOBALS['wgCustomVariables'] as $var) $variables[] = constant("MAG_$var");
 
return true;
 
}
 
 
function wfAddCustomVariableLang(&$langMagic, $langCode = 0) {
 
foreach($GLOBALS['wgCustomVariables'] as $var) {
 
$magic = "MAG_$var";
 
$langMagic[defined($magic) ? constant($magic) : $magic] = array(0,$var);
 
}
 
return true;
 
}
 
 
function wfGetCustomVariable(&$parser,&$cache,&$index,&$ret) {
 
if ($index == MAG_EMAILTOWIKI) {
 
global $wgTitle,$wgServer;
 
$url = parse_url($wgServer);
 
$ret = $wgTitle->getPrefixedURL();
 
$ret = str_replace(':','&3A',$ret);
 
$ret = ereg_replace('^www.','',$ret);
 
$ret = eregi_replace('%([0-9a-z]{2})','&$1',$ret);
 
$ret = "$ret@".$url['host'];
 
$ret = "[mailto:$ret $ret]";
 
}
 
return true;
 
}
 
?>
 

Latest revision as of 12:46, 30 April 2015

Info.svg This code is in our Git repository here.

Note: If there is no information in this page about this code and it's a MediaWiki extension, there may be something at mediawiki.org.


Info.svg The information page for this extension is at MW:Extension:EmailToWiki