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