Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
HighwirePress | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
4.37 | |
0.00% |
0 / 1 |
getMappedData | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
4.37 |
1 | <?php |
2 | |
3 | /** |
4 | * Metadata vocabulary implementation for Highwire Press |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) University of Tübingen 2019. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package Metadata_Vocabularies |
25 | * @author Mario Trojan <mario.trojan@uni-tuebingen.de> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org/wiki/development Wiki |
28 | */ |
29 | |
30 | namespace VuFind\MetadataVocabulary; |
31 | |
32 | /** |
33 | * Metadata vocabulary implementation for Highwire Press |
34 | * |
35 | * @category VuFind |
36 | * @package Metadata_Vocabularies |
37 | * @author Mario Trojan <mario.trojan@uni-tuebingen.de> |
38 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
39 | * @link https://vufind.org/wiki/development Wiki |
40 | */ |
41 | class HighwirePress extends AbstractBase |
42 | { |
43 | /** |
44 | * Mapping from Highwire Press to VuFind fields; see |
45 | * https://jira.duraspace.org/secure/attachment/13020/Invisible_institutional.pdf |
46 | * |
47 | * @var array |
48 | */ |
49 | protected $vocabFieldToGenericFieldsMap = [ |
50 | 'citation_author' => 'author', |
51 | 'citation_date' => 'date', |
52 | 'citation_doi' => 'doi', |
53 | 'citation_firstpage' => 'startpage', |
54 | 'citation_isbn' => 'isbn', |
55 | 'citation_issn' => 'issn', |
56 | 'citation_issue' => 'issue', |
57 | 'citation_journal_title' => 'container_title', |
58 | 'citation_language' => 'language', |
59 | 'citation_lastpage' => 'endpage', |
60 | 'citation_publisher' => 'publisher', |
61 | 'citation_title' => 'title', |
62 | 'citation_volume' => 'volume', |
63 | ]; |
64 | |
65 | /** |
66 | * Special implementation for date formats |
67 | * |
68 | * @param \VuFind\RecordDriver\AbstractBase $driver Record driver |
69 | * |
70 | * @return array |
71 | */ |
72 | public function getMappedData(\VuFind\RecordDriver\AbstractBase $driver) |
73 | { |
74 | $mappedData = parent::getMappedData($driver); |
75 | |
76 | // special handling for dates |
77 | if (isset($mappedData['citation_date'])) { |
78 | foreach ($mappedData['citation_date'] as $key => $date) { |
79 | // If we only have a year, leave it as-is |
80 | // If we have a date, we need to convert to MM-DD-YYYY or MM/DD/YYYY |
81 | if (!preg_match('"^\d+$"', $date)) { |
82 | $mappedData['citation_date'][$key] |
83 | = date('m/d/Y', strtotime($date)); |
84 | } |
85 | } |
86 | } |
87 | |
88 | return $mappedData; |
89 | } |
90 | } |