00001 <?php
00002
00016
00017
00018
00019 class OAIMetadataFormat_MARC21 extends OAIMetadataFormat {
00023 function toXML(&$record) {
00024 $response = "<record\n" .
00025 "\txmlns=\"http://www.loc.gov/MARC21/slim\"\n" .
00026 "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
00027 "\txsi:schemaLocation=\"http://www.loc.gov/MARC21/slim\n" .
00028 "\thttp://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\">\n" .
00029 "\t<leader> cam 3u </leader>\n" .
00030 "\t<controlfield tag=\"008\">\"" . date('ymd', strtotime($record->date)) . " " . date("Y", strtotime($record->date)) ." eng \"</controlfield>\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[$record->primaryLocale]) .
00047 "</record>\n";
00048
00049 return $response;
00050 }
00051
00060 function formatElement($tag, $ind1, $ind2, $code, $value) {
00061 if (!is_array($value)) {
00062 $value = array($value);
00063 }
00064
00065 $response = '';
00066 foreach ($value as $v) {
00067 $response .= "\t<datafield tag=\"$tag\" ind1=\"$ind1\" ind2=\"$ind2\">\n" .
00068 "\t\t<subfield code=\"$code\">" . $this->oai->prepOutput($v) . "</subfield>\n" .
00069 "\t</datafield>\n";
00070 }
00071 return $response;
00072 }
00073
00074 }
00075
00076 ?>