3 # Make an HTML table showing all the wikis on the site
6 $wgExtensionFunctions[] = "wfSiteMatrix";
8 function wfSiteMatrix() {
9 class SiteMatrixPage
extends SpecialPage
11 function SiteMatrixPage() {
12 SpecialPage
::SpecialPage("SiteMatrix");
15 function execute( $par ) {
16 global $wgRequest, $wgOut, $wgTitle, $wgLocalDatabases;
19 $langlist = array_map( 'trim', file( '/home/wikipedia/common/langlist' ) );
21 $xLanglist = array_flip( $langlist );
23 $sites = array( 'wiki', 'wiktionary', 'wikibooks', 'wikiquote' );
25 'wiki' => 'Wikipedia<br />w',
26 'wiktionary' => 'Wiktionary<br />wikt',
27 'wikibooks' => 'Wikibooks<br />b',
28 'wikiquote' => 'Wikiquote<br />q'
31 'wiki' => 'wikipedia.org',
32 'wiktionary' => 'wiktionary.org',
33 'wikibooks' => 'wikibooks.org',
34 'wikiquote' => 'wikiquote.org'
40 foreach( $wgLocalDatabases as $db ) {
42 foreach ( $sites as $site ) {
43 if ( preg_match( "/(.*)$site\$/", $db, $m ) ) {
45 if ( empty( $xLanglist[$lang] ) && $site == 'wiki' ) {
48 $matrix[$site][$lang] = 1;
59 foreach ( $names as $name ) {
60 $s .= "<td><strong>$name</strong></td>";
65 foreach ( $langlist as $lang ) {
67 foreach ( $names as $site => $name ) {
68 $url = "http://$lang." . $hosts[$site] . "/";
69 if ( empty( $matrix[$site][$lang] ) ) {
71 $s .= "<td><a href=\"$url\" class=\"new\">$lang</a></td>";
74 $s .= "<td><a href=\"$url\">$lang</a></td>";
83 foreach ( $specials as $lang ) {
84 $s .= "<li><a href=\"http://$lang.wikipedia.org/\">$lang</a></li>\n";
87 $wgOut->addHTML( $s );
91 SpecialPage
::addPage( new SiteMatrixPage
);
92 global $wgMessageCache;
93 $wgMessageCache->addMessage( "sitematrix", "List of Wikimedia wikis" );
95 } # End of extension function