plugins/oaiMetadataFormats/marc/OAIMetadataFormat_MARC.inc.php

00001 <?php
00002 
00016 // $Id$
00017 
00018 
00019 class OAIMetadataFormat_MARC extends OAIMetadataFormat {
00020 
00024    function toXml(&$record, $format = null) {
00025       $conference =& $record->getData('conference');
00026       $schedConf =& $record->getData('schedConf');
00027       $paper =& $record->getData('paper');
00028       $track =& $record->getData('track');
00029       $galleys =& $record->getData('galleys');
00030 
00031       // Add page information to sources
00032       $source = $conference->getConferenceTitle() . '; ' . $schedConf->getSchedConfTitle();
00033       if ($paper->getPages() != '') {
00034          $source .= '; ' . $paper->getPages();
00035       }
00036 
00037       // Get author names
00038       $creators = array();
00039       foreach ($paper->getAuthors() as $author) {
00040          $authorName = $author->getFullName();
00041          $affiliation = $author->getAffiliation();
00042          if (!empty($affiliation)) {
00043             $authorName .= '; ' . $affiliation;
00044          }
00045          $creators[] = $authorName;
00046       }
00047 
00048       // Subjects
00049       $subject = array(
00050          $paper->getLocalizedDiscipline(null),
00051          $paper->getLocalizedSubject(null),
00052          $paper->getLocalizedSubjectClass(null)
00053       );
00054 
00055       // Publishers
00056       $publisher = $conference->getConferenceTitle(); // Default
00057       $publisherInstitution = $conference->getSetting('publisherInstitution');
00058       if (!empty($publisherInstitution)) {
00059          $publisher = $publisherInstitution;
00060       }
00061 
00062       // Types
00063       AppLocale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
00064       $type = __('rt.metadata.pkp.peerReviewed');
00065 
00066       // Formats
00067       $format = array();
00068       foreach ($galleys as $galley) {
00069          $format[] = $galley->getFileType();
00070       }
00071 
00072       // Get supplementary files
00073       $relation = array();
00074       foreach ($paper->getSuppFiles() as $suppFile) {
00075          // FIXME replace with correct URL
00076          $relation[] = Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'download', array($paper->getId(), $suppFile->getFileId()));
00077       }
00078 
00079       $response = "<oai_marc status=\"c\" type=\"a\" level=\"m\" encLvl=\"3\" catForm=\"u\"\n" .
00080          "\txmlns=\"http://www.openarchives.org/OAI/1.1/oai_marc\"\n" .
00081          "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
00082          "\txsi:schemaLocation=\"http://www.openarchives.org/OAI/1.1/oai_marc\n" .
00083          "\thttp://www.openarchives.org/OAI/1.1/oai_marc.xsd\">\n" .
00084          "\t<fixfield id=\"008\">\"" . date('ymd Y', strtotime($paper->getDatePublished())) . '                                  eng  "</fixfield>' . "\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          "</oai_marc>\n";
00106 
00107       return $response;
00108    }
00109 
00118    function formatElement($id, $i1, $i2, $label, $value) {
00119       if (!is_array($value)) {
00120          $value = array($value);
00121       }
00122 
00123       $response = '';
00124       foreach ($value as $v) {
00125          $response .= "\t<varfield id=\"$id\" i1=\"$i1\" i2=\"$i2\">\n" .
00126             "\t\t<subfield label=\"$label\">" . OAIUtils::prepOutput($v) . "</subfield>\n" .
00127             "\t</varfield>\n";
00128       }
00129       return $response;
00130    }
00131 }
00132 
00133 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7