Use Linker::link() in a couple more places, since I want to break lots more bits...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 1 Aug 2008 01:37:07 +0000 (01:37 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 1 Aug 2008 01:37:07 +0000 (01:37 +0000)
includes/Linker.php
includes/Skin.php

index ef1a49b..afeabf1 100644 (file)
@@ -147,7 +147,8 @@ class Linker {
         *   change to support Images, literal URLs, etc.
         * @param $text          string The HTML contents of the <a> element, i.e.,
         *   the link text.  This is raw HTML and will not be escaped.  If null,
-        *   defaults to the page name of the Title.
+        *   defaults to the prefixed text of the Title; or if the Title is just a
+        *   fragment, the contents of the fragment.
         * @param $query         array  The query string to append to the URL
         *   you're linking to, in key => value array form.  Query keys and values
         *   will be URL-encoded.
index 5fcaf68..58a4881 100644 (file)
@@ -655,7 +655,7 @@ END;
 
                        $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
                        $s .= '<div id="mw-normal-catlinks">' .
-                               $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
+                               $this->link( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
                                . $colon . $t . '</div>';
                }
 
@@ -710,8 +710,8 @@ END;
                                $return .= Skin::drawCategoryBrowser($parent, $skin) . ' &gt; ';
                        }
                        # add our current element to the list
-                       $eltitle = Title::NewFromText($element);
-                       $return .=  $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
+                       $eltitle = Title::newFromText($element);
+                       $return .=  $skin->link( $eltitle, $eltitle->getText() ) ;
                }
                return $return;
        }
@@ -926,50 +926,54 @@ END;
        function nameAndLogin() {
                global $wgUser, $wgTitle, $wgLang, $wgContLang;
 
-               $lo = $wgContLang->specialPage( 'Userlogout' );
+               $logoutPage = $wgContLang->specialPage( 'Userlogout' );
 
-               $s = '';
+               $ret = '';
                if ( $wgUser->isAnon() ) {
                        if( $this->showIPinHeader() ) {
-                               $n = wfGetIP();
+                               $name = wfGetIP();
 
-                               $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
-                                 $wgLang->getNsText( NS_TALK ) );
+                               $talkLink = $this->link( $wgUser->getTalkPage(),
+                                       $wgLang->getNsText( NS_TALK ) );
 
-                               $s .= $n . ' ('.$tl.')';
+                               $ret .= "$name ($talkLink)";
                        } else {
-                               $s .= wfMsg('notloggedin');
+                               $ret .= wfMsg( 'notloggedin' );
                        }
 
-                       $rt = $wgTitle->getPrefixedURL();
-                       if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
-                               $q = '';
-                       } else { $q = "returnto={$rt}"; }
+                       $returnTo = $wgTitle->getPrefixedDBkey();
+                       $query = array();
+                       if ( $logoutPage != $returnTo ) {
+                               $query['returnto'] = $returnTo;
+                       }
 
                        $loginlink = $wgUser->isAllowed( 'createaccount' )
                                ? 'nav-login-createaccount'
                                : 'login';
-                       $s .= "\n<br />" . $this->makeKnownLinkObj(
+                       $ret .= "\n<br />" . $this->link(
                                SpecialPage::getTitleFor( 'Userlogin' ),
-                               wfMsg( $loginlink ), $q );
+                               wfMsg( $loginlink ), array(), $query
+                       );
                } else {
-                       $n = $wgUser->getName();
-                       $rt = $wgTitle->getPrefixedURL();
-                       $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
-                         $wgLang->getNsText( NS_TALK ) );
-
-                       $tl = " ({$tl})";
-
-                       $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
-                         $n ) . "{$tl}<br />" .
-                         $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
-                         "returnto={$rt}" ) . ' | ' .
-                         $this->specialLink( 'preferences' );
+                       $returnTo = $wgTitle->getPrefixedDBkey();
+                       $talkLink = $this->link( $wgUser->getTalkPage(),
+                               $wgLang->getNsText( NS_TALK ) );
+
+                       $ret .= $this->link( $wgUser->getUserPage(),
+                               htmlspecialchars( $wgUser->getName() ) );
+                       $ret .= " ($talkLink)<br />";
+                       $ret .= $this->link(
+                               SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
+                               array(), array( 'returnto' => $returnTo )
+                       );
+                       $ret .= ' | ' . $this->specialLink( 'preferences' );
                }
-               $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
-                 wfMsg( 'help' ) );
+               $ret .= ' | ' . $this->link(
+                       Title::newFromText( wfMsgForContent( 'helppage' ) ),
+                       wfMsg( 'help' )
+               );
 
-               return $s;
+               return $ret;
        }
 
        function getSearchLink() {