|
1
|
|
|
<?php |
|
2
|
|
|
namespace Fab\Vidi\Backend; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the Fab/Vidi project under GPLv2 or later. |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please read the |
|
8
|
|
|
* LICENSE.md file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
12
|
|
|
use Fab\Vidi\Configuration\ConfigurationUtility; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Display custom fields in the Extension Manager. |
|
16
|
|
|
*/ |
|
17
|
|
|
class ExtensionManager |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var array |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $excludedContentTypes = array('pages', 'pages_language_overlay', 'tx_rtehtmlarea_acronym'); |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Display a message to the Extension Manager whether the configuration is OK or KO. |
|
27
|
|
|
* |
|
28
|
|
|
* @param array $params |
|
29
|
|
|
* @param \TYPO3\CMS\Core\TypoScript\ConfigurationForm $tsObj |
|
30
|
|
|
* @return string |
|
31
|
|
|
*/ |
|
32
|
|
|
public function renderDataTypes(&$params, &$tsObj) |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
|
|
35
|
|
|
$configuration = ConfigurationUtility::getInstance()->getConfiguration(); |
|
36
|
|
|
$selectedDataTypes = GeneralUtility::trimExplode(',', $configuration['data_types']); |
|
37
|
|
|
$options = ''; |
|
38
|
|
|
foreach ($this->getDataTypes() as $dataType) { |
|
39
|
|
|
$checked = ''; |
|
40
|
|
|
|
|
41
|
|
|
if (in_array($dataType, $selectedDataTypes)) { |
|
42
|
|
|
$checked = 'checked="checked"'; |
|
43
|
|
|
} |
|
44
|
|
|
$options .= sprintf( |
|
45
|
|
|
'<li><label><input type="checkbox" class="fieldDataType" value="%s" %s /> %s</label></li>', |
|
46
|
|
|
$dataType, |
|
47
|
|
|
$checked, |
|
48
|
|
|
$dataType |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
$menu = sprintf('<ul class="list-unstyled" style="margin-top: 10px;">%s</ul>', $options); |
|
53
|
|
|
|
|
54
|
|
|
// Assemble final output. |
|
55
|
|
|
$output = <<<EOF |
|
56
|
|
|
<div class="form-group form-group-dashed> |
|
57
|
|
|
<div class="form-control-wrap"> |
|
58
|
|
|
|
|
59
|
|
|
<div class="typo3-tstemplate-ceditor-row" id="userTS-dataTypes"> |
|
60
|
|
|
<script type="text/javascript"> |
|
61
|
|
|
(function($) { |
|
62
|
|
|
$(function() { |
|
63
|
|
|
|
|
64
|
|
|
// Handler which will concatenate selected data types. |
|
65
|
|
|
$('.fieldDataType').change(function() { |
|
66
|
|
|
|
|
67
|
|
|
var dataTypes = $('#fieldDataTypes').val(); |
|
68
|
|
|
var currentValue = $(this).val(); |
|
69
|
|
|
|
|
70
|
|
|
// In any case remove item |
|
71
|
|
|
var expression = new RegExp(', *' + currentValue, 'i'); |
|
72
|
|
|
dataTypes = dataTypes.replace(expression, ''); |
|
73
|
|
|
$('#fieldDataTypes').val(dataTypes); |
|
74
|
|
|
|
|
75
|
|
|
// Append new data type at the end if checked. |
|
76
|
|
|
if ($(this).is(':checked')) { |
|
77
|
|
|
$('#fieldDataTypes').val(dataTypes + ', ' + currentValue); |
|
78
|
|
|
} |
|
79
|
|
|
}); |
|
80
|
|
|
}); |
|
81
|
|
|
})(jQuery); |
|
82
|
|
|
</script> |
|
83
|
|
|
<input type="text" class="form-control" id="fieldDataTypes" name="tx_extensionmanager_tools_extensionmanagerextensionmanager[config][data_types][value]" value="{$configuration['data_types']}" /> |
|
84
|
|
|
</div> |
|
85
|
|
|
$menu |
|
86
|
|
|
</div> |
|
87
|
|
|
EOF; |
|
88
|
|
|
|
|
89
|
|
|
return $output; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return array |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getDataTypes() |
|
96
|
|
|
{ |
|
97
|
|
|
|
|
98
|
|
|
$dataTypes = []; |
|
99
|
|
|
|
|
100
|
|
|
if (is_array($GLOBALS['TCA'])) { |
|
101
|
|
|
foreach ($GLOBALS['TCA'] as $contentType => $tca) { |
|
102
|
|
|
if (!in_array($contentType, $this->excludedContentTypes) |
|
103
|
|
|
&& isset($GLOBALS['TCA'][$contentType]['ctrl']['label']) |
|
104
|
|
|
&& ( |
|
105
|
|
|
!isset($GLOBALS['TCA'][$contentType]['ctrl']['hideTable']) |
|
106
|
|
|
|| true !== (bool)$GLOBALS['TCA'][$contentType]['ctrl']['hideTable'] |
|
107
|
|
|
) |
|
108
|
|
|
) { |
|
109
|
|
|
$dataTypes[] = $contentType; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
return $dataTypes; |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.