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