User:Mutante/Interwiki
This will allow users to use an <interwiki>Something</interwiki> tag, which will produce a table with all links from the 'interwiki' mysql table with the attached Something as query string. A contribution to wikilandia networking.
<?php # Interwiki Mediawiki extension # display interwiki links using an <interwiki> tag. # reads from interwiki mysqltable and adds the # word in the interwiki tag to all URLs as query string # by mutante 24.04.2005 $wgExtensionFunctions[] = "wfInterwikiExtension"; function wfInterwikiExtension() { global $wgParser; $wgParser->setHook( "interwiki", "renderInterwiki" ); } function renderInterwiki( $input ) { $input = mysql_escape_string($input); $count=0; $hd = mysql_connect("localhost", "wikiuser", "password") or die ("Unable to connect"); mysql_select_db ("wikidb", $hd) or die ("Unable to select database"); $res = mysql_query("SELECT * from interwiki", $hd) or die ("Unable to run query"); $output="<table border='1'><tr><th colspan='2'>Interwiki-Links for '$input'</th></tr>"; while ($row = mysql_fetch_assoc($res)) { $prefix = $row["iw_prefix"]; $url = $row["iw_url"]; $url = substr($url, 0, -2); $uurl = $url . $input; $output.="<tr><td><a href=\"$uurl\">$prefix:$input</a></td></tr>"; $count++; } $output.="<tr><td>S23-Automatic Interwiki-Link Generator - $count links generated.</td></tr></table>"; return $output; } ?>
</nowiki>