‪TYPO3CMS  10.4
LinkPopup.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 
24 
30 {
36  public function ‪render(): array
37  {
38  $options = $this->data['renderData']['fieldControlOptions'];
39 
40  $title = $options['title'] ?? 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.link';
41 
42  $parameterArray = $this->data['parameterArray'];
43  $itemName = $parameterArray['itemFormElName'];
44 
45  $linkBrowserArguments = [];
46  if (isset($options['blindLinkOptions'])) {
47  $linkBrowserArguments['blindLinkOptions'] = $options['blindLinkOptions'];
48  }
49  if (isset($options['blindLinkFields'])) {
50  $linkBrowserArguments['blindLinkFields'] = $options['blindLinkFields'];
51  }
52  if (isset($options['allowedExtensions'])) {
53  $linkBrowserArguments['allowedExtensions'] = $options['allowedExtensions'];
54  }
55  $urlParameters = [
56  'P' => [
57  'params' => $linkBrowserArguments,
58  'table' => $this->data['tableName'],
59  'uid' => $this->data['databaseRow']['uid'],
60  'pid' => $this->data['databaseRow']['pid'],
61  'field' => $this->data['fieldName'],
62  'formName' => 'editform',
63  'itemName' => $itemName,
64  'hmac' => GeneralUtility::hmac('editform' . $itemName, 'wizard_js'),
65  'fieldChangeFunc' => $parameterArray['fieldChangeFunc'],
66  'fieldChangeFuncHash' => GeneralUtility::hmac(serialize($parameterArray['fieldChangeFunc']), 'backend-link-browser'),
67  ],
68  ];
70  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
71  $url = (string)$uriBuilder->buildUriFromRoute('wizard_link', $urlParameters);
72 
73  $id = ‪StringUtility::getUniqueId('t3js-formengine-fieldcontrol-');
74 
75  return [
76  'iconIdentifier' => 'actions-wizard-link',
77  'title' => $title,
78  'linkAttributes' => [
79  'id' => htmlspecialchars($id),
80  'href' => $url,
81  'data-item-name' => htmlspecialchars($itemName),
82  ],
83  'requireJsModules' => [
84  ['TYPO3/CMS/Backend/FormEngine/FieldControl/LinkPopup' => 'function(LinkPopup) {new LinkPopup(' . GeneralUtility::quoteJSvalue('#' . $id) . ');}'],
85  ],
86  ];
87  }
88 }
‪TYPO3\CMS\Backend\Form\FieldControl
Definition: AddRecord.php:18
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪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