‪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 TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\Imaging\IconSize;
22 
27 {
33  protected ‪$relatingTable;
34 
40  protected ‪$relatingField;
41 
51  public function ‪linkWrapItems(‪$table, ‪$uid, $code, $row)
52  {
53  if (!$code) {
54  $code = '<i>[' . htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title')) . ']</i>';
55  } else {
56  $code = BackendUtility::getRecordTitlePrep($code);
57  }
58  $title = BackendUtility::getRecordTitle(‪$table, $row, false, true);
59 
60  $ATag = '<a href="#" data-close="0" title="' . htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_browse_links.xlf:addToList')) . '">';
61  $ATag_alt = '<a href="#" data-close="1" title="' . htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_browse_links.xlf:addToList')) . '">';
62  $ATag_e = '</a>';
63  $out = '<span data-uid="' . htmlspecialchars($row['uid']) . '" data-table="' . htmlspecialchars(‪$table) . '" data-title="' . htmlspecialchars($title) . '">';
64  $out .= $ATag . $this->iconFactory->getIcon('actions-plus', IconSize::SMALL)->render() . $ATag_e . $ATag_alt . $code . $ATag_e;
65  $out .= '</span>';
66 
67  return $out;
68  }
69 
77  protected function ‪isRowListingConditionFulfilled(‪$table, $row)
78  {
79  $returnValue = true;
80  if ($this->relatingField && $this->relatingTable) {
81  $tcaFieldConfig = ‪$GLOBALS['TCA'][‪$this->relatingTable]['columns'][‪$this->relatingField]['config'] ?? [];
82  if (is_array($tcaFieldConfig['filter'] ?? false)) {
83  foreach ($tcaFieldConfig['filter'] as $filter) {
84  if (!$filter['userFunc']) {
85  continue;
86  }
87  $parameters = $filter['parameters'] ?: [];
88  $parameters['values'] = [‪$table . '_' . $row['uid']];
89  $parameters['tcaFieldConfig'] = $tcaFieldConfig;
90  $valueArray = GeneralUtility::callUserFunction($filter['userFunc'], $parameters, $this);
91  if (empty($valueArray)) {
92  $returnValue = false;
93  }
94  }
95  }
96  if (($tcaFieldConfig['type'] ?? '') === 'file') {
97  $valueArray = GeneralUtility::makeInstance(FileExtensionFilter::class)->filter(
98  [‪$table . '_' . $row['uid']],
99  (string)($tcaFieldConfig['allowed'] ?? ''),
100  (string)($tcaFieldConfig['disallowed'] ?? ''),
101  $this
102  );
103  if (empty($valueArray)) {
104  $returnValue = false;
105  }
106  }
107  }
108  return $returnValue;
109  }
110 
117  public function ‪setRelatingTableAndField($tableName, $fieldName)
118  {
119  // Check validity of the input data and load TCA
120  if (isset(‪$GLOBALS['TCA'][$tableName])) {
121  $this->relatingTable = $tableName;
122  if ($fieldName && isset(‪$GLOBALS['TCA'][$tableName]['columns'][$fieldName])) {
123  $this->relatingField = $fieldName;
124  }
125  }
126  }
127 }
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\$relatingField
‪string $relatingField
Definition: ElementBrowserRecordList.php:38
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList
Definition: ElementBrowserRecordList.php:27
‪TYPO3\CMS\Backend\RecordList\DatabaseRecordList\$table
‪string $table
Definition: DatabaseRecordList.php:217
‪TYPO3\CMS\Backend\RecordList\DatabaseRecordList
Definition: DatabaseRecordList.php:68
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\$relatingTable
‪string $relatingTable
Definition: ElementBrowserRecordList.php:32
‪TYPO3\CMS\Backend\RecordList
Definition: DatabaseRecordList.php:18
‪TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter
Definition: FileExtensionFilter.php:31
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\isRowListingConditionFulfilled
‪bool isRowListingConditionFulfilled($table, $row)
Definition: ElementBrowserRecordList.php:75
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\linkWrapItems
‪string linkWrapItems($table, $uid, $code, $row)
Definition: ElementBrowserRecordList.php:49
‪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:115
‪TYPO3\CMS\Backend\RecordList\DatabaseRecordList\getLanguageService
‪getLanguageService()
Definition: DatabaseRecordList.php:3189