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