|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Plugins\DownloadTool; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Plugin 'DPF: DownloadTool' for the 'dlf / dpf' extension. |
|
21
|
|
|
* |
|
22
|
|
|
* @author Alexander Bigga <[email protected]> |
|
23
|
|
|
* @package TYPO3 |
|
24
|
|
|
* @subpackage tx_dpf |
|
25
|
|
|
* @access public |
|
26
|
|
|
*/ |
|
27
|
|
|
class DownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
public $scriptRelPath = 'Classes/Plugins/DownloadTool.php'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* The main method of the PlugIn |
|
33
|
|
|
* |
|
34
|
|
|
* @access public |
|
35
|
|
|
* |
|
36
|
|
|
* @param string $content: The PlugIn content |
|
37
|
|
|
* @param array $conf: The PlugIn configuration |
|
38
|
|
|
* |
|
39
|
|
|
* @return string The content that is displayed on the website |
|
40
|
|
|
*/ |
|
41
|
|
|
public function main($content, $conf) |
|
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
|
|
|
if (is_array($dpfTSconfig['settings.'])) { |
|
49
|
|
|
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($dpfTSconfig['settings.'], $this->conf, true, false); |
|
50
|
|
|
$this->conf = $dpfTSconfig['settings.']; |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// Load current document. |
|
54
|
|
|
$this->loadDocument(); |
|
55
|
|
|
if ($this->doc === null || empty($this->conf['fileGrpDownload'])) { |
|
56
|
|
|
// Quit without doing anything if required variables are not set. |
|
57
|
|
|
return $content; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
// Load template file. |
|
61
|
|
|
if (!empty($this->conf['templateFile'])) { |
|
62
|
|
|
$this->template = $this->templateService->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###'); |
|
|
|
|
|
|
63
|
|
|
} else { |
|
64
|
|
|
$this->template = $this->templateService->getSubpart($this->cObj->fileResource('EXT:dpf/Classes/Plugins/DownloadTool/template.tmpl'), '###TEMPLATE###'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$subpartArray['downloads'] = $this->templateService->getSubpart($this->template, '###DOWNLOADS###'); |
|
|
|
|
|
|
68
|
|
|
// Show all PDF documents in download filegroup |
|
69
|
|
|
$attachments = $this->getAttachments(); |
|
70
|
|
|
// Get VG-Wort-Url |
|
71
|
|
|
$vgwort = $this->getVGWortUrl(); |
|
72
|
|
|
$content = ''; |
|
73
|
|
|
if (is_array($attachments)) { |
|
|
|
|
|
|
74
|
|
|
foreach ($attachments as $id => $file) { |
|
75
|
|
|
$conf = array( |
|
76
|
|
|
'useCacheHash' => 0, |
|
77
|
|
|
'parameter' => $this->conf['apiPid'] . ' - piwik_download', |
|
78
|
|
|
'additionalParams' => '&tx_dpf[qid]=' . $this->doc->recordId . '&tx_dpf[action]=attachment' . '&tx_dpf[attachment]=' . $file['ID'], |
|
79
|
|
|
'forceAbsoluteUrl' => true, |
|
80
|
|
|
); |
|
81
|
|
|
$title = $file['LABEL'] ? $file['LABEL'] : $file['ID']; |
|
82
|
|
|
$markerArray['###FILE###'] = $this->cObj->typoLink($title, $conf); |
|
83
|
|
|
|
|
84
|
|
|
if(!empty($vgwort)) { |
|
85
|
|
|
$markerArray['###VGWORT###'] = "<div class='div_vgwpixel' data-url='" . $vgwort . "'></div>"; |
|
86
|
|
|
} else { |
|
87
|
|
|
$markerArray['###VGWORT###'] = ""; |
|
88
|
|
|
} |
|
89
|
|
|
$content .= $this->cObj->substituteMarkerArray($subpartArray['downloads'], $markerArray); |
|
|
|
|
|
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
return $this->cObj->substituteSubpart($this->template, '###DOWNLOADS###', $content, true); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Get PDF document list |
|
97
|
|
|
|
|
98
|
|
|
* @return array of attachments |
|
99
|
|
|
*/ |
|
100
|
|
|
protected function getAttachments() |
|
101
|
|
|
{ |
|
102
|
|
|
// Get pdf documents |
|
103
|
|
|
$xPath = 'mets:fileSec/mets:fileGrp[@USE="' . $this->conf['fileGrpDownload'] . '"]/mets:file'; |
|
104
|
|
|
$files = $this->doc->mets->xpath($xPath); |
|
105
|
|
|
if (!is_array($files)) { |
|
106
|
|
|
return array(); |
|
107
|
|
|
} |
|
108
|
|
|
foreach ($files as $key => $file) { |
|
109
|
|
|
$singleFile = array(); |
|
110
|
|
|
foreach ($file->attributes('mext', 1) as $attribute => $value) { |
|
111
|
|
|
$singleFile[$attribute] = $value; |
|
112
|
|
|
} |
|
113
|
|
|
foreach ($file->attributes() as $attribute => $value) { |
|
114
|
|
|
$singleFile[$attribute] = $value; |
|
115
|
|
|
} |
|
116
|
|
|
$attachments[(string) $singleFile['ID']] = $singleFile; |
|
117
|
|
|
} |
|
118
|
|
|
if (is_array($attachments) && count($attachments) > 1) { |
|
|
|
|
|
|
119
|
|
|
ksort($attachments); |
|
120
|
|
|
} |
|
121
|
|
|
return $attachments; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
protected function getVGWortUrl() |
|
125
|
|
|
{ |
|
126
|
|
|
// Get VG-Wort-OpenKey for document |
|
127
|
|
|
$this->doc->mets->registerXPathNamespace("slub", 'http://slub-dresden.de/'); |
|
128
|
|
|
$xPath = '//slub:info/slub:vgwortOpenKey'; |
|
129
|
|
|
$vgwortOpenKey = $this->doc->mets->xpath($xPath)[0]; |
|
130
|
|
|
|
|
131
|
|
|
if (!empty($vgwortOpenKey) or $vgwortOpenKey != FALSE ) { |
|
132
|
|
|
if (GeneralUtility::getIndpEnv('TYPO3_SSL')) { |
|
133
|
|
|
$vgwortserver = 'https://ssl-vg03.met.vgwort.de/na/'; |
|
134
|
|
|
} else { |
|
135
|
|
|
$vgwortserver = 'http://vg08.met.vgwort.de/na/'; |
|
136
|
|
|
} |
|
137
|
|
|
return $vgworturl = $vgwortserver . $vgwortOpenKey; |
|
|
|
|
|
|
138
|
|
|
} |
|
139
|
|
|
return FALSE; |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
|
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