‪TYPO3CMS  10.4
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 
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, $this->fixedL);
57  }
58  $title = ‪BackendUtility::getRecordTitle(‪$table, $row, false, true);
59  $ficon = $this->iconFactory->getIconForRecord(‪$table, $row, ‪Icon::SIZE_SMALL)->render();
60 
61  $ATag = '<a href="#" data-close="0" title="' . htmlspecialchars($this->‪getLanguageService()->getLL('addToList')) . '">';
62  $ATag_alt = '<a href="#" data-close="1" title="' . htmlspecialchars($this->‪getLanguageService()->getLL('addToList')) . '">';
63  $ATag_e = '</a>';
64  $out = '<span data-uid="' . htmlspecialchars($row['uid']) . '" data-table="' . htmlspecialchars(‪$table) . '" data-title="' . htmlspecialchars($title) . '" data-icon="' . htmlspecialchars($ficon) . '">';
65  $out .= $ATag . $this->iconFactory->getIcon('actions-add', ‪Icon::SIZE_SMALL)->render() . $ATag_e . $ATag_alt . $code . $ATag_e;
66  $out .= '</span>';
67 
68  return $out;
69  }
70 
78  protected function ‪isRowListingConditionFulfilled(‪$table, $row)
79  {
80  $returnValue = true;
81  if ($this->relatingField && $this->relatingTable) {
82  $tcaFieldConfig = ‪$GLOBALS['TCA'][‪$this->relatingTable]['columns'][‪$this->relatingField]['config'];
83  if (is_array($tcaFieldConfig['filter'])) {
84  foreach ($tcaFieldConfig['filter'] as $filter) {
85  if (!$filter['userFunc']) {
86  continue;
87  }
88  $parameters = $filter['parameters'] ?: [];
89  $parameters['values'] = [‪$table . '_' . $row['uid']];
90  $parameters['tcaFieldConfig'] = $tcaFieldConfig;
91  $valueArray = GeneralUtility::callUserFunction($filter['userFunc'], $parameters, $this);
92  if (empty($valueArray)) {
93  $returnValue = false;
94  }
95  }
96  }
97  }
98  return $returnValue;
99  }
100 
107  public function ‪setRelatingTableAndField($tableName, $fieldName)
108  {
109  // Check validity of the input data and load TCA
110  if (isset(‪$GLOBALS['TCA'][$tableName])) {
111  $this->relatingTable = $tableName;
112  if ($fieldName && isset(‪$GLOBALS['TCA'][$tableName]['columns'][$fieldName])) {
113  $this->relatingField = $fieldName;
114  }
115  }
116  }
117 
123  public function ‪generateList()
124  {
125  $this->allFields = true;
126  parent::generateList();
127  }
128 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\$relatingField
‪string $relatingField
Definition: ElementBrowserRecordList.php:38
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList
Definition: ElementBrowserRecordList.php:27
‪TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList\getLanguageService
‪LanguageService getLanguageService()
Definition: DatabaseRecordList.php:4048
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\generateList
‪generateList()
Definition: ElementBrowserRecordList.php:121
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\$relatingTable
‪string $relatingTable
Definition: ElementBrowserRecordList.php:32
‪TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList\$table
‪string $table
Definition: DatabaseRecordList.php:316
‪TYPO3\CMS\Backend\RecordList
Definition: ElementBrowserRecordList.php:16
‪TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList
Definition: DatabaseRecordList.php:57
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitlePrep
‪static string getRecordTitlePrep($title, $titleLength=0)
Definition: BackendUtility.php:1614
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitle
‪static string getRecordTitle($table, $row, $prep=false, $forceResult=true)
Definition: BackendUtility.php:1541
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\isRowListingConditionFulfilled
‪bool isRowListingConditionFulfilled($table, $row)
Definition: ElementBrowserRecordList.php:76
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\linkWrapItems
‪string linkWrapItems($table, $uid, $code, $row)
Definition: ElementBrowserRecordList.php:49
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList\setRelatingTableAndField
‪setRelatingTableAndField($tableName, $fieldName)
Definition: ElementBrowserRecordList.php:105