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