plugins/oaiMetadataFormats/dc/OAIMetadataFormat_DC.inc.php

00001 <?php
00002 
00020 // $Id$
00021 
00022 
00023 class OAIMetadataFormat_DC extends OAIMetadataFormat {
00027    function toXml(&$record, $format = null) {
00028       $conference =& $record->getData('conference');
00029       $schedConf =& $record->getData('schedConf');
00030       $paper =& $record->getData('paper');
00031       $track =& $record->getData('track');
00032       $galleys =& $record->getData('galleys');
00033 
00034       // Add page information to sources
00035       $sources = array($conference->getConferenceTitle() . '; ' . $schedConf->getSchedConfTitle());
00036       if ($paper->getPages() != '') foreach ($sources as $a => $b) {
00037          $sources[$a] .= '; ' . $paper->getPages();
00038       }
00039 
00040       // Get author names
00041       $creator = array();
00042       foreach ($paper->getAuthors() as $author) {
00043          $authorName = $author->getFullName();
00044          $affiliation = $author->getAffiliation();
00045          if (!empty($affiliation)) {
00046             $authorName .= '; ' . $affiliation;
00047          }
00048          $creator[] = $authorName;
00049       }
00050 
00051       // Subjects
00052       $subjects = array_merge_recursive(
00053          $this->stripAssocArray((array) $paper->getDiscipline(null)),
00054          $this->stripAssocArray((array) $paper->getSubject(null)),
00055          $this->stripAssocArray((array) $paper->getSubjectClass(null))
00056       );
00057 
00058       // Publishers
00059       $publishers = $this->stripAssocArray((array) $conference->getTitle(null)); // Default
00060       $publisherInstitution = (array) $conference->getSetting('publisherInstitution');
00061       if (!empty($publisherInstitution)) {
00062          $publishers = $publisherInstitution;
00063       }
00064 
00065       // Types
00066       AppLocale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
00067       $this->stripAssocArray((array) $track->getIdentifyType(null));
00068       $types = array_merge_recursive(
00069          empty($types)?array(AppLocale::getLocale() => __('rt.metadata.pkp.peerReviewed')):$types,
00070          $this->stripAssocArray((array) $paper->getType(null))
00071       );
00072 
00073       // Formats
00074       $format = array();
00075       foreach ($galleys as $galley) {
00076          $format[] = $galley->getFileType();
00077       }
00078 
00079       // Get supplementary files
00080       $relation = array();
00081       foreach ($paper->getSuppFiles() as $suppFile) {
00082          // FIXME replace with correct URL
00083          $relation[] = Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'download', array($paper->getId(), $suppFile->getFileId()));
00084       }
00085 
00086       $response = "<oai_dc:dc\n" .
00087          "\txmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\"\n" .
00088          "\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" .
00089          "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
00090          "\txsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai_dc/\n" .
00091          "\thttp://www.openarchives.org/OAI/2.0/oai_dc.xsd\">\n" .
00092          $this->formatElement('title', $this->stripAssocArray((array) $paper->getLocalizedTitle(null)), true) .
00093          $this->formatElement('creator', $creator) .
00094          $this->formatElement('subject', $subjects, true) .
00095          $this->formatElement('description', $this->stripAssocArray((array) $paper->getAbstract(null)), true) .
00096          $this->formatElement('publisher', $publishers, true) .
00097          $this->formatElement('contributor', $this->stripAssocArray((array) $paper->getSponsor(null)), true) .
00098          $this->formatElement('date', $paper->getDatePublished()) .
00099          $this->formatElement('type', $types, true) .
00100          $this->formatElement('format', $format) .
00101          $this->formatElement('identifier', Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'view', array($paper->getBestPaperId()))) .
00102          $this->formatElement('source', $sources, true) .
00103          $this->formatElement('language', $paper->getLanguage()) .
00104          $this->formatElement('relation', $relation) .
00105          $this->formatElement('coverage', array_merge_recursive(
00106             $this->stripAssocArray((array) $paper->getCoverageGeo(null)),
00107             $this->stripAssocArray((array) $paper->getCoverageChron(null)),
00108             $this->stripAssocArray((array) $paper->getCoverageSample(null))
00109          ), true) .
00110          $this->formatElement('rights', (array) $conference->getSetting('copyrightNotice')) .
00111          "</oai_dc:dc>\n";
00112 
00113       return $response;
00114    }
00115 
00122    function formatElement($name, $value, $multilingual = false) {
00123       if (!is_array($value)) {
00124          $value = array($value);
00125       }
00126 
00127       $response = '';
00128       foreach ($value as $key => $v) {
00129          $key = str_replace('_', '-', $key);
00130          if (!$multilingual) $response .= "\t<dc:$name>" . OAIUtils::prepOutput($v) . "</dc:$name>\n";
00131          else {
00132             if (is_array($v)) {
00133                foreach ($v as $subV) {
00134                   $response .= "\t<dc:$name xml:lang=\"$key\">" . OAIUtils::prepOutput($subV) . "</dc:$name>\n";
00135                }
00136             } else {
00137                $response .= "\t<dc:$name xml:lang=\"$key\">" . OAIUtils::prepOutput($v) . "</dc:$name>\n";
00138             }
00139          }
00140       }
00141       return $response;
00142    }
00143 }
00144 
00145 ?>

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