‪TYPO3CMS  11.5
EditPopup.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
21 use TYPO3\CMS\Backend\Form\Behavior\OnFieldChangeTrait;
26 
32 {
33  use OnFieldChangeTrait;
34 
40  public function ‪render()
41  {
42  $options = $this->data['renderData']['fieldControlOptions'];
43 
44  $title = $options['title'] ?? 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.edit';
45 
46  $parameterArray = $this->data['parameterArray'];
47  $itemName = $parameterArray['itemFormElName'];
48  $windowOpenParameters = $options['windowOpenParameters'] ?? 'height=800,width=600,status=0,menubar=0,scrollbars=1';
49 
50  $flexFormDataStructureIdentifier = $this->data['flexFormDataStructureIdentifier'] ?? '';
51  $flexFormDataStructurePath = '';
52  if (!empty($flexFormDataStructureIdentifier)) {
53  if (empty($this->data['flexFormContainerName'])) {
54  // simple flex form element
55  $flexFormDataStructurePath = 'sheets/'
56  . $this->data['flexFormSheetName']
57  . '/ROOT/el/'
58  . $this->data['flexFormFieldName']
59  . '/TCEforms/config';
60  } else {
61  // flex form section container element
62  $flexFormDataStructurePath = 'sheets/'
63  . $this->data['flexFormSheetName']
64  . '/ROOT/el/'
65  . $this->data['flexFormFieldName']
66  . '/el/'
67  . $this->data['flexFormContainerName']
68  . '/el/'
69  . $this->data['flexFormContainerFieldName']
70  . '/TCEforms/config';
71  }
72  }
73 
74  $urlParameters = array_merge(
75  [
76  'table' => $this->data['tableName'],
77  'field' => $this->data['fieldName'],
78  'formName' => 'editform',
79  'flexFormDataStructureIdentifier' => $flexFormDataStructureIdentifier,
80  'flexFormDataStructurePath' => $flexFormDataStructurePath,
81  'hmac' => GeneralUtility::hmac('editform' . $itemName, 'wizard_js'),
82  ],
83  $this->forwardOnFieldChangeQueryParams($parameterArray['fieldChangeFunc'] ?? [])
84  );
85  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
86  $url = (string)$uriBuilder->buildUriFromRoute('wizard_edit', ['P' => $urlParameters]);
87  $id = ‪StringUtility::getUniqueId('t3js-formengine-fieldcontrol-');
88 
89  return [
90  'iconIdentifier' => 'actions-open',
91  'title' => $title,
92  'linkAttributes' => [
93  'id' => htmlspecialchars($id),
94  'href' => $url,
95  'data-element' => $itemName,
96  'data-window-parameters' => $windowOpenParameters,
97  ],
98  'requireJsModules' => [
99  ‪JavaScriptModuleInstruction::forRequireJS('TYPO3/CMS/Backend/FormEngine/FieldControl/EditPopup')->instance('#' . $id),
100  ],
101  ];
102  }
103 }
‪TYPO3\CMS\Backend\Form\FieldControl
Definition: AddRecord.php:18
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction
Definition: JavaScriptModuleInstruction.php:23
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction\forRequireJS
‪static self forRequireJS(string $name, string $exportName=null)
Definition: JavaScriptModuleInstruction.php:49
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:40
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup
Definition: EditPopup.php:32
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:128
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup\render
‪array render()
Definition: EditPopup.php:39