00001 <?php
00002
00016
00017
00018
00019 class OAIMetadataFormat_MARC extends OAIMetadataFormat {
00020
00024 function toXML(&$record) {
00025 $response = "<oai_marc status=\"c\" type=\"a\" level=\"m\" encLvl=\"3\" catForm=\"u\"\n" .
00026 "\txmlns=\"http://www.openarchives.org/OAI/1.1/oai_marc\"\n" .
00027 "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
00028 "\txsi:schemaLocation=\"http://www.openarchives.org/OAI/1.1/oai_marc\n" .
00029 "\thttp://www.openarchives.org/OAI/1.1/oai_marc.xsd\">\n" .
00030 "\t<fixfield id=\"008\">\"" . date('ymd', strtotime($record->date)) . ' ' . date('Y', strtotime($record->date)) . ' eng "</fixfield>' . "\n" .
00031 $this->formatElement('042', ' ', ' ', 'a', 'dc') .
00032 $this->formatElement('245', '0', '0', 'a', $record->titles[$record->primaryLocale]) .
00033 $this->formatElement('720', ' ', ' ', 'a', $record->creator) .
00034 $this->formatElement('653', ' ', ' ', 'a', $this->getLocalizedData($record->subjects, $record->primaryLocale)) .
00035 $this->formatElement('520', ' ', ' ', 'a', $this->getLocalizedData($record->descriptions, $record->primaryLocale)) .
00036 $this->formatElement('260', ' ', ' ', 'b', $record->publishers[$record->primaryLocale]) .
00037 $this->formatElement('720', ' ', ' ', 'a', $this->getLocalizedData($record->contributors, $record->primaryLocale)) .
00038 $this->formatElement('260', ' ', ' ', 'c', $record->date) .
00039 $this->formatElement('655', ' ', '7', 'a', $record->types[$record->primaryLocale]) .
00040 $this->formatElement('856', ' ', ' ', 'q', $record->format) .
00041 $this->formatElement('856', '4', '0', 'u', $record->url) .
00042 $this->formatElement('786', '0', ' ', 'n', $record->sources[$record->primaryLocale] . (!empty($record->pages)?"; " . $record->pages:"")) .
00043 $this->formatElement('546', ' ', ' ', 'a', $record->language) .
00044 $this->formatElement('787', '0', ' ', 'n', $record->relation) .
00045 $this->formatElement('500', ' ', ' ', 'a', $this->getLocalizedData($record->coverage, $record->primaryLocale)) .
00046 $this->formatElement('540', ' ', ' ', 'a', $record->rights) .
00047 "</oai_marc>\n";
00048
00049 return $response;
00050 }
00051
00060 function formatElement($id, $i1, $i2, $label, $value) {
00061 if (!is_array($value)) {
00062 $value = array($value);
00063 }
00064
00065 $response = '';
00066 foreach ($value as $v) {
00067 $response .= "\t<varfield id=\"$id\" i1=\"$i1\" i2=\"$i2\">\n" .
00068 "\t\t<subfield label=\"$label\">" . $this->oai->prepOutput($v) . "</subfield>\n" .
00069 "\t</varfield>\n";
00070 }
00071 return $response;
00072 }
00073
00074 }
00075
00076 ?>