* Wikimedia specific!
*
* @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
*/
/** */
/**
* @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
*/
class Site {
var $suffix, $lateral, $url;
}
function getRebuildInterwikiSQL() {
- global $langlist, $languageAliases, $prefixRewrites, $wgDBname;
+ global $langlist, $languageAliases, $prefixRewrites;
# Multi-language sites
# db suffix => db suffix, iw prefix, hostname
# List of all database names
$dblist = array_map( "trim", file( "/home/wikipedia/common/all.dblist" ) );
-
+
# Special-case hostnames
$specials = array(
'sourceswiki' => 'sources.wikipedia.org',
'sep11wiki' => 'sep11.wikipedia.org',
'metawiki' => 'meta.wikimedia.org',
'commonswiki' => 'commons.wikimedia.org',
+ 'specieswiki' => 'species.wikimedia.org',
);
# Extra interwiki links that can't be in the intermap for some reason
$lines = array_map( 'trim', explode( "\n", trim( $intermap ) ) );
if ( !$lines || count( $lines ) < 2 ) {
- die( "m:Interwiki_map not found" );
+ wfDie( "m:Interwiki_map not found" );
}
$iwArray = array();
foreach ( $lines as $line ) {
- if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(.*?)\s*$/', $line, $matches ) ) {
+ $matches = array();
+ if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(https?:\/\/.*?)\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;
}
-
+
if ( empty( $reserved[$prefix] ) ) {
$iwArray[$prefix] = array( "iw_prefix" => $prefix, "iw_url" => $url, "iw_local" => $local );
}
}
}
-
+
$sql = "-- Generated by rebuildInterwiki.php";
if ( isset( $specials[$db] ) ) {
# Special wiki
# Has interwiki links and interlanguage links to wikipedia
-
+
$host = $specials[$db];
$sql .= "\n--$host\n\n";
$sql .= "USE $db;\n" .
"TRUNCATE TABLE interwiki;\n" .
"INSERT INTO interwiki (iw_prefix, iw_url, iw_local) VALUES \n";
$first = true;
-
+
# Intermap links
foreach ( $iwArray as $iwEntry ) {
$sql .= makeLink( $iwEntry, $first, $db );
foreach ( $sites as $targetSite ) {
$sql .= makeLink( array( $targetSite->lateral, $targetSite->getURL( 'en' ), 1 ), $first, $db );
}
-
+
# Interlanguage links to wikipedia
$sql .= makeLanguageLinks( $sites['wiki'], $first, $db );
foreach ( $extraLinks as $link ) {
$sql .= makeLink( $link, $first, $db );
}
-
+
$sql .= ";\n";
} else {
# Find out which site this DB belongs to
$lang = $matches[1];
$host = "$lang." . $site->url;
$sql .= "\n--$host\n\n";
-
+
$sql .= "USE $db;\n" .
"TRUNCATE TABLE interwiki;\n" .
"INSERT INTO interwiki (iw_prefix,iw_url,iw_local) VALUES\n";
if ( $site->suffix == "wiki" ) {
$sql .= makeLink( array("w", "http://en.wikipedia.org/wiki/$1", 1), $first, $db );
}
-
+
# Extra links
foreach ( $extraLinks as $link ){
$sql .= makeLink( $link, $first, $db );
} else {
$sql .= ",\n";
}
- $dbr =& wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
$sql .= "(" . $dbr->makeList( $entry ) . ")";
return $sql;
}