00001 <?php
00002
00016
00017
00018
00019 class OAIMetadataFormat_MARC21 extends OAIMetadataFormat {
00023 function toXml(&$record, $format = null) {
00024 $conference =& $record->getData('conference');
00025 $schedConf =& $record->getData('schedConf');
00026 $paper =& $record->getData('paper');
00027 $track =& $record->getData('track');
00028 $galleys =& $record->getData('galleys');
00029
00030
00031 $source = $conference->getConferenceTitle() . '; ' . $schedConf->getSchedConfTitle();
00032 if ($paper->getPages() != '') {
00033 $source .= '; ' . $paper->getPages();
00034 }
00035
00036
00037 $creators = array();
00038 foreach ($paper->getAuthors() as $author) {
00039 $authorName = $author->getFullName();
00040 $affiliation = $author->getAffiliation();
00041 if (!empty($affiliation)) {
00042 $authorName .= '; ' . $affiliation;
00043 }
00044 $creators[] = $authorName;
00045 }
00046
00047
00048 $subject = array(
00049 $paper->getLocalizedDiscipline(null),
00050 $paper->getLocalizedSubject(null),
00051 $paper->getLocalizedSubjectClass(null)
00052 );
00053
00054
00055 $publisher = $conference->getConferenceTitle();
00056 $publisherInstitution = $conference->getSetting('publisherInstitution');
00057 if (!empty($publisherInstitution)) {
00058 $publisher = $publisherInstitution;
00059 }
00060
00061
00062 AppLocale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
00063 $type = __('rt.metadata.pkp.peerReviewed');
00064
00065
00066 $format = array();
00067 foreach ($galleys as $galley) {
00068 $format[] = $galley->getFileType();
00069 }
00070
00071
00072 $relation = array();
00073 foreach ($paper->getSuppFiles() as $suppFile) {
00074
00075 $relation[] = Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'download', array($paper->getId(), $suppFile->getFileId()));
00076 }
00077
00078 $response = "<record\n" .
00079 "\txmlns=\"http://www.loc.gov/MARC21/slim\"\n" .
00080 "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
00081 "\txsi:schemaLocation=\"http://www.loc.gov/MARC21/slim\n" .
00082 "\thttp://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\">\n" .
00083 "\t<leader> cam 3u </leader>\n" .
00084 "\t<controlfield tag=\"008\">\"" . date('ymd Y', strtotime($paper->getDatePublished())) . " eng \"</controlfield>\n" .
00085 $this->formatElement('042', ' ', ' ', 'a', 'dc') .
00086 $this->formatElement('245', '0', '0', 'a', $paper->getLocalizedTitle()) .
00087 $this->formatElement('720', ' ', ' ', 'a', $creators) .
00088 $this->formatElement('653', ' ', ' ', 'a', $subject) .
00089 $this->formatElement('520', ' ', ' ', 'a', strip_tags($paper->getLocalizedAbstract())) .
00090 $this->formatElement('260', ' ', ' ', 'b', $publisher) .
00091 $this->formatElement('720', ' ', ' ', 'a', $paper->getLocalizedSponsor()) .
00092 $this->formatElement('260', ' ', ' ', 'c', $paper->getDatePublished()) .
00093 $this->formatElement('655', ' ', '7', 'a', $type) .
00094 $this->formatElement('856', ' ', ' ', 'q', $format) .
00095 $this->formatElement('856', '4', '0', 'u', Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'view', array($paper->getBestPaperId()))) .
00096 $this->formatElement('786', '0', ' ', 'n', $source) .
00097 $this->formatElement('546', ' ', ' ', 'a', $paper->getLanguage()) .
00098 $this->formatElement('787', '0', ' ', 'n', $relation) .
00099 $this->formatElement('500', ' ', ' ', 'a', array(
00100 $paper->getLocalizedCoverageGeo(null),
00101 $paper->getLocalizedCoverageChron(null),
00102 $paper->getLocalizedCoverageSample(null)
00103 )) .
00104 $this->formatElement('540', ' ', ' ', 'a', $conference->getLocalizedSetting('copyrightNotice')) .
00105 "</record>\n";
00106
00107 return $response;
00108 }
00109
00118 function formatElement($tag, $ind1, $ind2, $code, $value) {
00119 if (!is_array($value)) {
00120 $value = array($value);
00121 }
00122 $response = '';
00123 foreach ($value as $v) {
00124 $response .= "\t<datafield tag=\"$tag\" ind1=\"$ind1\" ind2=\"$ind2\">\n" .
00125 "\t\t<subfield code=\"$code\">" . OAIUtils::prepOutput($v) . "</subfield>\n" .
00126 "\t</datafield>\n";
00127 }
00128 return $response;
00129 }
00130 }
00131
00132 ?>