Localisation updates for core messages from translatewiki.net (2009-09-03 16:52 UTC)
[lhc/web/wiklou.git] / maintenance / dumpInterwiki.inc
index 5e54bea..c366b08 100644 (file)
@@ -3,22 +3,20 @@
  * Rebuild interwiki table using the file on meta and the language list
  * Wikimedia specific!
  *
+ * @file
  * @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @ingroup Maintenance
+ * @ingroup Wikimedia
  */
 
-/** */
-
 /**
  * @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 +29,7 @@ class Site {
 }
 
 function getRebuildInterwikiDump() {
-       global $langlist, $languageAliases, $prefixRewrites, $wgDBname;
+       global $langlist, $languageAliases, $prefixRewrites;
 
        # Multi-language sites
        # db suffix => db suffix, iw prefix, hostname
@@ -43,6 +41,7 @@ function getRebuildInterwikiDump() {
                'wikinews' => new Site( 'wikinews', 'n', 'wikinews.org' ),
                'wikisource' => new Site( 'wikisource', 's', 'wikisource.org' ),
                'wikimedia' => new Site( 'wikimedia', 'chapter', 'wikimedia.org' ),
+               'wikiversity' => new Site( 'wikiversity', 'v', 'wikiversity.org' ),
        );
 
        # List of language prefixes likely to be found in multi-language sites
@@ -51,15 +50,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(
@@ -98,20 +92,19 @@ 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] );
                        $url = $matches[2];
-                       if ( preg_match( '/(wikipedia|wiktionary|wikisource|wikiquote|wikibooks)\.org/', $url ) ) {
+                       if ( preg_match( '/(wikipedia|wiktionary|wikisource|wikiquote|wikibooks|wikimedia)\.org/', $url ) ) {
                                $local = 1;
                        } else {
                                $local = 0;
@@ -129,7 +122,7 @@ function getRebuildInterwikiDump() {
         
         #Multilanguage sites
         foreach ($sites as $site) 
-            $sql .= makeLanguageLinks ( $site, "_".$site->suffix );
+            makeLanguageLinks ( $site, "_".$site->suffix );
 
 
         foreach ( $dblist as $db ) {
@@ -161,7 +154,6 @@ function getRebuildInterwikiDump() {
                                continue;
                        }
                        $lang = $matches[1];
-                       $host = "$lang." . $site->url;
 
                        # Lateral links
                        foreach ( $sites as $targetSite ) {
@@ -186,7 +178,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
@@ -210,10 +202,8 @@ function makeLink( $entry, $source ) {
                 array_key_exists($entry['iw_prefix'],$prefixRewrites[$source]))
                     $entry['iw_prefix'] = $prefixRewrites[$source][$entry['iw_prefix']];
         if ($dbFile)
-            dba_insert("{$source}:{$entry['iw_prefix']}", trim("{$entry['iw_local']} {$entry['iw_url']}"),$dbFile);
+            $dbFile->set( "{$source}:{$entry['iw_prefix']}", trim("{$entry['iw_local']} {$entry['iw_url']}") );
         else
             print "{$source}:{$entry['iw_prefix']} {$entry['iw_url']} {$entry['iw_local']}\n";
 
     }
-
-?>