summaryrefslogtreecommitdiff
path: root/languages/LanguageConverter.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
committerPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
commitb9b85843572bf283f48285001e276ba7e61b63f6 (patch)
tree4c6f4571552ada9ccfb4030481dcf77308f8b254 /languages/LanguageConverter.php
parentd9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff)
updated to MediaWiki 1.14.0
Diffstat (limited to 'languages/LanguageConverter.php')
-rw-r--r--languages/LanguageConverter.php40
1 files changed, 31 insertions, 9 deletions
diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php
index bbf15971..dd69e826 100644
--- a/languages/LanguageConverter.php
+++ b/languages/LanguageConverter.php
@@ -180,7 +180,8 @@ class LanguageConverter {
$header = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]));
$zh = strstr($header, $pv.'-');
if($zh) {
- $pv = substr($zh,0,5);
+ $ary = split("[,;]",$zh);
+ $pv = $ary[0];
}
}
// don't try to return bad variant
@@ -374,8 +375,10 @@ class LanguageConverter {
* @private
*/
function convertTitle($text){
- // check for __NOTC__ tag
- if( !$this->mDoTitleConvert ) {
+ global $wgDisableTitleConversion, $wgUser;
+
+ // check for global param and __NOTC__ tag
+ if( $wgDisableTitleConversion || !$this->mDoTitleConvert || $wgUser->getOption('noconvertlink') == 1 ) {
$this->mTitleDisplay = $text;
return $text;
}
@@ -389,7 +392,8 @@ class LanguageConverter {
global $wgRequest;
$isredir = $wgRequest->getText( 'redirect', 'yes' );
$action = $wgRequest->getText( 'action' );
- if ( $isredir == 'no' || $action == 'edit' ) {
+ $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
+ if ( $isredir == 'no' || $action == 'edit' || $action == 'submit' || $linkconvert == 'no' ) {
return $text;
} else {
$this->mTitleDisplay = $this->convert($text);
@@ -432,8 +436,9 @@ class LanguageConverter {
if ($isTitle) return $this->convertTitle($text);
$plang = $this->getPreferredVariant();
- $tarray = explode($this->mMarkup['end'], $text);
+ $tarray = StringUtils::explode($this->mMarkup['end'], $text);
$text = '';
+ $lastDelim = false;
foreach($tarray as $txt) {
$marked = explode($this->mMarkup['begin'], $txt, 2);
@@ -449,8 +454,17 @@ class LanguageConverter {
$text .= $crule->getDisplay();
$this->applyManualConv($crule);
+ $lastDelim = false;
+ } else {
+ // Reinsert the }- which wasn't part of anything
+ $text .= $this->mMarkup['end'];
+ $lastDelim = true;
}
}
+ if ( $lastDelim ) {
+ // Remove the last delimiter (wasn't real)
+ $text = substr( $text, 0, -strlen( $this->mMarkup['end'] ) );
+ }
return $text;
}
@@ -466,12 +480,21 @@ class LanguageConverter {
* @return null the input parameters may be modified upon return
* @public
*/
- function findVariantLink( &$link, &$nt ) {
- global $wgDisableLangConversion;
+ function findVariantLink( &$link, &$nt, $forTemplate = false ) {
+ global $wgDisableLangConversion, $wgDisableTitleConversion, $wgRequest, $wgUser;
+ $isredir = $wgRequest->getText( 'redirect', 'yes' );
+ $action = $wgRequest->getText( 'action' );
+ $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
+ $disableLinkConversion = $wgDisableLangConversion || $wgDisableTitleConversion;
$linkBatch = new LinkBatch();
$ns=NS_MAIN;
+ if ( $disableLinkConversion || ( !$forTemplate && ( $isredir == 'no' || $action == 'edit'
+ || $action == 'submit' || $linkconvert == 'no' || $wgUser->getOption('noconvertlink') == 1 ) ) ) {
+ return;
+ }
+
if(is_object($nt))
$ns = $nt->getNamespace();
@@ -497,8 +520,7 @@ class LanguageConverter {
foreach( $titles as $varnt ) {
if( $varnt->getArticleID() > 0 ) {
$nt = $varnt;
- if( !$wgDisableLangConversion )
- $link = $v;
+ $link = $v;
break;
}
}