‪TYPO3CMS  9.5
LinkPopup.php
Go to the documentation of this file.
1 <?php
2 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 
20 
26 {
32  public function ‪render(): array
33  {
34  $options = $this->data['renderData']['fieldControlOptions'];
35 
36  $title = $options['title'] ?? 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.link';
37 
38  $parameterArray = $this->data['parameterArray'];
39  $itemName = $parameterArray['itemFormElName'];
40  $windowOpenParameters = $options['windowOpenParameters'] ?? 'height=800,width=1000,status=0,menubar=0,scrollbars=1';
41 
42  $linkBrowserArguments = [];
43  if (isset($options['blindLinkOptions'])) {
44  $linkBrowserArguments['blindLinkOptions'] = $options['blindLinkOptions'];
45  }
46  if (isset($options['blindLinkFields'])) {
47  $linkBrowserArguments['blindLinkFields'] = $options['blindLinkFields'];
48  }
49  if (isset($options['allowedExtensions'])) {
50  $linkBrowserArguments['allowedExtensions'] = $options['allowedExtensions'];
51  }
52  $urlParameters = [
53  'P' => [
54  'params' => $linkBrowserArguments,
55  'table' => $this->data['tableName'],
56  'uid' => $this->data['databaseRow']['uid'],
57  'pid' => $this->data['databaseRow']['pid'],
58  'field' => $this->data['fieldName'],
59  'formName' => 'editform',
60  'itemName' => $itemName,
61  'hmac' => GeneralUtility::hmac('editform' . $itemName, 'wizard_js'),
62  'fieldChangeFunc' => $parameterArray['fieldChangeFunc'],
63  'fieldChangeFuncHash' => GeneralUtility::hmac(serialize($parameterArray['fieldChangeFunc']), 'backend-link-browser'),
64  ],
65  ];
67  $uriBuilder = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\UriBuilder::class);
68  $url = (string)$uriBuilder->buildUriFromRoute('wizard_link', $urlParameters);
69  $onClick = [];
70  $onClick[] = 'this.blur();';
71  $onClick[] = 'vHWin=window.open(';
72  $onClick[] = GeneralUtility::quoteJSvalue($url);
73  $onClick[] = '+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode(';
74  $onClick[] = 'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . '].value';
75  $onClick[] = ')';
76  $onClick[] = '+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(';
77  $onClick[] = GeneralUtility::quoteJSvalue($itemName);
78  $onClick[] = '),';
79  $onClick[] = '\'\',';
80  $onClick[] = GeneralUtility::quoteJSvalue($windowOpenParameters);
81  $onClick[] = ');';
82  $onClick[] = 'vHWin.focus();';
83  $onClick[] = 'return false;';
84 
85  return [
86  'iconIdentifier' => 'actions-wizard-link',
87  'title' => $title,
88  'linkAttributes' => [
89  'onClick' => implode('', $onClick),
90  ],
91  ];
92  }
93 }
‪TYPO3\CMS\Backend\Form\FieldControl
Definition: AddRecord.php:3
‪TYPO3
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45