From 9d6bd18753aade1b3aaab31939b5466c92944e95 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 23 Apr 2004 21:01:29 +0000 Subject: [PATCH] Moved contributor logic to Article class, and changed Metadata to use that method instead. --- includes/Article.php | 35 +++++++++++++++++++++++++++++++++++ includes/Metadata.php | 8 ++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 7f1aacf8a9..10e6a7b4f7 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -380,6 +380,41 @@ class Article { return $this->mMinorEdit; } + function getContributors($limit = 0, $offset = 0) + { + # 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); + + while ( $line = wfFetchObject( $res ) ) { + $contribs[$line->old_user] = array($line->old_user_text, $line->user_real_name); + } + + # Count anonymous users + + $res = wfQuery("SELECT COUNT(*) AS cnt " . + " FROM old " . + " WHERE old_namespace = " . $title->getNamespace() . + " AND old_title = '" . $title->getDBkey() . "'" . + " AND old_user = 0 ", DB_READ); + + while ( $line = wfFetchObject( $res ) ) { + $contribs[0] = array($line->cnt, 'Anonymous'); + } + + return $contribs; + } + # This is the default action of the script: just view the page of # the given title. diff --git a/includes/Metadata.php b/includes/Metadata.php index f9df5393aa..48e48eb609 100644 --- a/includes/Metadata.php +++ b/includes/Metadata.php @@ -108,11 +108,11 @@ function wfCreativeCommonsRdf($article) { dcElement('identifier', dcReallyFullUrl($article->mTitle)); dcElement('date', dcDate($article->getTimestamp())); dcPerson('creator', $article->getUser()); + + $contributors = $article->getContributors(); - $contributors = dcContributors($article); - - foreach ($contributors as $user_name => $cid) { - dcPerson('contributor', $cid, $user_name); + foreach ($contributors as $cid => $user_parts) { + dcPerson('contributor', $cid, $user_parts[0]); } dcRights($article); -- 2.20.1