From: Evan Prodromou Date: Mon, 28 Jun 2004 18:35:03 +0000 (+0000) Subject: Make user names (and real names) in credits block link to user pages. X-Git-Tag: 1.5.0alpha1~2753 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=e9080b7357a395ad6605108fc94dd6a3aeba493b;p=lhc%2Fweb%2Fwiklou.git Make user names (and real names) in credits block link to user pages. Also, fix a bug in Skin.php so that if $wgMaxCredits < 0, all credits are shown. Finally, document the $wgMaxCredits config var better. --- diff --git a/includes/Credits.php b/includes/Credits.php index 18558bcda3..1f370f1832 100644 --- a/includes/Credits.php +++ b/includes/Credits.php @@ -40,8 +40,6 @@ function showCreditsPage($article) $s = getCredits($article, -1); } - wfDebug("Credits: '$s'\n"); - $wgOut->addHTML( $s ); wfProfileOut( $fname ); @@ -70,14 +68,17 @@ function getAuthorCredits($article) { if ($last_author == 0) { $author_credit = wfMsg('anonymous'); } else { + $real_name = User::whoIsReal($last_author); + $user_name = User::whoIs($last_author); + if (!empty($real_name)) { - $author_credit = $real_name; + $author_credit = creditLink($user_name, $real_name); } else { - $author_credit = wfMsg('siteuser', User::whoIs($last_author)); + $author_credit = wfMsg('siteuser', creditLink($user_name)); } } - + $timestamp = $article->getTimestamp(); if ($timestamp) { $d = $wgLang->timeanddate($article->getTimestamp(), true); @@ -101,9 +102,9 @@ function getContributorCredits($article, $cnt) { foreach ($contributors as $user_id => $user_parts) { if ($user_id != 0) { if ($wgAllowRealName && !empty($user_parts[1])) { - $real_names[$user_id] = $user_parts[1]; + $real_names[$user_id] = creditLink($user_parts[0], $user_parts[1]); } else { - $user_names[$user_id] = $user_parts[0]; + $user_names[$user_id] = creditLink($user_parts[0]); } } } @@ -126,4 +127,11 @@ function getContributorCredits($article, $cnt) { return wfMsg('othercontribs', $creds); } +function creditLink($user_name, $link_text = '') { + global $wgUser, $wgLang; + $skin = $wgUser->getSkin(); + return $skin->makeKnownLink($wgLang->getNsText(NS_USER) . ":" . $user_name, + (empty($link_text)) ? $user_name : $link_text); +} + ?> diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 0eaf809ba8..9c2640db6a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -372,10 +372,11 @@ $wgCapitalLinks = true; # can be imported, these should be 'trusted'. $wgImportSources = array(); -# Set this to the number of authors that you want to be credited -# below an article text. Set it to zero to hide the attribution block. -# Note that this will require checking the table of old revisions, -# which can have a significant impact on performance for large wikis. +# Set this to the number of authors that you want to be credited below an +# article text. Set it to zero to hide the attribution block, and a +# negative number (like -1) to show all authors. Note that this will +# require checking the table of old revisions, which can have a significant +# impact on performance for large wikis. $wgMaxCredits = 0; # Text matching this regular expression will be recognised as spam diff --git a/includes/Skin.php b/includes/Skin.php index f9b95830ce..3387ebdcb6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -783,7 +783,7 @@ class Skin { } } - if (isset($wgMaxCredits) && $wgMaxCredits > 0) { + if (isset($wgMaxCredits) && $wgMaxCredits != 0) { require_once("Credits.php"); $s .= ' ' . getCredits($wgArticle, $wgMaxCredits); } else {