‪TYPO3CMS  9.5
ElementBrowser.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 
27 {
33  public function ‪render()
34  {
35  $table = $this->data['tableName'];
36  $fieldName = $this->data['fieldName'];
37  $parameterArray = $this->data['parameterArray'];
38  $elementName = $parameterArray['itemFormElName'];
39  $config = $parameterArray['fieldConf']['config'];
40  $internalType = (string)$config['internal_type'];
41  $allowed = $config['allowed'];
42 
43  if (isset($config['readOnly']) && $config['readOnly']) {
44  return [];
45  }
46 
47  if ($internalType === 'db') {
48  $title = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.browse_db';
49  } else {
50  $title = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.browse_file';
51  }
52 
53  // Check against inline uniqueness - Create some onclick js for delete control and element browser
54  // to override record selection in some FAL scenarios - See 'appearance' docs of group element
55  $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
56  $inlineStackProcessor->initializeByGivenStructure($this->data['inlineStructure']);
57  $elementBrowserOnClickInline = '';
58  if ($this->data['isInlineChild']
59  && $this->data['inlineParentUid']
60  && $this->data['inlineParentConfig']['foreign_table'] === $table
61  && $this->data['inlineParentConfig']['foreign_unique'] === $fieldName
62  ) {
63  $objectPrefix = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']) . '-' . $table;
64  $elementBrowserOnClickInline = $objectPrefix . '|inline.checkUniqueElement|inline.setUniqueElement';
65  }
66  $elementBrowserType = $internalType;
67  if (is_array($config['appearance']) && isset($config['appearance']['elementBrowserType'])) {
68  $elementBrowserType = $config['appearance']['elementBrowserType'];
69  }
70  if (is_array($config['appearance']) && isset($config['appearance']['elementBrowserAllowed'])) {
71  $allowed = $config['appearance']['elementBrowserAllowed'];
72  }
73  // Remove any white-spaces from the allowed extension lists
74  $elementBrowserAllowed = implode(',', GeneralUtility::trimExplode(',', $allowed, true));
75 
76  $elementBrowserOnClick = 'setFormValueOpenBrowser('
77  . GeneralUtility::quoteJSvalue($elementBrowserType) . ','
78  . GeneralUtility::quoteJSvalue($elementName . '|||' . $elementBrowserAllowed . '|' . $elementBrowserOnClickInline)
79  . ');'
80  . ' return false;';
81 
82  return [
83  'iconIdentifier' => 'actions-insert-record',
84  'title' => $title,
85  'linkAttributes' => [
86  'onClick' => $elementBrowserOnClick,
87  ],
88  ];
89  }
90 }
‪TYPO3\CMS\Backend\Form\FieldControl\ElementBrowser\render
‪array render()
Definition: ElementBrowser.php:33
‪TYPO3\CMS\Backend\Form\FieldControl
Definition: AddRecord.php:3
‪TYPO3\CMS\Backend\Form\FieldControl\ElementBrowser
Definition: ElementBrowser.php:27
‪TYPO3\CMS\Backend\Form\InlineStackProcessor
Definition: InlineStackProcessor.php:29
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45