‪TYPO3CMS  ‪main
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 
35  public function ‪__construct(
36  private readonly ‪UriBuilder $uriBuilder,
37  ) {}
38 
44  public function ‪render(): array
45  {
46  $options = $this->data['renderData']['fieldControlOptions'];
47 
48  $title = $options['title'] ?? 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.edit';
49 
50  $parameterArray = $this->data['parameterArray'];
51  $itemName = $parameterArray['itemFormElName'];
52  $windowOpenParameters = $options['windowOpenParameters'] ?? 'height=800,width=900,status=0,menubar=0,scrollbars=1';
53 
54  $flexFormDataStructureIdentifier = $this->data['flexFormDataStructureIdentifier'] ?? '';
55  $flexFormDataStructurePath = '';
56  if (!empty($flexFormDataStructureIdentifier)) {
57  if (empty($this->data['flexFormContainerName'])) {
58  // simple flex form element
59  $flexFormDataStructurePath = 'sheets/'
60  . $this->data['flexFormSheetName']
61  . '/ROOT/el/'
62  . $this->data['flexFormFieldName']
63  . '/TCEforms/config';
64  } else {
65  // flex form section container element
66  $flexFormDataStructurePath = 'sheets/'
67  . $this->data['flexFormSheetName']
68  . '/ROOT/el/'
69  . $this->data['flexFormFieldName']
70  . '/el/'
71  . $this->data['flexFormContainerName']
72  . '/el/'
73  . $this->data['flexFormContainerFieldName']
74  . '/TCEforms/config';
75  }
76  }
77 
78  $urlParameters = array_merge(
79  [
80  'table' => $this->data['tableName'],
81  'field' => $this->data['fieldName'],
82  'formName' => 'editform',
83  'flexFormDataStructureIdentifier' => $flexFormDataStructureIdentifier,
84  'flexFormDataStructurePath' => $flexFormDataStructurePath,
85  'hmac' => ‪GeneralUtility::hmac('editform' . $itemName, 'wizard_js'),
86  ],
87  $this->forwardOnFieldChangeQueryParams($parameterArray['fieldChangeFunc'] ?? [])
88  );
89  ‪$url = (string)$this->uriBuilder->buildUriFromRoute('wizard_edit', ['P' => $urlParameters]);
90  $id = ‪StringUtility::getUniqueId('t3js-formengine-fieldcontrol-');
91 
92  return [
93  'iconIdentifier' => 'actions-open',
94  'title' => $title,
95  'linkAttributes' => [
96  'id' => $id,
97  'href' => ‪$url,
98  'data-element' => $itemName,
99  'data-window-parameters' => $windowOpenParameters,
100  ],
101  'javaScriptModules' => [
102  ‪JavaScriptModuleInstruction::create('@typo3/backend/form-engine/field-control/edit-popup.js')->instance('#' . $id),
103  ],
104  ];
105  }
106 }
‪TYPO3\CMS\Backend\Form\FieldControl
Definition: AddRecord.php:18
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction\create
‪static create(string $name, string $exportName=null)
Definition: JavaScriptModuleInstruction.php:47
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction
Definition: JavaScriptModuleInstruction.php:23
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility\hmac
‪static string hmac($input, $additionalSecret='')
Definition: GeneralUtility.php:474
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup
Definition: EditPopup.php:32
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup\render
‪array render()
Definition: EditPopup.php:43
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:57
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup\__construct
‪__construct(private readonly UriBuilder $uriBuilder,)
Definition: EditPopup.php:34