DatabaseRecordList.php 85.1 KB
Newer Older
1
2
3
<?php
namespace TYPO3\CMS\Recordlist\RecordList;

4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
8
9
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
10
 *
11
12
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
15
 * The TYPO3 project - inspiring people to share!
 */
16

17
use TYPO3\CMS\Backend\Module\BaseScriptClass;
Markus Klein's avatar
Markus Klein committed
18
use TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface;
19
20
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Core\Database\DatabaseConnection;
21
22
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
Markus Klein's avatar
Markus Klein committed
23
24
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
25
use TYPO3\CMS\Core\Type\Bitmask\Permission;
26
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
27
28
29
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
Markus Klein's avatar
Markus Klein committed
30
use TYPO3\CMS\Frontend\Page\PageRepository;
31

32
33
34
/**
 * Class for rendering of Web>List module
 */
35
class DatabaseRecordList extends AbstractDatabaseRecordList {
36

37
	// *********
38
	// External:
39
40
	// *********

41
	/**
42
43
44
	 * Used to indicate which tables (values in the array) that can have a
	 * create-new-record link. If the array is empty, all tables are allowed.
	 *
Markus Klein's avatar
Markus Klein committed
45
	 * @var string[]
46
47
48
49
	 */
	public $allowedNewTables = array();

	/**
50
51
52
	 * Used to indicate which tables (values in the array) that cannot have a
	 * create-new-record link. If the array is empty, all tables are allowed.
	 *
Markus Klein's avatar
Markus Klein committed
53
	 * @var string[]
54
55
56
57
	 */
	public $deniedNewTables = array();

	/**
58
59
60
61
62
	 * If TRUE, the control panel will contain links to the create-new wizards for
	 * pages and tt_content elements (normally, the link goes to just creatinga new
	 * element without the wizards!).
	 *
	 * @var bool
63
64
65
66
	 */
	public $newWizards = FALSE;

	/**
67
68
69
	 * If TRUE, will disable the rendering of clipboard + control panels.
	 *
	 * @var bool
70
71
72
73
	 */
	public $dontShowClipControlPanels = FALSE;

	/**
74
75
76
	 * If TRUE, will show the clipboard in the field list.
	 *
	 * @var bool
77
78
79
80
	 */
	public $showClipboard = FALSE;

	/**
81
82
83
	 * If TRUE, will DISABLE all control panels in lists. (Takes precedence)
	 *
	 * @var bool
84
85
86
87
	 */
	public $noControlPanels = FALSE;

	/**
88
89
90
	 * If TRUE, clickmenus will be rendered
	 *
	 * @var bool
91
92
93
94
	 */
	public $clickMenuEnabled = TRUE;

	/**
95
96
97
	 * Count of record rows in view
	 *
	 * @var int
98
99
100
101
	 */
	public $totalRowCount;

	/**
102
103
104
	 * Space icon used for alignment
	 *
	 * @var string
105
106
107
	 */
	public $spaceIcon;

108
109
110
111
112
113
114
115
	/**
	 * Disable single table view
	 *
	 * @var bool
	 */
	public $disableSingleTableView = FALSE;

	// *********
116
	// Internal:
117
118
	// *********

119
	/**
120
121
	 * Set to the page record (see writeTop())
	 *
Markus Klein's avatar
Markus Klein committed
122
	 * @var string[]
123
124
125
	 */
	public $pageRow = array();

126
127
128
	/**
	 * Used to accumulate CSV lines for CSV export.
	 *
Markus Klein's avatar
Markus Klein committed
129
	 * @var string[]
130
	 */
131
132
133
	protected $csvLines = array();

	/**
134
135
136
	 * If set, the listing is returned as CSV instead.
	 *
	 * @var bool
137
138
139
140
141
142
143
144
145
146
147
	 */
	public $csvOutput = FALSE;

	/**
	 * Clipboard object
	 *
	 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
	 */
	public $clipObj;

	/**
148
149
	 * Tracking names of elements (for clipboard use)
	 *
Markus Klein's avatar
Markus Klein committed
150
	 * @var string[]
151
152
153
154
155
156
	 */
	public $CBnames = array();

	/**
	 * [$tablename][$uid] = number of references to this record
	 *
Markus Klein's avatar
Markus Klein committed
157
	 * @var int[][]
158
159
160
161
	 */
	protected $referenceCount = array();

	/**
162
163
	 * Translations of the current record
	 *
Markus Klein's avatar
Markus Klein committed
164
	 * @var string[]
165
166
167
168
	 */
	public $translations;

	/**
169
170
171
172
	 * select fields for the query which fetches the translations of the current
	 * record
	 *
	 * @var string
173
174
175
	 */
	public $selFieldList;

176
	/**
Markus Klein's avatar
Markus Klein committed
177
	 * @var mixed[]
178
179
	 */
	public $pageinfo;
180

Markus Klein's avatar
Markus Klein committed
181
182
183
184
185
186
187
	/**
	 * Injected by RecordList
	 *
	 * @var string[]
	 */
	public $MOD_MENU;

188
189
190
191
192
193
194
	/**
	 * If defined the records are editable
	 *
	 * @var bool
	 */
	protected $editable = TRUE;

195
196
197
198
199
200
201
202
203
	/**
	 * @var IconFactory
	 */
	protected $iconFactory;

	/**
	 * Constructor
	 */
	public function __construct() {
204
		parent::__construct();
205
206
207
		$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
	}

208
	/**
209
210
	 * Create the panel of buttons for submitting the form or otherwise perform
	 * operations.
211
	 *
Markus Klein's avatar
Markus Klein committed
212
	 * @return string[] All available buttons as an assoc. array
213
214
	 */
	public function getButtons() {
Markus Klein's avatar
Markus Klein committed
215
216
217
		$module = $this->getModule();
		$backendUser = $this->getBackendUserAuthentication();
		$lang = $this->getLanguageService();
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
		$buttons = array(
			'csh' => '',
			'view' => '',
			'edit' => '',
			'hide_unhide' => '',
			'move' => '',
			'new_record' => '',
			'paste' => '',
			'level_up' => '',
			'cache' => '',
			'reload' => '',
			'shortcut' => '',
			'back' => '',
			'csv' => '',
			'export' => ''
		);
		// Get users permissions for this page record:
Markus Klein's avatar
Markus Klein committed
235
		$localCalcPerms = $backendUser->calcPerms($this->pageRow);
236
		// CSH
237
		if ((string)$this->id === '') {
Benni Mack's avatar
Benni Mack committed
238
			$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_noId');
239
		} elseif (!$this->id) {
Benni Mack's avatar
Benni Mack committed
240
			$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_root');
241
		} else {
Benni Mack's avatar
Benni Mack committed
242
			$buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module');
243
244
		}
		if (isset($this->id)) {
245
246
			// View Exclude doktypes 254,255 Configuration:
			// mod.web_list.noViewWithDokTypes = 254,255
Markus Klein's avatar
Markus Klein committed
247
248
			if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
				$noViewDokTypes = GeneralUtility::trimExplode(',', $module->modTSconfig['properties']['noViewWithDokTypes'], TRUE);
249
250
			} else {
				//default exclusion: doktype 254 (folder), 255 (recycler)
251
				$noViewDokTypes = array(
Markus Klein's avatar
Markus Klein committed
252
253
					PageRepository::DOKTYPE_SYSFOLDER,
					PageRepository::DOKTYPE_RECYCLER
254
				);
255
256
			}
			if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
257
				$onClick = htmlspecialchars(BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id)));
258
				$buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
Markus Klein's avatar
Markus Klein committed
259
					. $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">'
260
					. $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL) . '</a>';
261
			}
262
263
			// New record on pages that are not locked by editlock
			if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
264
				$onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => $this->id])) . ');');
265
				$buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
Markus Klein's avatar
Markus Klein committed
266
					. $lang->getLL('newRecordGeneral', TRUE) . '">'
267
					. $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL) . '</a>';
268
			}
269
270
			// If edit permissions are set, see
			// \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
271
			if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions()) {
272
				// Edit
273
				$params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
274
				$onClick = htmlspecialchars(BackendUtility::editOnClick($params, '', -1));
275
				$buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="'
Markus Klein's avatar
Markus Klein committed
276
					. $lang->getLL('editPage', TRUE) . '">'
277
					. IconUtility::getSpriteIcon('actions-page-open') . '</a>';
278
279
			}
			// Paste
280
			if (($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
281
				$elFromTable = $this->clipObj->elFromTable('');
282
				if (!empty($elFromTable)) {
283
284
					$onClick = htmlspecialchars(('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable)));
					$buttons['paste'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id))
Markus Klein's avatar
Markus Klein committed
285
						. '" onclick="' . $onClick . '" title="' . $lang->getLL('clip_paste', TRUE) . '">'
286
						. $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL) . '</a>';
287
288
289
				}
			}
			// Cache
290
			$buttons['cache'] = '<a href="' . htmlspecialchars(($this->listURL() . '&clear_cache=1')) . '" title="'
Markus Klein's avatar
Markus Klein committed
291
				. $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache', TRUE) . '">'
292
293
				. IconUtility::getSpriteIcon('actions-system-cache-clear') . '</a>';
			if (
Markus Klein's avatar
Markus Klein committed
294
295
296
				$this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
				|| (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
					&& !$module->modTSconfig['properties']['noExportRecordsLinks']))
297
			) {
298
				// CSV
299
				$buttons['csv'] = '<a href="' . htmlspecialchars(($this->listURL() . '&csv=1')) . '" title="'
Markus Klein's avatar
Markus Klein committed
300
					. $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.csv', TRUE) . '">'
301
					. IconUtility::getSpriteIcon('mimetypes-text-csv') . '</a>';
302
				// Export
303
				if (ExtensionManagementUtility::isLoaded('impexp')) {
304
					$url = BackendUtility::getModuleUrl('xMOD_tximpexp', array('tx_impexp[action]' => 'export'));
305
306
					$buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
							. rawurlencode($this->table . ':' . $this->id)) . '" title="'
Markus Klein's avatar
Markus Klein committed
307
						. $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.export', TRUE) . '">'
308
						. $this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL) . '</a>';
309
310
311
				}
			}
			// Reload
312
			$buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
Markus Klein's avatar
Markus Klein committed
313
				. $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">'
314
				. IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
315
			// Shortcut
Markus Klein's avatar
Markus Klein committed
316
317
			if ($backendUser->mayMakeShortcut()) {
				$buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
318
319
320
321
					'id, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
					implode(',', array_keys($this->MOD_MENU)),
					'web_list'
				);
322
323
324
			}
			// Back
			if ($this->returnUrl) {
325
326
				$href = htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl, array('id' => $this->id)));
				$buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
Markus Klein's avatar
Markus Klein committed
327
					. $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">'
328
					. IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
329
330
331
332
333
334
335
336
337
			}
		}
		return $buttons;
	}

	/**
	 * Creates the listing of records from a single table
	 *
	 * @param string $table Table name
338
339
340
	 * @param int $id Page id
	 * @param string $rowList List of fields to show in the listing. Pseudo fields will be added including the record header.
	 * @throws \UnexpectedValueException
341
342
	 * @return string HTML table with the listing for the record.
	 */
Susanne Moog's avatar
Susanne Moog committed
343
	public function getTable($table, $id, $rowList = '') {
344
345
346
347
348
		$rowListArray = GeneralUtility::trimExplode(',', $rowList, TRUE);
		// if no columns have been specified, show description (if configured)
		if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
			array_push($rowListArray, $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']);
		}
Markus Klein's avatar
Markus Klein committed
349
350
351
		$backendUser = $this->getBackendUserAuthentication();
		$lang = $this->getLanguageService();
		$db = $this->getDatabaseConnection();
352
353
354
355
		// Init
		$addWhere = '';
		$titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
		$thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
356
357
358
359
		$l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
			&& $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
			&& !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
		$tableCollapsed = (bool)$this->tablesCollapsed[$table];
360
		// prepare space icon
361
		$this->spaceIcon = '<span class="btn btn-default disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
362
363
364
365
366
367
		// Cleaning rowlist for duplicates and place the $titleCol as the first column always!
		$this->fieldArray = array();
		// title Column
		// Add title column
		$this->fieldArray[] = $titleCol;
		// Control-Panel
368
		if (!GeneralUtility::inList($rowList, '_CONTROL_')) {
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
			$this->fieldArray[] = '_CONTROL_';
		}
		// Clipboard
		if ($this->showClipboard) {
			$this->fieldArray[] = '_CLIPBOARD_';
		}
		// Ref
		if (!$this->dontShowClipControlPanels) {
			$this->fieldArray[] = '_REF_';
		}
		// Path
		if ($this->searchLevels) {
			$this->fieldArray[] = '_PATH_';
		}
		// Localization
		if ($this->localizationView && $l10nEnabled) {
			$this->fieldArray[] = '_LOCALIZATION_';
			$this->fieldArray[] = '_LOCALIZATION_b';
387
388
			$addWhere .= ' AND (
				' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '<=0
389
				OR
390
				' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ' = 0
391
392
393
			)';
		}
		// Cleaning up:
394
		$this->fieldArray = array_unique(array_merge($this->fieldArray, $rowListArray));
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
		if ($this->noControlPanels) {
			$tempArray = array_flip($this->fieldArray);
			unset($tempArray['_CONTROL_']);
			unset($tempArray['_CLIPBOARD_']);
			$this->fieldArray = array_keys($tempArray);
		}
		// Creating the list of fields to include in the SQL query:
		$selectFields = $this->fieldArray;
		$selectFields[] = 'uid';
		$selectFields[] = 'pid';
		// adding column for thumbnails
		if ($thumbsCol) {
			$selectFields[] = $thumbsCol;
		}
		if ($table == 'pages') {
410
411
412
			$selectFields[] = 'module';
			$selectFields[] = 'extendToSubpages';
			$selectFields[] = 'nav_hide';
413
			$selectFields[] = 'doktype';
414
			$selectFields[] = 'shortcut';
415
416
			$selectFields[] = 'shortcut_mode';
			$selectFields[] = 'mount_pid';
417
418
419
420
		}
		if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
			$selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
		}
421
422
423
424
		foreach(array('type', 'typeicon_column', 'editlock') as $field) {
			if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
				$selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
			}
425
426
427
428
429
430
431
432
433
434
435
		}
		if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
			$selectFields[] = 't3ver_id';
			$selectFields[] = 't3ver_state';
			$selectFields[] = 't3ver_wsid';
		}
		if ($l10nEnabled) {
			$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
			$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
		}
		if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
436
437
438
439
			$selectFields = array_merge(
				$selectFields,
				GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], TRUE)
			);
440
441
442
443
444
		}
		// Unique list!
		$selectFields = array_unique($selectFields);
		$fieldListFields = $this->makeFieldList($table, 1);
		if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
Markus Klein's avatar
Markus Klein committed
445
446
			$message = sprintf($lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessage', TRUE), $table, $table);
			$messageTitle = $lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle', TRUE);
447
			/** @var FlashMessage $flashMessage */
448
			$flashMessage = GeneralUtility::makeInstance(
Markus Klein's avatar
Markus Klein committed
449
				FlashMessage::class,
450
451
				$message,
				$messageTitle,
Markus Klein's avatar
Markus Klein committed
452
				FlashMessage::WARNING,
453
454
				TRUE
			);
Markus Klein's avatar
Markus Klein committed
455
456
			/** @var $flashMessageService FlashMessageService */
			$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
457
458
459
			/** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
			$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
			$defaultFlashMessageQueue->enqueue($flashMessage);
460
461
462
463
464
465
466
467
		}
		// Making sure that the fields in the field-list ARE in the field-list from TCA!
		$selectFields = array_intersect($selectFields, $fieldListFields);
		// Implode it into a list of fields for the SQL-statement.
		$selFieldList = implode(',', $selectFields);
		$this->selFieldList = $selFieldList;
		if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
			foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
468
				$hookObject = GeneralUtility::getUserObj($classData);
Markus Klein's avatar
Markus Klein committed
469
470
				if (!$hookObject instanceof RecordListGetTableHookInterface) {
					throw new \UnexpectedValueException('$hookObject must implement interface ' . RecordListGetTableHookInterface::class, 1195114460);
471
472
473
474
475
476
477
478
479
480
481
482
483
				}
				$hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
			}
		}
		// Create the SQL query for selecting the elements in the listing:
		// do not do paging when outputting as CSV
		if ($this->csvOutput) {
			$this->iLimit = 0;
		}
		if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
			// Get the two previous rows for sorting if displaying page > 1
			$this->firstElementNumber = $this->firstElementNumber - 2;
			$this->iLimit = $this->iLimit + 2;
484
			// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
485
486
487
488
			$queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
			$this->firstElementNumber = $this->firstElementNumber + 2;
			$this->iLimit = $this->iLimit - 2;
		} else {
489
			// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
490
491
			$queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
		}
492
493
494

		// Finding the total amount of records on the page
		// (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
495
		$this->setTotalItems($queryParts);
496

497
498
499
		// Init:
		$dbCount = 0;
		$out = '';
500
		$tableHeader = '';
501
		$result = NULL;
502
		$listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
503
504
		// If the count query returned any number of records, we perform the real query,
		// selecting records.
505
		if ($this->totalItems) {
506
507
			// Fetch records only if not in single table mode
			if ($listOnlyInSingleTableMode) {
508
509
510
511
512
513
514
				$dbCount = $this->totalItems;
			} else {
				// Set the showLimit to the number of records when outputting as CSV
				if ($this->csvOutput) {
					$this->showLimit = $this->totalItems;
					$this->iLimit = $this->totalItems;
				}
Markus Klein's avatar
Markus Klein committed
515
516
				$result = $db->exec_SELECT_queryArray($queryParts);
				$dbCount = $db->sql_num_rows($result);
517
518
519
520
			}
		}
		// If any records was selected, render the list:
		if ($dbCount) {
Markus Klein's avatar
Markus Klein committed
521
			$tableTitle = $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
522
523
524
525
526
527
			if ($tableTitle === '') {
				$tableTitle = $table;
			}
			// Header line is drawn
			$theData = array();
			if ($this->disableSingleTableView) {
528
				$theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $tableTitle)
529
					. '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
530
			} else {
531
				$icon = $this->table
Markus Klein's avatar
Markus Klein committed
532
533
					? IconUtility::getSpriteIcon('actions-view-table-collapse', array('title' => $lang->getLL('contractView', TRUE)))
					: IconUtility::getSpriteIcon('actions-view-table-expand', array('title' => $lang->getLL('expandView', TRUE)));
534
				$theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon);
535
536
			}
			if ($listOnlyInSingleTableMode) {
537
				$tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]);
538
539
540
541
			} else {
				// Render collapse button if in multi table mode
				$collapseIcon = '';
				if (!$this->table) {
542
543
					$href = htmlspecialchars(($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1')));
					$title = $tableCollapsed
Markus Klein's avatar
Markus Klein committed
544
545
						? $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.expandTable', TRUE)
						: $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.collapseTable', TRUE);
546
547
548
					$icon = $tableCollapsed
						? IconUtility::getSpriteIcon('actions-view-list-expand', array('class' => 'collapseIcon'))
						: IconUtility::getSpriteIcon('actions-view-list-collapse', array('class' => 'collapseIcon'));
549
					$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>';
550
				}
551
				$tableHeader .= $theData[$titleCol] . $collapseIcon;
552
			}
553
			// Render table rows only if in multi table view or if in single table view
Markus Klein's avatar
Markus Klein committed
554
			$rowOutput = '';
555
			if (!$listOnlyInSingleTableMode || $this->table) {
556
				// Fixing an order table for sortby tables
557
558
559
560
561
562
563
				$this->currentTable = array();
				$currentIdList = array();
				$doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
				$prevUid = 0;
				$prevPrevUid = 0;
				// Get first two rows and initialize prevPrevUid and prevUid if on page > 1
				if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
Markus Klein's avatar
Markus Klein committed
564
					$row = $db->sql_fetch_assoc($result);
565
					$prevPrevUid = -((int)$row['uid']);
Markus Klein's avatar
Markus Klein committed
566
					$row = $db->sql_fetch_assoc($result);
567
568
569
570
					$prevUid = $row['uid'];
				}
				$accRows = array();
				// Accumulate rows here
Markus Klein's avatar
Markus Klein committed
571
				while ($row = $db->sql_fetch_assoc($result)) {
572
573
574
575
					if (!$this->isRowListingConditionFulfilled($table, $row)) {
						continue;
					}
					// In offline workspace, look for alternative record:
Markus Klein's avatar
Markus Klein committed
576
					BackendUtility::workspaceOL($table, $row, $backendUser->workspace, TRUE);
577
578
579
580
581
582
583
584
585
586
587
588
589
590
					if (is_array($row)) {
						$accRows[] = $row;
						$currentIdList[] = $row['uid'];
						if ($doSort) {
							if ($prevUid) {
								$this->currentTable['prev'][$row['uid']] = $prevPrevUid;
								$this->currentTable['next'][$prevUid] = '-' . $row['uid'];
								$this->currentTable['prevUid'][$row['uid']] = $prevUid;
							}
							$prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
							$prevUid = $row['uid'];
						}
					}
				}
Markus Klein's avatar
Markus Klein committed
591
				$db->sql_free_result($result);
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
				$this->totalRowCount = count($accRows);
				// CSV initiated
				if ($this->csvOutput) {
					$this->initCSV();
				}
				// Render items:
				$this->CBnames = array();
				$this->duplicateStack = array();
				$this->eCounter = $this->firstElementNumber;
				$cc = 0;
				foreach ($accRows as $row) {
					// Render item row if counter < limit
					if ($cc < $this->iLimit) {
						$cc++;
						$this->translations = FALSE;
Markus Klein's avatar
Markus Klein committed
607
						$rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
608
609
610
611
612
613
614
615
616
617
						// If localization view is enabled it means that the selected records are
						// either default or All language and here we will not select translations
						// which point to the main record:
						if ($this->localizationView && $l10nEnabled) {
							// For each available translation, render the record:
							if (is_array($this->translations)) {
								foreach ($this->translations as $lRow) {
									// $lRow isn't always what we want - if record was moved we've to work with the
									// placeholder records otherwise the list is messed up a bit
									if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
618
619
620
										$where = 't3ver_move_id="' . (int)$lRow['uid'] . '" AND pid="' . $row['_MOVE_PLH_pid']
											. '" AND t3ver_wsid=' . $row['t3ver_wsid'] . BackendUtility::deleteClause($table);
										$tmpRow = BackendUtility::getRecordRaw($table, $where, $selFieldList);
621
622
623
										$lRow = is_array($tmpRow) ? $tmpRow : $lRow;
									}
									// In offline workspace, look for alternative record:
Markus Klein's avatar
Markus Klein committed
624
625
									BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, TRUE);
									if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
626
										$currentIdList[] = $lRow['uid'];
Markus Klein's avatar
Markus Klein committed
627
										$rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
628
629
630
631
632
633
634
635
									}
								}
							}
						}
					}
					// Counter of total rows incremented:
					$this->eCounter++;
				}
636
637
				// Record navigation is added to the beginning and end of the table if in single
				// table mode
638
				if ($this->table) {
Markus Klein's avatar
Markus Klein committed
639
					$rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
640
641
642
643
644
				} else {
					// Show that there are more records than shown
					if ($this->totalItems > $this->itemsLimitPerTable) {
						$countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
						$hasMore = $this->totalItems > $this->itemsLimitSingleTable;
645
						$colspan = $this->showIcon ? count($this->fieldArray) + 1 : count($this->fieldArray);
Markus Klein's avatar
Markus Klein committed
646
						$rowOutput .= '<tr><td colspan="' . $colspan . '">
647
								<a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table))) . '" class="btn btn-default">'
648
							. '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
649
650
651
652
653
654
								</td></tr>';
					}
				}
				// The header row for the table is now created:
				$out .= $this->renderListHeader($table, $currentIdList);
			}
655
656
657
658

			$collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse in';
			$dataState = $tableCollapsed && !$this->table ? 'collapsed' : 'expanded';

659
			// The list of records is added after the header:
Markus Klein's avatar
Markus Klein committed
660
			$out .= $rowOutput;
661
			// ... and it is all wrapped in a table:
662
			$out = '
663
664
665
666



			<!--
667
				DB listing of elements:	"' . htmlspecialchars($table) . '"
668
			-->
669
				<div class="panel panel-space panel-default">
670
671
672
					<div class="panel-heading">
					' . $tableHeader . '
					</div>
673
					<div class="table-fit ' . $collapseClass . '" id="recordlist-' . htmlspecialchars($table) . '" data-state="' . $dataState . '">
674
						<table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
675
676
677
678
679
							' . $out . '
						</table>
					</div>
				</div>
			';
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
			// Output csv if...
			// This ends the page with exit.
			if ($this->csvOutput) {
				$this->outputCSV($table);
			}
		}
		// Return content:
		return $out;
	}

	/**
	 * Check if all row listing conditions are fulfilled.
	 *
	 * This function serves as a dummy method to be overriden in extending classes.
	 *
	 * @param string $table Table name
Markus Klein's avatar
Markus Klein committed
696
	 * @param string[] $row Record
697
	 * @return bool True, if all conditions are fulfilled.
698
699
700
701
702
703
704
705
706
	 */
	protected function isRowListingConditionFulfilled($table, $row) {
		return TRUE;
	}

	/**
	 * Rendering a single row for the list
	 *
	 * @param string $table Table name
Markus Klein's avatar
Markus Klein committed
707
	 * @param mixed[] $row Current record
708
	 * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
709
710
	 * @param string $titleCol Table field (column) where header value is found
	 * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
711
	 * @param int $indent Indent from left.
712
713
714
715
716
	 * @return string Table row for the element
	 * @access private
	 * @see getTable()
	 */
	public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0) {
Markus Klein's avatar
Markus Klein committed
717
718
719
720
		if (!is_array($row)) {
			return '';
		}
		$rowOutput = '';
721
		$id_orig = NULL;
722
		// If in search mode, make sure the preview will show the correct page
723
		if ((string)$this->searchString !== '') {
724
725
726
			$id_orig = $this->id;
			$this->id = $row['pid'];
		}
Markus Klein's avatar
Markus Klein committed
727
728
729
730
731
732
733
734
		// Add special classes for first and last row
		$rowSpecial = '';
		if ($cc == 1 && $indent == 0) {
			$rowSpecial .= ' firstcol';
		}
		if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
			$rowSpecial .= ' lastcol';
		}
735

Markus Klein's avatar
Markus Klein committed
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
		$row_bgColor = ' class="' . $rowSpecial . '"';

		// Overriding with versions background color if any:
		$row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
		// Incr. counter.
		$this->counter++;
		// The icon with link
		$altText = htmlspecialchars(BackendUtility::getRecordIconAltText($row, $table));
		$iconImg = IconUtility::getSpriteIconForRecord(
			$table,
			$row,
			array('title' => $altText, 'style' => $indent ? ' margin-left: ' . $indent . 'px;' : '')
		);
		$theIcon = $this->clickMenuEnabled ? $this->getModule()->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
		// Preparing and getting the data-array
		$theData = array();
		$localizationMarkerClass = '';
		foreach ($this->fieldArray as $fCol) {
			if ($fCol == $titleCol) {
				$recTitle = BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
				$warning = '';
				// If the record is edit-locked	by another user, we will show a little warning sign:
758
759
				$lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
				if ($lockInfo) {
Markus Klein's avatar
Markus Klein committed
760
761
762
763
764
					$warning = '<a href="#" onclick="alert('
						. GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="'
						. htmlspecialchars($lockInfo['msg']) . '">'
						. IconUtility::getSpriteIcon('status-warning-in-use') . '</a>';
				}
765
				$theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
Markus Klein's avatar
Markus Klein committed
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
				// Render thumbnails, if:
				// - a thumbnail column exists
				// - there is content in it
				// - the thumbnail column is visible for the current type
				$type = 0;
				if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
					$typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
					$type = $row[$typeColumn];
				}
				// If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
				// if 0 doesn't exist)
				if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
					$type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
				}
				$visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
781

Markus Klein's avatar
Markus Klein committed
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
				if ($this->thumbs &&
					trim($row[$thumbsCol]) &&
					preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
				) {
					$theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
				}
				if (
					isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
					&& $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
					&& $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
				) {
					// It's a translated record with a language parent
					$localizationMarkerClass = ' localization';
				}
			} elseif ($fCol == 'pid') {
				$theData[$fCol] = $row[$fCol];
			} elseif ($fCol == '_PATH_') {
				$theData[$fCol] = $this->recPath($row['pid']);
			} elseif ($fCol == '_REF_') {
				$theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
			} elseif ($fCol == '_CONTROL_') {
				$theData[$fCol] = $this->makeControl($table, $row);
			} elseif ($fCol == '_CLIPBOARD_') {
				$theData[$fCol] = $this->makeClip($table, $row);
			} elseif ($fCol == '_LOCALIZATION_') {
				list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
				$theData[$fCol] = $lC1;
				$theData[$fCol . 'b'] = $lC2;
			} elseif ($fCol == '_LOCALIZATION_b') {
				// deliberately empty
			} else {
813
814
				$pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
				$tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], TRUE, $pageId);
Markus Klein's avatar
Markus Klein committed
815
816
817
				$theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
				if ($this->csvOutput) {
					$row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
818
819
820
				}
			}
		}
Markus Klein's avatar
Markus Klein committed
821
822
823
824
825
826
827
828
829
830
		// Reset the ID if it was overwritten
		if ((string)$this->searchString !== '') {
			$this->id = $id_orig;
		}
		// Add row to CSV list:
		if ($this->csvOutput) {
			$this->addToCSV($row, $table);
		}
		// Add classes to table cells
		$this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
831
832
		$this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
		if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
Markus Klein's avatar
Markus Klein committed
833
834
835
836
837
838
839
			$this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
		}
		$this->addElement_tdCssClass['_PATH_'] = 'col-path';
		$this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
		$this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
		// Create element in table cells:
		$theData['uid'] = $row['uid'];
840
841
842
843
844
845
846
		if (
			isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
			&& isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
			&& !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])
		) {
			$theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
		}
Markus Klein's avatar
Markus Klein committed
847
848
849
		$rowOutput .= $this->addelement(1, $theIcon, $theData, $row_bgColor);
		// Finally, return table row element:
		return $rowOutput;
850
851
852
853
854
855
856
	}

	/**
	 * Gets the number of records referencing the record with the UID $uid in
	 * the table $tableName.
	 *
	 * @param string $tableName
857
858
	 * @param int $uid
	 * @return int The number of references to record $uid in table
859
860
	 */
	protected function getReferenceCount($tableName, $uid) {
Markus Klein's avatar
Markus Klein committed
861
		$db = $this->getDatabaseConnection();
862
		if (!isset($this->referenceCount[$tableName][$uid])) {
Markus Klein's avatar
Markus Klein committed
863
			$where = 'ref_table = ' . $db->fullQuoteStr($tableName, 'sys_refindex')
864
				. ' AND ref_uid = ' . $uid . ' AND deleted = 0';
Markus Klein's avatar
Markus Klein committed
865
			$numberOfReferences = $db->exec_SELECTcountRows('*', 'sys_refindex', $where);
866
867
868
869
870
871
872
873
874
			$this->referenceCount[$tableName][$uid] = $numberOfReferences;
		}
		return $this->referenceCount[$tableName][$uid];
	}

	/**
	 * Rendering the header row for a table
	 *
	 * @param string $table Table name
Markus Klein's avatar
Markus Klein committed
875
	 * @param int[] $currentIdList Array of the currently displayed uids of the table
876
	 * @throws \UnexpectedValueException
877
878
879
880
881
	 * @return string Header table row
	 * @access private
	 * @see getTable()
	 */
	public function renderListHeader($table, $currentIdList) {
Markus Klein's avatar
Markus Klein committed
882
		$lang = $this->getLanguageService();
883
884
		// Init:
		$theData = array();
885
		$icon = '';
886
887
888
		// Traverse the fields:
		foreach ($this->fieldArray as $fCol) {
			// Calculate users permissions to edit records in the table:
889
			$permsEdit = $this->calcPerms & ($table == 'pages' ? 2 : 16) && $this->overlayEditLockPermissions($table);
890
			switch ((string)$fCol) {
891
892
				case '_PATH_':
					// Path
Markus Klein's avatar
Markus Klein committed
893
					$theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels._PATH_', TRUE) . ']</i>';
894
895
896
					break;
				case '_REF_':
					// References
Markus Klein's avatar
Markus Klein committed
897
					$theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:c__REF_', TRUE) . ']</i>';
898
899
900
					break;
				case '_LOCALIZATION_':
					// Path
Markus Klein's avatar
Markus Klein committed
901
					$theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels._LOCALIZATION_', TRUE) . ']</i>';
902
903
904
					break;
				case '_LOCALIZATION_b':
					// Path
Markus Klein's avatar
Markus Klein committed
905
					$theData[$fCol] = $lang->getLL('Localize', TRUE);
906
907
					break;
				case '_CLIPBOARD_':
908
909
910
					if (!$this->getModule()->MOD_SETTINGS['clipBoard']) {
						break;
					}
911
912
					// Clipboard:
					$cells = array();
913
914
					// If there are elements on the clipboard for this table, and the parent page is not locked by editlock
					// then display the "paste into" icon:
915
					$elFromTable = $this->clipObj->elFromTable($table);
916
					if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) {
917
918
						$href = htmlspecialchars($this->clipObj->pasteUrl($table, $this->id));
						$onClick = htmlspecialchars('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable));
919
						$cells['pasteAfter'] = '<a class="btn btn-default" href="' . $href . '" onclick="' . $onClick
Markus Klein's avatar
Markus Klein committed
920
							. '" title="' . $lang->getLL('clip_paste', TRUE) . '">'
921
							. $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL) . '</a>';
922
					}
923
924
925
					// If the numeric clipboard pads are enabled, display the control icons for that:
					if ($this->clipObj->current != 'normal') {
						// The "select" link:
Markus Klein's avatar
Markus Klein committed
926
						$spriteIcon = IconUtility::getSpriteIcon('actions-edit-copy', array('title' => $lang->getLL('clip_selectMarked', TRUE)));
927
						$cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB');
928
929
930
						// The "edit marked" link:
						$editIdList = implode(',', $currentIdList);
						$editIdList = '\'+editList(\'' . $table . '\',\'' . $editIdList . '\')+\'';
931
932
933
934
935
936
937
						$params = 'edit[' . $table . '][' . $editIdList . ']=edit';
						$onClick = BackendUtility::editOnClick('', '', -1);
						$onClickArray = explode('?', $onClick, 2);
						$lastElement = array_pop($onClickArray);
						array_push($onClickArray, $params . '&' . $lastElement);
						$onClick = implode('?', $onClickArray);
						$cells['edit'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
Markus Klein's avatar
Markus Klein committed
938
							. $lang->getLL('clip_editMarked', TRUE) . '">'
939
							. IconUtility::getSpriteIcon('actions-document-open') . '</a>';
940
						// The "Delete marked" link:
941
						$cells['delete'] = $this->linkClipboardHeaderIcon(
Markus Klein's avatar
Markus Klein committed
942
							IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $lang->getLL('clip_deleteMarked', TRUE))),
943
944
							$table,
							'delete',
Markus Klein's avatar
Markus Klein committed
945
							sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']))
946
						);
947
						// The "Select all" link:
948
						$onClick = htmlspecialchars(('checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;'));
949
						$cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="'
Markus Klein's avatar
Markus Klein committed
950
							. $lang->getLL('clip_markRecords', TRUE) . '">'
951
							. $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL) . '</a>';
952
953
954
955
					} else {
						$cells['empty'] = '';
					}
					/**
956
957
958
959
960
					 * @hook renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
					 * @usage Above each listed table in Web>List a header row is shown.
					 *        This hook allows to modify the icons responsible for the clipboard functions
					 *        (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected),
					 *        or other "Action" functions which perform operations on the listed records.
961
962
963
					*/
					if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
						foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
964
							$hookObject = GeneralUtility::getUserObj($classData);
Markus Klein's avatar
Markus Klein committed
965
966
							if (!$hookObject instanceof RecordListHookInterface) {
								throw new \UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface::class, 1195567850);
967
							}
968
							$cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
969
970
						}
					}
971
					$theData[$fCol] = '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
972
973
974
					break;
				case '_CONTROL_':
					// Control panel:
975
					if ($this->isEditable($table)) {
976
						// If new records can be created on this page, add links:
977
978
						$permsAdditional = ($table === 'pages' ? 8 : 16);
						if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) {
979
980
981
982
983
							$spriteIcon = $table === 'pages'
								? IconUtility::getSpriteIcon('actions-page-new')
								: IconUtility::getSpriteIcon('actions-document-new');
							if ($table === 'tt_content' && $this->newWizards) {
								// If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
984
								$tmpTSc = BackendUtility::getModTSconfig($this->pageinfo['uid'], 'mod.web_list');
985
								$tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension'];
986
								$newContentWizScriptPath = ExtensionManagementUtility::isLoaded($tmpTSc)
987
									? ExtensionManagementUtility::extRelPath($tmpTSc) . 'mod1/db_new_content_el.php?id=' . $this->id
988
									: BackendUtility::getModuleUrl('new_content_element', array('id' => $this->id));
989
990

								$onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($newContentWizScriptPath) . ');';
991
								$icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
Markus Klein's avatar
Markus Klein committed
992
									. $lang->getLL('new', TRUE) . '">' . $spriteIcon . '</a>';
993
							} elseif ($table == 'pages' && $this->newWizards) {
994
								$parameters = ['id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
995
								$href = BackendUtility::getModuleUrl('db_new', $parameters);
996
								$icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . $lang->getLL('new', TRUE) . '">'
997
									. $spriteIcon . '</a>';
998
999
1000
							} else {
								$params = '&edit[' . $table . '][' . $this->id . ']=new';
								if ($table == 'pages_language_overlay') {
1001
									$params .= '&overrideVals[pages_language_overlay][doktype]=' . (int)$this->pageRow['doktype'];
1002
								}
1003
								$icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
Markus Klein's avatar
Markus Klein committed
1004
									. '" title="' . $lang->getLL('new', TRUE) . '">' . $spriteIcon . '</a>';
1005
							}
1006
						}
1007
1008
1009
1010
1011
1012
						// If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
						if ($permsEdit && $this->table && is_array($currentIdList)) {
							$editIdList = implode(',', $currentIdList);
							if ($this->clipNumPane()) {
								$editIdList = '\'+editList(\'' . $table . '\',\'' . $editIdList . '\')+\'';
							}
1013
							$params = '&edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . implode(',', $this->fieldArray);
1014
							$icon .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
Markus Klein's avatar
Markus Klein committed
1015
								. '" title="' . $lang->getLL('editShownColumns', TRUE) . '">'
1016
								. IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1017
							$icon = '<div class="btn-group" role="group">' . $icon . '</div>';
1018
1019
1020
						}
						// Add an empty entry, so column count fits again after moving this into $icon
						$theData[$fCol] = '&nbsp;';