From: Siebrand Mazeland Date: Thu, 5 Jan 2012 09:33:46 +0000 (+0000) Subject: Add additional parameter $altUserName to Linker::userLink to make it possible to... X-Git-Tag: 1.31.0-rc.0~25513 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=449864b78202540f8a95950b5c1f7f008065f3df;p=lhc%2Fweb%2Fwiklou.git Add additional parameter $altUserName to Linker::userLink to make it possible to override the displayed user name. Renamed $userText to $userName following Nikerabbit's advice. --- diff --git a/includes/Linker.php b/includes/Linker.php index e789113733..d4fcb2fd8d 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -918,16 +918,23 @@ class Linker { /** * Make user link (or user contributions for unregistered users) * @param $userId Integer: user id in database. - * @param $userText String: user name in database + * @param $userName String: user name in database. + * @param $altUserName String: text to display instead of the user name (optional) * @return String: HTML fragment + * @since 1.19 Method exists for a long time. $displayText was added in 1.19. */ - public static function userLink( $userId, $userText ) { + public static function userLink( $userId, $userName, $altUserName = false ) { if ( $userId == 0 ) { - $page = SpecialPage::getTitleFor( 'Contributions', $userText ); + $page = SpecialPage::getTitleFor( 'Contributions', $userName ); } else { - $page = Title::makeTitle( NS_USER, $userText ); + $page = Title::makeTitle( NS_USER, $userName ); } - return self::link( $page, htmlspecialchars( $userText ), array( 'class' => 'mw-userlink' ) ); + + return self::link( + $page, + htmlspecialchars( $altUserName !== false ? $altUserName : $userName ), + array( 'class' => 'mw-userlink' ) + ); } /**