From 95201d803b98e290a346a42d1aa9f4aed645d707 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 23 Apr 2004 20:13:31 +0000 Subject: [PATCH] Fix trail on bolded self-links (bug #938954). Adds Skin::makeSelfLinkObj. These all have some duplicate code for dealing with link trails and the link and could probably be folded together more. --- includes/Parser.php | 3 ++- includes/Skin.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/includes/Parser.php b/includes/Parser.php index ac119e3d0d..4d42876313 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -906,7 +906,8 @@ class Parser } if( ( $nt->getPrefixedText() == $this->mTitle->getPrefixedText() ) && ( strpos( $link, "#" ) == FALSE ) ) { - $s .= $prefix . "" . $text . "" . $trail; + # Self-links are handled specially; generally de-link and change to bold. + $s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, "", $trail ); return $s; } diff --git a/includes/Skin.php b/includes/Skin.php index 79b99bb84b..ee23afee75 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1514,6 +1514,22 @@ class Skin { } return $s; } + + function makeSelfLinkObj( &$nt, $text = "", $query = "", $trail = "", $prefix = "" ) + { + $u = $nt->escapeLocalURL( $query ); + if ( "" == $text ) { + $text = htmlspecialchars( $nt->getPrefixedText() ); + } + $inside = ""; + if ( "" != $trail ) { + if ( preg_match( $this->linktrail, $trail, $m ) ) { + $inside = $m[1]; + $trail = $m[2]; + } + } + return "{$prefix}{$text}{$inside}{$trail}"; + } function fnamePart( $url ) { -- 2.20.1