From 12f66fd7c2782a5b3d92e4858fe51f73c8301dd3 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 1 Aug 2008 01:37:07 +0000 Subject: [PATCH] Use Linker::link() in a couple more places, since I want to break lots more bits of the site interface. Also clean up Skin::nameAndLogin(), although it's seemingly only used in Standard. --- includes/Linker.php | 3 ++- includes/Skin.php | 66 ++++++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index ef1a49b415..afeabf150c 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -147,7 +147,8 @@ class Linker { * change to support Images, literal URLs, etc. * @param $text string The HTML contents of the 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. diff --git a/includes/Skin.php b/includes/Skin.php index 5fcaf68152..58a4881d6b 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -655,7 +655,7 @@ END; $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) ); $s .= ''; } @@ -710,8 +710,8 @@ END; $return .= Skin::drawCategoryBrowser($parent, $skin) . ' > '; } # 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
" . $this->makeKnownLinkObj( + $ret .= "\n
" . $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}
" . - $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)
"; + $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() { -- 2.20.1