Make user names (and real names) in credits block link to user pages.
authorEvan Prodromou <evanprodromou@users.mediawiki.org>
Mon, 28 Jun 2004 18:35:03 +0000 (18:35 +0000)
committerEvan Prodromou <evanprodromou@users.mediawiki.org>
Mon, 28 Jun 2004 18:35:03 +0000 (18:35 +0000)
Also, fix a bug in Skin.php so that if $wgMaxCredits < 0, all credits are
shown.

Finally, document the $wgMaxCredits config var better.

includes/Credits.php
includes/DefaultSettings.php
includes/Skin.php

index 18558bc..1f370f1 100644 (file)
@@ -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);
+}
+
 ?>
index 0eaf809..9c2640d 100644 (file)
@@ -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
index f9b9583..3387ebd 100644 (file)
@@ -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 {