allwiki首页  
天下维客 你可以修改的网络知识库
首页最近更改优秀条目专题展示电脑科技词典软件学习网络知识电脑安全明星时尚天下百科
 

MediaWiki扩展:Email地址检查

天下维客,你可以修改的网络知识库

Jump to: navigation, search

本文取自元维基,欢迎共同翻译、整理与大家共享,促进中文wiki发展^_^

目录

Email Link extension

This extension matches things that look like email addresses, and turns them into links. It was not written because it's a good idea to do this, but because many people did want this feature.

Note that it does NOT match ALL valid email addresses because the author believes that this would match too many non-email things.

The regular expression tries to avoid linking what is already linked, but cannot entirely reliably do so, because it doesn't parse all of the wikitext.

The code

<?php

function addMailLinks(&$parser, &$text, &$strip_state) {
    $mc = "[A-Za-z0-9._+-]";
    $mcs = "[A-Za-z0-9]";
    $text = preg_replace(
        "{(?<![\\[:/])(?<!$mcs)($mcs$mc*@$mcs$mc*\.$mcs{2,})(?!$mc)(?![\\]:/])}",
        '[mailto:$1 $1]',
        $text
    );
} 
$wgHooks['ParserAfterStrip'][] = 'addMailLinks';

?>

Installation

Put the code above in a file called maillink.php in your extensions directory, and add the following line just before the closing ?> of your LocalSettings.php:

require_once('extensions/maillink.php');

Note: you need to make sure that there is no whitespace just before the initial <?php<tt> in <tt>maillink.php.

Bugging the author

The author's website is at http://juerd.nl/, and provides several ways of contacting him.

原文参见: Email Link

Personal tools
工具
金银币拍卖 金币拍卖预展  金银币网店 熊猫金银币 生肖金银币