$this->addOption( 'dblist', 'File with one db per line', false, true );
$this->addOption( 'specialdbs', "File with one 'special' db per line", false, true );
$this->addOption( 'o', 'Cdb output file', false, true );
+ $this->addOption( 'protocolrelative', 'Output wikimedia interwiki urls as protocol relative', false, false );
}
function execute() {
$this->dbFile = false;
}
+ if ( $this->hasOption( 'protocolrelative' ) ) {
+ $this->urlprotocol = '';
+ } else {
+ $this->urlprotocol = 'http:';
+ }
+
$this->getRebuildInterwikiDump();
}
# Extra interwiki links that can't be in the intermap for some reason
$extraLinks = array(
- array( 'm', 'http://meta.wikimedia.org/wiki/$1', 1 ),
- array( 'meta', 'http://meta.wikimedia.org/wiki/$1', 1 ),
- array( 'sep11', 'http://sep11.wikipedia.org/wiki/$1', 1 ),
+ array( 'm', $this->urlprotocol . '//meta.wikimedia.org/wiki/$1', 1 ),
+ array( 'meta', $this->urlprotocol . '//meta.wikimedia.org/wiki/$1', 1 ),
+ array( 'sep11', $this->urlprotocol . '//sep11.wikipedia.org/wiki/$1', 1 ),
);
# Language aliases, usually configured as redirects to the real wiki in apache
$url = $matches[2];
if ( preg_match( '/(wikipedia|wiktionary|wikisource|wikiquote|wikibooks|wikimedia)\.org/', $url ) ) {
+ if ( $this->hasOption( 'protocolrelative' ) ) {
+ if ( substr( $url, 0, 5 ) == 'http:' ) {
+ $url = substr( $url, 5 );
+ } else if ( substr( $url, 0, 6 ) == 'https:' ) {
+ $url = substr( $url, 6 );
+ }
+ }
$local = 1;
} else {
$local = 0;
# Links to multilanguage sites
foreach ( $sites as $targetSite ) {
$this->makeLink( array( 'iw_prefix' => $targetSite->lateral,
- 'iw_url' => $targetSite->getURL( 'en' ),
+ 'iw_url' => $targetSite->getURL( 'en', $this->urlprotocol ),
'iw_local' => 1 ), $db );
}
} else {
foreach ( $sites as $targetSite ) {
if ( $targetSite->suffix != $site->suffix ) {
$this->makeLink( array( 'iw_prefix' => $targetSite->lateral,
- 'iw_url' => $targetSite->getURL( $lang ),
+ 'iw_url' => $targetSite->getURL( $lang, $this->urlprotocol ),
'iw_local' => 1 ), $db );
}
}
if ( $site->suffix == "wiki" ) {
$this->makeLink( array( 'iw_prefix' => 'w',
- 'iw_url' => "http://en.wikipedia.org/wiki/$1",
+ 'iw_url' => $this->urlprotocol . "//en.wikipedia.org/wiki/$1",
'iw_local' => 1 ), $db );
}
function makeLanguageLinks( &$site, $source ) {
# Actual languages with their own databases
foreach ( $this->langlist as $targetLang ) {
- $this->makeLink( array( $targetLang, $site->getURL( $targetLang ), 1 ), $source );
+ $this->makeLink( array( $targetLang, $site->getURL( $targetLang, $this->urlprotocol ), 1 ), $source );
}
# Language aliases
foreach ( $this->languageAliases as $alias => $lang ) {
- $this->makeLink( array( $alias, $site->getURL( $lang ), 1 ), $source );
+ $this->makeLink( array( $alias, $site->getURL( $lang, $this->urlprotocol ), 1 ), $source );
}
}