‪TYPO3CMS  ‪main
ElementBrowserRecordList.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
19 use TYPO3\CMS\Backend\Utility\BackendUtility;
20 use TYPO3\CMS\Core\Imaging\IconSize;
23 
27 #[Autoconfigure(public: true, shared: false)]
29 {
35  protected ‪$relatingTable;
36 
42  protected ‪$relatingField;
43 
53  public function ‪linkWrapItems(‪$table, ‪$uid, $code, $row)
54  {
55  if (!$code) {
56  $code = '<i>[' . htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title')) . ']</i>';
57  } else {
58  $code = BackendUtility::getRecordTitlePrep($code);
59  }
60  $title = BackendUtility::getRecordTitle(‪$table, $row, false, true);
61 
62  $ATag = '<a href="#" data-close="0" title="' . htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_browse_links.xlf:addToList')) . '">';
63  $ATag_alt = '<a href="#" data-close="1" title="' . htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_browse_links.xlf:addToList')) . '">';
64  $ATag_e = '</a>';
65  $out = '<span data-uid="' . htmlspecialchars($row['uid']) . '" data-table="' . htmlspecialchars(‪$table) . '" data-title="' . htmlspecialchars($title) . '">';
66  $out .= $ATag . $this->iconFactory->getIcon('actions-plus', IconSize::SMALL)->render() . $ATag_e . $ATag_alt . $code . $ATag_e;
67  $out .= '</span>';
68 
69  return $out;
70  }
71 
79  protected function ‪isRowListingConditionFulfilled(‪$table, $row)
80  {
81  $returnValue = true;
82  if ($this->relatingField && $this->relatingTable) {
83  $tcaFieldConfig = ‪$GLOBALS['TCA'][‪$this->relatingTable]['columns'][‪$this->relatingField]['config'] ?? [];
84  if (is_array($tcaFieldConfig['filter'] ?? false)) {
85  foreach ($tcaFieldConfig['filter'] as $filter) {
86  if (!$filter['userFunc']) {
87  continue;
88  }
89  $parameters = $filter['parameters'] ?: [];
90  $parameters['values'] = [‪$table . '_' . $row['uid']];
91  $parameters['tcaFieldConfig'] = $tcaFieldConfig;
92  $valueArray = GeneralUtility::callUserFunction($filter['userFunc'], $parameters, $this);
93  if (empty($valueArray)) {
94  $returnValue = false;
95  }
96  }
97  }
98  if (($tcaFieldConfig['type'] ?? '') === 'file') {
99  $valueArray = GeneralUtility::makeInstance(FileExtensionFilter::class)->filter(
100  [‪$table . '_' . $row['uid']],
101  (string)($tcaFieldConfig['allowed'] ?? ''),
102  (string)($tcaFieldConfig['disallowed'] ?? ''),
103  );
104  if (empty($valueArray)) {
105  $returnValue = false;
106  }
107  }
108  }
109  return $returnValue;
110  }
111 
118  public function ‪setRelatingTableAndField($tableName, $fieldName)
119  {
120  // Check validity of the input data and load TCA
121  if (isset(‪$GLOBALS['TCA'][$tableName])) {
122  $this->relatingTable = $tableName;
123  if ($fieldName && isset(‪$GLOBALS['TCA'][$tableName]['columns'][$fieldName])) {
124  $this->relatingField = $fieldName;
125  }
126  }
127  }
128 }
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\$relatingField
‪string $relatingField
Definition: ElementBrowserRecordList.php:40
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList
Definition: ElementBrowserRecordList.php:29
‪TYPO3\CMS\Backend\RecordList\DatabaseRecordList\$table
‪string $table
Definition: DatabaseRecordList.php:221
‪TYPO3\CMS\Backend\RecordList\DatabaseRecordList
Definition: DatabaseRecordList.php:72
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\$relatingTable
‪string $relatingTable
Definition: ElementBrowserRecordList.php:34
‪TYPO3\CMS\Backend\RecordList
Definition: DatabaseRecordList.php:18
‪TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter
Definition: FileExtensionFilter.php:30
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\isRowListingConditionFulfilled
‪bool isRowListingConditionFulfilled($table, $row)
Definition: ElementBrowserRecordList.php:77
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\linkWrapItems
‪string linkWrapItems($table, $uid, $code, $row)
Definition: ElementBrowserRecordList.php:51
‪TYPO3\CMS\Webhooks\Message\$uid
‪identifier readonly int $uid
Definition: PageModificationMessage.php:35
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\setRelatingTableAndField
‪setRelatingTableAndField($tableName, $fieldName)
Definition: ElementBrowserRecordList.php:116
‪TYPO3\CMS\Backend\RecordList\DatabaseRecordList\getLanguageService
‪getLanguageService()
Definition: DatabaseRecordList.php:3264