|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EWW\Dpf\Plugins\RelatedListTool; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the TYPO3 CMS project. |
|
7
|
|
|
* |
|
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
10
|
|
|
* of the License, or any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* For the full copyright and license information, please read the |
|
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
14
|
|
|
* |
|
15
|
|
|
* The TYPO3 project - inspiring people to share! |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Plugin 'DPF: RElatedListTool' for the 'dlf / dpf' extension. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
22
|
|
|
* @author Alexander Bigga <[email protected]> |
|
23
|
|
|
* @package TYPO3 |
|
24
|
|
|
* @subpackage tx_dpf |
|
25
|
|
|
* @access public |
|
26
|
|
|
*/ |
|
27
|
|
|
class RelatedListTool extends \tx_dlf_plugin |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* The main method of the PlugIn |
|
32
|
|
|
* |
|
33
|
|
|
* @access public |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $content: The PlugIn content |
|
36
|
|
|
* @param array $conf: The PlugIn configuration |
|
37
|
|
|
* |
|
38
|
|
|
* @return string The content that is displayed on the website |
|
39
|
|
|
*/ |
|
40
|
|
|
public function main($content, $conf) |
|
41
|
|
|
{ |
|
42
|
|
|
|
|
43
|
|
|
$this->init($conf); |
|
44
|
|
|
|
|
45
|
|
|
// get the tx_dpf.settings too |
|
46
|
|
|
// Flexform wins over TS |
|
47
|
|
|
$dpfTSconfig = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_dpf.']; |
|
48
|
|
|
|
|
49
|
|
|
if (is_array($dpfTSconfig['settings.'])) { |
|
50
|
|
|
|
|
51
|
|
|
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($dpfTSconfig['settings.'], $this->conf, true, false); |
|
|
|
|
|
|
52
|
|
|
$this->conf = $dpfTSconfig['settings.']; |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
// Load current document. |
|
57
|
|
|
$this->loadDocument(); |
|
58
|
|
|
|
|
59
|
|
|
if ($this->doc === null) { |
|
60
|
|
|
|
|
61
|
|
|
// Quit without doing anything if required variables are not set. |
|
62
|
|
|
return $content; |
|
63
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
// Load template file. |
|
67
|
|
|
if (!empty($this->conf['templateFile'])) { |
|
68
|
|
|
|
|
69
|
|
|
$this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###'); |
|
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
} else { |
|
72
|
|
|
|
|
73
|
|
|
$this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dpf/Classes/Plugins/RelatedListTool/template.tmpl'), '###TEMPLATE###'); |
|
74
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$subpartArray['items'] = $this->cObj->getSubpart($this->template, '###ITEMS###'); |
|
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
$relatedItems = $this->getRelatedItems(); |
|
80
|
|
|
|
|
81
|
|
|
$content = ''; |
|
82
|
|
|
|
|
83
|
|
|
if (!empty($relatedItems)) { |
|
84
|
|
|
foreach ($relatedItems as $key => $value) { |
|
85
|
|
|
// set link |
|
86
|
|
|
if ($value['type'] == 'local') { |
|
87
|
|
|
$confApi = array( |
|
88
|
|
|
'useCacheHash' => 0, |
|
89
|
|
|
'parameter' => $this->conf['apiPid'], |
|
90
|
|
|
'additionalParams' => '&tx_dpf[qid]=' . $value['docId'] . '&tx_dpf[action]=mets', |
|
91
|
|
|
'forceAbsoluteUrl' => true, |
|
92
|
|
|
); |
|
93
|
|
|
|
|
94
|
|
|
$metsApiUrl = urlencode($this->cObj->typoLink_URL($confApi)); |
|
95
|
|
|
|
|
96
|
|
|
$conf = array( |
|
97
|
|
|
'useCacheHash' => 1, |
|
98
|
|
|
'parameter' => $GLOBALS['TSFE']->page['uid'], |
|
99
|
|
|
'additionalParams' => '&tx_dlf[id]=' . $metsApiUrl, |
|
100
|
|
|
'forceAbsoluteUrl' => true, |
|
101
|
|
|
); |
|
102
|
|
|
|
|
103
|
|
|
} elseif ($value['type'] == 'urn') { |
|
104
|
|
|
// use urn link |
|
105
|
|
|
$conf = array( |
|
106
|
|
|
'useCacheHash' => 0, |
|
107
|
|
|
'parameter' => 'http://nbn-resolving.de/' . $value['docId'], |
|
108
|
|
|
'forceAbsoluteUrl' => true, |
|
109
|
|
|
); |
|
110
|
|
|
|
|
111
|
|
|
} else { |
|
112
|
|
|
|
|
113
|
|
|
$conf = array( |
|
114
|
|
|
'useCacheHash' => 0, |
|
115
|
|
|
'forceAbsoluteUrl' => true, |
|
116
|
|
|
); |
|
117
|
|
|
|
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
$title = $value['title'] ? $value['title'] : $value['docId']; |
|
121
|
|
|
|
|
122
|
|
|
// replace uid with URI to dpf API |
|
123
|
|
|
$markerArray['###ITEM###'] = $this->cObj->typoLink($title, $conf); |
|
124
|
|
|
|
|
125
|
|
|
$content .= $this->cObj->substituteMarkerArray($subpartArray['items'], $markerArray); |
|
|
|
|
|
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
return $this->cObj->substituteSubpart($this->template, '###ITEMS###', $content, true); |
|
130
|
|
|
|
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
private function compareByOrderVolumeTitle($a, $b) |
|
134
|
|
|
{ |
|
135
|
|
|
$s1 = join(' ', array($a['order'], $a['volume'], $a['title'])); |
|
136
|
|
|
$s2 = join(' ', array($b['order'], $b['volume'], $b['title'])); |
|
137
|
|
|
return strnatcmp($s1, $s2); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
public function getRelatedItems() |
|
141
|
|
|
{ |
|
142
|
|
|
$xPath = '//mods:relatedItem[@type="constituent"]'; |
|
143
|
|
|
|
|
144
|
|
|
$items = $this->doc->mets->xpath($xPath); |
|
145
|
|
|
|
|
146
|
|
|
$relatedItems = array(); |
|
147
|
|
|
|
|
148
|
|
|
foreach ($items as $index => $relatedItemXmlElement) { |
|
149
|
|
|
$relatedItemXmlElement->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3'); |
|
150
|
|
|
|
|
151
|
|
|
$type = (string) $relatedItemXmlElement->xpath('mods:identifier/@type')[0]; |
|
152
|
|
|
$title = (string) $relatedItemXmlElement->xpath('mods:titleInfo/mods:title')[0]; |
|
153
|
|
|
$docId = (string) $relatedItemXmlElement->xpath('mods:identifier[@type="' . $type . '"]')[0]; |
|
154
|
|
|
$order = (string) $relatedItemXmlElement->xpath('mods:part/@order')[0]; |
|
155
|
|
|
$volume = (string) $relatedItemXmlElement->xpath('mods:part[@type="volume" or @type="issue"]/mods:detail/mods:number')[0]; |
|
156
|
|
|
|
|
157
|
|
|
$element = array(); |
|
158
|
|
|
$element['type'] = $type; |
|
159
|
|
|
$element['title'] = $title; |
|
160
|
|
|
$element['docId'] = $docId; |
|
161
|
|
|
$element['order'] = (!empty($order)) ? $order : null; |
|
162
|
|
|
$element['volume'] = (!empty($volume)) ? $volume : null; |
|
163
|
|
|
|
|
164
|
|
|
$relatedItems[$index] = $element; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
usort($relatedItems, array('EWW\Dpf\Plugins\RelatedListTool\RelatedListTool', 'compareByOrderVolumeTitle')); |
|
168
|
|
|
|
|
169
|
|
|
return $relatedItems; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths