‪TYPO3CMS  10.4
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 
25 
31 {
37  public function ‪render()
38  {
39  $languageService = $this->‪getLanguageService();
40  $options = $this->data['renderData']['fieldControlOptions'];
41 
42  $title = $options['title'] ?? 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.edit';
43 
44  $parameterArray = $this->data['parameterArray'];
45  $itemName = $parameterArray['itemFormElName'];
46  $windowOpenParameters = $options['windowOpenParameters'] ?? 'height=800,width=600,status=0,menubar=0,scrollbars=1';
47 
48  $flexFormDataStructureIdentifier = $this->data['flexFormDataStructureIdentifier'] ?? '';
49  $flexFormDataStructurePath = '';
50  if (!empty($flexFormDataStructureIdentifier)) {
51  if (empty($this->data['flexFormContainerName'])) {
52  // simple flex form element
53  $flexFormDataStructurePath = 'sheets/'
54  . $this->data['flexFormSheetName']
55  . '/ROOT/el/'
56  . $this->data['flexFormFieldName']
57  . '/TCEforms/config';
58  } else {
59  // flex form section container element
60  $flexFormDataStructurePath = 'sheets/'
61  . $this->data['flexFormSheetName']
62  . '/ROOT/el/'
63  . $this->data['flexFormFieldName']
64  . '/el/'
65  . $this->data['flexFormContainerName']
66  . '/el/'
67  . $this->data['flexFormContainerFieldName']
68  . '/TCEforms/config';
69  }
70  }
71 
72  $urlParameters = [
73  'P' => [
74  'table' => $this->data['tableName'],
75  'field' => $this->data['fieldName'],
76  'formName' => 'editform',
77  'flexFormDataStructureIdentifier' => $flexFormDataStructureIdentifier,
78  'flexFormDataStructurePath' => $flexFormDataStructurePath,
79  'hmac' => GeneralUtility::hmac('editform' . $itemName, 'wizard_js'),
80  'fieldChangeFunc' => $parameterArray['fieldChangeFunc'],
81  'fieldChangeFuncHash' => GeneralUtility::hmac(serialize($parameterArray['fieldChangeFunc']), 'backend-link-browser'),
82  ],
83  ];
84  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
85  $url = (string)$uriBuilder->buildUriFromRoute('wizard_edit', $urlParameters);
86 
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  ['TYPO3/CMS/Backend/FormEngine/FieldControl/EditPopup' => 'function(FieldControl) {new FieldControl(' . GeneralUtility::quoteJSvalue('#' . $id) . ');}'],
100  ],
101  ];
102  }
103 
109  protected function ‪getLanguageService()
110  {
111  return ‪$GLOBALS['LANG'];
112  }
113 }
‪TYPO3\CMS\Backend\Form\FieldControl
Definition: AddRecord.php:18
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup
Definition: EditPopup.php:31
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup\render
‪array render()
Definition: EditPopup.php:37
‪TYPO3\CMS\Backend\Form\FieldControl\EditPopup\getLanguageService
‪LanguageService getLanguageService()
Definition: EditPopup.php:109