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
" 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');
}
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 ""; }
$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() {
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();
$creds = $wgLang->listToText(array($real, $user, $anon));
- return wfMsg("contributions", $creds);
+ return wfMsg("othercontribs", $creds);
}
function getCopyright() {
"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",
);