Extension:MiniCity

From Crossroads Wiki
Jump to: navigation, search

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

[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

<?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>');
}

?>
include_once('extensions/minicity.php');

[edit] History

Personal tools
Namespaces
Variants
Actions
Directory
Toolbox