* Rebuild interwiki table using the file on meta and the language list
* Wikimedia specific!
*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
* @file
* @todo document
* @ingroup Maintenance
* @ingroup Wikimedia
*/
-/**
- * @todo document
- * @ingroup Maintenance
- */
-class Site {
- var $suffix, $lateral, $url;
-
- function __construct( $s, $l, $u ) {
- $this->suffix = $s;
- $this->lateral = $l;
- $this->url = $u;
- }
-
- function getURL( $lang ) {
- $xlang = str_replace( '_', '-', $lang );
- return "http://$xlang.{$this->url}/wiki/\$1";
- }
-}
+require_once( dirname( __FILE__ ) . '/Site.php' );
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
class RebuildInterwiki extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Protect or unprotect an article from the command line.";
+ $this->mDescription = "Rebuild the interwiki table using the file on meta and the language list.";
$this->addOption( 'langlist', 'File with one language code per line', false, true );
$this->addOption( 'dblist', 'File with one db per line', false, true );
$this->addOption( 'd', 'Output folder', false, true );
# List of all database names
$this->dblist = array_map( "trim", file( $this->getOption( 'dblist', "/home/wikipedia/common/all.dblist" ) ) );
+ # Special-case databases
+ //$this->specials = array_flip( array_map( "trim", file( $this->getOption( 'specialdbs', "/home/wikipedia/common/special.dblist" ) ) ) );
+
$this->makeInterwikiSQL( $this->getOption( 'd', '/home/wikipedia/conf/interwiki/sql' ) );
}
);
# Special-case hostnames
- $specials = array(
+ $this->specials = array(
'sourceswiki' => 'sources.wikipedia.org',
'quotewiki' => 'wikiquote.org',
'textbookwiki' => 'wikibooks.org',
$lines = array_map( 'trim', explode( "\n", trim( $intermap ) ) );
if ( !$lines || count( $lines ) < 2 ) {
- wfDie( "m:Interwiki_map not found" );
+ $this->error( "m:Interwiki_map not found", true );
}
$iwArray = array();
foreach ( $this->dblist as $db ) {
$sql = "-- Generated by rebuildInterwiki.php";
- if ( isset( $specials[$db] ) ) {
+ if ( isset( $this->specials[$db] ) ) {
# Special wiki
# Has interwiki links and interlanguage links to wikipedia
- $host = $specials[$db];
+ $host = $this->specials[$db];
$sql .= "\n--$host\n\n";
$sql .= "USE $db;\n" .
"TRUNCATE TABLE interwiki;\n" .
}
$maintClass = "RebuildInterwiki";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );