[TASK] Remove second parameter of sL - Part 1/3
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / RecordList / ElementBrowserRecordList.php
1 <?php
2 namespace TYPO3\CMS\Backend\RecordList;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Core\Imaging\Icon;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList;
21
22 /**
23 * Displays the page tree for browsing database records.
24 */
25 class ElementBrowserRecordList extends DatabaseRecordList
26 {
27 /**
28 * Table name of the field pointing to this element browser
29 *
30 * @var string
31 */
32 protected $relatingTable;
33
34 /**
35 * Field name of the field pointing to this element browser
36 *
37 * @var string
38 */
39 protected $relatingField;
40
41 /**
42 * Returns the title (based on $code) of a record (from table $table) with the proper link around (that is for "pages"-records a link to the level of that record...)
43 *
44 * @param string $table Table name
45 * @param int $uid UID (not used here)
46 * @param string $code Title string
47 * @param array $row Records array (from table name)
48 * @return string
49 */
50 public function linkWrapItems($table, $uid, $code, $row)
51 {
52 if (!$code) {
53 $code = '<i>[' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title')) . ']</i>';
54 } else {
55 $code = BackendUtility::getRecordTitlePrep($code, $this->fixedL);
56 }
57 $title = BackendUtility::getRecordTitle($table, $row, false, true);
58 $ficon = $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render();
59
60 $ATag = '<a href="#" data-close="0" title="' . htmlspecialchars($this->getLanguageService()->getLL('addToList')) . '">';
61 $ATag_alt = '<a href="#" data-close="1" title="' . htmlspecialchars($this->getLanguageService()->getLL('addToList')) . '">';
62 $ATag_e = '</a>';
63 $out = '<span data-uid="' . htmlspecialchars($row['uid']) . '" data-table="' . htmlspecialchars($table) . '" data-title="' . htmlspecialchars($title) . '" data-icon="' . htmlspecialchars($ficon) . '">';
64 $out .= $ATag . $this->iconFactory->getIcon('actions-edit-add', Icon::SIZE_SMALL)->render() . $ATag_e . $ATag_alt . $code . $ATag_e;
65 $out .= '</span>';
66
67 return $out;
68 }
69
70 /**
71 * Check if all row listing conditions are fulfilled.
72 *
73 * @param string $table String Table name
74 * @param array $row Array Record
75 * @return bool True, if all conditions are fulfilled.
76 */
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'])) {
83 foreach ($tcaFieldConfig['filter'] as $filter) {
84 if (!$filter['userFunc']) {
85 continue;
86 }
87 $parameters = $filter['parameters'] ?: array();
88 $parameters['values'] = array($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 }
97 return $returnValue;
98 }
99
100 /**
101 * Set which pointing field (in the TCEForm) we are currently rendering the element browser for
102 *
103 * @param string $tableName Table name
104 * @param string $fieldName Field name
105 */
106 public function setRelatingTableAndField($tableName, $fieldName)
107 {
108 // Check validity of the input data and load TCA
109 if (isset($GLOBALS['TCA'][$tableName])) {
110 $this->relatingTable = $tableName;
111 if ($fieldName && isset($GLOBALS['TCA'][$tableName]['columns'][$fieldName])) {
112 $this->relatingField = $fieldName;
113 }
114 }
115 }
116
117 /**
118 * Local version that sets allFields to TRUE to support userFieldSelect
119 *
120 * @return void
121 * @see fieldSelectBox
122 */
123 public function generateList()
124 {
125 $this->allFields = true;
126 parent::generateList();
127 }
128 }