Difference between revisions of "Extension:WikiaInfo.php"

From Organic Design wiki
(sortkey)
(move to svn)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<?php
+
{{svn|extensions|WikiaInfo/WikiaInfo.php}}
# Extension:WikiaInfo{{Category:Extensions|WIkiaInfo}}{{php}}{{Category:Extensions created with Template:SpecialPage}}{{Category:OD2}}
 
# - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
 
# - Author: [http://www.organicdesign.co.nz/nad 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'      => '[http://www.organicdesign.co.nz/nad 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=<big><b>Currently installed wikia</b></big>|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 .= "**[[Config:$file/LocalSettings.php|LocalSettings.php]]\n";
 
sort($dlist);
 
foreach ($dlist as $domain) {
 
$wiki = "http://$domain/wiki/index.php?title";
 
$table .= "**[http://$domain $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());
 
}
 
?>
 

Latest revision as of 03:27, 12 September 2009

Info.svg This code is in our Git repository here.

Note: If there is no information in this page about this code and it's a MediaWiki extension, there may be something at mediawiki.org.