|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\ViewHelpers\Link; |
|
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
|
|
|
use TYPO3\CMS\Core\Utility\MathUtility; |
|
|
|
|
|
|
19
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
|
|
|
|
|
|
20
|
|
|
use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper; |
|
|
|
|
|
|
21
|
|
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
class PreviewViewHelper extends AbstractBackendViewHelper |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface |
|
28
|
|
|
* @inject |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $configurationManager; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* documentRepository |
|
34
|
|
|
* |
|
35
|
|
|
* @var \EWW\Dpf\Domain\Repository\DocumentRepository |
|
36
|
|
|
* @inject |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $documentRepository; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Secret API key for delivering inactive documents. |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
private $secretKey; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Initialize secret key from plugin TYPOScript configuration. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function initialize() { |
|
50
|
|
|
parent::initialize(); |
|
51
|
|
|
|
|
52
|
|
|
$settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); |
|
53
|
|
|
|
|
54
|
|
|
if (isset($settings['plugin.']['tx_dpf.']['settings.']['deliverInactiveSecretKey'])) { |
|
55
|
|
|
$this->secretKey = $settings['plugin.']['tx_dpf.']['settings.']['deliverInactiveSecretKey']; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Returns the View Icon with link |
|
61
|
|
|
* |
|
62
|
|
|
* @param array $row Data row |
|
63
|
|
|
* @param integer $viewPage Detail View page id |
|
64
|
|
|
* @param integer $apiPid |
|
65
|
|
|
* @param string $insideText |
|
66
|
|
|
* @param string $class |
|
67
|
|
|
* @return string html output |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function getViewIcon(array $row, $pageUid, $apiPid, $insideText, $class) |
|
70
|
|
|
{ |
|
71
|
|
|
|
|
72
|
|
|
$previewMets = BackendUtility::getViewDomain($pageUid) |
|
73
|
|
|
. '/index.php?id=' . $apiPid |
|
74
|
|
|
. '&tx_dpf[qid]=' . $row['uid'] |
|
75
|
|
|
. '&tx_dpf[action]=' . $row['action']; |
|
76
|
|
|
|
|
77
|
|
|
if (array_key_exists('deliverInactive', $row)) { |
|
78
|
|
|
$previewMets .= '&tx_dpf[deliverInactive]=' . $row['deliverInactive']; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
$additionalGetVars = '&tx_dlf[id]=' . urlencode($previewMets) . '&no_cache=1'; |
|
82
|
|
|
$title = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('manager.tooltip.preview', 'dpf', $arguments = null); |
|
|
|
|
|
|
83
|
|
|
$icon = '<a href="#" data-toggle="tooltip" class="' . $class . '" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($pageUid, $this->backPath, '', '', '', $additionalGetVars)) . '" title="' . $title . '">' . |
|
84
|
|
|
$insideText . '</a>'; |
|
85
|
|
|
|
|
86
|
|
|
return $icon; |
|
87
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Renders a record list as known from the TYPO3 list module |
|
92
|
|
|
* Note: This feature is experimental! |
|
93
|
|
|
* |
|
94
|
|
|
* @param array() $arguments |
|
95
|
|
|
* @param integer $pageUid |
|
96
|
|
|
* @param integer $apiPid |
|
97
|
|
|
* @param string $class |
|
98
|
|
|
* @return string the rendered record list |
|
99
|
|
|
*/ |
|
100
|
|
|
public function render(array $arguments, $pageUid, $apiPid, $class) |
|
101
|
|
|
{ |
|
102
|
|
|
|
|
103
|
|
|
if ($arguments['document']) { |
|
104
|
|
|
|
|
105
|
|
|
// it's already a document object? |
|
106
|
|
|
if ($arguments['document'] instanceof \EWW\Dpf\Domain\Model\Document) { |
|
107
|
|
|
|
|
108
|
|
|
$document = $arguments['document']; |
|
109
|
|
|
|
|
110
|
|
|
} else if (MathUtility::canBeInterpretedAsInteger($arguments['document'])) { |
|
111
|
|
|
|
|
112
|
|
|
$document = $this->documentRepository->findByUid($arguments['document']); |
|
113
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
// we found a valid document |
|
117
|
|
|
if ($document) { |
|
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
$row['uid'] = $document->getUid(); |
|
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
$row['title'] = $document->getTitle(); |
|
122
|
|
|
|
|
123
|
|
|
$row['action'] = 'preview'; |
|
124
|
|
|
|
|
125
|
|
|
} else { |
|
126
|
|
|
|
|
127
|
|
|
// ok, nothing to render. So return empty content. |
|
128
|
|
|
return ''; |
|
129
|
|
|
|
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
} else if ($arguments['documentObjectIdentifier']) { |
|
133
|
|
|
|
|
134
|
|
|
$row['action'] = 'mets'; |
|
135
|
|
|
|
|
136
|
|
|
$row['uid'] = $arguments['documentObjectIdentifier']; |
|
137
|
|
|
|
|
138
|
|
|
// pass configured API secret key parameter to enable dissemination of inactive documents |
|
139
|
|
|
if (isset($this->secretKey)) { |
|
140
|
|
|
$row['deliverInactive'] = $this->secretKey; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
$insideText = $this->renderChildren(); |
|
146
|
|
|
|
|
147
|
|
|
$content = $this->getViewIcon($row, $pageUid, $apiPid, $insideText, $class); |
|
|
|
|
|
|
148
|
|
|
|
|
149
|
|
|
return $content; |
|
150
|
|
|
|
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|
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