00001 <?php
00002
00020
00021
00022
00023 class OAIMetadataFormat_DC extends OAIMetadataFormat {
00024
00028 function toXML(&$record) {
00029
00030 if (!empty($record->pages)) foreach ((array) $record->sources as $a => $b) {
00031 $record->sources[$a] .= '; ' . $record->pages;
00032 }
00033
00034 $response = "<oai_dc:dc\n" .
00035 "\txmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\"\n" .
00036 "\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" .
00037 "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
00038 "\txsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai_dc/\n" .
00039 "\thttp://www.openarchives.org/OAI/2.0/oai_dc.xsd\">\n" .
00040 $this->formatElement('title', $record->titles, true) .
00041 $this->formatElement('creator', $record->creator) .
00042 $this->formatElement('subject', $record->subjects, true) .
00043 $this->formatElement('description', $record->descriptions, true) .
00044 $this->formatElement('publisher', $record->publishers, true) .
00045 $this->formatElement('contributor', $record->contributors, true) .
00046 $this->formatElement('date', $record->date) .
00047 $this->formatElement('type', $record->types, true) .
00048 $this->formatElement('format', $record->format) .
00049 $this->formatElement('identifier', $record->url) .
00050 $this->formatElement('source', $record->sources, true) .
00051 $this->formatElement('language', $record->language) .
00052 $this->formatElement('relation', $record->relation) .
00053 $this->formatElement('coverage', $record->coverage, true) .
00054 $this->formatElement('rights', $record->rights) .
00055 "</oai_dc:dc>\n";
00056
00057 return $response;
00058 }
00059
00066 function formatElement($name, $value, $multilingual = false) {
00067 if (!is_array($value)) {
00068 $value = array($value);
00069 }
00070
00071 $response = '';
00072 foreach ($value as $key => $v) {
00073 if (!$multilingual) $response .= "\t<dc:$name>" . $this->oai->prepOutput($v) . "</dc:$name>\n";
00074 else {
00075 if (is_array($v)) {
00076 foreach ($v as $subV) {
00077 $response .= "\t<dc:$name xml:lang=\"$key\">" . $this->oai->prepOutput($subV) . "</dc:$name>\n";
00078 }
00079 } else {
00080 $response .= "\t<dc:$name xml:lang=\"$key\">" . $this->oai->prepOutput($v) . "</dc:$name>\n";
00081 }
00082 }
00083 }
00084 return $response;
00085 }
00086
00087 }
00088
00089 ?>