Extension:MiniCity
From Crossroads Wiki
Contents |
[edit] Purpose
This extension is meant to process the XML data from a myminicity.com site and present information to a user to assist in choosing a link.
[edit] Features
- Will work with any myminicity.com site
[edit] Audience
This extension is meant for wiki authors who have a myminicity.com site.
[edit] Usage
<minicity>http://yoursite.myminicity.com/xml</minicity>
[edit] Examples
See MUSHpark city.
[edit] Dependancy
None.
[edit] Installation
- Copy the below code to extensions/minicity.php
<?php
$wgExtensionFunctions[] = 'registerMiniCity';
$wgExtensionCredits['parserhook'][] = array(
'name' => 'MiniCity',
'version' => '0.31',
'author' =>'Minuet@CrossroadsMUSH',
'url' => 'http://www.crossroadsmush.com/wiki/Extension:MiniCity',
'description' => 'Grabs xml data from myminicity.com'
);
function registerMiniCity() {
global $wgParser;
$wgParser->setHook('minicity', 'renderMiniCity');
}
function renderMiniCity($url) {
$f = fopen($url, 'r');
while (!feof($f)) {
$document = fread($f, 1024);
}
$document = preg_replace('<\?xml version="1\.0" encoding="UTF-8"\?>','',$document);
$document = preg_replace('<city>','',$document);
$document = preg_replace('<\/city>','',$document);
$document = preg_replace("/<host>.*<\/host>/",'',$document);
$document = preg_replace("/<name>.*<\/name>\n/",'',$document);
$document = preg_replace("/<region code\=\".*?\">/",'<region>',$document);
$document = preg_replace("/<nextnuke>.*<\/nextnuke>\n/",'',$document);
$document = preg_replace("/<signatures>.*<\/signatures>\n/",'',$document);
$document = preg_replace("/<(.+?) (.+?)\/>/",'<${1}>${2}</${1}>',$document);
$document = preg_replace("/<(.+?)>(.*?)<\/\\1>/",'<li>${1}: ${2}</li>',$document);
$document = preg_replace("/<>/",'',$document);
return('<ul>' . $document . '</ul>');
}
?>
- Add the following line to LocalSettings.php near the bottom (but before the ?>):
include_once('extensions/minicity.php');
- Note that if you have enabled a cache on your wiki (on by default) then the page might not be updated. To be sure you get current data, include ?action=purge at the end of the URL when calling it.
[edit] History
- 0.3 - 12/19/07 - Initial release
- 0.31 - 12/20/07 - Updated for region code