|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\ViewHelpers; |
|
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
|
|
|
class FileUrlViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper |
|
|
|
|
|
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Secret API key for delivering inactive documents. |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
private $secretKey; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Initialize secret key from plugin TYPOScript configuration. |
|
29
|
|
|
*/ |
|
30
|
|
|
public function initialize() { |
|
31
|
|
|
parent::initialize(); |
|
32
|
|
|
|
|
33
|
|
|
$configurationManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); |
|
|
|
|
|
|
34
|
|
|
$settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
if (isset($settings['plugin.']['tx_dpf.']['settings.']['deliverInactiveSecretKey'])) { |
|
37
|
|
|
$this->secretKey = $settings['plugin.']['tx_dpf.']['settings.']['deliverInactiveSecretKey']; |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $uri |
|
44
|
|
|
* |
|
45
|
|
|
*/ |
|
46
|
|
|
public function render($uri) |
|
47
|
|
|
{ |
|
48
|
|
|
$fileUri = $this->buildFileUri($uri); |
|
49
|
|
|
|
|
50
|
|
|
// pass configured API secret key parameter to enable dissemination for inactive documents |
|
51
|
|
|
if (isset($this->secretKey)) { |
|
52
|
|
|
$fileUri .= '?tx_dpf[deliverInactive]=6fc4d012-11ac-46bf-9bfc-82240628656b'; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
return $fileUri; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Construct file URI |
|
60
|
|
|
*/ |
|
61
|
|
|
protected function buildFileUri($uri) |
|
62
|
|
|
{ |
|
63
|
|
|
|
|
64
|
|
|
$uploadFileUrl = new \EWW\Dpf\Helper\UploadFileUrl; |
|
65
|
|
|
|
|
66
|
|
|
$regex = '/\/(\w*:\d*)\/datastreams\/(\w*-\d*)/'; |
|
67
|
|
|
preg_match($regex, $uri, $treffer); |
|
68
|
|
|
|
|
69
|
|
|
if (!empty($treffer)) { |
|
70
|
|
|
$qid = $treffer[1]; |
|
71
|
|
|
$fid = $treffer[2]; |
|
72
|
|
|
return $uploadFileUrl->getBaseUrl() . '/api/' . urlencode($qid) . '/attachment/' . $fid; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return $uri; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
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