User:Dantman/GE Extended/Custom Extensions/GENetwork

The GENetwork extension is the core extension for the Networking of the different Wikia in the project. This extension does a number of things, mostly focused around a new set of SQL tables which define a list of GE Worlds and id's which refer to them.

Special:GENetwork is introduced by this extension. This specialpage lists information on all the GE Worlds and also allows new GE Worlds to be added and existing ones to be deleted and edited. As well as the Con ID's for them can be deleted and new ones can be added.
 * This page is being rebuilt from scratch; New things in the remake include: More user friendly interface, the sortable class is part of the table and the tables rely on the WGEP's Box classes so the tables will end up with a nice set of user control (I'm also planning to add proper show/hide classes to it to hide a large table when I find a proper setup which will work), Instead of specifying a interwiki style url, interwiki prefixes are used instead. So to link to the Narutopedia Using Anime:Naruto instead of the old http://naruto.wikia.com/wiki/$1 needing to be specified, w:c:Naruto would be used instead, : is now a Illegal character in prefixes, this is unfortunately because the previous system would half to potentially query over 100 database rows on every page.

World names are striped from the displayed title when using the view or purge action. This means that on FMP/Full Metal Panic! if FMP was specified as a world then that title would display as Full Metal Panic! instead of the normal name (Note that when editing and in other actions, the full title is still used to prevent confusion to editors)

For all worlds defined, the /Tech/Admin page and all of it's subpages are auto-protected in the same manor that MediaWiki namespace messages are protected (Note that the protection tab still shows up because removing the World from the World list will remove the auto-protection, this way things can be protected even if listing is removed). This means that if FMP was defined as a world, then FMP/Tech/Admin/Monobook.css which would be used to create an anime specific style would be auto-protected.

This extension also handles the redirection of links according to the set linking strategy.

Files

 * extensions/GENetwork/GENetwork.php
 * extensions/GENetwork/SpecialGENetwork.php
 * extensions/GENetwork/GEFunctions.php
 * extensions/GENetwork/GERedirect.php

SQL Setup
CREATE TABLE `etGENetworkWorlds` (	`wid` mediumint NOT NULL AUTO_INCREMENT PRIMARY KEY,	`world` varchar(255) NOT NULL,	`prefix` varchar(64) NOT NULL,	`forceslash` BOOL NOT NULL,	`forcecase` tinyint( 1 ) NOT NULL,	UNIQUE(`world`) ) ENGINE = MYISAM ; CREATE TABLE `etGENetworkIDs` (	`nid` mediumint NOT NULL AUTO_INCREMENT PRIMARY KEY,	`wid` mediumint NOT NULL,	`uid` varchar(64) NOT NULL,	UNIQUE(`uid`) ) ENGINE = MYISAM ;

Lines to add to LocalSettings.php
//ConNetwork extension require_once( "$IP/extensions/GENetwork/GENetwork.php" );

Variables to define
$egGEPrefixes is an array containing the prefixes that the networking extension will handle. By default the GE is placed in the array. On the Animepedia Anime sould be place in, Manga for Manga, etc...

Example line: $egGEPrefixes[] = 'Anime';

Extra note
To allow itself to use Anime: as a prefix on the Animepedia, or any other Wiki in the project when located on that wiki itself in counteraction to the code which stops interwiki links from pointing to the local wiki (Anime: can't be used on the Animepedia like we would like it to) the code does a few things: /\[\[({$prefixes}:[\s_]*)\]\]/i
 * Anime is defined as a special namespace (-3) with no parallel talk namespace because it is a special namespace.
 * It inserts a new variable, named something along the lines of $wgKnownNamespaces (I can't remember the name I used when I tested this on my other server) and uses that as an additional method of testing namespaces to see if they are known. And then it includes the special namespace number (-3) into that variable so that edit links to the page never show up.
 * Because the declaration of a namespace causes Anime: without any extra stuff to no longer work as a way to jump to the Main Page when inside the wiki an extra function is defined which runs through the code at a point in the parser before the links are handled but after most other things are handled which replaces:
 * with:

\1
 * Where $prefixes is the (|) set used to match the various valid GEPrefixes (Other than anime it's possible to define other valid prefixes, technically you could define A and then set it up just like Anime and then A:Naruto: would link to the narutopedia just like how Anime:Naruto: would) and $selfLink is the message MediaWiki:SelfLink which defaults to the same as MediaWiki:Mainpage so that it can link to the main page. Of course, since this is Wikia and here we have the w:c: interwiki, it's possible to redefine that on the individual wiki, and have it convert the link to w:c:anime so that it will still look like a interwiki link.