*/
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);
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 $user_parts) {
+ dcPerson('contributor', $user_parts[0], $user_parts[1], $user_parts[2]);
}
dcRights($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. */
/* private */ function getKnownLicenses() {
$ccLicenses = array('by', 'by-nd', 'by-nd-nc', 'by-nc',
- 'by-nc-sa', 'by-sa', 'nd', 'nd-nc',
- 'nc', 'nc-sa', 'sa');
-
+ 'by-nc-sa', 'by-sa');
+ $ccVersions = array('1.0', '2.0');
$knownLicenses = array();
- foreach ($ccLicenses as $license) {
- $lurl = "http://creativecommons.org/licenses/{$license}/1.0/";
- $knownLicenses[$lurl] = explode('-', $license);
- $knownLicenses[$lurl][] = 're';
- $knownLicenses[$lurl][] = 'di';
- $knownLicenses[$lurl][] = 'no';
- if (!in_array('nd', $knownLicenses[$lurl])) {
- $knownLicenses[$lurl][] = 'de';
+ foreach ($ccVersions as $version) {
+ foreach ($ccLicenses as $license) {
+ if( $version == '2.0' && substr( $license, 0, 2) != 'by' ) {
+ # 2.0 dropped the non-attribs licenses
+ continue;
+ }
+ $lurl = "http://creativecommons.org/licenses/{$license}/{$version}/";
+ $knownLicenses[$lurl] = explode('-', $license);
+ $knownLicenses[$lurl][] = 're';
+ $knownLicenses[$lurl][] = 'di';
+ $knownLicenses[$lurl][] = 'no';
+ if (!in_array('nd', $knownLicenses[$lurl])) {
+ $knownLicenses[$lurl][] = 'de';
+ }
}
}