Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -344,31 +344,30 @@ |
345 | 345 | 'lang' => $wgLanguageCode, |
346 | 346 | ); |
347 | 347 | |
348 | | - foreach( $wgOut->getLanguageLinks() as $l ) { |
349 | | - if ( preg_match( '!^(\w[-\w]*\w):(.+)$!', $l, $m ) ) { |
350 | | - $lang = $m[1]; |
351 | | - $linkText = $m[2]; |
352 | | - } else { |
353 | | - continue; //NOTE: shouldn't happen |
354 | | - } |
355 | | - |
| 348 | + foreach( $wgOut->getLanguageLinks() as $l ) { |
| 349 | + $tmp = explode( ':', $l, 2 ); |
| 350 | + $class = 'interwiki-' . $tmp[0]; |
| 351 | + $lang = $tmp[0]; |
| 352 | + unset( $tmp ); |
356 | 353 | $nt = Title::newFromText( $l ); |
357 | | - $parsedUrl = wfParseUrl( $nt->getFullURL() ); |
358 | | - if ( stristr( $parsedUrl['host'], $wgMobileDomain ) === false ) { |
359 | | - $hostParts = explode( '.', $parsedUrl['host'] ); |
360 | | - $parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2]; |
361 | | - } |
362 | | - $fragmentDelimiter = ( !empty( $parsedUrl['fragment'] ) ) ? '#' : ''; |
363 | | - $queryDelimiter = ( !empty( $parsedUrl['query'] ) ) ? '?' : ''; |
364 | | - $languageUrl = $parsedUrl['scheme'] . $parsedUrl['delimiter'] . $parsedUrl['host'] . $parsedUrl['path'] . $queryDelimiter . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment']; |
| 354 | + if ( $nt ) { |
| 355 | + $parsedUrl = wfParseUrl( $nt->getFullURL() ); |
| 356 | + if ( stristr( $parsedUrl['host'], $wgMobileDomain ) === false ) { |
| 357 | + $hostParts = explode( '.', $parsedUrl['host'] ); |
| 358 | + $parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2]; |
| 359 | + } |
| 360 | + $fragmentDelimiter = ( !empty( $parsedUrl['fragment'] ) ) ? '#' : ''; |
| 361 | + $queryDelimiter = ( !empty( $parsedUrl['query'] ) ) ? '?' : ''; |
| 362 | + $languageUrl = $parsedUrl['scheme'] . $parsedUrl['delimiter'] . $parsedUrl['host'] . $parsedUrl['path'] . $queryDelimiter . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment']; |
365 | 363 | |
366 | | - $languageUrls[] = array( |
367 | | - 'href' => $languageUrl, |
368 | | - 'text' => $linkText, |
369 | | - 'language' => $wgContLang->getLanguageName( $lang ), |
370 | | - 'class' => 'interwiki-' . $lang, |
371 | | - 'lang' => $lang, |
372 | | - ); |
| 364 | + $languageUrls[] = array( |
| 365 | + 'href' => $languageUrl, |
| 366 | + 'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ? $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ), |
| 367 | + 'language' => $wgContLang->getLanguageName( $lang ), |
| 368 | + 'class' => $class, |
| 369 | + 'lang' => $lang, |
| 370 | + ); |
| 371 | + } |
373 | 372 | } |
374 | 373 | |
375 | 374 | self::$languageUrls = $languageUrls; |