‪TYPO3CMS  9.5
EditPopup.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
21 
27 {
33  public function ‪render()
34  {
35  $languageService = $this->‪getLanguageService();
36  $options = $this->data['renderData']['fieldControlOptions'];
37 
38  $title = $options['title'] ?? 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.edit';
39 
40  $parameterArray = $this->data['parameterArray'];
41  $itemName = $parameterArray['itemFormElName'];
42  $windowOpenParameters = $options['windowOpenParameters'] ?? 'height=800,width=600,status=0,menubar=0,scrollbars=1';
43 
44  $flexFormDataStructureIdentifier = $this->data['flexFormDataStructureIdentifier'] ?? '';
45  $flexFormDataStructurePath = '';
46  if (!empty($flexFormDataStructureIdentifier)) {
47  if (empty($this->data['flexFormContainerName'])) {
48  // simple flex form element
49  $flexFormDataStructurePath = 'sheets/'
50  . $this->data['flexFormSheetName']
51  . '/ROOT/el/'
52  . $this->data['flexFormFieldName']
53  . '/TCEforms/config';
54  } else {
55  // flex form section container element
56  $flexFormDataStructurePath = 'sheets/'
57  . $this->data['flexFormSheetName']
58  . '/ROOT/el/'
59  . $this->data['flexFormFieldName']
60  . '/el/'
61  . $this->data['flexFormContainerName']
62  . '/el/'
63  . $this->data['flexFormContainerFieldName']
64  . '/TCEforms/config';
65  }
66  }
67 
68  $urlParameters = [
69  'P' => [
70  'table' => $this->data['tableName'],
71  'field' => $this->data['fieldName'],
72  'formName' => 'editform',
73  'flexFormDataStructureIdentifier' => $flexFormDataStructureIdentifier,
74  'flexFormDataStructurePath' => $flexFormDataStructurePath,
75  'hmac' => GeneralUtility::hmac('editform' . $itemName, 'wizard_js'),
76  'fieldChangeFunc' => $parameterArray['fieldChangeFunc'],
77  'fieldChangeFuncHash' => GeneralUtility::hmac(serialize($parameterArray['fieldChangeFunc']), 'backend-link-browser'),
78  ],
79  ];
80  $uriBuilder = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\UriBuilder::class);
81  $url = (string)$uriBuilder->buildUriFromRoute('wizard_edit', $urlParameters);
82 
83  $onClick = [];
84  $onClick[] = 'this.blur();';
85  $onClick[] = 'if (!TBE_EDITOR.curSelected(' . GeneralUtility::quoteJSvalue($itemName) . ')) {';
86  $onClick[] = 'top.TYPO3.Modal.confirm(';
87  $onClick[] = '"' . $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.header') . '",';
88  $onClick[] = '"' . $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.noSelItemForEdit') . '",';
89  $onClick[] = 'top.TYPO3.Severity.notice, [{text: TYPO3.lang[\'button.ok\'] || \'OK\', btnClass: \'btn-notice\', name: \'ok\'}]';
90  $onClick[] = ')';
91  $onClick[] = '.on("button.clicked", function(e) {';
92  $onClick[] = 'if (e.target.name == "ok") { top.TYPO3.Modal.dismiss(); }}';
93  $onClick[] = ');';
94  $onClick[] = 'return false;';
95  $onClick[] = '}';
96  $onClick[] = 'vHWin=window.open(';
97  $onClick[] = GeneralUtility::quoteJSvalue($url);
98  $onClick[] = '+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode(';
99  $onClick[] = 'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value';
100  $onClick[] = ')';
101  $onClick[] = '+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(';
102  $onClick[] = GeneralUtility::quoteJSvalue($itemName);
103  $onClick[] = '),';
104  $onClick[] = '\'\',';
105  $onClick[] = GeneralUtility::quoteJSvalue($windowOpenParameters);
106  $onClick[] = ');';
107  $onClick[] = 'vHWin.focus();';
108  $onClick[] = 'return false;';
109 
110  return [
111  'iconIdentifier' => 'actions-open',
112  'title' => $title,
113  'linkAttributes' => [
114  'onClick' => implode('', $onClick),
115  ],
116  ];
117  }
118 
124  protected function ‪getLanguageService()
125  {
126  return ‪$GLOBALS['LANG'];
127  }
128 }
‪TYPO3\CMS\Backend\Form\FieldControl
Definition: AddRecord.php:3
‪TYPO3
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup
Definition: EditPopup.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup\render
‪array render()
Definition: EditPopup.php:33
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup\getLanguageService
‪LanguageService getLanguageService()
Definition: EditPopup.php:124