-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathOAIMetadataFormat_EPICUR.inc.php
More file actions
94 lines (84 loc) · 3.35 KB
/
OAIMetadataFormat_EPICUR.inc.php
File metadata and controls
94 lines (84 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* @file OAIMetadataFormat_EPICUR.inc.php
*
* Author: Božana Bokan, Center for Digital Systems (CeDiS), Freie Universität Berlin
* Last update: September 25, 2015
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @package plugins.oaiMetadataFormats.epicur
* @class OAIMetadataFormat_EPICUR
*
* @brief OAI metadata format class -- epicur.
*/
class OAIMetadataFormat_EPICUR extends OAIMetadataFormat {
/**
* @see OAIMetadataFormat#toXml
*/
function toXml(&$record, $format = null) {
$article = $record->getData('article');
$issue = $record->getData('issue');
$journal = $record->getData('journal');
$section = $record->getData('section');
$galleys = $record->getData('galleys');
$identifiers = array();
$pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $journal->getId());
$urnDNBPlugin = $pubIdPlugins['URNDNBPubIdPlugin'];
if ($urnDNBPlugin) {
$urnScheme = $urnDNBPlugin->getSetting($journal->getId(), 'urnDNBNamespace');
$galleysIdentifiers = array();
foreach ($galleys as $galley) {
$galleyURN = $galley->getPubId('other::urnDNB');
if ($galleyURN && $galley->isPdfGalley()) {
$articleLanguages = array_map('trim', explode(';', $article->getLanguage()));
$galleyLocale = $galley->getLocale();
if (AppLocale::getIso1FromLocale($galleyLocale) == $articleLanguages[0]) {
$galleyViewURL = Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId($journal), $galley->getBestGalleyId($journal)));
$galleyDownloadURL = Request::url($journal->getPath(), 'article', 'download', array($article->getBestArticleId($journal), $galley->getBestGalleyId($journal)));
$identifiers[] = array(
'urn' => $galleyURN,
'viewURL' => $galleyViewURL,
'downloadURL' => $galleyDownloadURL
);
}
}
}
}
$response = "<epicur\n" .
"\txmlns=\"urn:nbn:de:1111-2004033116\"\n" .
"\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
"\txsi:schemaLocation=\"urn:nbn:de:1111-2004033116\n" .
//"\thttp://nbn-resolving.de/urn/resolver.pl?urn=urn:nbn:de:1111-2004033116\">\n" .
"\thttp://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd\">\n" .
"\t\t<administrative_data>\n" .
"\t\t\t<delivery>\n" .
"\t\t\t\t<update_status type=\"urn_new\"></update_status>\n" .
"\t\t\t</delivery>\n" .
"\t\t</administrative_data>\n" .
(!empty($identifiers) ? $this->formatIdentifier($urnScheme, $identifiers) : "") .
"</epicur>\n";
return $response;
}
/**
* Format XML for single identifier and resource element.
* @param $urnScheme string
* @param $values array
*/
function formatIdentifier($urnScheme, $values) {
$response = '';
$tab = "\t\t";
foreach ($values as $value) {
$response .= $tab. "\t<record>\n<identifier scheme=\"" .$urnScheme ."\">" .$value['urn'] ."</identifier>\n" .
$tab ."\t<resource>\n" .
$tab ."\t\t<identifier scheme=\"url\" type=\"frontpage\" role=\"primary\">" .$value['viewURL'] ."</identifier>\n" .
$tab ."\t\t<format scheme=\"imt\">text/html</format>\n" .
$tab ."\t</resource>\n" .
$tab ."\t<resource>\n" .
$tab ."\t\t<identifier scheme=\"url\">" .$value['downloadURL'] ."</identifier>\n" .
$tab ."\t\t<format scheme=\"imt\">application/pdf</format>\n" .
$tab ."\t</resource>\n</record>\n";
}
return $response;
}
}
?>