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