Open Journal Systems  3.3.0
OAIMetadataFormat_RFC1807.inc.php
1 <?php
2 
21  function toXml($record, $format = null) {
22  $article =& $record->getData('article');
23  $journal =& $record->getData('journal');
24  $section =& $record->getData('section');
25  $issue =& $record->getData('issue');
26  $galleys =& $record->getData('galleys');
27 
28  // Publisher
29  $publisher = $journal->getLocalizedName(); // Default
30  $publisherInstitution = $journal->getLocalizedData('publisherInstitution');
31  if (!empty($publisherInstitution)) {
32  $publisher = $publisherInstitution;
33  }
34 
35  // Sources contains journal title, issue ID, and pages
36  $source = $issue->getIssueIdentification();
37  $pages = $article->getPages();
38  if (!empty($pages)) $source .= '; ' . $pages;
39 
40  // Format creators
41  $creators = array();
42  $authors = $article->getAuthors();
43  for ($i = 0, $num = count($authors); $i < $num; $i++) {
44  $authorName = $authors[$i]->getFullName(false, true);
45  $affiliation = $authors[$i]->getLocalizedAffiliation();
46  if (!empty($affiliation)) {
47  $authorName .= '; ' . $affiliation;
48  }
49  $creators[] = $authorName;
50  }
51 
52  // Subject
53  $subjects = array_merge_recursive(
54  stripAssocArray((array) $article->getDiscipline(null)),
55  stripAssocArray((array) $article->getSubject(null))
56  );
57  $subject = isset($subjects[$journal->getPrimaryLocale()])?$subjects[$journal->getPrimaryLocale()]:'';
58 
59  // Coverage
60  $coverage = $article->getCoverage(null);
61 
62  import('classes.issue.IssueAction');
63  $issueAction = new IssueAction();
64  $request = Application::get()->getRequest();
65  $url = $request->url($journal->getPath(), 'article', 'view', array($article->getBestId()));
66  $includeUrls = $journal->getSetting('publishingMode') != PUBLISHING_MODE_NONE || $issueAction->subscribedUser($request->getUser(), $journal, null, $article->getId());
67  $response = "<rfc1807\n" .
68  "\txmlns=\"http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt\"\n" .
69  "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
70  "\txsi:schemaLocation=\"http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1807.txt\n" .
71  "\thttp://www.openarchives.org/OAI/1.1/rfc1807.xsd\">\n" .
72  "\t<bib-version>v2</bib-version>\n" .
73  $this->formatElement('id', $url) .
74  $this->formatElement('entry', $record->datestamp) .
75  $this->formatElement('organization', $publisher) .
76  $this->formatElement('organization', $source) .
77  $this->formatElement('title', $article->getLocalizedTitle()) .
78  $this->formatElement('type', $section->getLocalizedIdentifyType()) .
79 
80  $this->formatElement('author', $creators) .
81  ($article->getDatePublished()?$this->formatElement('date', $article->getDatePublished()):'') .
82  $this->formatElement('copyright', strip_tags($journal->getLocalizedData('licenseTerms'))) .
83  ($includeUrls?$this->formatElement('other_access', "url:$url"):'') .
84  $this->formatElement('keyword', $subject) .
85  $this->formatElement('period', $coverage) .
86  $this->formatElement('monitoring', $article->getLocalizedSponsor()) .
87  $this->formatElement('language', $article->getLanguage()) .
88  $this->formatElement('abstract', strip_tags($article->getLocalizedAbstract())) .
89  "</rfc1807>\n";
90 
91  return $response;
92  }
93 
99  function formatElement($name, $value) {
100  if (!is_array($value)) {
101  $value = array($value);
102  }
103 
104  $response = '';
105  foreach ($value as $v) {
106  $response .= "\t<$name>" . OAIUtils::prepOutput($v) . "</$name>\n";
107  }
108  return $response;
109  }
110 }
OAIMetadataFormat_RFC1807\toXml
toXml($record, $format=null)
Definition: OAIMetadataFormat_RFC1807.inc.php:21
OAIMetadataFormat_RFC1807\formatElement
formatElement($name, $value)
Definition: OAIMetadataFormat_RFC1807.inc.php:99
OAIMetadataFormat
Definition: OAIStruct.inc.php:183
OAIUtils\prepOutput
static prepOutput(&$data)
Definition: OAIUtils.inc.php:99
IssueAction
IssueAction class.
Definition: IssueAction.inc.php:17
stripAssocArray
stripAssocArray($values)
Definition: functions.inc.php:263
PKPApplication\get
static get()
Definition: PKPApplication.inc.php:235
OAIMetadataFormat_RFC1807
OAI metadata format class – RFC 1807.
Definition: OAIMetadataFormat_RFC1807.inc.php:17