[CLEANUP] Remove/Replace non-standard phpdoc annotations
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / RecordList / DatabaseRecordList.php
1 <?php
2 namespace TYPO3\CMS\Recordlist\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\Configuration\TranslationConfigurationProvider;
18 use TYPO3\CMS\Backend\Module\BaseScriptClass;
19 use TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface;
20 use TYPO3\CMS\Backend\Routing\UriBuilder;
21 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
22 use TYPO3\CMS\Backend\Template\DocumentTemplate;
23 use TYPO3\CMS\Backend\Template\ModuleTemplate;
24 use TYPO3\CMS\Backend\Tree\View\PageTreeView;
25 use TYPO3\CMS\Backend\Utility\BackendUtility;
26 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
27 use TYPO3\CMS\Core\Database\Connection;
28 use TYPO3\CMS\Core\Database\ConnectionPool;
29 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
30 use TYPO3\CMS\Core\Database\Query\QueryHelper;
31 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
32 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
33 use TYPO3\CMS\Core\Imaging\Icon;
34 use TYPO3\CMS\Core\Imaging\IconFactory;
35 use TYPO3\CMS\Core\Localization\LanguageService;
36 use TYPO3\CMS\Core\Log\LogManager;
37 use TYPO3\CMS\Core\Messaging\FlashMessage;
38 use TYPO3\CMS\Core\Messaging\FlashMessageService;
39 use TYPO3\CMS\Core\Service\DependencyOrderingService;
40 use TYPO3\CMS\Core\Type\Bitmask\Permission;
41 use TYPO3\CMS\Core\Utility\CsvUtility;
42 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
43 use TYPO3\CMS\Core\Utility\GeneralUtility;
44 use TYPO3\CMS\Core\Utility\HttpUtility;
45 use TYPO3\CMS\Core\Utility\MathUtility;
46 use TYPO3\CMS\Frontend\Page\PageRepository;
47
48 /**
49 * Class for rendering of Web>List module
50 */
51 class DatabaseRecordList
52 {
53 // *********
54 // External:
55 // *********
56
57 /**
58 * Used to indicate which tables (values in the array) that can have a
59 * create-new-record link. If the array is empty, all tables are allowed.
60 *
61 * @var string[]
62 */
63 public $allowedNewTables = [];
64
65 /**
66 * Used to indicate which tables (values in the array) that cannot have a
67 * create-new-record link. If the array is empty, all tables are allowed.
68 *
69 * @var string[]
70 */
71 public $deniedNewTables = [];
72
73 /**
74 * If TRUE, the control panel will contain links to the create-new wizards for
75 * pages and tt_content elements (normally, the link goes to just creatinga new
76 * element without the wizards!).
77 *
78 * @var bool
79 */
80 public $newWizards = false;
81
82 /**
83 * If TRUE, will disable the rendering of clipboard + control panels.
84 *
85 * @var bool
86 */
87 public $dontShowClipControlPanels = false;
88
89 /**
90 * If TRUE, will show the clipboard in the field list.
91 *
92 * @var bool
93 */
94 public $showClipboard = false;
95
96 /**
97 * If TRUE, will DISABLE all control panels in lists. (Takes precedence)
98 *
99 * @var bool
100 */
101 public $noControlPanels = false;
102
103 /**
104 * If TRUE, clickmenus will be rendered
105 *
106 * @var bool
107 */
108 public $clickMenuEnabled = true;
109
110 /**
111 * Count of record rows in view
112 *
113 * @var int
114 */
115 public $totalRowCount;
116
117 /**
118 * Space icon used for alignment
119 *
120 * @var string
121 */
122 public $spaceIcon;
123
124 /**
125 * Disable single table view
126 *
127 * @var bool
128 */
129 public $disableSingleTableView = false;
130
131 // *********
132 // Internal:
133 // *********
134
135 /**
136 * Set to the page record (see writeTop())
137 *
138 * @var string[]
139 */
140 public $pageRow = [];
141
142 /**
143 * Shared module configuration, used by localization features
144 *
145 * @var array
146 */
147 public $modSharedTSconfig = [];
148
149 /**
150 * Contains page translation languages
151 *
152 * @var array
153 */
154 public $pageOverlays = [];
155
156 /**
157 * Contains sys language icons and titles
158 *
159 * @var array
160 */
161 public $languageIconTitles = [];
162
163 /**
164 * Tables which should not list their translations
165 *
166 * @var string
167 */
168 public $hideTranslations = '';
169
170 /**
171 * If set, the listing is returned as CSV instead.
172 *
173 * @var bool
174 */
175 public $csvOutput = false;
176
177 /**
178 * Cache for record path
179 *
180 * @var mixed[]
181 */
182 public $recPath_cache = [];
183
184 /**
185 * Field, to sort list by
186 *
187 * @var string
188 */
189 public $sortField;
190
191 /**
192 * default Max items shown per table in "multi-table mode", may be overridden by tables.php
193 *
194 * @var int
195 */
196 public $itemsLimitPerTable = 20;
197
198 /**
199 * Keys are fieldnames and values are td-parameters to add in addElement(), please use $addElement_tdCSSClass for CSS-classes;
200 *
201 * @var array
202 */
203 public $addElement_tdParams = [];
204
205 /**
206 * Page id
207 *
208 * @var int
209 */
210 public $id;
211
212 /**
213 * @var int
214 */
215 public $no_noWrap = 0;
216
217 /**
218 * Set to zero, if you don't want a left-margin with addElement function
219 *
220 * @var int
221 */
222 public $setLMargin = 1;
223
224 /**
225 * Used for tracking duplicate values of fields
226 *
227 * @var string[]
228 */
229 public $duplicateStack = [];
230
231 /**
232 * Current script name
233 *
234 * @var string
235 */
236 public $script = 'index.php';
237
238 /**
239 * If TRUE, records are listed only if a specific table is selected.
240 *
241 * @var bool
242 */
243 public $listOnlyInSingleTableMode = false;
244
245 /**
246 * Script URL
247 *
248 * @var string
249 */
250 public $thisScript = '';
251
252 /**
253 * JavaScript code accumulation
254 *
255 * @var string
256 */
257 public $JScode = '';
258
259 /**
260 * @var TranslationConfigurationProvider
261 */
262 public $translateTools;
263
264 /**
265 * default Max items shown per table in "single-table mode", may be overridden by tables.php
266 *
267 * @var int
268 */
269 public $itemsLimitSingleTable = 100;
270
271 /**
272 * Array of collapsed / uncollapsed tables in multi table view
273 *
274 * @var int[][]
275 */
276 public $tablesCollapsed = [];
277
278 /**
279 * @var array[] Module configuration
280 */
281 public $modTSconfig;
282
283 /**
284 * String with accumulated HTML content
285 *
286 * @var string
287 */
288 public $HTMLcode = '';
289
290 /**
291 * Keys are fieldnames and values are td-css-classes to add in addElement();
292 *
293 * @var array
294 */
295 public $addElement_tdCssClass = [];
296
297 /**
298 * Thumbnails on records containing files (pictures)
299 *
300 * @var bool
301 */
302 public $thumbs = 0;
303
304 /**
305 * Used for tracking next/prev uids
306 *
307 * @var int[][]
308 */
309 public $currentTable = [];
310
311 /**
312 * Indicates if all available fields for a user should be selected or not.
313 *
314 * @var int
315 */
316 public $allFields = 0;
317
318 /**
319 * Number of records to show
320 *
321 * @var int
322 */
323 public $showLimit = 0;
324
325 /**
326 * Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column.
327 *
328 * @var array
329 */
330 public $fieldArray = [];
331
332 /**
333 * Tables which should not get listed
334 *
335 * @var string
336 */
337 public $hideTables = '';
338
339 /**
340 * Containing which fields to display in extended mode
341 *
342 * @var string[]
343 */
344 public $displayFields;
345
346 /**
347 * If set this is <td> CSS-classname for odd columns in addElement. Used with db_layout / pages section
348 *
349 * @var string
350 */
351 public $oddColumnsCssClass = '';
352
353 /**
354 * Not used in this class - but maybe extension classes...
355 * Max length of strings
356 *
357 * @var int
358 */
359 public $fixedL = 30;
360
361 /**
362 * Page select permissions
363 *
364 * @var string
365 */
366 public $perms_clause = '';
367
368 /**
369 * Return URL
370 *
371 * @var string
372 */
373 public $returnUrl = '';
374
375 /**
376 * Tablename if single-table mode
377 *
378 * @var string
379 */
380 public $table = '';
381
382 /**
383 * Some permissions...
384 *
385 * @var int
386 */
387 public $calcPerms = 0;
388
389 /**
390 * Mode for what happens when a user clicks the title of a record.
391 *
392 * @var string
393 */
394 public $clickTitleMode = '';
395
396 /**
397 * @var int
398 */
399 public $showIcon = 1;
400
401 /**
402 * Levels to search down.
403 *
404 * @var int
405 */
406 public $searchLevels = '';
407
408 /**
409 * "LIMIT " in SQL...
410 *
411 * @var int
412 */
413 public $iLimit = 0;
414
415 /**
416 * Set to the total number of items for a table when selecting.
417 *
418 * @var string
419 */
420 public $totalItems = '';
421
422 /**
423 * OBSOLETE - NOT USED ANYMORE. leftMargin
424 *
425 * @var int
426 */
427 public $leftMargin = 0;
428
429 /**
430 * TSconfig which overwrites TCA-Settings
431 *
432 * @var mixed[][]
433 */
434 public $tableTSconfigOverTCA = [];
435
436 /**
437 * Loaded with page record with version overlay if any.
438 *
439 * @var string[]
440 */
441 public $pageRecord = [];
442
443 /**
444 * Fields to display for the current table
445 *
446 * @var string[]
447 */
448 public $setFields = [];
449
450 /**
451 * Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard
452 *
453 * @var int
454 */
455 public $counter = 0;
456
457 /**
458 * Pointer for browsing list
459 *
460 * @var int
461 */
462 public $firstElementNumber = 0;
463
464 /**
465 * Counting the elements no matter what...
466 *
467 * @var int
468 */
469 public $eCounter = 0;
470
471 /**
472 * Search string
473 *
474 * @var string
475 */
476 public $searchString = '';
477
478 /**
479 * Field, indicating to sort in reverse order.
480 *
481 * @var bool
482 */
483 public $sortRev;
484
485 /**
486 * String, can contain the field name from a table which must have duplicate values marked.
487 *
488 * @var string
489 */
490 public $duplicateField;
491
492 /**
493 * Specify a list of tables which are the only ones allowed to be displayed.
494 *
495 * @var string
496 */
497 public $tableList = '';
498
499 /**
500 * Used to accumulate CSV lines for CSV export.
501 *
502 * @var string[]
503 */
504 protected $csvLines = [];
505
506 /**
507 * Clipboard object
508 *
509 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
510 */
511 public $clipObj;
512
513 /**
514 * Tracking names of elements (for clipboard use)
515 *
516 * @var string[]
517 */
518 public $CBnames = [];
519
520 /**
521 * [$tablename][$uid] = number of references to this record
522 *
523 * @var int[][]
524 */
525 protected $referenceCount = [];
526
527 /**
528 * Translations of the current record
529 *
530 * @var string[]
531 */
532 public $translations;
533
534 /**
535 * select fields for the query which fetches the translations of the current
536 * record
537 *
538 * @var string
539 */
540 public $selFieldList;
541
542 /**
543 * @var mixed[]
544 */
545 public $pageinfo;
546
547 /**
548 * Injected by RecordList
549 *
550 * @var string[]
551 */
552 public $MOD_MENU;
553
554 /**
555 * If defined the records are editable
556 *
557 * @var bool
558 */
559 protected $editable = true;
560
561 /**
562 * @var IconFactory
563 */
564 protected $iconFactory;
565
566 /**
567 * Array with before/after setting for tables
568 * Structure:
569 * 'tableName' => [
570 * 'before' => ['A', ...]
571 * 'after' => []
572 * ]
573 *
574 * @var array[]
575 */
576 protected $tableDisplayOrder = [];
577
578 /**
579 * Override the page ids taken into account by getPageIdConstraint()
580 *
581 * @var array
582 */
583 protected $overridePageIdList = [];
584
585 /**
586 * Override/add urlparameters in listUrl() method
587 * @var string[]
588 */
589 protected $overrideUrlParameters = [];
590
591 /**
592 * Only used to render translated records, used in list module to show page translations
593 *
594 * @var bool
595 */
596 protected $showOnlyTranslatedRecords = false;
597
598 /**
599 * Constructor
600 */
601 public function __construct()
602 {
603 if (isset($GLOBALS['BE_USER']->uc['titleLen']) && $GLOBALS['BE_USER']->uc['titleLen'] > 0) {
604 $this->fixedL = $GLOBALS['BE_USER']->uc['titleLen'];
605 }
606 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
607 $this->getTranslateTools();
608 $this->determineScriptUrl();
609
610 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
611 }
612
613 /**
614 * Create the panel of buttons for submitting the form or otherwise perform
615 * operations.
616 *
617 * @return string[] All available buttons as an assoc. array
618 */
619 public function getButtons()
620 {
621 $module = $this->getModule();
622 $backendUser = $this->getBackendUserAuthentication();
623 $lang = $this->getLanguageService();
624 $buttons = [
625 'csh' => '',
626 'view' => '',
627 'edit' => '',
628 'hide_unhide' => '',
629 'move' => '',
630 'new_record' => '',
631 'paste' => '',
632 'level_up' => '',
633 'cache' => '',
634 'reload' => '',
635 'shortcut' => '',
636 'back' => '',
637 'csv' => '',
638 'export' => ''
639 ];
640 // Get users permissions for this page record:
641 $localCalcPerms = $backendUser->calcPerms($this->pageRow);
642 // CSH
643 if ((string)$this->id === '') {
644 $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_noId');
645 } elseif (!$this->id) {
646 $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_root');
647 } else {
648 $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module');
649 }
650 if (isset($this->id)) {
651 // View Exclude doktypes 254,255 Configuration:
652 // mod.web_list.noViewWithDokTypes = 254,255
653 if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
654 $noViewDokTypes = GeneralUtility::trimExplode(',', $module->modTSconfig['properties']['noViewWithDokTypes'], true);
655 } else {
656 //default exclusion: doktype 254 (folder), 255 (recycler)
657 $noViewDokTypes = [
658 PageRepository::DOKTYPE_SYSFOLDER,
659 PageRepository::DOKTYPE_RECYCLER
660 ];
661 }
662 if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
663 $onClick = htmlspecialchars(BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id)));
664 $buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
665 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">'
666 . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
667 }
668 // New record on pages that are not locked by editlock
669 if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
670 $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => $this->id])) . ');');
671 $buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
672 . htmlspecialchars($lang->getLL('newRecordGeneral')) . '">'
673 . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . '</a>';
674 }
675 // If edit permissions are set, see
676 // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
677 if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions() && $this->getBackendUserAuthentication()->checkLanguageAccess(0)) {
678 // Edit
679 $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
680 $onClick = htmlspecialchars(BackendUtility::editOnClick($params, '', -1));
681 $buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="' . htmlspecialchars($lang->getLL('editPage')) . '">'
682 . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render()
683 . '</a>';
684 }
685 // Paste
686 if (($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
687 $elFromTable = $this->clipObj->elFromTable('');
688 if (!empty($elFromTable)) {
689 $confirmText = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
690 $buttons['paste'] = '<a'
691 . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id)) . '"'
692 . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
693 . ' class="t3js-modal-trigger"'
694 . ' data-severity="warning"'
695 . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
696 . ' data-content="' . htmlspecialchars($confirmText) . '"'
697 . '>'
698 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
699 . '</a>';
700 }
701 }
702 // Cache
703 $buttons['cache'] = '<a href="' . htmlspecialchars(($this->listURL() . '&clear_cache=1')) . '" title="'
704 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clear_cache')) . '">'
705 . $this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL)->render() . '</a>';
706 if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
707 || (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
708 && !$module->modTSconfig['properties']['noExportRecordsLinks']))
709 ) {
710 // CSV
711 $buttons['csv'] = '<a href="' . htmlspecialchars(($this->listURL() . '&csv=1')) . '" title="'
712 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.csv')) . '">'
713 . $this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL)->render() . '</a>';
714 // Export
715 if (ExtensionManagementUtility::isLoaded('impexp')) {
716 $url = BackendUtility::getModuleUrl('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
717 $buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
718 . rawurlencode($this->table . ':' . $this->id)) . '" title="'
719 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.export')) . '">'
720 . $this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL)->render() . '</a>';
721 }
722 }
723 // Reload
724 $buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
725 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.reload')) . '">'
726 . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a>';
727 // Shortcut
728 if ($backendUser->mayMakeShortcut()) {
729 $buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
730 'id, M, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
731 implode(',', array_keys($this->MOD_MENU)),
732 'web_list'
733 );
734 }
735 // Back
736 if ($this->returnUrl) {
737 $href = htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl, ['id' => $this->id]));
738 $buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
739 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack')) . '">'
740 . $this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL)->render() . '</a>';
741 }
742 }
743 return $buttons;
744 }
745
746 /**
747 * Create the panel of buttons for submitting the form or otherwise perform
748 * operations.
749 *
750 * @param ModuleTemplate $moduleTemplate
751 */
752 public function getDocHeaderButtons(ModuleTemplate $moduleTemplate)
753 {
754 $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
755 $module = $this->getModule();
756 $backendUser = $this->getBackendUserAuthentication();
757 $lang = $this->getLanguageService();
758 // Get users permissions for this page record:
759 $localCalcPerms = $backendUser->calcPerms($this->pageRow);
760 // CSH
761 if ((string)$this->id === '') {
762 $fieldName = 'list_module_noId';
763 } elseif (!$this->id) {
764 $fieldName = 'list_module_root';
765 } else {
766 $fieldName = 'list_module';
767 }
768 $cshButton = $buttonBar->makeHelpButton()
769 ->setModuleName('xMOD_csh_corebe')
770 ->setFieldName($fieldName);
771 $buttonBar->addButton($cshButton);
772 if (isset($this->id)) {
773 // View Exclude doktypes 254,255 Configuration:
774 // mod.web_list.noViewWithDokTypes = 254,255
775 if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
776 $noViewDokTypes = GeneralUtility::trimExplode(',', $module->modTSconfig['properties']['noViewWithDokTypes'], true);
777 } else {
778 //default exclusion: doktype 254 (folder), 255 (recycler)
779 $noViewDokTypes = [
780 PageRepository::DOKTYPE_SYSFOLDER,
781 PageRepository::DOKTYPE_RECYCLER
782 ];
783 }
784 // New record on pages that are not locked by editlock
785 if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
786 $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => $this->id])) . ');';
787 $newRecordButton = $buttonBar->makeLinkButton()
788 ->setHref('#')
789 ->setOnClick($onClick)
790 ->setTitle($lang->getLL('newRecordGeneral'))
791 ->setIcon($this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
792 $buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
793 }
794 if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
795 $onClick = BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id));
796 $viewButton = $buttonBar->makeLinkButton()
797 ->setHref('#')
798 ->setOnClick($onClick)
799 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
800 ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL));
801 $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
802 }
803 // If edit permissions are set, see
804 // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
805 if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions()) {
806 // Edit
807 $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
808 $onClick = BackendUtility::editOnClick($params, '', -1);
809 $editButton = $buttonBar->makeLinkButton()
810 ->setHref('#')
811 ->setOnClick($onClick)
812 ->setTitle($lang->getLL('editPage'))
813 ->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
814 $buttonBar->addButton($editButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
815 }
816 // Paste
817 if ($this->showClipboard && ($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
818 $elFromTable = $this->clipObj->elFromTable('');
819 if (!empty($elFromTable)) {
820 $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
821 $pasteButton = $buttonBar->makeLinkButton()
822 ->setHref($this->clipObj->pasteUrl('', $this->id))
823 ->setTitle($lang->getLL('clip_paste'))
824 ->setClasses('t3js-modal-trigger')
825 ->setDataAttributes([
826 'severity' => 'warning',
827 'content' => $confirmMessage,
828 'title' => $lang->getLL('clip_paste')
829 ])
830 ->setIcon($this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL));
831 $buttonBar->addButton($pasteButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
832 }
833 }
834 // Cache
835 $clearCacheButton = $buttonBar->makeLinkButton()
836 ->setHref($this->listURL() . '&clear_cache=1')
837 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
838 ->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
839 $buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT);
840 if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
841 || (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
842 && !$module->modTSconfig['properties']['noExportRecordsLinks']))
843 ) {
844 // CSV
845 $csvButton = $buttonBar->makeLinkButton()
846 ->setHref($this->listURL() . '&csv=1')
847 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.csv'))
848 ->setIcon($this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL));
849 $buttonBar->addButton($csvButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
850 // Export
851 if (ExtensionManagementUtility::isLoaded('impexp')) {
852 $url = BackendUtility::getModuleUrl('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
853 $exportButton = $buttonBar->makeLinkButton()
854 ->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id))
855 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.export'))
856 ->setIcon($this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL));
857 $buttonBar->addButton($exportButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
858 }
859 }
860 // Reload
861 $reloadButton = $buttonBar->makeLinkButton()
862 ->setHref($this->listURL())
863 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.reload'))
864 ->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
865 $buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
866 // Shortcut
867 if ($backendUser->mayMakeShortcut()) {
868 $shortCutButton = $buttonBar->makeShortcutButton()
869 ->setModuleName('web_list')
870 ->setGetVariables([
871 'id',
872 'route',
873 'imagemode',
874 'pointer',
875 'table',
876 'search_field',
877 'search_levels',
878 'showLimit',
879 'sortField',
880 'sortRev'
881 ])
882 ->setSetVariables(array_keys($this->MOD_MENU));
883 $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
884 }
885 // Back
886 if ($this->returnUrl) {
887 $backButton = $buttonBar->makeLinkButton()
888 ->setHref($this->returnUrl)
889 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
890 ->setIcon($this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
891 $buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT);
892 }
893 }
894 }
895
896 /**
897 * Creates the listing of records from a single table
898 *
899 * @param string $table Table name
900 * @param int $id Page id
901 * @param string $rowList List of fields to show in the listing. Pseudo fields will be added including the record header.
902 * @throws \UnexpectedValueException
903 * @return string HTML table with the listing for the record.
904 */
905 public function getTable($table, $id, $rowList = '')
906 {
907 $rowListArray = GeneralUtility::trimExplode(',', $rowList, true);
908 // if no columns have been specified, show description (if configured)
909 if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
910 $rowListArray[] = $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn'];
911 }
912 $backendUser = $this->getBackendUserAuthentication();
913 $lang = $this->getLanguageService();
914 // Init
915 $addWhere = '';
916 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
917 $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
918 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
919 $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
920 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
921 $tableCollapsed = (bool)$this->tablesCollapsed[$table];
922 // prepare space icon
923 $this->spaceIcon = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
924 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
925 $this->fieldArray = [];
926 // title Column
927 // Add title column
928 $this->fieldArray[] = $titleCol;
929 // Control-Panel
930 if (!GeneralUtility::inList($rowList, '_CONTROL_')) {
931 $this->fieldArray[] = '_CONTROL_';
932 }
933 // Clipboard
934 if ($this->showClipboard) {
935 $this->fieldArray[] = '_CLIPBOARD_';
936 }
937 // Ref
938 if (!$this->dontShowClipControlPanels) {
939 $this->fieldArray[] = '_REF_';
940 }
941 // Path
942 if ($this->searchLevels) {
943 $this->fieldArray[] = '_PATH_';
944 }
945 // Localization
946 if ($l10nEnabled) {
947 $this->fieldArray[] = '_LOCALIZATION_';
948 // Do not show the "Localize to:" field when only translated records should be shown
949 if (!$this->showOnlyTranslatedRecords) {
950 $this->fieldArray[] = '_LOCALIZATION_b';
951 }
952 // Only restrict to the default language if no search request is in place
953 // And if only translations should be shown
954 if ($this->searchString === '' && !$this->showOnlyTranslatedRecords) {
955 $addWhere = (string)$queryBuilder->expr()->orX(
956 $queryBuilder->expr()->lte($GLOBALS['TCA'][$table]['ctrl']['languageField'], 0),
957 $queryBuilder->expr()->eq($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], 0)
958 );
959 }
960 }
961 // Cleaning up:
962 $this->fieldArray = array_unique(array_merge($this->fieldArray, $rowListArray));
963 if ($this->noControlPanels) {
964 $tempArray = array_flip($this->fieldArray);
965 unset($tempArray['_CONTROL_']);
966 unset($tempArray['_CLIPBOARD_']);
967 $this->fieldArray = array_keys($tempArray);
968 }
969 // Creating the list of fields to include in the SQL query:
970 $selectFields = $this->fieldArray;
971 $selectFields[] = 'uid';
972 $selectFields[] = 'pid';
973 // adding column for thumbnails
974 if ($thumbsCol) {
975 $selectFields[] = $thumbsCol;
976 }
977 if ($table === 'pages') {
978 $selectFields[] = 'module';
979 $selectFields[] = 'extendToSubpages';
980 $selectFields[] = 'nav_hide';
981 $selectFields[] = 'doktype';
982 $selectFields[] = 'shortcut';
983 $selectFields[] = 'shortcut_mode';
984 $selectFields[] = 'mount_pid';
985 }
986 if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
987 $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
988 }
989 foreach (['type', 'typeicon_column', 'editlock'] as $field) {
990 if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
991 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
992 }
993 }
994 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
995 $selectFields[] = 't3ver_id';
996 $selectFields[] = 't3ver_state';
997 $selectFields[] = 't3ver_wsid';
998 }
999 if ($l10nEnabled) {
1000 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
1001 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
1002 }
1003 if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
1004 $selectFields = array_merge(
1005 $selectFields,
1006 GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true)
1007 );
1008 }
1009 // Unique list!
1010 $selectFields = array_unique($selectFields);
1011 $fieldListFields = $this->makeFieldList($table, 1);
1012 if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
1013 $message = sprintf($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'), $table, $table);
1014 $messageTitle = $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle');
1015 /** @var FlashMessage $flashMessage */
1016 $flashMessage = GeneralUtility::makeInstance(
1017 FlashMessage::class,
1018 $message,
1019 $messageTitle,
1020 FlashMessage::WARNING,
1021 true
1022 );
1023 /** @var $flashMessageService FlashMessageService */
1024 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
1025 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
1026 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1027 $defaultFlashMessageQueue->enqueue($flashMessage);
1028 }
1029 // Making sure that the fields in the field-list ARE in the field-list from TCA!
1030 $selectFields = array_intersect($selectFields, $fieldListFields);
1031 // Implode it into a list of fields for the SQL-statement.
1032 $selFieldList = implode(',', $selectFields);
1033 $this->selFieldList = $selFieldList;
1034 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
1035 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $className) {
1036 $hookObject = GeneralUtility::makeInstance($className);
1037 if (!$hookObject instanceof RecordListGetTableHookInterface) {
1038 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListGetTableHookInterface::class, 1195114460);
1039 }
1040 $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
1041 }
1042 }
1043 $additionalConstraints = empty($addWhere) ? [] : [QueryHelper::stripLogicalOperatorPrefix($addWhere)];
1044 $selFieldList = GeneralUtility::trimExplode(',', $selFieldList, true);
1045
1046 // Create the SQL query for selecting the elements in the listing:
1047 // do not do paging when outputting as CSV
1048 if ($this->csvOutput) {
1049 $this->iLimit = 0;
1050 }
1051 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
1052 // Get the two previous rows for sorting if displaying page > 1
1053 $this->firstElementNumber -= 2;
1054 $this->iLimit += 2;
1055 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1056 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
1057 $this->firstElementNumber += 2;
1058 $this->iLimit -= 2;
1059 } else {
1060 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1061 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
1062 }
1063
1064 // Finding the total amount of records on the page
1065 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1066 $this->setTotalItems($table, $id, $additionalConstraints);
1067
1068 // Init:
1069 $queryResult = $queryBuilder->execute();
1070 $dbCount = 0;
1071 $out = '';
1072 $tableHeader = '';
1073 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
1074 // If the count query returned any number of records, we perform the real query,
1075 // selecting records.
1076 if ($this->totalItems) {
1077 // Fetch records only if not in single table mode
1078 if ($listOnlyInSingleTableMode) {
1079 $dbCount = $this->totalItems;
1080 } else {
1081 // Set the showLimit to the number of records when outputting as CSV
1082 if ($this->csvOutput) {
1083 $this->showLimit = $this->totalItems;
1084 $this->iLimit = $this->totalItems;
1085 }
1086 $dbCount = $queryResult->rowCount();
1087 }
1088 }
1089 // If any records was selected, render the list:
1090 if ($dbCount) {
1091 // Use a custom table title for translated pages
1092 if ($table == 'pages' && $this->showOnlyTranslatedRecords) {
1093 $tableTitle = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:pageTranslation'));
1094 } else {
1095 $tableTitle = htmlspecialchars($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
1096 if ($tableTitle === '') {
1097 $tableTitle = $table;
1098 }
1099 }
1100 // Header line is drawn
1101 $theData = [];
1102 if ($this->disableSingleTableView) {
1103 $theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $tableTitle)
1104 . '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
1105 } else {
1106 $icon = $this->table
1107 ? '<span title="' . htmlspecialchars($lang->getLL('contractView')) . '">' . $this->iconFactory->getIcon('actions-view-table-collapse', Icon::SIZE_SMALL)->render() . '</span>'
1108 : '<span title="' . htmlspecialchars($lang->getLL('expandView')) . '">' . $this->iconFactory->getIcon('actions-view-table-expand', Icon::SIZE_SMALL)->render() . '</span>';
1109 $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon);
1110 }
1111 if ($listOnlyInSingleTableMode) {
1112 $tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]);
1113 } else {
1114 // Render collapse button if in multi table mode
1115 $collapseIcon = '';
1116 if (!$this->table) {
1117 $href = htmlspecialchars(($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1')));
1118 $title = $tableCollapsed
1119 ? htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.expandTable'))
1120 : htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.collapseTable'));
1121 $icon = '<span class="collapseIcon">' . $this->iconFactory->getIcon(($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse'), Icon::SIZE_SMALL)->render() . '</span>';
1122 $collapseIcon = '<a href="' . $href . '" title="' . $title . '" class="pull-right t3js-toggle-recordlist" data-table="' . htmlspecialchars($table) . '" data-toggle="collapse" data-target="#recordlist-' . htmlspecialchars($table) . '">' . $icon . '</a>';
1123 }
1124 $tableHeader .= $theData[$titleCol] . $collapseIcon;
1125 }
1126 // Render table rows only if in multi table view or if in single table view
1127 $rowOutput = '';
1128 if (!$listOnlyInSingleTableMode || $this->table) {
1129 // Fixing an order table for sortby tables
1130 $this->currentTable = [];
1131 $currentIdList = [];
1132 $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
1133 $prevUid = 0;
1134 $prevPrevUid = 0;
1135 // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
1136 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
1137 $row = $queryResult->fetch();
1138 $prevPrevUid = -((int)$row['uid']);
1139 $row = $queryResult->fetch();
1140 $prevUid = $row['uid'];
1141 }
1142 $accRows = [];
1143 // Accumulate rows here
1144 while ($row = $queryResult->fetch()) {
1145 if (!$this->isRowListingConditionFulfilled($table, $row)) {
1146 continue;
1147 }
1148 // In offline workspace, look for alternative record:
1149 BackendUtility::workspaceOL($table, $row, $backendUser->workspace, true);
1150 if (is_array($row)) {
1151 $accRows[] = $row;
1152 $currentIdList[] = $row['uid'];
1153 if ($doSort) {
1154 if ($prevUid) {
1155 $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
1156 $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
1157 $this->currentTable['prevUid'][$row['uid']] = $prevUid;
1158 }
1159 $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
1160 $prevUid = $row['uid'];
1161 }
1162 }
1163 }
1164 $this->totalRowCount = count($accRows);
1165 // CSV initiated
1166 if ($this->csvOutput) {
1167 $this->initCSV();
1168 }
1169 // Render items:
1170 $this->CBnames = [];
1171 $this->duplicateStack = [];
1172 $this->eCounter = $this->firstElementNumber;
1173 $cc = 0;
1174 foreach ($accRows as $row) {
1175 // Render item row if counter < limit
1176 if ($cc < $this->iLimit) {
1177 $cc++;
1178 $this->translations = false;
1179 $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
1180 // If no search happened it means that the selected
1181 // records are either default or All language and here we will not select translations
1182 // which point to the main record:
1183 if ($l10nEnabled && $this->searchString === '') {
1184 // For each available translation, render the record:
1185 if (is_array($this->translations)) {
1186 foreach ($this->translations as $lRow) {
1187 // $lRow isn't always what we want - if record was moved we've to work with the
1188 // placeholder records otherwise the list is messed up a bit
1189 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
1190 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
1191 ->getQueryBuilderForTable($table);
1192 $queryBuilder->getRestrictions()
1193 ->removeAll()
1194 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
1195 $predicates = [
1196 $queryBuilder->expr()->eq(
1197 't3ver_move_id',
1198 $queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO::PARAM_INT)
1199 ),
1200 $queryBuilder->expr()->eq(
1201 'pid',
1202 $queryBuilder->createNamedParameter((int)$row['_MOVE_PLH_pid'], \PDO::PARAM_INT)
1203 ),
1204 $queryBuilder->expr()->eq(
1205 't3ver_wsid',
1206 $queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)
1207 ),
1208 ];
1209
1210 $tmpRow = $queryBuilder
1211 ->select(...$selFieldList)
1212 ->from($table)
1213 ->andWhere(...$predicates)
1214 ->execute()
1215 ->fetch();
1216
1217 $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
1218 }
1219 // In offline workspace, look for alternative record:
1220 BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, true);
1221 if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
1222 $currentIdList[] = $lRow['uid'];
1223 $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
1224 }
1225 }
1226 }
1227 }
1228 }
1229 // Counter of total rows incremented:
1230 $this->eCounter++;
1231 }
1232 // Record navigation is added to the beginning and end of the table if in single
1233 // table mode
1234 if ($this->table) {
1235 $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
1236 } else {
1237 // Show that there are more records than shown
1238 if ($this->totalItems > $this->itemsLimitPerTable) {
1239 $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
1240 $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
1241 $colspan = $this->showIcon ? count($this->fieldArray) + 1 : count($this->fieldArray);
1242 $rowOutput .= '<tr><td colspan="' . $colspan . '">
1243 <a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table))) . '" class="btn btn-default">'
1244 . '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
1245 </td></tr>';
1246 }
1247 }
1248 // The header row for the table is now created:
1249 $out .= $this->renderListHeader($table, $currentIdList);
1250 }
1251
1252 $collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse in';
1253 $dataState = $tableCollapsed && !$this->table ? 'collapsed' : 'expanded';
1254
1255 // The list of records is added after the header:
1256 $out .= $rowOutput;
1257 // ... and it is all wrapped in a table:
1258 $out = '
1259
1260
1261
1262 <!--
1263 DB listing of elements: "' . htmlspecialchars($table) . '"
1264 -->
1265 <div class="panel panel-space panel-default recordlist">
1266 <div class="panel-heading">
1267 ' . $tableHeader . '
1268 </div>
1269 <div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($table) . '">
1270 <div class="table-fit">
1271 <table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
1272 ' . $out . '
1273 </table>
1274 </div>
1275 </div>
1276 </div>
1277 ';
1278 // Output csv if...
1279 // This ends the page with exit.
1280 if ($this->csvOutput) {
1281 $this->outputCSV($table);
1282 }
1283 }
1284 // Return content:
1285 return $out;
1286 }
1287
1288 /**
1289 * Get viewOnClick link for pages or tt_content records
1290 *
1291 * @param string $table
1292 * @param array $row
1293 *
1294 * @return string
1295 */
1296 protected function getOnClickForRow(string $table, array $row): string
1297 {
1298 if ($table === 'tt_content') {
1299 // Link to a content element
1300 $onClick = BackendUtility::viewOnClick($this->id, '', null, '#' . $row['uid']);
1301 } elseif ($table === 'pages' && $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] > 0) {
1302 // Link to a page translation
1303 $onClick = BackendUtility::viewOnClick(
1304 $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']],
1305 '',
1306 null,
1307 '',
1308 '',
1309 '&L=' . $row[$GLOBALS['TCA']['pages']['ctrl']['languageField']]
1310 );
1311 } else {
1312 // Link to a page in the default language
1313 $onClick = BackendUtility::viewOnClick($row['uid']);
1314 }
1315 return $onClick;
1316 }
1317
1318 /**
1319 * Check if all row listing conditions are fulfilled.
1320 *
1321 * This function serves as a dummy method to be overridden in extending classes.
1322 *
1323 * @param string $table Table name
1324 * @param string[] $row Record
1325 * @return bool True, if all conditions are fulfilled.
1326 */
1327 protected function isRowListingConditionFulfilled($table, $row)
1328 {
1329 return true;
1330 }
1331
1332 /**
1333 * Rendering a single row for the list
1334 *
1335 * @param string $table Table name
1336 * @param mixed[] $row Current record
1337 * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
1338 * @param string $titleCol Table field (column) where header value is found
1339 * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
1340 * @param int $indent Indent from left.
1341 * @return string Table row for the element
1342 * @access private
1343 * @see getTable()
1344 */
1345 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
1346 {
1347 if (!is_array($row)) {
1348 return '';
1349 }
1350 $rowOutput = '';
1351 $id_orig = null;
1352 // If in search mode, make sure the preview will show the correct page
1353 if ((string)$this->searchString !== '') {
1354 $id_orig = $this->id;
1355 $this->id = $row['pid'];
1356 }
1357
1358 $tagAttributes = [
1359 'class' => ['t3js-entity'],
1360 'data-table' => $table,
1361 'title' => 'id=' . $row['uid'],
1362 ];
1363
1364 // Add special classes for first and last row
1365 if ($cc == 1 && $indent == 0) {
1366 $tagAttributes['class'][] = 'firstcol';
1367 }
1368 if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
1369 $tagAttributes['class'][] = 'lastcol';
1370 }
1371 // Overriding with versions background color if any:
1372 if (!empty($row['_CSSCLASS'])) {
1373 $tagAttributes['class'] = [$row['_CSSCLASS']];
1374 }
1375 // Incr. counter.
1376 $this->counter++;
1377 // The icon with link
1378 $toolTip = BackendUtility::getRecordToolTip($row, $table);
1379 $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
1380 $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>'
1381 . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render()
1382 . '</span>';
1383 $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
1384 // Preparing and getting the data-array
1385 $theData = [];
1386 $localizationMarkerClass = '';
1387 foreach ($this->fieldArray as $fCol) {
1388 if ($fCol == $titleCol) {
1389 $recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
1390 $warning = '';
1391 // If the record is edit-locked by another user, we will show a little warning sign:
1392 $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
1393 if ($lockInfo) {
1394 $warning = '<span data-toggle="tooltip" data-placement="right" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
1395 . $this->iconFactory->getIcon('warning-in-use', Icon::SIZE_SMALL)->render() . '</span>';
1396 }
1397 $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
1398 // Render thumbnails, if:
1399 // - a thumbnail column exists
1400 // - there is content in it
1401 // - the thumbnail column is visible for the current type
1402 $type = 0;
1403 if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
1404 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
1405 $type = $row[$typeColumn];
1406 }
1407 // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
1408 // if 0 doesn't exist)
1409 if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
1410 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
1411 }
1412 $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
1413
1414 if ($this->thumbs &&
1415 trim($row[$thumbsCol]) &&
1416 preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
1417 ) {
1418 $thumbCode = '<br />' . $this->thumbCode($row, $table, $thumbsCol);
1419 $theData[$fCol] .= $thumbCode;
1420 $theData['__label'] .= $thumbCode;
1421 }
1422 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1423 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
1424 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
1425 ) {
1426 // It's a translated record with a language parent
1427 $localizationMarkerClass = ' localization';
1428 }
1429 } elseif ($fCol === 'pid') {
1430 $theData[$fCol] = $row[$fCol];
1431 } elseif ($fCol === '_PATH_') {
1432 $theData[$fCol] = $this->recPath($row['pid']);
1433 } elseif ($fCol === '_REF_') {
1434 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
1435 } elseif ($fCol === '_CONTROL_') {
1436 $theData[$fCol] = $this->makeControl($table, $row);
1437 } elseif ($fCol === '_CLIPBOARD_') {
1438 $theData[$fCol] = $this->makeClip($table, $row);
1439 } elseif ($fCol === '_LOCALIZATION_') {
1440 list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
1441 $theData[$fCol] = $lC1;
1442 $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>';
1443 } elseif ($fCol === '_LOCALIZATION_b') {
1444 // deliberately empty
1445 } else {
1446 $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
1447 $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId);
1448 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
1449 if ($this->csvOutput) {
1450 $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
1451 }
1452 }
1453 }
1454 // Reset the ID if it was overwritten
1455 if ((string)$this->searchString !== '') {
1456 $this->id = $id_orig;
1457 }
1458 // Add row to CSV list:
1459 if ($this->csvOutput) {
1460 $this->addToCSV($row);
1461 }
1462 // Add classes to table cells
1463 $this->addElement_tdCssClass[$titleCol] = 'col-title col-responsive' . $localizationMarkerClass;
1464 $this->addElement_tdCssClass['__label'] = $this->addElement_tdCssClass[$titleCol];
1465 $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
1466 if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
1467 $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
1468 }
1469 $this->addElement_tdCssClass['_PATH_'] = 'col-path';
1470 $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
1471 $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
1472 // Create element in table cells:
1473 $theData['uid'] = $row['uid'];
1474 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1475 && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
1476 ) {
1477 $theData['_l10nparent_'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
1478 }
1479
1480 $tagAttributes = array_map(
1481 function ($attributeValue) {
1482 if (is_array($attributeValue)) {
1483 return implode(' ', $attributeValue);
1484 }
1485 return $attributeValue;
1486 },
1487 $tagAttributes
1488 );
1489
1490 $rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true));
1491 // Finally, return table row element:
1492 return $rowOutput;
1493 }
1494
1495 /**
1496 * Gets the number of records referencing the record with the UID $uid in
1497 * the table $tableName.
1498 *
1499 * @param string $tableName
1500 * @param int $uid
1501 * @return int The number of references to record $uid in table
1502 */
1503 protected function getReferenceCount($tableName, $uid)
1504 {
1505 if (!isset($this->referenceCount[$tableName][$uid])) {
1506 $numberOfReferences = GeneralUtility::makeInstance(ConnectionPool::class)
1507 ->getConnectionForTable('sys_refindex')
1508 ->count(
1509 '*',
1510 'sys_refindex',
1511 [
1512 'ref_table' => $tableName,
1513 'ref_uid' => (int)$uid,
1514 'deleted' => 0
1515 ]
1516 );
1517 $this->referenceCount[$tableName][$uid] = $numberOfReferences;
1518 }
1519 return $this->referenceCount[$tableName][$uid];
1520 }
1521
1522 /**
1523 * Rendering the header row for a table
1524 *
1525 * @param string $table Table name
1526 * @param int[] $currentIdList Array of the currently displayed uids of the table
1527 * @throws \UnexpectedValueException
1528 * @return string Header table row
1529 * @access private
1530 * @see getTable()
1531 */
1532 public function renderListHeader($table, $currentIdList)
1533 {
1534 $lang = $this->getLanguageService();
1535 // Init:
1536 $theData = [];
1537 $icon = '';
1538 // Traverse the fields:
1539 foreach ($this->fieldArray as $fCol) {
1540 // Calculate users permissions to edit records in the table:
1541 $permsEdit = $this->calcPerms & ($table === 'pages' ? 2 : 16) && $this->overlayEditLockPermissions($table);
1542 switch ((string)$fCol) {
1543 case '_PATH_':
1544 // Path
1545 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels._PATH_')) . ']</i>';
1546 break;
1547 case '_REF_':
1548 // References
1549 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c__REF_')) . ']</i>';
1550 break;
1551 case '_LOCALIZATION_':
1552 // Path
1553 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels._LOCALIZATION_')) . ']</i>';
1554 break;
1555 case '_LOCALIZATION_b':
1556 // Path
1557 $theData[$fCol] = htmlspecialchars($lang->getLL('Localize'));
1558 break;
1559 case '_CLIPBOARD_':
1560 if (!$this->getModule()->MOD_SETTINGS['clipBoard']) {
1561 break;
1562 }
1563 // Clipboard:
1564 $cells = [];
1565 // If there are elements on the clipboard for this table, and the parent page is not locked by editlock
1566 // then display the "paste into" icon:
1567 $elFromTable = $this->clipObj->elFromTable($table);
1568 if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) {
1569 $href = htmlspecialchars($this->clipObj->pasteUrl($table, $this->id));
1570 $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
1571 $cells['pasteAfter'] = '<a class="btn btn-default t3js-modal-trigger"'
1572 . ' href="' . $href . '"'
1573 . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1574 . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1575 . ' data-content="' . htmlspecialchars($confirmMessage) . '"'
1576 . ' data-severity="warning">'
1577 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
1578 . '</a>';
1579 }
1580 // If the numeric clipboard pads are enabled, display the control icons for that:
1581 if ($this->clipObj->current !== 'normal') {
1582 // The "select" link:
1583 $spriteIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render();
1584 $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB', '', $lang->getLL('clip_selectMarked'));
1585 // The "edit marked" link:
1586 $editUri = BackendUtility::getModuleUrl('record_edit')
1587 . '&edit[' . $table . '][{entityIdentifiers:editList}]=edit'
1588 . '&returnUrl={T3_THIS_LOCATION}';
1589 $cells['edit'] = '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1590 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1591 . ' title="' . htmlspecialchars($lang->getLL('clip_editMarked')) . '">'
1592 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1593 // The "Delete marked" link:
1594 $cells['delete'] = $this->linkClipboardHeaderIcon(
1595 $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(),
1596 $table,
1597 'delete',
1598 sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])),
1599 $lang->getLL('clip_deleteMarked')
1600 );
1601 // The "Select all" link:
1602 $onClick = htmlspecialchars(('checkOffCB(' . GeneralUtility::quoteJSvalue(implode(',', $this->CBnames)) . ', this); return false;'));
1603 $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="'
1604 . htmlspecialchars($lang->getLL('clip_markRecords')) . '">'
1605 . $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL)->render() . '</a>';
1606 } else {
1607 $cells['empty'] = '';
1608 }
1609 /*
1610 * hook: renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
1611 * usage: Above each listed table in Web>List a header row is shown.
1612 * This hook allows to modify the icons responsible for the clipboard functions
1613 * (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected),
1614 * or other "Action" functions which perform operations on the listed records.
1615 */
1616 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1617 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
1618 $hookObject = GeneralUtility::makeInstance($className);
1619 if (!$hookObject instanceof RecordListHookInterface) {
1620 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567850);
1621 }
1622 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
1623 }
1624 }
1625 $theData[$fCol] = '';
1626 if (isset($cells['edit']) && isset($cells['delete'])) {
1627 $theData[$fCol] .= '<div class="btn-group" role="group">' . $cells['edit'] . $cells['delete'] . '</div>';
1628 unset($cells['edit'], $cells['delete']);
1629 }
1630 $theData[$fCol] .= '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1631 break;
1632 case '_CONTROL_':
1633 // Control panel:
1634 if ($this->isEditable($table)) {
1635 // If new records can be created on this page, add links:
1636 $permsAdditional = ($table === 'pages' ? 8 : 16);
1637 if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) {
1638 $spriteIcon = $table === 'pages'
1639 ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)
1640 : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL);
1641 if ($table === 'tt_content' && $this->newWizards) {
1642 // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
1643 $tmpTSc = BackendUtility::getModTSconfig($this->pageinfo['uid'], 'mod');
1644 $newContentElementWizard = isset($tmpTSc['properties']['newContentElementWizard.']['override'])
1645 ? $tmpTSc['properties']['newContentElementWizard.']['override']
1646 : 'new_content_element';
1647 $newContentWizScriptPath = BackendUtility::getModuleUrl($newContentElementWizard, ['id' => $this->id]);
1648
1649 $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($newContentWizScriptPath) . ');';
1650 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1651 . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1652 } elseif ($table === 'pages' && $this->newWizards) {
1653 $parameters = ['id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
1654 $href = BackendUtility::getModuleUrl('db_new', $parameters);
1655 $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">'
1656 . $spriteIcon->render() . '</a>';
1657 } else {
1658 $params = '&edit[' . $table . '][' . $this->id . ']=new';
1659 if ($table === 'pages') {
1660 $params .= '&overrideVals[pages][doktype]=' . (int)$this->pageRow['doktype'];
1661 }
1662 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
1663 . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1664 }
1665 }
1666 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
1667 if ($permsEdit && $this->table && is_array($currentIdList)) {
1668 $entityIdentifiers = 'entityIdentifiers';
1669 if ($this->clipNumPane()) {
1670 $entityIdentifiers .= ':editList';
1671 }
1672 $editUri = BackendUtility::getModuleUrl('record_edit')
1673 . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1674 . '&columnsOnly=' . implode(',', $this->fieldArray)
1675 . '&returnUrl={T3_THIS_LOCATION}';
1676 $icon .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1677 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1678 . ' title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">'
1679 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1680 $icon = '<div class="btn-group" role="group">' . $icon . '</div>';
1681 }
1682 // Add an empty entry, so column count fits again after moving this into $icon
1683 $theData[$fCol] = '&nbsp;';
1684 }
1685 break;
1686 default:
1687 // Regular fields header:
1688 $theData[$fCol] = '';
1689
1690 // Check if $fCol is really a field and get the label and remove the colons
1691 // at the end
1692 $sortLabel = BackendUtility::getItemLabel($table, $fCol);
1693 if ($sortLabel !== null) {
1694 $sortLabel = htmlspecialchars($lang->sL($sortLabel));
1695 $sortLabel = rtrim(trim($sortLabel), ':');
1696 } else {
1697 // No TCA field, only output the $fCol variable with square brackets []
1698 $sortLabel = htmlspecialchars($fCol);
1699 $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>';
1700 }
1701
1702 if ($this->table && is_array($currentIdList)) {
1703 // If the numeric clipboard pads are selected, show duplicate sorting link:
1704 if ($this->clipNumPane()) {
1705 $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL('', '-1') . '&duplicateField=' . $fCol)
1706 . '" title="' . htmlspecialchars($lang->getLL('clip_duplicates')) . '">'
1707 . $this->iconFactory->getIcon('actions-document-duplicates-select', Icon::SIZE_SMALL)->render() . '</a>';
1708 }
1709 // If the table can be edited, add link for editing THIS field for all
1710 // listed records:
1711 if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
1712 $entityIdentifiers = 'entityIdentifiers';
1713 if ($this->clipNumPane()) {
1714 $entityIdentifiers .= ':editList';
1715 }
1716 $editUri = BackendUtility::getModuleUrl('record_edit')
1717 . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1718 . '&columnsOnly=' . $fCol
1719 . '&returnUrl={T3_THIS_LOCATION}';
1720 $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
1721 $theData[$fCol] .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1722 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1723 . ' title="' . htmlspecialchars($iTitle) . '">'
1724 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1725 }
1726 if (strlen($theData[$fCol]) > 0) {
1727 $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> ';
1728 }
1729 }
1730 $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table);
1731 }
1732 }
1733 /*
1734 * hook: renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
1735 * usage: Above each listed table in Web>List a header row is shown.
1736 * Containing the labels of all shown fields and additional icons to create new records for this
1737 * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.
1738 */
1739 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1740 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
1741 $hookObject = GeneralUtility::makeInstance($className);
1742 if (!$hookObject instanceof RecordListHookInterface) {
1743 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567855);
1744 }
1745 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
1746 }
1747 }
1748
1749 // Create and return header table row:
1750 return '<thead>' . $this->addElement(1, $icon, $theData, '', '', '', 'th') . '</thead>';
1751 }
1752
1753 /**
1754 * Get pointer for first element on the page
1755 *
1756 * @param int $page Page number starting with 1
1757 * @return int Pointer to first element on the page (starting with 0)
1758 */
1759 protected function getPointerForPage($page)
1760 {
1761 return ($page - 1) * $this->iLimit;
1762 }
1763
1764 /**
1765 * Creates a page browser for tables with many records
1766 *
1767 * @param string $renderPart Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
1768 * @return string Navigation HTML
1769 */
1770 protected function renderListNavigation($renderPart = 'top')
1771 {
1772 $totalPages = ceil($this->totalItems / $this->iLimit);
1773 // Show page selector if not all records fit into one page
1774 if ($totalPages <= 1) {
1775 return '';
1776 }
1777 $content = '';
1778 $listURL = $this->listURL('', $this->table);
1779 // 1 = first page
1780 // 0 = first element
1781 $currentPage = floor($this->firstElementNumber / $this->iLimit) + 1;
1782 // Compile first, previous, next, last and refresh buttons
1783 if ($currentPage > 1) {
1784 $labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:first'));
1785 $labelPrevious = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:previous'));
1786 $first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
1787 . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</a></li>';
1788 $previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
1789 . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</a></li>';
1790 } else {
1791 $first = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</span></li>';
1792 $previous = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</span></li>';
1793 }
1794 if ($currentPage < $totalPages) {
1795 $labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:next'));
1796 $labelLast = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:last'));
1797 $next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage + 1) . '" title="' . $labelNext . '">'
1798 . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</a></li>';
1799 $last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
1800 . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</a></li>';
1801 } else {
1802 $next = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</span></li>';
1803 $last = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</span></li>';
1804 }
1805 $reload = '<li><a href="#" onclick="document.dblistForm.action=' . GeneralUtility::quoteJSvalue($listURL
1806 . '&pointer=') . '+calculatePointer(document.getElementById(' . GeneralUtility::quoteJSvalue('jumpPage-' . $renderPart)
1807 . ').value); document.dblistForm.submit(); return true;" title="'
1808 . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:reload')) . '">'
1809 . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a></li>';
1810 if ($renderPart === 'top') {
1811 // Add js to traverse a page select input to a pointer value
1812 $content = '
1813 <script type="text/javascript">
1814 /*<![CDATA[*/
1815 function calculatePointer(page) {
1816 if (page > ' . $totalPages . ') {
1817 page = ' . $totalPages . ';
1818 }
1819 if (page < 1) {
1820 page = 1;
1821 }
1822 return (page - 1) * ' . $this->iLimit . ';
1823 }
1824 /*]]>*/
1825 </script>
1826 ';
1827 }
1828 $pageNumberInput = '
1829 <input type="number" min="1" max="' . $totalPages . '" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
1830 . $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=' . GeneralUtility::quoteJSvalue($listURL
1831 . '&pointer=') . '+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1832 ';
1833 $pageIndicatorText = sprintf(
1834 $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:pageIndicator'),
1835 $pageNumberInput,
1836 $totalPages
1837 );
1838 $pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
1839 if ($this->totalItems > $this->firstElementNumber + $this->iLimit) {
1840 $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1841 } else {
1842 $lastElementNumber = $this->totalItems;
1843 }
1844 $rangeIndicator = '<li><span>' . sprintf($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:rangeIndicator'), ($this->firstElementNumber + 1), $lastElementNumber) . '</span></li>';
1845
1846 $titleColumn = $this->fieldArray[0];
1847 $data = [
1848 $titleColumn => $content . '
1849 <nav class="pagination-wrap">
1850 <ul class="pagination pagination-block">
1851 ' . $first . '
1852 ' . $previous . '
1853 ' . $rangeIndicator . '
1854 ' . $pageIndicator . '
1855 ' . $next . '
1856 ' . $last . '
1857 ' . $reload . '
1858 </ul>
1859 </nav>
1860 '
1861 ];
1862 return $this->addElement(1, '', $data);
1863 }
1864
1865 /*********************************
1866 *
1867 * Rendering of various elements
1868 *
1869 *********************************/
1870
1871 /**
1872 * Creates the control panel for a single record in the listing.
1873 *
1874 * @param string $table The table
1875 * @param mixed[] $row The record for which to make the control panel.
1876 * @throws \UnexpectedValueException
1877 * @return string HTML table with the control panel (unless disabled)
1878 */
1879 public function makeControl($table, $row)
1880 {
1881 $module = $this->getModule();
1882 $rowUid = $row['uid'];
1883 if (ExtensionManagementUtility::isLoaded('workspaces') && isset($row['_ORIG_uid'])) {
1884 $rowUid = $row['_ORIG_uid'];
1885 }
1886 $cells = [
1887 'primary' => [],
1888 'secondary' => []
1889 ];
1890 // Enables to hide the move elements for localized records - doesn't make much sense to perform these options for them
1891 // For page translations these icons should never be shown
1892 $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
1893 // If the listed table is 'pages' we have to request the permission settings for each page:
1894 $localCalcPerms = 0;
1895 if ($table === 'pages') {
1896 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
1897 }
1898 $permsEdit = $table === 'pages'
1899 && $this->getBackendUserAuthentication()->checkLanguageAccess(0)
1900 && $localCalcPerms & Permission::PAGE_EDIT
1901 || $table !== 'pages'
1902 && $this->calcPerms & Permission::CONTENT_EDIT
1903 && $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $row);
1904 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1905 // "Show" link (only pages and tt_content elements)
1906 if ($table === 'pages' || $table === 'tt_content') {
1907 $onClick = $this->getOnClickForRow($table, $row);
1908 $viewAction = '<a class="btn btn-default" href="#" onclick="'
1909 . htmlspecialchars(
1910 $onClick
1911 ) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">';
1912 if ($table === 'pages') {
1913 $viewAction .= $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render();
1914 } else {
1915 $viewAction .= $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render();
1916 }
1917 $viewAction .= '</a>';
1918 $this->addActionToCellGroup($cells, $viewAction, 'view');
1919 }
1920 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1921 if ($permsEdit) {
1922 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
1923 $iconIdentifier = 'actions-open';
1924 if ($table === 'pages') {
1925 $iconIdentifier = 'actions-page-open';
1926 }
1927 $overlayIdentifier = !$this->isEditable($table) ? 'overlay-readonly' : null;
1928 $editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
1929 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $this->iconFactory->getIcon($iconIdentifier, Icon::SIZE_SMALL, $overlayIdentifier)->render() . '</a>';
1930 } else {
1931 $editAction = $this->spaceIcon;
1932 }
1933 $this->addActionToCellGroup($cells, $editAction, 'edit');
1934 // "Info": (All records)
1935 $onClick = 'top.launchView(' . GeneralUtility::quoteJSvalue($table) . ', ' . (int)$row['uid'] . '); return false;';
1936 $viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('showInfo')) . '">'
1937 . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
1938 $this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
1939 // "Move" wizard link for pages/tt_content elements:
1940 if ($permsEdit && ($table === 'tt_content' || $table === 'pages')) {
1941 if ($isL10nOverlay) {
1942 $moveAction = $this->spaceIcon;
1943 } else {
1944 $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');';
1945 $linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page')));
1946 $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-move', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL));
1947 $moveAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
1948 }
1949 $this->addActionToCellGroup($cells, $moveAction, 'move');
1950 }
1951 // If the table is NOT a read-only table, then show these links:
1952 if ($this->isEditable($table)) {
1953 // "Revert" link (history/undo)
1954 $moduleUrl = BackendUtility::getModuleUrl('record_history', ['element' => $table . ':' . $row['uid']]);
1955 $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($moduleUrl) . ',\'#latest\');';
1956 $historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1957 . htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
1958 . $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render() . '</a>';
1959 $this->addActionToCellGroup($cells, $historyAction, 'history');
1960 // "Edit Perms" link:
1961 if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) {
1962 if ($isL10nOverlay) {
1963 $permsAction = $this->spaceIcon;
1964 } else {
1965 $href = BackendUtility::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit' . $this->makeReturnUrl();
1966 $permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1967 . htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
1968 . $this->iconFactory->getIcon('actions-lock', Icon::SIZE_SMALL)->render() . '</a>';
1969 }
1970 $this->addActionToCellGroup($cells, $permsAction, 'perms');
1971 }
1972 // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
1973 // or if default values can depend on previous record):
1974 if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
1975 if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT || $table === 'pages' && $this->calcPerms & Permission::PAGE_NEW) {
1976 if ($table === 'pages' && $isL10nOverlay) {
1977 $this->addActionToCellGroup($cells, $this->spaceIcon, 'new');
1978 } elseif ($this->showNewRecLink($table)) {
1979 $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
1980 $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
1981 $titleLabel = 'new';
1982 if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
1983 $titleLabel .= ($table === 'pages' ? 'Page' : 'Record');
1984 }
1985 $newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
1986 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($titleLabel)) . '">'
1987 . $icon->render() . '</a>';
1988 $this->addActionToCellGroup($cells, $newAction, 'new');
1989 }
1990 }
1991 }
1992 // "Up/Down" links
1993 if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
1994 if (!$isL10nOverlay && isset($this->currentTable['prev'][$row['uid']])) {
1995 // Up
1996 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']];
1997 $moveUpAction = '<a class="btn btn-default" href="#" onclick="'
1998 . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
1999 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
2000 . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
2001 } else {
2002 $moveUpAction = $this->spaceIcon;
2003 }
2004 $this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
2005
2006 if (!$isL10nOverlay && $this->currentTable['next'][$row['uid']]) {
2007 // Down
2008 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']];
2009 $moveDownAction = '<a class="btn btn-default" href="#" onclick="'
2010 . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
2011 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
2012 . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
2013 } else {
2014 $moveDownAction = $this->spaceIcon;
2015 }
2016 $this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
2017 }
2018 // "Hide/Unhide" links:
2019 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
2020
2021 if (
2022 !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
2023 && (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
2024 || $this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField))
2025 ) {
2026 if (!$permsEdit || $this->isRecordCurrentBackendUser($table, $row)) {
2027 $hideAction = $this->spaceIcon;
2028 } else {
2029 $hideTitle = htmlspecialchars($this->getLanguageService()->getLL('hide' . ($table === 'pages' ? 'Page' : '')));
2030 $unhideTitle = htmlspecialchars($this->getLanguageService()->getLL('unHide' . ($table === 'pages' ? 'Page' : '')));
2031 if ($row[$hiddenField]) {
2032 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
2033 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
2034 . ' data-params="' . htmlspecialchars($params) . '"'
2035 . ' title="' . $unhideTitle . '"'
2036 . ' data-toggle-title="' . $hideTitle . '">'
2037 . $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . '</a>';
2038 } else {
2039 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
2040 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
2041 . ' data-params="' . htmlspecialchars($params) . '"'
2042 . ' title="' . $hideTitle . '"'
2043 . ' data-toggle-title="' . $unhideTitle . '">'
2044 . $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . '</a>';
2045 }
2046 }
2047 $this->addActionToCellGroup($cells, $hideAction, 'hide');
2048 }
2049 // "Delete" link:
2050 $disableDeleteTS = $this->getBackendUserAuthentication()->getTSConfig('options.disableDelete');
2051 $disableDelete = (bool) trim(isset($disableDeleteTS['properties'][$table]) ? $disableDeleteTS['properties'][$table] : $disableDeleteTS['value']);
2052 if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission::PAGE_DELETE || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT)) {
2053 // Check if the record version is in "deleted" state, because that will switch the action to "restore"
2054 if ($this->getBackendUserAuthentication()->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
2055 $actionName = 'restore';
2056 $refCountMsg = '';
2057 } else {
2058 $actionName = 'delete';
2059 $refCountMsg = BackendUtility::referenceCount(
2060 $table,
2061 $row['uid'],
2062 ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
2063 $this->getReferenceCount($table, $row['uid'])
2064 ) . BackendUtility::translationCount(
2065 $table,
2066 $row['uid'],
2067 ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
2068 );
2069 }
2070
2071 if ($this->isRecordCurrentBackendUser($table, $row)) {
2072 $deleteAction = $this->spaceIcon;
2073 } else {
2074 $title = BackendUtility::getRecordTitle($table, $row);
2075 $warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
2076
2077 $params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
2078 $icon = $this->iconFactory->getIcon('actions-edit-' . $actionName, Icon::SIZE_SMALL)->render();
2079 $linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
2080 $deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
2081 . ' data-l10parent="' . htmlspecialchars($row['l10n_parent']) . '"'
2082 . ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
2083 . ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
2084 . '>' . $icon . '</a>';
2085 }
2086 } else {
2087 $deleteAction = $this->spaceIcon;
2088 }
2089 $this->addActionToCellGroup($cells, $deleteAction, 'delete');
2090 // "Levels" links: Moving pages into new levels...
2091 if ($permsEdit && $table === 'pages' && !$this->searchLevels) {
2092 // Up (Paste as the page right after the current parent page)
2093 if ($this->calcPerms & Permission::PAGE_NEW) {
2094 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
2095 $moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
2096 . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
2097 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
2098 . $this->iconFactory->getIcon('actions-move-left', Icon::SIZE_SMALL)->render() . '</a>';
2099 $this->addActionToCellGroup($cells, $isL10nOverlay ? $this->spaceIcon : $moveLeftAction, 'moveLeft');
2100 }
2101 // Down (Paste as subpage to the page right above)
2102 if (!$isL10nOverlay && $this->currentTable['prevUid'][$row['uid']]) {
2103 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']]));
2104 if ($localCalcPerms & Permission::PAGE_NEW) {
2105 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
2106 $moveRightAction = '<a class="btn btn-default" href="#" onclick="'
2107 . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
2108 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
2109 . $this->iconFactory->getIcon('actions-move-right', Icon::SIZE_SMALL)->render() . '</a>';
2110 } else {
2111 $moveRightAction = $this->spaceIcon;
2112 }
2113 } else {
2114 $moveRightAction = $this->spaceIcon;
2115 }
2116 $this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
2117 }
2118 }
2119 /*
2120 * hook: recStatInfoHooks: Allows to insert HTML before record icons on various places
2121 */
2122 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
2123 $stat = '';
2124 $_params = [$table, $row['uid']];
2125 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
2126 $stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2127 }
2128 $this->addActionToCellGroup($cells, $stat, 'stat');
2129 }
2130 /*
2131 * hook: makeControl: Allows to change control icons of records in list-module
2132 * usage: This hook method gets passed the current $cells array as third parameter.
2133 * This array contains values for the icons/actions generated for each record in Web>List.
2134 * Each array entry is accessible by an index-key.
2135 * The order of the icons is depending on the order of those array entries.
2136 */
2137 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
2138 // for compatibility reason, we move all icons to the rootlevel
2139 // before calling the hooks
2140 foreach ($cells as $section => $actions) {
2141 foreach ($actions as $actionKey => $action) {
2142 $cells[$actionKey] = $action;
2143 }
2144 }
2145 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
2146 $hookObject = GeneralUtility::makeInstance($className);
2147 if (!$hookObject instanceof RecordListHookInterface) {
2148 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567840);
2149 }
2150 $cells = $hookObject->makeControl($table, $row, $cells, $this);
2151 }
2152 // now sort icons again into primary and secondary sections
2153 // after all hooks are processed
2154 $hookCells = $cells;
2155 foreach ($hookCells as $key => $value) {
2156 if ($key === 'primary' || $key === 'secondary') {
2157 continue;
2158 }
2159 $this->addActionToCellGroup($cells, $value, $key);
2160 }
2161 }
2162 $output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
2163 foreach ($cells as $classification => $actions) {
2164 $visibilityClass = ($classification !== 'primary' && !$module->MOD_SETTINGS['bigControlPanel'] ? 'collapsed' : 'expanded');
2165 if ($visibilityClass === 'collapsed') {
2166 $cellOutput = '';
2167 foreach ($actions as $action) {
2168 $cellOutput .= $action;
2169 }
2170 $output .= ' <div class="btn-group">' .
2171 '<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
2172 '<a href="#actions_' . $table . '_' . $row['uid'] . '" class="btn btn-default collapsed" data-toggle="collapse" aria-expanded="false"><span class="t3-icon fa fa-ellipsis-h"></span></a>' .
2173 '</div>';
2174 } else {
2175 $output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
2176 }
2177 }
2178 return $output;
2179 }
2180
2181 /**
2182 * Creates the clipboard panel for a single record in the listing.
2183 *
2184 * @param string $table The table
2185 * @param mixed[] $row The record for which to make the clipboard panel.
2186 * @throws \UnexpectedValueException
2187 * @return string HTML table with the clipboard panel (unless disabled)
2188 */
2189 public function makeClip($table, $row)
2190 {
2191 // Return blank, if disabled:
2192 if (!$this->getModule()->MOD_SETTINGS['clipBoard']) {
2193 return '';
2194 }
2195 $cells = [];
2196 $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon);
2197 // Enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
2198 // For page translations these icons should never be shown
2199 $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
2200 // Return blank, if disabled:
2201 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
2202 // For the "Normal" pad:
2203 if ($this->clipObj->current === 'normal') {
2204 // Show copy/cut icons:
2205 $isSel = (string)$this->clipObj->isSelected($table, $row['uid']);
2206 if ($isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)) {
2207 $cells['copy'] = $this->spaceIcon;
2208 $cells['cut'] = $this->spaceIcon;
2209 } else {
2210 $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL);
2211 $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL);
2212
2213 if ($isSel === 'copy') {
2214 $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL);
2215 } elseif ($isSel === 'cut') {
2216 $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL);
2217 }
2218
2219 $cells['copy'] = '<a class="btn btn-default" href="#" onclick="'
2220 . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB($table, $row['uid'], 1, ($isSel === 'copy'), ['returnUrl' => ''])) . ');')
2221 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.copy')) . '">'
2222 . $copyIcon->render() . '</a>';
2223
2224 // Check permission to cut page or content
2225 if ($table === 'pages') {
2226 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
2227 $permsEdit = $localCalcPerms & Permission::PAGE_EDIT;
2228 } else {
2229 $permsEdit = $this->calcPerms & Permission::CONTENT_EDIT;
2230 }
2231 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
2232
2233 // If the listed table is 'pages' we have to request the permission settings for each page:
2234 if ($table === 'pages') {
2235 if ($permsEdit) {
2236 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
2237 . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''])) . ');')
2238 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
2239 . $cutIcon->render() . '</a>';
2240 } else {
2241 $cells['cut'] = $this->spaceIcon;
2242 }
2243 } else {
2244 if ($this->calcPerms & Permission::CONTENT_EDIT) {
2245 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
2246 . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''])) . ');')
2247 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
2248 . $cutIcon->render() . '</a>';
2249 } else {
2250 $cells['cut'] = $this->spaceIcon;
2251 }
2252 }
2253 }
2254 } else {
2255 // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
2256 // Setting name of the element in ->CBnames array:
2257 $n = $table . '|' . $row['uid'];
2258 $this->CBnames[] = $n;
2259 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
2260 $checked = $this->clipObj->isSelected($table, $row['uid']) ? 'checked="checked" ' : '';
2261 // If the "duplicateField" value is set then select all elements which are duplicates...
2262 if ($this->duplicateField && isset($row[$this->duplicateField])) {
2263 $checked = '';
2264 if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
2265 $checked = 'checked="checked" ';
2266 }
2267 $this->duplicateStack[] = $row[$this->duplicateField];
2268 }
2269 // Adding the checkbox to the panel:
2270 $cells['select'] = $isL10nOverlay
2271 ? $this->spaceIcon
2272 : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"'
2273 . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>';
2274 }
2275 // Now, looking for selected elements from the current table:
2276 $elFromTable = $this->clipObj->elFromTable($table);
2277 if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
2278 // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon:
2279 $cells['pasteAfter'] = $isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)
2280 ? $this->spaceIcon
2281 : '<a class="btn btn-default t3js-modal-trigger"'
2282 . ' href="' . htmlspecialchars($this->clipObj->pasteUrl($table, -$row['uid'])) . '"'
2283 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
2284 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
2285 . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'after', $elFromTable)) . '"'
2286 . ' data-severity="warning">'
2287 . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)->render() . '</a>';
2288 }
2289 // Now, looking for elements in general:
2290 $elFromTable = $this->clipObj->elFromTable('');
2291 if ($table === 'pages' && !$isL10nOverlay && !empty($elFromTable)) {
2292 $cells['pasteInto'] = '<a class="btn btn-default t3js-modal-trigger"'
2293 . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid'])) . '"'
2294 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
2295 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
2296 . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'into', $elFromTable)) . '"'
2297 . ' data-severity="warning">'
2298 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>';
2299 }
2300 /*
2301 * hook: makeClip: Allows to change clip-icons of records in list-module
2302 * usage: This hook method gets passed the current $cells array as third parameter.
2303 * This array contains values for the clipboard icons generated for each record in Web>List.
2304 * Each array entry is accessible by an index-key.
2305 * The order of the icons is depending on the order of those array entries.
2306 */
2307 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
2308 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
2309 $hookObject = GeneralUtility::makeInstance($className);
2310 if (!$hookObject instanceof RecordListHookInterface) {
2311 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567845);
2312 }
2313 $cells = $hookObject->makeClip($table, $row, $cells, $this);
2314 }
2315 }
2316 return '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
2317 }
2318
2319 /**
2320 * Creates the HTML for a reference count for the record with the UID $uid
2321 * in the table $tableName.
2322 *
2323 * @param string $tableName
2324 * @param int $uid
2325 * @return string HTML of reference a link, will be empty if there are no
2326 */
2327 protected function createReferenceHtml($tableName, $uid)
2328 {
2329 $referenceCount = GeneralUtility::makeInstance(ConnectionPool::class)
2330 ->getConnectionForTable('sys_refindex')
2331 ->count(
2332 '*',
2333 'sys_refindex',
2334 [
2335 'ref_table' => $tableName,
2336 'ref_uid' => (int)$uid,
2337 'deleted' => 0,
2338 ]
2339 );
2340
2341 return $this->generateReferenceToolTip(
2342 $referenceCount,
2343 GeneralUtility::quoteJSvalue($tableName) . ', ' . GeneralUtility::quoteJSvalue($uid)
2344 );
2345 }
2346
2347 /**
2348 * Creates the localization panel
2349 *
2350 * @param string $table The table
2351 * @param mixed[] $row The record for which to make the localization panel.
2352 * @return string[] Array with key 0/1 with content for column 1 and 2
2353 */
2354 public function makeLocalizationPanel($table, $row)
2355 {
2356 $out = [
2357 0 => '',
2358 1 => ''
2359 ];
2360 // Reset translations
2361 $this->translations = [];
2362
2363 // Language title and icon:
2364 $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
2365 // Guard clause so we can quickly return if a record is localized to "all languages"
2366 // It should only be possible to localize a record off default (uid 0)
2367 // Reasoning: The Parent is for ALL languages... why overlay with a localization?
2368 if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) {
2369 return $out;
2370 }
2371
2372 $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
2373 if (is_array($translations)) {
2374 $this->translations = $translations['translations'];
2375 // Traverse page translations and add icon for each language that does NOT yet exist:
2376 $lNew = '';
2377 foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) {
2378 if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
2379 $url = $this->listURL();
2380 $href = BackendUtility::getLinkToDataHandlerAction(
2381 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
2382 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
2383 );
2384 $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title');
2385 if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
2386 $lC = $this->iconFactory->getIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon'], Icon::SIZE_SMALL)->render();
2387 } else {
2388 $lC = $this->languageIconTitles[$lUid_OnPage]['title'];
2389 }
2390 $lC = '<a href="' . htmlspecialchars($href) . '" title="'
2391 . htmlspecialchars($language['title']) . '" class="btn btn-default">' . $lC . '</a> ';
2392 $lNew .= $lC;
2393 }
2394 }
2395 if ($lNew) {
2396 $out[1] .= $lNew;
2397 }
2398 } elseif ($row['l18n_parent']) {
2399 $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;' . $out[0];
2400 }
2401 return $out;
2402 }
2403
2404 /**
2405 * Creates a checkbox list for selecting fields to display from a table:
2406 *
2407 * @param string $table Table name
2408 * @param bool $formFields If TRUE, form-fields will be wrapped around the table.
2409 * @return string HTML table with the selector check box (name: displayFields['.$table.'][])
2410 */
2411 public function fieldSelectBox($table, $formFields = true)
2412 {
2413 $lang = $this->getLanguageService();
2414 // Init:
2415 $formElements = ['', ''];
2416 if ($formFields) {
2417 $formElements = ['<form action="' . htmlspecialchars($this->listURL()) . '" method="post" name="fieldSelectBox">', '</form>'];
2418 }
2419 // Load already selected fields, if any:
2420 $setFields = is_array($this->setFields[$table]) ? $this->setFields[$table] : [];
2421 // Request fields from table:
2422 $fields = $this->makeFieldList($table, false, true);
2423 // Add pseudo "control" fields
2424 $fields[] = '_PATH_';
2425 $fields[] = '_REF_';
2426 $fields[] = '_LOCALIZATION_';
2427 $fields[] = '_CONTROL_';
2428 $fields[] = '_CLIPBOARD_';
2429 // Create a checkbox for each field:
2430 $checkboxes = [];
2431 $checkAllChecked = true;
2432 $tsConfig = BackendUtility::getPagesTSconfig($this->id);
2433 $tsConfigOfTable = is_array($tsConfig['TCEFORM.'][$table . '.']) ? $tsConfig['TCEFORM.'][$table . '.'] : null;
2434 foreach ($fields as $fieldName) {
2435 // Hide field if hidden
2436 if ($tsConfigOfTable && is_array($tsConfigOfTable[$fieldName . '.']) && isset($tsConfigOfTable[$fieldName . '.']['disabled']) && (int)$tsConfigOfTable[$fieldName . '.']['disabled'] === 1) {
2437 continue;
2438 }
2439 // Determine, if checkbox should be checked
2440 if (in_array($fieldName, $setFields, true) || $fieldName === $this->fieldArray[0]) {
2441 $checked = ' checked="checked"';
2442 } else {
2443 $checkAllChecked = false;
2444 $checked = '';
2445 }
2446 // Field label
2447 $fieldLabel = is_array($GLOBALS['TCA'][$table]['columns'][$fieldName])
2448 ? rtrim($lang->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']), ':')
2449 : '';
2450 $checkboxes[] = '<tr><td class="col-checkbox"><input type="checkbox" id="check-' . $fieldName . '" name="displayFields['
2451 . $table . '][]" value="' . $fieldName . '" ' . $checked
2452 . ($fieldName === $this->fieldArray[0] ? ' disabled="disabled"' : '') . '></td><td class="col-title">'
2453 . '<label class="label-block" for="check-' . $fieldName . '">' . htmlspecialchars($fieldLabel) . ' <span class="text-muted text-monospace">[' . htmlspecialchars($fieldName) . ']</span></label></td></tr>';
2454 }
2455 // Table with the field selector::
2456 $content = $formElements[0] . '
2457 <input type="hidden" name="displayFields[' . $table . '][]" value="">
2458 <div class="table-fit table-scrollable">
2459 <table border="0" cellpadding="0" cellspacing="0" class="table table-transparent table-hover">
2460 <thead>
2461 <tr>
2462 <th class="col-checkbox checkbox" colspan="2">
2463 <label><input type="checkbox" class="checkbox checkAll" ' . ($checkAllChecked ? ' checked="checked"' : '') . '>
2464 ' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.toggleall')) . '</label>
2465 </th>
2466 </tr>
2467 </thead>
2468 <tbody>
2469 ' . implode('', $checkboxes) . '
2470 </tbody>
2471 </table>
2472 </div>
2473 <input type="submit" name="search" class="btn btn-default" value="'
2474 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.setFields')) . '"/>
2475 ' . $formElements[1];
2476 return '<div class="fieldSelectBox">' . $content . '</div>';
2477 }
2478
2479 /*********************************
2480 *
2481 * Helper functions
2482 *
2483 *********************************/
2484 /**
2485 * Creates a link around $string. The link contains an onclick action
2486 * which submits the script with some clipboard action.
2487 * Currently, this is used for setting elements / delete elements.
2488 *
2489 * @param string $string The HTML content to link (image/text)
2490 * @param string $table Table name
2491 * @param string $cmd Clipboard command (eg. "setCB" or "delete")
2492 * @param string $warning Warning text, if any ("delete" uses this for confirmation
2493 * @param string $title title attribute for the anchor
2494 * @return string <a> tag wrapped link.
2495 */
2496 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '', $title = '')
2497 {
2498 $jsCode = 'document.dblistForm.cmd.value=' . GeneralUtility::quoteJSvalue($cmd)
2499 . ';document.dblistForm.cmd_table.value='
2500 . GeneralUtility::quoteJSvalue($table)
2501 . ';document.dblistForm.submit();';
2502
2503 $attributes = [];
2504 if ($title !== '') {
2505 $attributes['title'] = $title;
2506 }
2507 if ($warning) {
2508 $attributes['class'] = 'btn btn-default t3js-modal-trigger';
2509 $attributes['data-href'] = 'javascript:' . $jsCode;
2510 $attributes['data-severity'] = 'warning';
2511 $attributes['data-title'] = $title;
2512 $attributes['data-content'] = $warning;
2513 } else {
2514 $attributes['class'] = 'btn btn-default';
2515 $attributes['onclick'] = $jsCode . 'return false;';
2516 }
2517
2518 $attributesString = '';
2519 foreach ($attributes as $key => $value) {
2520 $attributesString .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
2521 }
2522 return '<a href="#" ' . $attributesString . '>' . $string . '</a>';
2523 }
2524
2525 /**
2526 * Returns TRUE if a numeric clipboard pad is selected/active
2527 *
2528 * @return bool
2529 */
2530 public function clipNumPane()
2531 {
2532 return in_array('_CLIPBOARD_', $this->fieldArray) && $this->clipObj->current !== 'normal';
2533 }
2534
2535 /**
2536 * Creates a sort-by link on the input string ($code).
2537 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
2538 * Also some fields will not be possible to sort (including if single-table-view is disabled).
2539 *
2540 * @param string $code The string to link (text)
2541 * @param string $field The fieldname represented by the title ($code)
2542 * @param string $table Table name
2543 * @return string Linked $code variable
2544 */
2545 public function addSortLink($code, $field, $table)
2546 {
2547 // Certain circumstances just return string right away (no links):
2548 if ($field === '_CONTROL_' || $field === '_LOCALIZATION_' || $field === '_CLIPBOARD_' || $field === '_REF_' || $this->disableSingleTableView) {
2549 return $code;
2550 }
2551 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
2552 if ($field === '_PATH_') {
2553 $field = 'pid';
2554 }
2555 // Create the sort link:
2556 $sortUrl = $this->listURL('', '-1', 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table
2557 . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || $this->sortField != $field ? 0 : 1);
2558 $sortArrow = $this->sortField === $field
2559 ? $this->iconFactory->getIcon('status-status-sorting-' . ($this->sortRev ? 'desc' : 'asc'), Icon::SIZE_SMALL)->render()
2560 : '';
2561 // Return linked field:
2562 return '<a href="' . htmlspecialchars($sortUrl) . '">' . $code . $sortArrow . '</a>';
2563 }
2564
2565 /**
2566 * Returns the path for a certain pid
2567 * The result is cached internally for the session, thus you can call
2568 * this function as much as you like without performance problems.
2569 *
2570 * @param int $pid The page id for which to get the path
2571 * @return mixed[] The path.
2572 */
2573 public function recPath($pid)
2574 {
2575 if (!isset($this->recPath_cache[$pid])) {
2576 $this->recPath_cache[$pid] = BackendUtility::getRecordPath($pid, $this->perms_clause, 20);
2577 }
2578 return $this->recPath_cache[$pid];
2579 }
2580
2581 /**
2582 * Returns TRUE if a link for creating new records should be displayed for $table
2583 *
2584 * @param string $table Table name
2585 * @return bool Returns TRUE if a link for creating new records should be displayed for $table
2586 * @see \TYPO3\CMS\Backend\Controller\NewRecordController::showNewRecLink
2587 */
2588 public function showNewRecLink($table)
2589 {
2590 // No deny/allow tables are set:
2591 if (empty($this->allowedNewTables) && empty($this->deniedNewTables)) {
2592 return true;
2593 }
2594 return !in_array($table, $this->deniedNewTables)
2595 && (empty($this->allowedNewTables) || in_array($table, $this->allowedNewTables));
2596 }
2597
2598 /**
2599 * Creates the "&returnUrl" parameter for links - this is used when the script links
2600 * to other scripts and passes its own URL with the link so other scripts can return to the listing again.
2601 * Uses REQUEST_URI as value.
2602 *
2603 * @return string
2604 */
2605 public function makeReturnUrl()
2606 {
2607 return '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
2608 }
2609
2610 /************************************
2611 *
2612 * CSV related functions
2613 *
2614 ************************************/
2615 /**
2616 * Initializes internal csvLines array with the header of field names
2617 */
2618 protected function initCSV()
2619 {
2620 $this->addHeaderRowToCSV();
2621 }
2622
2623 /**
2624 * Add header line with field names as CSV line
2625 */
2626 protected function addHeaderRowToCSV()
2627 {
2628 // Add header row, control fields will be reduced inside addToCSV()
2629 $this->addToCSV(array_combine($this->fieldArray, $this->fieldArray));
2630 }
2631
2632 /**
2633 * Adds selected columns of one table row as CSV line.
2634 *
2635 * @param mixed[] $row Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
2636 */
2637 protected function addToCSV(array $row = [])
2638 {
2639 $rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
2640 // Get an field array without control fields but in the expected order
2641 $fieldArray = array_intersect_key(array_flip($this->fieldArray), $rowReducedByControlFields);
2642 // Overwrite fieldArray to keep the order with an array of needed fields
2643 $rowReducedToSelectedColumns = array_replace($fieldArray, array_intersect_key($rowReducedByControlFields, $fieldArray));
2644 $this->setCsvRow($rowReducedToSelectedColumns);
2645 }
2646
2647 /**
2648 * Remove control fields from row for CSV export
2649 *
2650 * @param mixed[] $row fieldNames => fieldValues
2651 * @return mixed[] Input array reduces by control fields
2652 */
2653 protected static function removeControlFieldsFromFieldRow(array $row = [])
2654 {
2655 // Possible control fields in a list row
2656 $controlFields = [
2657 '_PATH_',
2658 '_REF_',
2659 '_CONTROL_',
2660 '_CLIPBOARD_',
2661 '_LOCALIZATION_',
2662 '_LOCALIZATION_b'
2663 ];
2664 return array_diff_key($row, array_flip($controlFields));
2665 }
2666
2667 /**
2668 * Adds input row of values to the internal csvLines array as a CSV formatted line
2669 *
2670 * @param mixed[] $csvRow Array with values to be listed.
2671 */
2672 public function setCsvRow($csvRow)