Extension:WikiaInfo.php
<?php
- Extension:WikiaInfo
Template:PhpCategory:Extensions created with Template:SpecialPage
- - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
- - Author: User:Nad
- - Started: 2007-08-27
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('WIKIAINFO_VERSION','1.0.6, 2008-03-11');
$wgExtensionFunctions[] = 'wfSetupWikiaInfo';
$wgExtensionCredits['specialpage'][] = array( 'name' => 'Special:WikiaInfo', 'author' => 'User:Nad', 'description' => 'List the currently running wikia and the domains pointing to them', 'url' => 'http://www.organicdesign.co.nz/Extension:WikiaInfo.php', 'version' => WIKIAINFO_VERSION );
require_once "$IP/includes/SpecialPage.php";
- Define a new class based on the SpecialPage class
class SpecialWikiaInfo extends SpecialPage {
# Constructor function SpecialWikiaInfo() { SpecialPage::SpecialPage('WikiaInfo','sysop',true,false,false,false); }
# Override SpecialPage::execute() function execute() { global $wgOut,$domains,$settings; $this->setHeaders(); $wgOut->addWikiText("\n\n");
$codebases = array(); foreach (glob('/var/www/mediawiki-*') as $codebase) { $stat = stat($codebase); $codebases[$stat[1]] = basename($codebase); }
# Get list of domain symlinks by inode $dlist = array(); foreach (glob("$domains/*") as $link) { $stat = stat($link); $inode = $stat[1]; if (is_array($dlist[$inode])) $dlist[$inode][] = basename($link); else $dlist[$inode] = array(basename($link)); }
# Loop through settings files associating with domains $wikia = array(); foreach (glob("$settings/*") as $file) { $stat = stat($file); $wikia[basename($file)] = $dlist[$stat[1]]; } ksort($wikia);
# Render the list (don't show naked domains if a www also exists) $table = "{"."{#tree:root=Currently installed wikia|id=wikiatree|openlevels=1|\n"; foreach ($wikia as $file => $dlist) if (is_array($dlist)) { $stat = stat("$settings/$file/wiki"); $ver = $codebases[$stat[1]]; $table .= "*$file ($ver)\n"; $table .= "**LocalSettings.php\n"; sort($dlist); foreach ($dlist as $domain) { $wiki = "http://$domain/wiki/index.php?title"; $table .= "**$domain\n"; $table .= "***[$wiki=Special:Recentchanges Recent changes]\n"; $table .= "***[$wiki=Special:Version Version]\n"; $table .= "***[$wiki=Special:Statistics Statistics]\n"; } } $table .= "}"."}\n"; $wgOut->addWikiText($table);
}
}
- Called from $wgExtensionFunctions array when initialising extensions
function wfSetupWikiaInfo() { global $wgLanguageCode,$wgMessageCache; $wgMessageCache->addMessages(array('wikiainfo' => 'Current Wikia Information')); SpecialPage::addPage(new SpecialWikiaInfo()); } ?>