PageLayoutController.php 56.7 KB
Newer Older
1
2
3
<?php
namespace TYPO3\CMS\Backend\Controller;

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
18
19
20
21
use TYPO3\CMS\Backend\Form\Exception\AccessDeniedException;
use TYPO3\CMS\Backend\Form\FormDataCompiler;
use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord;
use TYPO3\CMS\Backend\Form\FormResultCompiler;
use TYPO3\CMS\Backend\Form\NodeFactory;
Nicole Cordes's avatar
Nicole Cordes committed
22
23
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
24
25
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
26
use TYPO3\CMS\Core\Page\PageRenderer;
27
use TYPO3\CMS\Core\Type\Bitmask\Permission;
Nicole Cordes's avatar
Nicole Cordes committed
28
29
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
30
use TYPO3\CMS\Core\Utility\HttpUtility;
Nicole Cordes's avatar
Nicole Cordes committed
31
use TYPO3\CMS\Core\Utility\MathUtility;
32
use TYPO3\CMS\Fluid\View\StandaloneView;
33
use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper;
34
35
36
37
38
39
40
41
42
use TYPO3\CMS\Recordlist\RecordList;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Frontend\Page\PageRepository;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\View\BackendLayoutView;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Backend\Tree\View\ContentLayoutPagePositionMap;
43
use TYPO3\CMS\Core\Versioning\VersionState;
Nicole Cordes's avatar
Nicole Cordes committed
44

45
46
47
48
49
/**
 * Script Class for Web > Layout module
 */
class PageLayoutController {

50
51
52
53
54
	/**
	 * Page Id for which to make the listing
	 *
	 * @var int
	 */
55
56
	public $id;

57
58
59
60
61
	/**
	 * Pointer - for browsing list of records.
	 *
	 * @var int
	 */
62
63
	public $pointer;

64
65
66
67
68
	/**
	 * Thumbnails or not
	 *
	 * @var string
	 */
69
70
	public $imagemode;

71
72
73
74
75
	/**
	 * Search-fields
	 *
	 * @var string
	 */
76
77
	public $search_field;

78
79
80
81
82
	/**
	 * Search-levels
	 *
	 * @var int
	 */
83
84
	public $search_levels;

85
86
87
88
89
	/**
	 * Show-limit
	 *
	 * @var int
	 */
90
91
	public $showLimit;

92
93
94
95
96
	/**
	 * Return URL
	 *
	 * @var string
	 */
97
98
	public $returnUrl;

99
100
101
102
103
	/**
	 * Clear-cache flag - if set, clears page cache for current id.
	 *
	 * @var bool
	 */
104
105
	public $clear_cache;

106
107
108
109
110
	/**
	 * PopView id - for opening a window with the page
	 *
	 * @var bool
	 */
111
112
	public $popView;

113
114
115
116
117
118
	/**
	 * QuickEdit: Variable, that tells quick edit what to show/edit etc.
	 * Format is [tablename]:[uid] with some exceptional values for both parameters (with special meanings).
	 *
	 * @var string
	 */
119
120
	public $edit_record;

121
122
123
124
125
126
127
128
	/**
	 * QuickEdit: If set, this variable tells quick edit that the last edited record had
	 * this value as UID and we should look up the new, real uid value in sys_log.
	 *
	 * @var string
	 */
	public $new_unique_uid;

129
130
131
132
133
	/**
	 * Page select perms clause
	 *
	 * @var string
	 */
134
135
	public $perms_clause;

136
137
138
139
140
	/**
	 * Module TSconfig
	 *
	 * @var array
	 */
141
142
	public $modTSconfig;

143
144
145
146
147
148
149
	/**
	 * Module shared TSconfig
	 *
	 * @var array
	 */
	public $modSharedTSconfig;

150
151
152
153
154
	/**
	 * Current ids page record
	 *
	 * @var array
	 */
155
156
157
158
159
	public $pageinfo;

	/**
	 * Document template object
	 *
160
	 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
161
162
163
	 */
	public $doc;

164
165
166
167
168
	/**
	 * "Pseudo" Description -table name
	 *
	 * @var string
	 */
169
170
	public $descrTable;

171
172
173
174
175
	/**
	 * List of column-integers to edit. Is set from TSconfig, default is "1,0,2,3"
	 *
	 * @var string
	 */
176
177
	public $colPosList;

178
179
180
181
182
	/**
	 * Flag: If content can be edited or not.
	 *
	 * @var bool
	 */
183
184
	public $EDIT_CONTENT;

185
186
187
188
189
	/**
	 * Users permissions integer for this page.
	 *
	 * @var int
	 */
190
191
	public $CALC_PERMS;

192
193
194
195
196
	/**
	 * Currently selected language for editing content elements
	 *
	 * @var int
	 */
197
198
	public $current_sys_language;

199
200
201
202
203
	/**
	 * Module configuration
	 *
	 * @var array
	 */
204
205
	public $MCONF = array();

206
207
208
209
210
	/**
	 * Menu configuration
	 *
	 * @var array
	 */
211
212
	public $MOD_MENU = array();

213
214
215
216
217
	/**
	 * Module settings (session variable)
	 *
	 * @var array
	 */
218
219
	public $MOD_SETTINGS = array();

220
221
222
223
224
	/**
	 * Array of tables to be listed by the Web > Page module in addition to the default tables
	 *
	 * @var array
	 */
225
226
	public $externalTables = array();

227
228
229
230
231
	/**
	 * Module output accumulation
	 *
	 * @var string
	 */
232
233
	public $content;

234
235
236
237
238
	/**
	 * Function menu temporary storage
	 *
	 * @var string
	 */
239
240
	public $topFuncMenu;

241
242
243
244
245
246
247
248
	/**
	 * List of column-integers accessible to the current BE user.
	 * Is set from TSconfig, default is $colPosList
	 *
	 * @var string
	 */
	public $activeColPosList;

249
	/**
250
251
252
	 * Markers array
	 *
	 * @var array
253
254
255
	 */
	protected $markers = array();

256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
	/**
	 * @var array
	 */
	protected $eRParts = array();

	/**
	 * @var string
	 */
	protected $editSelect;

	/**
	 * @var bool
	 */
	protected $deleteButton;

	/**
	 * @var bool
	 */
	protected $undoButton;

	/**
	 * @var array
	 */
	protected $undoButtonR;

	/**
	 * @var string
	 */
	protected $R_URI;

	/**
	 * @var string
	 */
	protected $closeUrl;

291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
	/**
	 * Caches the available languages in a colPos
	 *
	 * @var array
	 */
	protected $languagesInColumnCache = array();

	/**
	 * Caches the amount of content elements as a matrix
	 *
	 * @var array
	 * @internal
	 */
	public $contentElementCache = array();

306
307
308
309
310
	/**
	 * @var IconFactory
	 */
	protected $iconFactory;

311
312
313
314
315
316
	/**
	 * Initializing the module
	 *
	 * @return void
	 */
	public function init() {
317
		$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
Wouter Wolters's avatar
Wouter Wolters committed
318
		$this->getLanguageService()->includeLLFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
319

320
321
		// Setting module configuration / page select clause
		$this->MCONF = $GLOBALS['MCONF'];
322
		$this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
323
		// Get session data
324
		$sessionData = $this->getBackendUser()->getSessionData(RecordList::class);
325
		$this->search_field = !empty($sessionData['search_field']) ? $sessionData['search_field'] : '';
326
		// GPvars:
327
		$this->id = (int)GeneralUtility::_GP('id');
Nicole Cordes's avatar
Nicole Cordes committed
328
329
330
331
332
		$this->pointer = GeneralUtility::_GP('pointer');
		$this->imagemode = GeneralUtility::_GP('imagemode');
		$this->clear_cache = GeneralUtility::_GP('clear_cache');
		$this->popView = GeneralUtility::_GP('popView');
		$this->edit_record = GeneralUtility::_GP('edit_record');
333
		$this->new_unique_uid = GeneralUtility::_GP('new_unique_uid');
334
		$this->search_field = GeneralUtility::_GP('search_field');
Nicole Cordes's avatar
Nicole Cordes committed
335
336
337
		$this->search_levels = GeneralUtility::_GP('search_levels');
		$this->showLimit = GeneralUtility::_GP('showLimit');
		$this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
338
		$this->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
339
		$sessionData['search_field'] = $this->search_field;
340
		// Store session data
341
		$this->getBackendUser()->setAndSaveSessionData(RecordList::class, $sessionData);
342
		// Load page info array:
Nicole Cordes's avatar
Nicole Cordes committed
343
		$this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
344
345
346
		// Initialize menu
		$this->menuConfig();
		// Setting sys language from session var:
347
		$this->current_sys_language = (int)$this->MOD_SETTINGS['language'];
348
349
		// CSH / Descriptions:
		$this->descrTable = '_MOD_' . $this->MCONF['name'];
350
351
352

		$this->markers['SEARCHBOX'] = '';
		$this->markers['BUTTONLIST_ADDITIONAL'] = '';
353
354
355
356
357
358
359
360
	}

	/**
	 * Initialize menu array
	 *
	 * @return void
	 */
	public function menuConfig() {
361
		$lang = $this->getLanguageService();
362
363
364
365
		// MENU-ITEMS:
		$this->MOD_MENU = array(
			'tt_content_showHidden' => '',
			'function' => array(
366
367
368
				0 => $lang->getLL('m_function_0'),
				1 => $lang->getLL('m_function_1'),
				2 => $lang->getLL('m_function_2')
369
370
			),
			'language' => array(
371
				0 => $lang->getLL('m_default')
372
373
374
375
376
			)
		);
		// example settings:
		// 	$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['tx_myext'] =
		//		array ('default' => array(
377
		//				'MENU' => 'LLL:EXT:tx_myext/locallang_db.xlf:menuDefault',
378
379
380
381
382
383
384
385
386
387
		//				'fList' =>  'title,description,image',
		//				'icon' => TRUE));
		if (is_array($this->externalTables)) {
			foreach ($this->externalTables as $table => $tableSettings) {
				// delete the default settings from above
				if (is_array($this->MOD_MENU[$table])) {
					unset($this->MOD_MENU[$table]);
				}
				if (is_array($tableSettings) && count($tableSettings) > 1) {
					foreach ($tableSettings as $key => $settings) {
388
						$this->MOD_MENU[$table][$key] = $lang->sL($settings['MENU']);
389
390
391
392
393
394
					}
				}
			}
		}
		// First, select all pages_language_overlay records on the current page. Each represents a possibility for a language on the page. Add these to language selector.
		$res = $this->exec_languageQuery($this->id);
395
396
397
		while ($lRow = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
			if ($this->getBackendUser()->checkLanguageAccess($lRow['uid'])) {
				$this->MOD_MENU['language'][$lRow['uid']] = $lRow['hidden'] ? '(' . $lRow['title'] . ')' : $lRow['title'];
398
399
400
			}
		}
		// Find if there are ANY languages at all (and if not, remove the language option from function menu).
401
		$count = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', 'sys_language', $this->getBackendUser()->isAdmin() ? '' : 'hidden=0');
402
403
404
405
		if (!$count) {
			unset($this->MOD_MENU['function']['2']);
		}
		// page/be_user TSconfig settings and blinding of menu-items
Nicole Cordes's avatar
Nicole Cordes committed
406
407
		$this->modSharedTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.SHARED');
		$this->modTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.' . $this->MCONF['name']);
408
409
410
		if ($this->modTSconfig['properties']['QEisDefault']) {
			ksort($this->MOD_MENU['function']);
		}
Nicole Cordes's avatar
Nicole Cordes committed
411
		$this->MOD_MENU['function'] = BackendUtility::unsetMenuItems($this->modTSconfig['properties'], $this->MOD_MENU['function'], 'menu.function');
412
		// Remove QuickEdit as option if page type is not...
413
		if (!GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'] . ',6', $this->pageinfo['doktype'])) {
414
415
416
417
418
419
420
			unset($this->MOD_MENU['function'][0]);
		}
		// Setting alternative default label:
		if (($this->modSharedTSconfig['properties']['defaultLanguageLabel'] || $this->modTSconfig['properties']['defaultLanguageLabel']) && isset($this->MOD_MENU['language'][0])) {
			$this->MOD_MENU['language'][0] = $this->modTSconfig['properties']['defaultLanguageLabel'] ? $this->modSharedTSconfig['properties']['defaultLanguageLabel'] : $this->modSharedTSconfig['properties']['defaultLanguageLabel'];
		}
		// Clean up settings
421
		$this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), 'web_layout');
422
		// For all elements to be shown in draft workspaces & to also show hidden elements by default if user hasn't disabled the option
423
		if ($this->getBackendUser()->workspace != 0 || $this->MOD_SETTINGS['tt_content_showHidden'] !== '0') {
424
425
426
427
428
429
430
431
432
433
434
			$this->MOD_SETTINGS['tt_content_showHidden'] = 1;
		}
	}

	/**
	 * Clears page cache for the current id, $this->id
	 *
	 * @return void
	 */
	public function clearCache() {
		if ($this->clear_cache) {
435
436
			$tce = GeneralUtility::makeInstance(DataHandler::class);
			$tce->stripslashes_values = FALSE;
437
438
439
440
441
442
443
444
445
446
447
448
			$tce->start(array(), array());
			$tce->clear_cacheCmd($this->id);
		}
	}

	/**
	 * Generate the flashmessages for current pid
	 *
	 * @return string HTML content with flashmessages
	 */
	protected function getHeaderFlashMessagesForCurrentPid() {
		$content = '';
449
		$lang = $this->getLanguageService();
450
		// If page is a folder
451
		if ($this->pageinfo['doktype'] == PageRepository::DOKTYPE_SYSFOLDER) {
452
			// Access to list module
453
			$moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
454
455
456
			$moduleLoader->load($GLOBALS['TBE_MODULES']);
			$modules = $moduleLoader->modules;
			if (is_array($modules['web']['sub']['list'])) {
457
458
459
				$title = $lang->getLL('goToListModule');
				$message = '<p>' . $lang->getLL('goToListModuleMessage') . '</p>';
				$message .= '<a class="btn btn-info" href="javascript:top.goToModule(\'web_list\',1);">' . $lang->getLL('goToListModule') . '</a>';
460
461
462
463

				$view = GeneralUtility::makeInstance(StandaloneView::class);
				$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html'));
				$view->assignMultiple(array(
464
465
					'title' => $title,
					'message' => $message,
466
467
468
					'state' => InfoboxViewHelper::STATE_INFO
				));
				$content .= $view->render();
469
470
471
472
			}
		}
		// If content from different pid is displayed
		if ($this->pageinfo['content_from_pid']) {
473
			$contentPage = BackendUtility::getRecord('pages', (int)$this->pageinfo['content_from_pid']);
Nicole Cordes's avatar
Nicole Cordes committed
474
			$title = BackendUtility::getRecordTitle('pages', $contentPage);
475
			$linkToPid = $this->local_linkThisScript(array('id' => $this->pageinfo['content_from_pid']));
476
			$link = '<a href="' . $linkToPid . '">' . htmlspecialchars($title) . ' (PID ' . (int)$this->pageinfo['content_from_pid'] . ')</a>';
477
			$flashMessage = GeneralUtility::makeInstance(FlashMessage::class, sprintf($lang->getLL('content_from_pid_title'), $link), '', FlashMessage::INFO);
478
479
480
481
482
			$content .= $flashMessage->render();
		}
		return $content;
	}

483
484
485
486
487
488
	/**
	 *
	 * @return string $title
	 */
	protected function getLocalizedPageTitle() {
		if ($this->current_sys_language > 0) {
489
			$overlayRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
490
491
				'title',
				'pages_language_overlay',
492
493
				'pid = ' . (int)$this->id .
						' AND sys_language_uid = ' . (int)$this->current_sys_language .
Nicole Cordes's avatar
Nicole Cordes committed
494
495
						BackendUtility::deleteClause('pages_language_overlay') .
						BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
496
497
498
499
500
501
502
503
504
505
506
				'',
				'',
				'',
				'sys_language_uid'
			);
			return $overlayRecord['title'];
		} else {
			return $this->pageinfo['title'];
		}
	}

507
508
509
510
511
512
513
	/**
	 * Main function.
	 * Creates some general objects and calls other functions for the main rendering of module content.
	 *
	 * @return void
	 */
	public function main() {
514
		$lang = $this->getLanguageService();
515
516
517
518
519
		// Access check...
		// The page will show only if there is a valid page and if this page may be viewed by the user
		$access = is_array($this->pageinfo) ? 1 : 0;
		if ($this->id && $access) {
			// Initialize permission settings:
520
			$this->CALC_PERMS = $this->getBackendUser()->calcPerms($this->pageinfo);
521
522
			$this->EDIT_CONTENT = $this->pageIsNotLockedForEditors();

523
			// Start document template object:
524
			$this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
525
			$this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout.html');
526
527
528
529

			// override the default jumpToUrl
			$this->doc->JScodeArray['jumpToUrl'] = '
				function jumpToUrl(URL,formEl) {
530
					if (document.editform && TBE_EDITOR.isFormChanged)	{	// Check if the function exists... (works in all browsers?)
531
						if (!TBE_EDITOR.isFormChanged()) {
532
533
534
535
							window.location.href = URL;
						} else if (formEl) {
							if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
						}
536
537
538
					} else {
						window.location.href = URL;
					}
539
				}
540
541
542
543
544
';

			$this->doc->JScode .= $this->doc->wrapScriptTags('
				if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
				if (top.fsMod) top.fsMod.navFrameHighlightedID["web"] = "pages' . (int)$this->id . '_"+top.fsMod.currentBank; ' . (int)$this->id . ';
545
			' . ($this->popView ? BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id)) : '') . '
546
547

				function deleteRecord(table,id,url) {	//
548
					if (confirm(' . GeneralUtility::quoteJSvalue($lang->getLL('deleteWarning')) . ')) {
549
						window.location.href = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC=' . $this->getBackendUser()->veriCode() . '&prErr=1&uPT=1";
550
551
552
553
554
					}
					return false;
				}
			');
			$this->doc->JScode .= $this->doc->wrapScriptTags('
555
				var DTM_array = [];
556
				var DTM_origClass = "";
557
558
559

					// if tabs are used in a popup window the array might not exists
				if(!top.DTM_currentTabs) {
560
					top.DTM_currentTabs = [];
561
562
563
564
565
566
567
				}

				function DTM_activate(idBase,index,doToogle) {	//
						// Hiding all:
					if (DTM_array[idBase]) {
						for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
							if (DTM_array[idBase][cnt] != idBase+"-"+index) {
Benjamin Kott's avatar
Benjamin Kott committed
568
569
								document.getElementById(DTM_array[idBase][cnt]+"-DIV").className = "tab-pane";
								document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").value = "tab";
570
571
572
573
574
575
							}
						}
					}

						// Showing one:
					if (document.getElementById(idBase+"-"+index+"-DIV")) {
Benjamin Kott's avatar
Benjamin Kott committed
576
577
						if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").className === "tab-pane active") {
							document.getElementById(idBase+"-"+index+"-DIV").className = "tab-pane";
578
							if(DTM_origClass=="") {
Benjamin Kott's avatar
Benjamin Kott committed
579
								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").value = "tab";
580
581
582
583
584
							} else {
								DTM_origClass = "tab";
							}
							top.DTM_currentTabs[idBase] = -1;
						} else {
Benjamin Kott's avatar
Benjamin Kott committed
585
							document.getElementById(idBase+"-"+index+"-DIV").className = "tab-pane active";
586
							if(DTM_origClass=="") {
Benjamin Kott's avatar
Benjamin Kott committed
587
								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").value = "active";
588
							} else {
589
								DTM_origClass = "active";
590
591
592
593
594
595
596
597
598
							}
							top.DTM_currentTabs[idBase] = index;
						}
					}
				}
				function DTM_toggle(idBase,index,isInit) {	//
						// Showing one:
					if (document.getElementById(idBase+"-"+index+"-DIV")) {
						if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
Benjamin Kott's avatar
Benjamin Kott committed
599
							document.getElementById(idBase+"-"+index+"-DIV").className = "tab-pane";
600
							if(isInit) {
Benjamin Kott's avatar
Benjamin Kott committed
601
								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").value = "tab";
602
603
604
605
606
							} else {
								DTM_origClass = "tab";
							}
							top.DTM_currentTabs[idBase+"-"+index] = 0;
						} else {
Benjamin Kott's avatar
Benjamin Kott committed
607
							document.getElementById(idBase+"-"+index+"-DIV").className = "tab-pane active";
608
							if(isInit) {
Benjamin Kott's avatar
Benjamin Kott committed
609
								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").value = "active";
610
							} else {
611
								DTM_origClass = "active";
612
613
614
615
616
617
618
							}
							top.DTM_currentTabs[idBase+"-"+index] = 1;
						}
					}
				}
			');
			// Setting doc-header
619
620
621
622
			$this->doc->form = '<form action="' . htmlspecialchars(
				BackendUtility::getModuleUrl(
					'web_layout', array('id' => $this->id, 'imagemode' =>  $this->imagemode)
				)) . '" method="post">';
623
			// Creating the top function menu:
624
			$this->topFuncMenu = BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function'], '', '');
625
			$languageMenu = count($this->MOD_MENU['language']) > 1 ? $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.language', TRUE) . BackendUtility::getFuncMenu($this->id, 'SET[language]', $this->current_sys_language, $this->MOD_MENU['language'], '', '') : '';
626
			// Find backend layout / coumns
627
			$backendLayout = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getSelectedBackendLayout', $this->id, $this);
628
			if (!empty($backendLayout['__colPosList'])) {
629
630
631
				$this->colPosList = implode(',', $backendLayout['__colPosList']);
			}
			// Removing duplicates, if any
632
633
			$this->colPosList = array_unique(GeneralUtility::intExplode(',', $this->colPosList));
			// Accessible columns
634
			if (isset($this->modSharedTSconfig['properties']['colPos_list']) && trim($this->modSharedTSconfig['properties']['colPos_list']) !== '') {
635
636
				$this->activeColPosList = array_unique(GeneralUtility::intExplode(',', trim($this->modSharedTSconfig['properties']['colPos_list'])));
				// Match with the list which is present in the colPosList for the current page
637
638
				if (!empty($this->colPosList) && !empty($this->activeColPosList)) {
					$this->activeColPosList = array_unique(array_intersect(
639
640
						$this->activeColPosList,
						$this->colPosList
641
					));
642
				}
643
644
			} else {
				$this->activeColPosList = $this->colPosList;
645
			}
646
			$this->activeColPosList = implode(',', $this->activeColPosList);
647
648
			$this->colPosList = implode(',', $this->colPosList);

649
			$body = '';
650
651
652
653
654
655
			$body .= $this->getHeaderFlashMessagesForCurrentPid();
			// Render the primary module content:
			if ($this->MOD_SETTINGS['function'] == 0) {
				// QuickEdit
				$body .= $this->renderQuickEdit();
			} else {
656
657
				// Page title
				$body .= $this->doc->header($this->getLocalizedPageTitle());
658
659
660
661
662
				// All other listings
				$body .= $this->renderListContent();
			}
			// Setting up the buttons and markers for docheader
			$docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function'] == 0 ? 'quickEdit' : '');
663
664
			$this->markers['CSH'] = $docHeaderButtons['csh'];
			$this->markers['TOP_FUNCTION_MENU'] = $this->topFuncMenu . $this->editSelect;
665
			$this->markers['LANGSELECTOR'] = $languageMenu;
666
			$this->markers['CONTENT'] = $body;
667
			// Build the <body> for the module
668
			$this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $this->markers);
669
			// Renders the module page
670
			$this->content = $this->doc->render($lang->getLL('title'), $this->content);
671
672
		} else {
			// If no access or id value, create empty document:
673
			$this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
674
			$this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout.html');
675
			$this->doc->JScode = $this->doc->wrapScriptTags('
676
				if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
677
			');
678
679

			$body = $this->doc->header($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
680

681
682
			$title = $lang->getLL('clickAPage_header');
			$message = $lang->getLL('clickAPage_content');
683
684
685
686

			$view = GeneralUtility::makeInstance(StandaloneView::class);
			$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html'));
			$view->assignMultiple(array(
687
688
				'title' => $title,
				'message' => $message,
689
690
691
				'state' => InfoboxViewHelper::STATE_INFO
			));
			$body .= $view->render();
692

693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
			// Setting up the buttons and markers for docheader
			$docHeaderButtons = array(
				'view' => '',
				'history_page' => '',
				'new_content' => '',
				'move_page' => '',
				'move_record' => '',
				'new_page' => '',
				'edit_page' => '',
				'csh' => '',
				'shortcut' => '',
				'cache' => '',
				'savedok' => '',
				'savedokshow' => '',
				'closedok' => '',
				'deletedok' => '',
				'undo' => '',
710
711
				'history_record' => '',
				'edit_language' => ''
712
			);
Benni Mack's avatar
Benni Mack committed
713
			$this->markers['CSH'] = '';
714
715
716
717
			$this->markers['TOP_FUNCTION_MENU'] = '';
			$this->markers['LANGSELECTOR'] = '';
			$this->markers['CONTENT'] = $body;
			$this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $this->markers);
718
			// Renders the module page
719
			$this->content = $this->doc->render($lang->getLL('title'), $this->content);
720
721
722
723
724
725
		}
	}

	/**
	 * Rendering the quick-edit view.
	 *
726
	 * @return string
727
728
	 */
	public function renderQuickEdit() {
729
730
731
		$databaseConnection = $this->getDatabaseConnection();
		$beUser = $this->getBackendUser();
		$lang = $this->getLanguageService();
732
		// Alternative template
733
		$this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout_quickedit.html');
734
		// Alternative form tag; Quick Edit submits its content to tce_db.php.
735
		$this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db', ['prErr' => 1, 'uPT' => 1])) . '" method="post" enctype="multipart/form-data" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
736
737
738
739
		// Setting up the context sensitive menu:
		$this->doc->getContextMenuCode();
		// Set the edit_record value for internal use in this function:
		$edit_record = $this->edit_record;
740
		// If a command to edit all records in a column is issue, then select all those elements, and redirect to FormEngine
741
		if (substr($edit_record, 0, 9) == '_EDIT_COL') {
742
			$res = $databaseConnection->exec_SELECTquery('*', 'tt_content', 'pid=' . (int)$this->id . ' AND colPos=' . (int)substr($edit_record, 10) . ' AND sys_language_uid=' . (int)$this->current_sys_language . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
743
			$idListA = array();
744
			while ($cRow = $databaseConnection->sql_fetch_assoc($res)) {
745
746
				$idListA[] = $cRow['uid'];
			}
747
748
			$url = BackendUtility::getModuleUrl('record_edit', array(
				'edit[tt_content][' . implode(',', $idListA) . ']' => 'edit',
749
				'returnUrl' => $this->local_linkThisScript(array('edit_record' => ''))
750
			));
751
			HttpUtility::redirect($url);
752
		}
753
754
		// If the former record edited was the creation of a NEW record, this will look up the created records uid:
		if ($this->new_unique_uid) {
755
756
			$res = $databaseConnection->exec_SELECTquery('*', 'sys_log', 'userid=' . (int)$beUser->user['uid'] . ' AND NEWid=' . $databaseConnection->fullQuoteStr($this->new_unique_uid, 'sys_log'));
			$sys_log_row = $databaseConnection->sql_fetch_assoc($res);
757
758
759
760
			if (is_array($sys_log_row)) {
				$edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
			}
		}
761
762
763
764
765
		// Creating the selector box, allowing the user to select which element to edit:
		$opt = array();
		$is_selected = 0;
		$languageOverlayRecord = '';
		if ($this->current_sys_language) {
766
			list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . (int)$this->current_sys_language);
767
768
769
		}
		if (is_array($languageOverlayRecord)) {
			$inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
770
			$is_selected += (int)$edit_record == $inValue;
771
			$opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $lang->getLL('editLanguageHeader', TRUE) . ' ]</option>';
772
773
		} else {
			$inValue = 'pages:' . $this->id;
774
			$is_selected += (int)$edit_record == $inValue;
775
			$opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $lang->getLL('editPageProperties', TRUE) . ' ]</option>';
776
777
		}
		// Selecting all content elements from this language and allowed colPos:
778
779
780
781
782
		$whereClause = 'pid=' . (int)$this->id . ' AND sys_language_uid=' . (int)$this->current_sys_language . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content');
		if (!$this->getBackendUser()->user['admin']) {
			$whereClause .= ' AND editlock = 0';
		}
		$res = $databaseConnection->exec_SELECTquery('*', 'tt_content', $whereClause, '', 'colPos,sorting');
783
		$colPos = NULL;
784
785
786
		$first = 1;
		// Page is the pid if no record to put this after.
		$prev = $this->id;
787
		while ($cRow = $databaseConnection->sql_fetch_assoc($res)) {
Nicole Cordes's avatar
Nicole Cordes committed
788
			BackendUtility::workspaceOL('tt_content', $cRow);
789
790
791
792
793
794
795
			if (is_array($cRow)) {
				if ($first) {
					if (!$edit_record) {
						$edit_record = 'tt_content:' . $cRow['uid'];
					}
					$first = 0;
				}
796
				if (!isset($colPos) || $cRow['colPos'] !== $colPos) {
797
798
					$colPos = $cRow['colPos'];
					$opt[] = '<option value=""></option>';
799
					$opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $lang->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), TRUE) . ':__</option>';
800
801
				}
				$inValue = 'tt_content:' . $cRow['uid'];
802
				$is_selected += (int)$edit_record == $inValue;
803
				$opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(($cRow['header'] ? $cRow['header'] : '[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title') . '] ' . strip_tags($cRow['bodytext'])), $beUser->uc['titleLen'])) . '</option>';
804
805
806
807
808
				$prev = -$cRow['uid'];
			}
		}
		// If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
		if (!$edit_record) {
809
810
			$edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
			$inValue = 'tt_content:new/' . $prev . '/' . $colPos;
811
			$is_selected += (int)$edit_record == $inValue;
812
			$opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $lang->getLL('newLabel', 1) . ' ]</option>';
813
814
815
816
		}
		// If none is yet selected...
		if (!$is_selected) {
			$opt[] = '<option value=""></option>';
817
			$opt[] = '<option value="' . $edit_record . '"  selected="selected">[ ' . $lang->getLL('newLabel', TRUE) . ' ]</option>';
818
819
820
		}
		// Splitting the edit-record cmd value into table/uid:
		$this->eRParts = explode(':', $edit_record);
821
		$tableName = $this->eRParts[0];
822
		// Delete-button flag?
823
		$this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($tableName !== 'pages' && $this->EDIT_CONTENT || $tableName === 'pages' && $this->CALC_PERMS & Permission::PAGE_DELETE);
824
		// If undo-button should be rendered (depends on available items in sys_history)
825
		$this->undoButton = FALSE;
826
		$undoRes = $databaseConnection->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $databaseConnection->fullQuoteStr($tableName, 'sys_history') . ' AND recuid=' . (int)$this->eRParts[1], '', 'tstamp DESC', '1');
827
828
		if ($this->undoButtonR = $databaseConnection->sql_fetch_assoc($undoRes)) {
			$this->undoButton = TRUE;
829
830
		}
		// Setting up the Return URL for coming back to THIS script (if links take the user to another script)
Nicole Cordes's avatar
Nicole Cordes committed
831
832
		$R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
		$R_URL_getvars = GeneralUtility::_GET();
833
		unset($R_URL_getvars['popView']);
834
		unset($R_URL_getvars['new_unique_uid']);
835
		$R_URL_getvars['edit_record'] = $edit_record;
Nicole Cordes's avatar
Nicole Cordes committed
836
		$this->R_URI = $R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
837
838
839
840
841
842
843
		// Setting close url/return url for exiting this script:
		// Goes to 'Columns' view if close is pressed (default)
		$this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
		if ($this->returnUrl) {
			$this->closeUrl = $this->returnUrl;
		}
		// Return-url for JavaScript:
844
		$retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+' . GeneralUtility::quoteJSvalue(rawurlencode($this->returnUrl)) : '';
845
		// Drawing the edit record selectbox
846
847
848
		$this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars('jumpToUrl(' . GeneralUtility::quoteJSvalue(
			BackendUtility::getModuleUrl('web_layout') . '&id=' . $this->id . '&edit_record='
		) . '+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);') . '">' . implode('', $opt) . '</select>';
849

850
		// Creating editing form:
851
852
853
		$content = '';

		if ($edit_record) {
854
			// Splitting uid parts for special features, if new:
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
			list($uidVal, $neighborRecordUid, $ex_colPos) = explode('/', $this->eRParts[1]);

			if ($uidVal === 'new') {
				$command = 'new';
				// Page id of this new record
				$theUid = $this->id;
				if ($neighborRecordUid) {
					$theUid = $neighborRecordUid;
				}
			} else {
				$command = 'edit';
				$theUid = $uidVal;
				// Convert $uidVal to workspace version if any:
				$draftRecord = BackendUtility::getWorkspaceVersionOfRecord($beUser->workspace, $tableName, $theUid, 'uid');
				if ($draftRecord) {
					$theUid = $draftRecord['uid'];
871
872
				}
			}
873
874
875

			// @todo: Hack because DatabaseInitializeNewRow reads from _GP directly
			$GLOBALS['_GET']['defVals'][$tableName] = array(
876
877
				'colPos' => (int)$ex_colPos,
				'sys_language_uid' => (int)$this->current_sys_language
878
			);
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914

			/** @var TcaDatabaseRecord $formDataGroup */
			$formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
			/** @var FormDataCompiler $formDataCompiler */
			$formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
			/** @var NodeFactory $nodeFactory */
			$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);

			try {
				$formDataCompilerInput = [
					'tableName' => $tableName,
					'vanillaUid' => (int)$theUid,
					'command' => $command,
				];
				$formData = $formDataCompiler->compile($formDataCompilerInput);

				if ($command !== 'new') {
					BackendUtility::lockRecords($tableName, $formData['databaseRow']['uid'], $tableName === 'tt_content' ? $formData['databaseRow']['pid'] : 0);
				}

				$formData['renderType'] = 'outerWrapContainer';
				$formResult = $nodeFactory->create($formData)->render();

				$panel = $formResult['html'];
				$formResult['html'] = '';

				/** @var FormResultCompiler $formResultCompiler */
				$formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
				$formResultCompiler->mergeResult($formResult);

				$row = $formData['databaseRow'];
				$new_unique_uid = '';
				if ($command === 'new') {
					$new_unique_uid = $row['uid'];
				}

915
916
				// Add hidden fields:
				if ($uidVal == 'new') {
917
					$panel .= '<input type="hidden" name="data[' . $tableName . '][' . $row['uid'] . '][pid]" value="' . $row['pid'] . '" />';
918
				}
919
				$panel .= '
920
921
					<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
					<input type="hidden" name="edit_record" value="' . $edit_record . '" />
922
923
924
925
926
927
928
929
					<input type="hidden" name="redirect" value="' . htmlspecialchars(($uidVal == 'new' ? BackendUtility::getModuleUrl(
						'web_layout',
						array(
							'id' => $this->id,
							'new_unique_uid' => $new_unique_uid,
							'returnUrl' => $this->returnUrl
						)
					) : $this->R_URI)) . '" />
930
					';
931
				// Add JavaScript as needed around the form:
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
				$panel = $formResultCompiler->JStop() . $panel . $formResultCompiler->printNeededJSFunctions();
				$content = $this->doc->section('', $panel);

				// Display "is-locked" message:
				if ($command === 'edit') {
					$lockInfo = BackendUtility::isRecordLocked($tableName, $formData['databaseRow']['uid']);
					if ($lockInfo) {
						/** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
						$flashMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING);
						/** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
						$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
						/** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
						$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
						$defaultFlashMessageQueue->enqueue($flashMessage);
					}
947
				}
948
949
950
951
952
953
			} catch (AccessDeniedException $e) {
				// If no edit access, print error message:
				$content = $this->doc->section($lang->getLL('noAccess'), $lang->getLL('noAccess_msg')
					. '<br /><br />'
					. ($beUser->errorMsg ? 'Reason: ' . $beUser->errorMsg . '<br /><br />' : ''), 0, 1
				);
954
955
956
			}
		} else {
			// If no edit access, print error message:
957
			$content = $this->doc->section($lang->getLL('noAccess'), $lang->getLL('noAccess_msg') . '<br /><br />', 0, 1);
958
		}
959

960
961
		// Bottom controls (function menus):
		$q_count = $this->getNumberOfHiddenElements();
962
963
964
965
966
967
968
969
970
971
972
		if ($q_count) {
			$h_func_b = '<div class="checkbox">' .
				'<label for="checkTt_content_showHidden">' .
				BackendUtility::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], '', '', 'id="checkTt_content_showHidden"') .
				(!$q_count ? ('<span class="text-muted">' . $lang->getLL('hiddenCE', TRUE) . '</span>') : $lang->getLL('hiddenCE', TRUE) . ' (' . $q_count . ')') .
				'</label>' .
				'</div>';

			$content .= $this->doc->section('', $h_func_b, 0, 0);
			$content .= $this->doc->spacer(10);
		}
973

974
		// Select element matrix:
975
		if ($tableName === 'tt_content' && MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
976
			$posMap = GeneralUtility::makeInstance(ContentLayoutPagePositionMap::class);
977
978
979
			$posMap->cur_sys_language = $this->current_sys_language;
			$HTMLcode = '';
			// CSH:
Benni Mack's avatar
Benni Mack committed
980
			$HTMLcode .= BackendUtility::cshItem($this->descrTable, 'quickEdit_selElement', NULL, '|<br />');
981
982
			$HTMLcode .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
			$content .= $this->doc->spacer(20);
983
			$content .= $this->doc->section($lang->getLL('CEonThisPage'), $HTMLcode, 0, 1);
984
985
			$content .= $this->doc->spacer(20);
		}
986

987
988
989
990
991
992
		return $content;
	}

	/**
	 * Rendering all other listings than QuickEdit
	 *
993
	 * @return string
994
995
	 */
	public function renderListContent() {
996
997
998
999
1000
		/** @var $dbList \TYPO3\CMS\Backend\View\PageLayoutView */
		$dbList = GeneralUtility::makeInstance(PageLayoutView::class);
		$dbList->thumbs = $this->imagemode;
		$dbList->no_noWrap = 1;
		$dbList->descrTable = $this->descrTable;
Nicole Cordes's avatar
Nicole Cordes committed
1001
		$this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
		$dbList->script = BackendUtility::getModuleUrl('web_layout');
		$dbList->showIcon = 0;
		$dbList->setLMargin = 0;
		$dbList->doEdit = $this->EDIT_CONTENT;
		$dbList->ext_CALC_PERMS = $this->CALC_PERMS;
		$dbList->agePrefixes = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears');
		$dbList->id = $this->id;
		$dbList->nextThree = MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10);
		$dbList->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
		$dbList->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
		if (!$dbList->nextThree) {
			$dbList->nextThree = 1;
1014
		}
1015
		$dbList->externalTables = $this->externalTables;
1016
		// Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
1017
1018
		// also fills $dbList->activeTables
		$dbList->getTableMenu($this->id);
1019
1020
1021
1022
1023
1024
1025
		// Initialize other variables:
		$h_func = '';
		$tableOutput = array();
		$tableJSOutput = array();
		$CMcounter = 0;
		// Traverse the list of table names which has records on this page (that array is populated
		// by the $dblist object during the function getTableMenu()):
1026
1027
1028
		foreach ($dbList->activeTables as $table => $value) {
			$h_func_b = '';
			if (!isset($dbList->externalTables[$table])) {
1029
				$q_count = $this->getNumberOfHiddenElements();
1030

1031
1032
1033
				if ($q_count > 0) {
					$h_func_b =
						'<div class="checkbox">'
1034
						. '<label for="checkTt_content_showHidden">'
1035
1036
						. '<input type="checkbox" id="checkTt_content_showHidden" class="checkbox" name="SET[tt_content_showHidden]" value="1" ' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? 'checked="checked"' : '') . ' />'
						. $this->getLanguageService()->getLL('hiddenCE', TRUE) . ' (<span class="t3js-hidden-counter">' . $q_count . '</span>)'
1037
						. '</label>'
1038
1039
						. '</div>';
				}
1040
				// Boolean: Display up/down arrows and edit icons for tt_content records
1041
				$dbList->tt_contentConfig['showCommands'] = 1;
1042
				// Boolean: Display info-marks or not
1043
				$dbList->tt_contentConfig['showInfo'] = 1;
1044
1045
1046
				// Setting up the tt_content columns to show:
				if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
					$colList = array();
1047
					$tcaItems = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getColPosListItemsParsed', $this->id, $this);
1048
1049
1050
1051
1052
1053
1054
					foreach ($tcaItems as $temp) {
						$colList[] = $temp[1];
					}
				} else {
					// ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
					$colList = array('1', '0', '2', '3');
				}
1055
				if ($this->colPosList !== '') {
Nicole Cordes's avatar
Nicole Cordes committed
1056
					$colList = array_intersect(GeneralUtility::intExplode(',', $this->colPosList), $colList);
1057
1058
				}
				// The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
1059
1060
1061
1062
				$dbList->tt_contentConfig['cols'] = implode(',', $colList);
				$dbList->tt_contentConfig['activeCols'] = $this->activeColPosList;
				$dbList->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
				$dbList->tt_contentConfig['sys_language_uid'] = (int)$this->current_sys_language;
1063
1064
				// If the function menu is set to "Language":
				if ($this->MOD_SETTINGS['function'] == 2) {
1065
1066
1067
					$dbList->tt_contentConfig['languageMode'] = 1;
					$dbList->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
					$dbList->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
1068
1069
1070
				}
			} else {
				if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
1071
					$h_func = BackendUtility::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], '', '');
1072
1073
1074
1075
1076
				} else {
					$h_func = '';
				}
			}
			// Start the dblist object:
1077
1078
1079
1080
			$dbList->itemsLimitSingleTable = 1000;
			$dbList->start($this->id, $table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
			$dbList->counter = $CMcounter;
			$dbList->ext_function = $this->MOD_SETTINGS['function'];
1081
			// Render versioning selector:
1082
			$dbList->HTMLcode .= $this->doc->getVersionSelector($this->id);
1083
			// Generate the list of elements here:
1084
			$dbList->generateList();
1085
			// Adding the list content to the tableOutput variable:
1086
			$tableOutput[$table] = ($h_func ? $h_func . '<br /><span style="width: 1px; height: 4px; display: inline-block;"></span><br />' : '') . $dbList->HTMLcode . ($h_func_b ? '<span style="width: 1px; height: 10px; display:inline-block;"></span><br />' . $h_func_b : '');
1087
			// ... and any accumulated JavaScript goes the same way!
1088
			$tableJSOutput[$table] = $dbList->JScode;