1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace StudioMitte \RecordlistThumbnail \Xclass ;
6
+
7
+ use StudioMitte \RecordlistThumbnail \Configuration ;
8
+ use TYPO3 \CMS \Backend \Utility \BackendUtility ;
9
+ use TYPO3 \CMS \Core \Imaging \Icon ;
10
+ use TYPO3 \CMS \Core \Utility \GeneralUtility ;
11
+ use TYPO3 \CMS \Recordlist \RecordList \DatabaseRecordList ;
12
+
13
+ class XclassedDatabaseRecordList extends DatabaseRecordList {
14
+
15
+ public function renderListRow ($ table , array $ row , int $ indent , array $ translations , bool $ translationEnabled )
16
+ {
17
+ // xclass begin
18
+ $ thumbnailField = $ this ->getThumbnailField ($ table );
19
+ // xclass end
20
+ $ titleCol = $ GLOBALS ['TCA ' ][$ table ]['ctrl ' ]['label ' ] ?? '' ;
21
+ $ languageService = $ this ->getLanguageService ();
22
+ $ rowOutput = '' ;
23
+ $ id_orig = $ this ->id ;
24
+ // If in search mode, make sure the preview will show the correct page
25
+ if ((string )$ this ->searchString !== '' ) {
26
+ $ this ->id = $ row ['pid ' ];
27
+ }
28
+
29
+ $ tagAttributes = [
30
+ 'class ' => [],
31
+ 'data-table ' => $ table ,
32
+ 'title ' => 'id= ' . $ row ['uid ' ],
33
+ ];
34
+
35
+ // Add active class to record of current link
36
+ if (
37
+ isset ($ this ->currentLink ['tableNames ' ])
38
+ && (int )$ this ->currentLink ['uid ' ] === (int )$ row ['uid ' ]
39
+ && GeneralUtility::inList ($ this ->currentLink ['tableNames ' ], $ table )
40
+ ) {
41
+ $ tagAttributes ['class ' ][] = 'active ' ;
42
+ }
43
+ // Overriding with versions background color if any:
44
+ if (!empty ($ row ['_CSSCLASS ' ])) {
45
+ $ tagAttributes ['class ' ] = [$ row ['_CSSCLASS ' ]];
46
+ }
47
+
48
+ $ tagAttributes ['class ' ][] = 't3js-entity ' ;
49
+
50
+ // Preparing and getting the data-array
51
+ $ theData = [];
52
+ $ deletePlaceholderClass = '' ;
53
+ foreach ($ this ->fieldArray as $ fCol ) {
54
+ if ($ fCol === $ titleCol ) {
55
+ $ recTitle = BackendUtility::getRecordTitle ($ table , $ row , false , true );
56
+ $ warning = '' ;
57
+ // If the record is edit-locked by another user, we will show a little warning sign:
58
+ $ lockInfo = BackendUtility::isRecordLocked ($ table , $ row ['uid ' ]);
59
+ if ($ lockInfo ) {
60
+ $ warning = '<span tabindex="0" data-bs-toggle="tooltip" data-bs-placement="right" '
61
+ . ' title=" ' . htmlspecialchars ($ lockInfo ['msg ' ]) . '" '
62
+ . ' aria-label=" ' . htmlspecialchars ($ lockInfo ['msg ' ]) . '"> '
63
+ . $ this ->iconFactory ->getIcon ('warning-in-use ' , Icon::SIZE_SMALL )->render ()
64
+ . '</span> ' ;
65
+ }
66
+ if ($ this ->isRecordDeletePlaceholder ($ row )) {
67
+ // Delete placeholder records do not link to formEngine edit and are rendered strike-through
68
+ $ deletePlaceholderClass = ' deletePlaceholder ' ;
69
+ $ theData [$ fCol ] = $ theData ['__label ' ] =
70
+ $ warning
71
+ . '<span title=" ' . htmlspecialchars ($ languageService ->sL ('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:row.deletePlaceholder.title ' )) . '"> '
72
+ . htmlspecialchars ($ recTitle )
73
+ . '</span> ' ;
74
+ } else {
75
+ $ theData [$ fCol ] = $ theData ['__label ' ] = $ warning . $ this ->linkWrapItems ($ table , $ row ['uid ' ], $ recTitle , $ row );
76
+ }
77
+
78
+ if ($ thumbnailField ) {
79
+ $ fullRow = isset ($ row [$ thumbnailField ]) ? $ row : BackendUtility::getRecord ($ table , $ row ['uid ' ]);
80
+
81
+ $ thumbCode = '<br /> ' . BackendUtility::thumbCode ($ fullRow , $ table , $ thumbnailField );
82
+ $ theData [$ fCol ] .= $ thumbCode ;
83
+ $ theData ['__label ' ] .= $ thumbCode ;
84
+ }
85
+ } elseif ($ fCol === 'pid ' ) {
86
+ $ theData [$ fCol ] = $ row [$ fCol ];
87
+ } elseif ($ fCol !== '' && $ fCol === ($ GLOBALS ['TCA ' ][$ table ]['ctrl ' ]['cruser_id ' ] ?? '' )) {
88
+ $ theData [$ fCol ] = $ this ->getBackendUserInformation ((int )$ row [$ fCol ]);
89
+ } elseif ($ fCol === '_SELECTOR_ ' ) {
90
+ if ($ table !== 'pages ' || !$ this ->showOnlyTranslatedRecords ) {
91
+ // Add checkbox for all tables except the special page translations table
92
+ $ theData [$ fCol ] = $ this ->makeCheckbox ($ table , $ row );
93
+ } else {
94
+ // Remove "_SELECTOR_", which is always the first item, from the field list
95
+ array_splice ($ this ->fieldArray , 0 , 1 );
96
+ }
97
+ } elseif ($ fCol === 'icon ' ) {
98
+ $ iconImg = '
99
+ <span ' . BackendUtility::getRecordToolTip ($ row , $ table ) . ' ' . ($ indent ? ' style="margin-left: ' . $ indent . 'px;" ' : '' ) . '>
100
+ ' . $ this ->iconFactory ->getIconForRecord ($ table , $ row , Icon::SIZE_SMALL )->render () . '
101
+ </span> ' ;
102
+ $ theData [$ fCol ] = ($ this ->clickMenuEnabled && !$ this ->isRecordDeletePlaceholder ($ row )) ? BackendUtility::wrapClickMenuOnIcon ($ iconImg , $ table , $ row ['uid ' ]) : $ iconImg ;
103
+ } elseif ($ fCol === '_PATH_ ' ) {
104
+ $ theData [$ fCol ] = $ this ->recPath ($ row ['pid ' ]);
105
+ } elseif ($ fCol === '_REF_ ' ) {
106
+ $ theData [$ fCol ] = $ this ->generateReferenceToolTip ($ table , $ row ['uid ' ]);
107
+ } elseif ($ fCol === '_CONTROL_ ' ) {
108
+ $ theData [$ fCol ] = $ this ->makeControl ($ table , $ row );
109
+ } elseif ($ fCol === '_LOCALIZATION_ ' ) {
110
+ // Language flag an title
111
+ $ theData [$ fCol ] = $ this ->languageFlag ($ table , $ row );
112
+ // Localize record
113
+ $ localizationPanel = $ translationEnabled ? $ this ->makeLocalizationPanel ($ table , $ row , $ translations ) : '' ;
114
+ if ($ localizationPanel !== '' ) {
115
+ $ theData ['_LOCALIZATION_b ' ] = '<div class="btn-group"> ' . $ localizationPanel . '</div> ' ;
116
+ $ this ->showLocalizeColumn [$ table ] = true ;
117
+ }
118
+ } elseif ($ fCol !== '_LOCALIZATION_b ' ) {
119
+ // default for all other columns, except "_LOCALIZATION_b"
120
+ $ pageId = $ table === 'pages ' ? $ row ['uid ' ] : $ row ['pid ' ];
121
+ $ tmpProc = BackendUtility::getProcessedValueExtra ($ table , $ fCol , $ row [$ fCol ], 100 , $ row ['uid ' ], true , $ pageId );
122
+ $ theData [$ fCol ] = $ this ->linkUrlMail (htmlspecialchars ((string )$ tmpProc ), (string )($ row [$ fCol ] ?? '' ));
123
+ }
124
+ }
125
+ // Reset the ID if it was overwritten
126
+ if ((string )$ this ->searchString !== '' ) {
127
+ $ this ->id = $ id_orig ;
128
+ }
129
+ // Add classes to table cells
130
+ $ this ->addElement_tdCssClass ['_SELECTOR_ ' ] = 'col-selector ' ;
131
+ $ this ->addElement_tdCssClass [$ titleCol ] = 'col-title col-responsive ' . $ deletePlaceholderClass ;
132
+ $ this ->addElement_tdCssClass ['__label ' ] = $ this ->addElement_tdCssClass [$ titleCol ];
133
+ $ this ->addElement_tdCssClass ['icon ' ] = 'col-icon ' ;
134
+ $ this ->addElement_tdCssClass ['_CONTROL_ ' ] = 'col-control ' ;
135
+ $ this ->addElement_tdCssClass ['_PATH_ ' ] = 'col-path ' ;
136
+ $ this ->addElement_tdCssClass ['_LOCALIZATION_ ' ] = 'col-localizationa ' ;
137
+ $ this ->addElement_tdCssClass ['_LOCALIZATION_b ' ] = 'col-localizationb ' ;
138
+ // Create element in table cells:
139
+ $ theData ['uid ' ] = $ row ['uid ' ];
140
+ if (isset ($ GLOBALS ['TCA ' ][$ table ]['ctrl ' ]['languageField ' ])
141
+ && isset ($ GLOBALS ['TCA ' ][$ table ]['ctrl ' ]['transOrigPointerField ' ])
142
+ ) {
143
+ $ theData ['_l10nparent_ ' ] = $ row [$ GLOBALS ['TCA ' ][$ table ]['ctrl ' ]['transOrigPointerField ' ]];
144
+ }
145
+
146
+ $ tagAttributes = array_map (
147
+ static function ($ attributeValue ) {
148
+ if (is_array ($ attributeValue )) {
149
+ return implode (' ' , $ attributeValue );
150
+ }
151
+ return $ attributeValue ;
152
+ },
153
+ $ tagAttributes
154
+ );
155
+
156
+ $ rowOutput .= $ this ->addElement ($ theData , GeneralUtility::implodeAttributes ($ tagAttributes , true ));
157
+ // Finally, return table row element:
158
+ return $ rowOutput ;
159
+ }
160
+
161
+ protected function getThumbnailField (string $ tableName ): string
162
+ {
163
+ return GeneralUtility::makeInstance (Configuration::class)->getField ($ tableName );
164
+ }
165
+ }
0 commit comments