Moved contributor logic to Article class, and changed Metadata to use that
authorEvan Prodromou <evanprodromou@users.mediawiki.org>
Fri, 23 Apr 2004 21:01:29 +0000 (21:01 +0000)
committerEvan Prodromou <evanprodromou@users.mediawiki.org>
Fri, 23 Apr 2004 21:01:29 +0000 (21:01 +0000)
method instead.

includes/Article.php
includes/Metadata.php

index 7f1aacf..10e6a7b 100644 (file)
@@ -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.
 
index f9df539..48e48eb 100644 (file)
@@ -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);