$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
$isredir = $wgRequest->getText( 'redirect', 'yes' );
$action = $wgRequest->getText( 'action' );
$linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
- if ( $isredir == 'no' || $action == 'edit' || $linkconvert == 'no' ) {
+ if ( $isredir == 'no' || $action == 'edit' || $action == 'submit' || $linkconvert == 'no' ) {
return $text;
} else {
$this->mTitleDisplay = $this->convert($text);
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);
$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;
}
* @return null the input parameters may be modified upon return
* @public
*/
- function findVariantLink( &$link, &$nt ) {
+ function findVariantLink( &$link, &$nt, $forTemplate = false ) {
global $wgDisableLangConversion, $wgDisableTitleConversion, $wgRequest, $wgUser;
$isredir = $wgRequest->getText( 'redirect', 'yes' );
$action = $wgRequest->getText( 'action' );
$ns=NS_MAIN;
- if ( $disableLinkConversion || $isredir == 'no' || $action == 'edit'
- || $linkconvert == 'no' || $wgUser->getOption('noconvertlink') == 1 ) {
+ if ( $disableLinkConversion || ( !$forTemplate && ( $isredir == 'no' || $action == 'edit'
+ || $action == 'submit' || $linkconvert == 'no' || $wgUser->getOption('noconvertlink') == 1 ) ) ) {
return;
}