Fix syntax error
[lhc/web/wiklou.git] / maintenance / dumpInterwiki.inc
index f7a56ee..481e21c 100644 (file)
@@ -3,22 +3,19 @@
  * Rebuild interwiki table using the file on meta and the language list
  * Wikimedia specific!
  *
+ * @file
  * @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @ingroup Maintenance
  */
 
-/** */
-
 /**
  * @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @ingroup Maintenance
  */
 class Site {
        var $suffix, $lateral, $url;
 
-       function Site( $s, $l, $u ) {
+       function __construct( $s, $l, $u ) {
                $this->suffix = $s;
                $this->lateral = $l;
                $this->url = $u;
@@ -31,7 +28,7 @@ class Site {
 }
 
 function getRebuildInterwikiDump() {
-       global $langlist, $languageAliases, $prefixRewrites, $wgDBname;
+       global $langlist, $languageAliases, $prefixRewrites;
 
        # Multi-language sites
        # db suffix => db suffix, iw prefix, hostname
@@ -52,15 +49,10 @@ function getRebuildInterwikiDump() {
        # List of all database names
        $dblist = array_map( "trim", file( "/home/wikipedia/common/all.dblist" ) );
 
-       # Special-case hostnames
-       $specials = array(
-               'sourceswiki' => 'sources.wikipedia.org',
-               'quotewiki' => 'wikiquote.org',
-               'textbookwiki' => 'wikibooks.org',
-               'sep11wiki' => 'sep11.wikipedia.org',
-               'metawiki' => 'meta.wikimedia.org',
-               'commonswiki' => 'commons.wikimedia.org',
-       );
+       # Special-case databases
+       $specials = array_flip(
+               array_map( "trim",
+                       file( "/home/wikipedia/common/special.dblist" ) ) );
 
        # Extra interwiki links that can't be in the intermap for some reason
        $extraLinks = array(
@@ -99,15 +91,14 @@ function getRebuildInterwikiDump() {
        }
 
        # Extract the intermap from meta
-       $intermap = wfGetHTTP( 'http://meta.wikimedia.org/w/index.php?title=Interwiki_map&action=raw', 30 );
+       $intermap = Http::get( 'http://meta.wikimedia.org/w/index.php?title=Interwiki_map&action=raw', 30 );
        $lines = array_map( 'trim', explode( "\n", trim( $intermap ) ) );
 
        if ( !$lines || count( $lines ) < 2 ) {
                wfDie( "m:Interwiki_map not found" );
        }
 
-       $iwArray = array();
-        # Global iterwiki map
+       # Global iterwiki map
        foreach ( $lines as $line ) {
                if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(.*?)\s*$/', $line, $matches ) ) {
                        $prefix = strtolower( $matches[1] );
@@ -130,7 +121,7 @@ function getRebuildInterwikiDump() {
         
         #Multilanguage sites
         foreach ($sites as $site) 
-            $sql .= makeLanguageLinks ( $site, "_".$site->suffix );
+            makeLanguageLinks ( $site, "_".$site->suffix );
 
 
         foreach ( $dblist as $db ) {
@@ -162,7 +153,6 @@ function getRebuildInterwikiDump() {
                                continue;
                        }
                        $lang = $matches[1];
-                       $host = "$lang." . $site->url;
 
                        # Lateral links
                        foreach ( $sites as $targetSite ) {
@@ -187,7 +177,7 @@ function getRebuildInterwikiDump() {
 
 # ------------------------------------------------------------------------------------------
 
-# Returns part of an INSERT statement, corresponding to all interlanguage links to a particular site
+# Executes part of an INSERT statement, corresponding to all interlanguage links to a particular site
 function makeLanguageLinks( &$site, $source ) {
        global $langlist, $languageAliases;
        # Actual languages with their own databases
@@ -216,5 +206,3 @@ function makeLink( $entry, $source ) {
             print "{$source}:{$entry['iw_prefix']} {$entry['iw_url']} {$entry['iw_local']}\n";
 
     }
-
-?>