Extension:Soundex/Soundex.php

From MediaWiki.org
Jump to navigation Jump to search
<?php
/*
 * Soundex - this extension adds a <soundex></soundex> tag to generate the Soundex code of a word
 *
 * To activate this extension, add the following into your LocalSettings.php file:
 * require_once('$IP/extensions/Soundex.php');
 *
 * @ingroup Extensions
 * @author Kurt Weber <kmw@kurtweber.us>
 * @version 0.1
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 */

/*
 * Protect against register_globals vulnerabilities.
 * This line must be present before any global variable is referenced.
 */
if(!defined('MEDIAWIKI')){
        echo("This is an extension to the MediaWiki package and cannot be run standalone.\n" );
        die(-1);
        }

$wgExtensionCredits['parserhook'][] = array(
        'name'          =>      'Soundex',
        'version'       =>      '0.1',
        'author'        =>      'Kurt Weber',
        'url'           =>      'http://www.mediawiki.org/wiki/Extension:Soundex',
        'description'   =>      'Generates Soundex codes with <soundex></soundex> tags'
        );

$wgExtensionFunctions[] = 'efSoundexSetup';

function efSoundexSetup(){
        global $wgParser;

        $wgParser->setHook("soundex", 'efSoundexRender');
        }

function efSoundexRender($input, $args, $parser){
        return soundex($input);
        }
?>