3 # Make an HTML table showing all the wikis on the site
5 # Not a valid entry point, skip unless MEDIAWIKI is defined
6 if (defined('MEDIAWIKI')) {
8 $wgExtensionFunctions[] = "wfSiteMatrix";
10 function wfSiteMatrix() {
12 require_once( "$IP/includes/SpecialPage.php" );
14 class SiteMatrixPage
extends SpecialPage
16 function SiteMatrixPage() {
17 SpecialPage
::SpecialPage("SiteMatrix");
20 function execute( $par ) {
21 global $wgRequest, $wgOut, $wgTitle, $wgLocalDatabases;
24 $langlist = array_map( 'trim', file( '/home/wikipedia/common/langlist' ) );
26 $xLanglist = array_flip( $langlist );
28 $sites = array( 'wiki', 'wiktionary', 'wikibooks', 'wikiquote' );
30 'wiki' => 'Wikipedia<br />w',
31 'wiktionary' => 'Wiktionary<br />wikt',
32 'wikibooks' => 'Wikibooks<br />b',
33 'wikiquote' => 'Wikiquote<br />q'
36 'wiki' => 'wikipedia.org',
37 'wiktionary' => 'wiktionary.org',
38 'wikibooks' => 'wikibooks.org',
39 'wikiquote' => 'wikiquote.org'
45 foreach( $wgLocalDatabases as $db ) {
47 foreach ( $sites as $site ) {
48 if ( preg_match( "/(.*)$site\$/", $db, $m ) ) {
50 if ( empty( $xLanglist[$lang] ) && $site == 'wiki' ) {
53 $matrix[$site][$lang] = 1;
64 foreach ( $names as $name ) {
65 $s .= "<td><strong>$name</strong></td>";
70 foreach ( $langlist as $lang ) {
72 foreach ( $names as $site => $name ) {
73 $url = "http://$lang." . $hosts[$site] . "/";
74 if ( empty( $matrix[$site][$lang] ) ) {
76 $s .= "<td><a href=\"$url\" class=\"new\">$lang</a></td>";
79 $s .= "<td><a href=\"$url\">$lang</a></td>";
88 foreach ( $specials as $lang ) {
89 $s .= "<li><a href=\"http://$lang.wikipedia.org/\">$lang</a></li>\n";
92 $wgOut->addHTML( $s );
96 SpecialPage
::addPage( new SiteMatrixPage
);
97 global $wgMessageCache;
98 $wgMessageCache->addMessage( "sitematrix", "List of Wikimedia wikis" );
100 } # End of extension function
101 } # End of invocation protection