1
|
|
|
<?php |
2
|
|
|
namespace Aoe\AoeDbSequenzer\Form; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2017 AOE GmbH ([email protected]) |
8
|
|
|
* All rights reserved |
9
|
|
|
* |
10
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
11
|
|
|
* free software; you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU General Public License as published by |
13
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* The GNU General Public License can be found at |
17
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
18
|
|
|
* |
19
|
|
|
* This script is distributed in the hope that it will be useful, |
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
* GNU General Public License for more details. |
23
|
|
|
* |
24
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
25
|
|
|
***************************************************************/ |
26
|
|
|
|
27
|
|
|
use Aoe\AoeDbSequenzer\Service\OverwriteProtectionService; |
28
|
|
|
use TYPO3\CMS\Backend\Form\Element\SelectSingleElement; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @package Aoe\AoeDbSequenzer\Form |
32
|
|
|
*/ |
33
|
|
|
class OverwriteModeElement extends AbstractOverwriteElement |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* @var integer |
37
|
|
|
*/ |
38
|
|
|
const OVERWRITE_PROTECTION_MODE_CONFLICT = 0; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var integer |
42
|
|
|
*/ |
43
|
|
|
const OVERWRITE_PROTECTION_MODE_OVERWRITE = 1; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param array $PA |
47
|
|
|
* @return String |
48
|
|
|
*/ |
49
|
|
|
public function render(array $PA) |
50
|
|
|
{ |
51
|
|
|
$itemFormElValue = ''; |
52
|
|
|
if ($this->hasOverwriteProtection($PA['row']['uid'], $PA['table'])) { |
53
|
|
|
$overwriteProtection = $this->getOverwriteProtection($PA['row']['uid'], $PA['table']); |
54
|
|
|
$itemFormElValue = $overwriteProtection->getProtectedMode(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$data = [ |
58
|
|
|
'inlineStructure' => [], |
59
|
|
|
'parameterArray' => [ |
60
|
|
|
'itemFormElName' => 'data[' . $PA['table'] . '][' . $PA['row']['uid'] . ']['.OverwriteProtectionService::OVERWRITE_PROTECTION_MODE.']', |
61
|
|
|
'itemFormElValue' => [$itemFormElValue], |
62
|
|
|
'fieldName' => OverwriteProtectionService::OVERWRITE_PROTECTION_MODE, |
63
|
|
|
'fieldChangeFunc' => [], |
64
|
|
|
'fieldConf' => [ |
65
|
|
|
'label' => '', |
66
|
|
|
'config' => [ |
67
|
|
|
'type' => 'select', |
68
|
|
|
'renderType' => 'selectSingle', |
69
|
|
|
'size' => 1, |
70
|
|
|
'maxitems' => 1, |
71
|
|
|
'items' => [ |
72
|
|
|
[ |
73
|
|
|
$this->getLanguageService()->sL('LLL:EXT:aoe_dbsequenzer/Resources/Private/Language/locallang_db.xml:mode_conflict'), |
74
|
|
|
self::OVERWRITE_PROTECTION_MODE_CONFLICT |
75
|
|
|
], |
76
|
|
|
[ |
77
|
|
|
$this->getLanguageService()->sL('LLL:EXT:aoe_dbsequenzer/Resources/Private/Language/locallang_db.xml:mode_overwrite'), |
78
|
|
|
self::OVERWRITE_PROTECTION_MODE_OVERWRITE |
79
|
|
|
] |
80
|
|
|
] |
81
|
|
|
], |
82
|
|
|
], |
83
|
|
|
], |
84
|
|
|
]; |
85
|
|
|
|
86
|
|
|
$element = new SelectSingleElement($this->getNodeFactory(), $data); |
87
|
|
|
$resultArray = $element->render(); |
88
|
|
|
return $resultArray['html']; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|