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