For on-page attribution, only show last ($wgMaxCredits - 1) contributors. No
authorEvan Prodromou <evanprodromou@users.mediawiki.org>
Thu, 29 Apr 2004 01:58:20 +0000 (01:58 +0000)
committerEvan Prodromou <evanprodromou@users.mediawiki.org>
Thu, 29 Apr 2004 01:58:20 +0000 (01:58 +0000)
indication yet that there may be other contributors, and no separate credits
page.

Also, remove conflict over "contributions" string.

includes/Article.php
includes/Skin.php
languages/Language.php

index ef285db..8b1d25b 100644 (file)
@@ -398,22 +398,34 @@ class Article {
 
         function getContributors($limit = 0, $offset = 0)
         {
+                $fname = "Article::getContributors";
+
                # XXX: this is expensive; cache this info somewhere.
                
                $title = $this->mTitle;
 
                $contribs = array();
-       
-               $res = wfQuery("SELECT DISTINCT old.old_user, old.old_user_text, user.user_real_name " .
-                              " FROM old, user " .
-                              " WHERE old.old_user = user.user_id " .
-                              " AND old.old_namespace = " . $title->getNamespace() .
-                              " AND old.old_title = '" . $title->getDBkey() . "'" .
-                               " AND old.old_user != 0 " .
-                               " AND old.old_user != " . $this->getUser(), DB_READ);
+
+                $sql = "SELECT old.old_user, old.old_user_text, " .
+                       "  user.user_real_name, MAX(old.old_timestamp) as timestamp" .
+                       " FROM old, user " .
+                       " WHERE old.old_user = user.user_id " .
+                      " AND old.old_namespace = " . $title->getNamespace() .
+                       " AND old.old_title = '" . $title->getDBkey() . "'" .
+                       " AND old.old_user != 0 " .
+                       " AND old.old_user != " . $this->getUser() . 
+                       " GROUP BY old.old_user " . 
+                       " ORDER BY timestamp DESC ";
+
+                if ($limit > 0) {
+                        $sql .= " LIMIT $limit";
+                }
+
+               $res = wfQuery($sql, DB_READ, $fname);
        
                while ( $line = wfFetchObject( $res ) ) {
-                       $contribs[$line->old_user] = array($line->old_user_text, $line->user_real_name);
+                       $contribs[$line->old_user] = 
+                                array($line->old_user_text, $line->user_real_name);
                }    
 
                 # Count anonymous users
@@ -422,8 +434,8 @@ class Article {
                               " FROM old " .
                               " WHERE old_namespace = " . $title->getNamespace() .
                               " AND old_title = '" . $title->getDBkey() . "'" .
-                               " AND old_user = 0 ", DB_READ);
-
+                               " AND old_user = 0 ", DB_READ, $fname);
+       
                while ( $line = wfFetchObject( $res ) ) {
                         $contribs[0] = array($line->cnt, 'Anonymous');
                }    
index 16e5711..c19b90e 100644 (file)
@@ -712,8 +712,8 @@ class Skin {
        function pageStats()
        {
                global $wgOut, $wgLang, $wgArticle, $wgRequest;
-               global $wgDisableCounters, $wgMaxCredits;
-               
+               global $wgDisableCounters;
+
                extract( $wgRequest->getValues( 'oldid', 'diff' ) );
                if ( ! $wgOut->isArticle() ) { return ""; }
                if ( isset( $oldid ) || isset( $diff ) ) { return ""; }
@@ -726,19 +726,27 @@ class Skin {
                                $s = wfMsg( "viewcount", $count );
                        }
                }
-               if (!isset($wgMaxCredits) || $wgMaxCredits <= 0) {
-                   $s .= $this->lastModified();
-               } else {
-                   $s .= " " . $this->getCredits();
-               }
+
+               $s .= " " . $this->getCredits();
            
                return $s . " " .  $this->getCopyright();
        }
 
         function getCredits() {
-               $s = $this->getAuthorCredits();
-               $s .= "<br />\n " . $this->getContributorCredits();
-               return $s;
+              global $wgMaxCredits;
+              
+              $s = '';
+           
+              if (!isset($wgMaxCredits) || $wgMaxCredits == 0) {
+                       $s = $this->lastModified();
+              } else {
+                       $s = $this->getAuthorCredits();
+                       if ($wgMaxCredits > 1) {
+                           $s .= " " . $this->getContributorCredits();
+                       }
+              }
+           
+              return $s;
        }
 
         function getAuthorCredits() {
@@ -769,8 +777,10 @@ class Skin {
         function getContributorCredits() {
            
                global $wgArticle, $wgMaxCredits, $wgLang;
-           
-               $contributors = $wgArticle->getContributors($wgMaxCredits);
+
+                # don't count last editor
+
+               $contributors = $wgArticle->getContributors($wgMaxCredits - 1);
            
                $real_names = array();
                $user_names = array();
@@ -802,7 +812,7 @@ class Skin {
            
                $creds = $wgLang->listToText(array($real, $user, $anon));
            
-               return wfMsg("contributions", $creds);
+               return wfMsg("othercontribs", $creds);
        }
     
        function getCopyright() {
index 53740ef..4c8adbb 100644 (file)
@@ -1568,7 +1568,7 @@ amusement.",
 "siteuser" => "$wgSitename user $1",
 "lastmodifiedby" => "This page was last modified $1 by $2.",
 "and" => "and",
-"contributions" => "Based on work by $1.",
+"othercontribs" => "Based on work by $1.",
 "siteusers" => "$wgSitename user(s) $1",
 );