Fix trail on bolded self-links (bug #938954).
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 23 Apr 2004 20:13:31 +0000 (20:13 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 23 Apr 2004 20:13:31 +0000 (20:13 +0000)
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
includes/Skin.php

index ac119e3..4d42876 100644 (file)
@@ -906,7 +906,8 @@ class Parser
                }
                if( ( $nt->getPrefixedText() == $this->mTitle->getPrefixedText() ) &&
                    ( strpos( $link, "#" ) == FALSE ) ) {
-                       $s .= $prefix . "<strong>" . $text . "</strong>" . $trail;
+                       # Self-links are handled specially; generally de-link and change to bold.
+                       $s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, "", $trail );
                        return $s;
                }
 
index 79b99bb..ee23afe 100644 (file)
@@ -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 "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
+       }
 
        function fnamePart( $url )
        {