‪TYPO3CMS  10.4
TableList.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 
25 
31 {
37  public function ‪render(): array
38  {
39  $languageService = $this->‪getLanguageService();
40  $result = $this->‪initializeResultArray();
41 
42  $parameterArray = $this->data['parameterArray'];
43  $config = $parameterArray['fieldConf']['config'];
44  $itemName = $parameterArray['itemFormElName'];
45 
46  if (empty($config['allowed']) || !is_string($config['allowed']) || !isset($config['internal_type']) || $config['internal_type'] !== 'db') {
47  // No handling if the field has no, or funny "allowed" setting and if internal_type is not "db"
48  return $result;
49  }
50 
51  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
52  $allowed = ‪GeneralUtility::trimExplode(',', $config['allowed'], true);
53  $allowedTablesHtml = [];
54  foreach ($allowed as $tableName) {
55  if ($tableName === '*') {
56  $label = $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.allTables');
57  $allowedTablesHtml[] = '<span>';
58  $allowedTablesHtml[] = htmlspecialchars($label);
59  $allowedTablesHtml[] = '</span>';
60  } else {
61  $label = $languageService->sL(‪$GLOBALS['TCA'][$tableName]['ctrl']['title']);
62  $icon = $iconFactory->getIconForRecord($tableName, [], ‪Icon::SIZE_SMALL)->render();
63  if ((bool)($config['fieldControl']['elementBrowser']['disabled'] ?? false)) {
64  $allowedTablesHtml[] = '<span class="tablelist-item-nolink">';
65  $allowedTablesHtml[] = $icon;
66  $allowedTablesHtml[] = htmlspecialchars($label);
67  $allowedTablesHtml[] = '</span>';
68  } else {
69  $allowedTablesHtml[] = '<a href="#" class="btn btn-default t3js-element-browser" data-mode="db" data-params="' . htmlspecialchars($itemName . '|||' . $tableName) . '">';
70  $allowedTablesHtml[] = $icon;
71  $allowedTablesHtml[] = htmlspecialchars($label);
72  $allowedTablesHtml[] = '</a>';
73  }
74  }
75  }
76 
77  $html = [];
78  $html[] = '<div class="help-block">';
79  $html[] = implode(LF, $allowedTablesHtml);
80  $html[] = '</div>';
81 
82  $result['html'] = implode(LF, $html);
83  return $result;
84  }
85 
89  protected function ‪getLanguageService()
90  {
91  return ‪$GLOBALS['LANG'];
92  }
93 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:90
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Backend\Form\FieldWizard\TableList\render
‪array render()
Definition: TableList.php:37
‪TYPO3\CMS\Backend\Form\FieldWizard
Definition: DefaultLanguageDifferences.php:18
‪TYPO3\CMS\Backend\Form\FieldWizard\TableList
Definition: TableList.php:31
‪TYPO3\CMS\Backend\Form\FieldWizard\TableList\getLanguageService
‪LanguageService getLanguageService()
Definition: TableList.php:89
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static string[] trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:1059
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46