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