From a3e315593661ca75e60fa71761c96ff05747a823 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 29 Jul 2004 04:48:42 +0000 Subject: [PATCH] Fix fragments on interwiki links and in-wiki links with case sensitive option on. * [ 991569 ] Interwiki Links to Sections Do Not Work --- includes/Parser.php | 2 +- includes/Title.php | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 01b4a78771..ebccf2ce05 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1151,7 +1151,7 @@ class Parser $iw = $nt->getInterWiki(); if( $noforce ) { if( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgLang->getLanguageName( $iw ) ) { - array_push( $this->mOutput->mLanguageLinks, $nt->getPrefixedText() ); + array_push( $this->mOutput->mLanguageLinks, $nt->getFullText() ); $tmp = $prefix . $trail ; $s .= (trim($tmp) == '')? '': $tmp; continue; diff --git a/includes/Title.php b/includes/Title.php index b2f39bc864..961bdb8424 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -344,6 +344,15 @@ class Title { } return $this->mPrefixedText; } + + # As getPrefixedText(), plus fragment. + function getFullText() { + $text = $this->getPrefixedText(); + if( '' != $this->mFragment ) { + $text .= '#' . $this->mFragment; + } + return $text; + } # Get a URL-encoded title (not an actual URL) including interwiki function getPrefixedURL() @@ -370,13 +379,19 @@ class Title { if ( "" == $this->mInterwiki ) { $p = $wgArticlePath; return $wgServer . $this->getLocalUrl( $query ); + } else { + $baseUrl = $this->getInterwikiLink( $this->mInterwiki ); + $namespace = $wgLang->getNsText( $this->mNamespace ); + if ( "" != $namespace ) { + # Can this actually happen? Interwikis shouldn't be parsed. + $namepace .= ":"; + } + $url = str_replace( "$1", $namespace . $this->mUrlform, $baseUrl ); + if ( '' != $this->mFragment ) { + $url .= '#' . $this->mFragment; + } + return $url; } - - $p = $this->getInterwikiLink( $this->mInterwiki ); - $n = $wgLang->getNsText( $this->mNamespace ); - if ( "" != $n ) { $n .= ":"; } - $u = str_replace( "$1", $n . $this->mUrlform, $p ); - return $u; } # Get a URL with an optional query string, no fragment @@ -746,6 +761,8 @@ class Title { # Initial capital letter if( $wgCapitalLinks && $this->mInterwiki == "") { $t = $wgLang->ucfirst( $r ); + } else { + $t = $r; } # Fill fields -- 2.20.1