Index: branches/wmf/1.18wmf1/maintenance/Site.php |
— | — | @@ -12,8 +12,8 @@ |
13 | 13 | $this->url = $u; |
14 | 14 | } |
15 | 15 | |
16 | | - function getURL( $lang ) { |
| 16 | + function getURL( $lang, $urlprotocol ) { |
17 | 17 | $xlang = str_replace( '_', '-', $lang ); |
18 | | - return "http://$xlang.{$this->url}/wiki/\$1"; |
| 18 | + return "$urlprotocol//$xlang.{$this->url}/wiki/\$1"; |
19 | 19 | } |
20 | | -} |
\ No newline at end of file |
| 20 | +} |
Index: branches/wmf/1.18wmf1/maintenance/dumpInterwiki.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | $this->addOption( 'dblist', 'File with one db per line', false, true ); |
39 | 39 | $this->addOption( 'specialdbs', "File with one 'special' db per line", false, true ); |
40 | 40 | $this->addOption( 'o', 'Cdb output file', false, true ); |
| 41 | + $this->addOption( 'protocolrelative', 'Output wikimedia interwiki urls as protocol relative', false, false ); |
41 | 42 | } |
42 | 43 | |
43 | 44 | function execute() { |
— | — | @@ -55,6 +56,12 @@ |
56 | 57 | $this->dbFile = false; |
57 | 58 | } |
58 | 59 | |
| 60 | + if ( $this->hasOption( 'protocolrelative' ) ) { |
| 61 | + $this->urlprotocol = ''; |
| 62 | + } else { |
| 63 | + $this->urlprotocol = 'http:'; |
| 64 | + } |
| 65 | + |
59 | 66 | $this->getRebuildInterwikiDump(); |
60 | 67 | } |
61 | 68 | |
— | — | @@ -76,9 +83,9 @@ |
77 | 84 | |
78 | 85 | # Extra interwiki links that can't be in the intermap for some reason |
79 | 86 | $extraLinks = array( |
80 | | - array( 'm', 'http://meta.wikimedia.org/wiki/$1', 1 ), |
81 | | - array( 'meta', 'http://meta.wikimedia.org/wiki/$1', 1 ), |
82 | | - array( 'sep11', 'http://sep11.wikipedia.org/wiki/$1', 1 ), |
| 87 | + array( 'm', $this->urlprotocol . '//meta.wikimedia.org/wiki/$1', 1 ), |
| 88 | + array( 'meta', $this->urlprotocol . '//meta.wikimedia.org/wiki/$1', 1 ), |
| 89 | + array( 'sep11', $this->urlprotocol . '//sep11.wikipedia.org/wiki/$1', 1 ), |
83 | 90 | ); |
84 | 91 | |
85 | 92 | # Language aliases, usually configured as redirects to the real wiki in apache |
— | — | @@ -126,6 +133,13 @@ |
127 | 134 | |
128 | 135 | $url = $matches[2]; |
129 | 136 | if ( preg_match( '/(wikipedia|wiktionary|wikisource|wikiquote|wikibooks|wikimedia)\.org/', $url ) ) { |
| 137 | + if ( $this->hasOption( 'protocolrelative' ) ) { |
| 138 | + if ( substr( $url, 0, 5 ) == 'http:' ) { |
| 139 | + $url = substr( $url, 5 ); |
| 140 | + } else if ( substr( $url, 0, 6 ) == 'https:' ) { |
| 141 | + $url = substr( $url, 6 ); |
| 142 | + } |
| 143 | + } |
130 | 144 | $local = 1; |
131 | 145 | } else { |
132 | 146 | $local = 0; |
— | — | @@ -155,7 +169,7 @@ |
156 | 170 | # Links to multilanguage sites |
157 | 171 | foreach ( $sites as $targetSite ) { |
158 | 172 | $this->makeLink( array( 'iw_prefix' => $targetSite->lateral, |
159 | | - 'iw_url' => $targetSite->getURL( 'en' ), |
| 173 | + 'iw_url' => $targetSite->getURL( 'en', $this->urlprotocol ), |
160 | 174 | 'iw_local' => 1 ), $db ); |
161 | 175 | } |
162 | 176 | } else { |
— | — | @@ -179,14 +193,14 @@ |
180 | 194 | foreach ( $sites as $targetSite ) { |
181 | 195 | if ( $targetSite->suffix != $site->suffix ) { |
182 | 196 | $this->makeLink( array( 'iw_prefix' => $targetSite->lateral, |
183 | | - 'iw_url' => $targetSite->getURL( $lang ), |
| 197 | + 'iw_url' => $targetSite->getURL( $lang, $this->urlprotocol ), |
184 | 198 | 'iw_local' => 1 ), $db ); |
185 | 199 | } |
186 | 200 | } |
187 | 201 | |
188 | 202 | if ( $site->suffix == "wiki" ) { |
189 | 203 | $this->makeLink( array( 'iw_prefix' => 'w', |
190 | | - 'iw_url' => "http://en.wikipedia.org/wiki/$1", |
| 204 | + 'iw_url' => $this->urlprotocol . "//en.wikipedia.org/wiki/$1", |
191 | 205 | 'iw_local' => 1 ), $db ); |
192 | 206 | } |
193 | 207 | |
— | — | @@ -203,12 +217,12 @@ |
204 | 218 | function makeLanguageLinks( &$site, $source ) { |
205 | 219 | # Actual languages with their own databases |
206 | 220 | foreach ( $this->langlist as $targetLang ) { |
207 | | - $this->makeLink( array( $targetLang, $site->getURL( $targetLang ), 1 ), $source ); |
| 221 | + $this->makeLink( array( $targetLang, $site->getURL( $targetLang, $this->urlprotocol ), 1 ), $source ); |
208 | 222 | } |
209 | 223 | |
210 | 224 | # Language aliases |
211 | 225 | foreach ( $this->languageAliases as $alias => $lang ) { |
212 | | - $this->makeLink( array( $alias, $site->getURL( $lang ), 1 ), $source ); |
| 226 | + $this->makeLink( array( $alias, $site->getURL( $lang, $this->urlprotocol ), 1 ), $source ); |
213 | 227 | } |
214 | 228 | } |
215 | 229 | |