typo leading to fatal error.
[lhc/web/wiklou.git] / includes / Metadata.php
index ebc7164..49a2275 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 define("RDF_TYPE_PREFS", "application/rdf+xml,text/xml;q=0.7,application/xml;q=0.5,text/rdf;q=0.1");
-                        
+
 function wfDublinCoreRdf($article) {
        
        $url = dcReallyFullUrl($article->mTitle);
@@ -107,12 +107,20 @@ function wfCreativeCommonsRdf($article) {
        dcElement('format', 'text/html');
        dcElement('identifier', dcReallyFullUrl($article->mTitle));
        dcElement('date', dcDate($article->getTimestamp()));
-       dcPerson('creator', $article->getUser());
-       
-       $contributors = dcContributors($article->mTitle);
+
+        $last_editor = $article->getUser();
+        
+        if ($last_editor == 0) {
+           dcPerson('creator', 0);
+       } else {
+           dcPerson('creator', $last_editor, $article->getUserText(),
+                    User::whoIsReal($last_editor));
+       }
+
+       $contributors = $article->getContributors();
        
-       foreach ($contributors as $cid) {
-               dcPerson('contributor', $cid);
+       foreach ($contributors as $cid => $user_parts) {
+               dcPerson('contributor', $cid, $user_parts[0], $user_parts[1]);
        }
        
        dcRights($article);
@@ -204,33 +212,22 @@ function wfCreativeCommonsRdf($article) {
        print "    <dc:{$name} rdf:resource=\"{$url}\" />\n";
 }
 
-/* private */ function dcPerson($name, $id) {
+/* private */ function dcPerson($name, $id, $user_name="", $user_real_name="") {
        global $wgLang;
 
        if ($id == 0) {
                dcElement($name, wfMsg("anonymous"));
+       } else if ( !empty($user_real_name) ) {
+               dcElement($name, $user_real_name);
        } else {
-               $user_name = User::whoIs($id);
-               dcPageOrString($name, $wgLang->getNsText(NS_USER) . ":" . $user_name, $user_name);
+               # XXX: This shouldn't happen.
+               if( empty( $user_name ) ) {
+                       $user_name = User::whoIs($id);
+               }
+               dcPageOrString($name, $wgLang->getNsText(NS_USER) . ":" . $user_name, wfMsg("siteuser", $user_name));
        }
 }
 
-/* private */ function dcContributors($title) {
-       
-       $contribs = array();
-       
-       $res = wfQuery("SELECT DISTINCT old_user" .
-                      " FROM old " .
-                      " WHERE old_namespace = " . $title->getNamespace() .
-                      " AND old_title = '" . $title->getDBkey() . "'", DB_READ);
-       
-       while ( $line = wfFetchObject( $res ) ) {
-               $contribs[] = $line->old_user;
-       }    
-       
-       return $contribs;
-}
-
 /* Takes an arg, for future enhancement with different rights for
  different pages. */