From 8157c2167504701f9e53fe764400bdab5a60657e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 29 Apr 2004 01:58:20 +0000 Subject: [PATCH] For on-page attribution, only show last ($wgMaxCredits - 1) contributors. No indication yet that there may be other contributors, and no separate credits page. Also, remove conflict over "contributions" string. --- includes/Article.php | 34 +++++++++++++++++++++++----------- includes/Skin.php | 36 +++++++++++++++++++++++------------- languages/Language.php | 2 +- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index ef285db046..8b1d25b3c6 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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'); } diff --git a/includes/Skin.php b/includes/Skin.php index 16e57116ca..c19b90e75b 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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 .= "
\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() { diff --git a/languages/Language.php b/languages/Language.php index 53740ef09e..4c8adbb996 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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", ); -- 2.20.1