[CLEANUP] Replace count with empty in EXT:backend
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / View / PageLayoutView.php
1 <?php
2 namespace TYPO3\CMS\Backend\View;
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\Controller\PageLayoutController;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Backend\Utility\IconUtility;
20 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
21 use TYPO3\CMS\Core\Database\DatabaseConnection;
22 use TYPO3\CMS\Core\Messaging\FlashMessage;
23 use TYPO3\CMS\Core\Type\Bitmask\Permission;
24 use TYPO3\CMS\Core\Utility\GeneralUtility;
25 use TYPO3\CMS\Core\Versioning\VersionState;
26
27 /**
28 * Child class for the Web > Page module
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 */
32 class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList {
33
34 /**
35 * If TRUE, users/groups are shown in the page info box.
36 *
37 * @var int
38 */
39 public $pI_showUser = 0;
40
41 /**
42 * The number of successive records to edit when showing content elements.
43 *
44 * @var int
45 */
46 public $nextThree = 3;
47
48 /**
49 * If TRUE, disables the edit-column icon for tt_content elements
50 *
51 * @var int
52 */
53 public $pages_noEditColumns = 0;
54
55 /**
56 * If TRUE, shows big buttons for editing page properties, moving, creating elements etc. in the columns view.
57 *
58 * @var int
59 */
60 public $option_showBigButtons = 1;
61
62 /**
63 * If TRUE, new-wizards are linked to rather than the regular new-element list.
64 *
65 * @var int
66 */
67 public $option_newWizard = 1;
68
69 /**
70 * If set to "1", will link a big button to content element wizard.
71 *
72 * @var int
73 */
74 public $ext_function = 0;
75
76 /**
77 * If TRUE, elements will have edit icons (probably this is whether the user has permission to edit the page content). Set externally.
78 *
79 * @var int
80 */
81 public $doEdit = 1;
82
83 /**
84 * Age prefixes for displaying times. May be set externally to localized values.
85 *
86 * @var string
87 */
88 public $agePrefixes = ' min| hrs| days| yrs| min| hour| day| year';
89
90 /**
91 * Array of tables to be listed by the Web > Page module in addition to the default tables.
92 *
93 * @var array
94 */
95 public $externalTables = array();
96
97 /**
98 * "Pseudo" Description -table name
99 *
100 * @var string
101 */
102 public $descrTable;
103
104 /**
105 * If set TRUE, the language mode of tt_content elements will be rendered with hard binding between
106 * default language content elements and their translations!
107 *
108 * @var bool
109 */
110 public $defLangBinding = FALSE;
111
112 /**
113 * External, static: Configuration of tt_content element display:
114 *
115 * @var array
116 */
117 public $tt_contentConfig = array(
118 // Boolean: Display info-marks or not
119 'showInfo' => 1,
120 // Boolean: Display up/down arrows and edit icons for tt_content records
121 'showCommands' => 1,
122 'languageCols' => 0,
123 'languageMode' => 0,
124 'languageColsPointer' => 0,
125 'showHidden' => 1,
126 // Displays hidden records as well
127 'sys_language_uid' => 0,
128 // Which language
129 'cols' => '1,0,2,3',
130 'activeCols' => '1,0,2,3'
131 // Which columns can be accessed by current BE user
132 );
133
134 /**
135 * Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
136 *
137 * @var array
138 */
139 public $activeTables = array();
140
141 /**
142 * @var array
143 */
144 public $tt_contentData = array(
145 'nextThree' => array(),
146 'prev' => array(),
147 'next' => array()
148 );
149
150 /**
151 * Used to store labels for CTypes for tt_content elements
152 *
153 * @var array
154 */
155 public $CType_labels = array();
156
157 /**
158 * Used to store labels for the various fields in tt_content elements
159 *
160 * @var array
161 */
162 public $itemLabels = array();
163
164 /**
165 * Used to store the RTE setup of a particular page
166 *
167 * @var array
168 */
169 protected $rteSetup = array();
170
171 /**
172 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
173 */
174 protected $clipboard;
175
176 /**
177 * @var array
178 */
179 protected $plusPages = array();
180
181 /**
182 * User permissions
183 *
184 * @var int
185 */
186 public $ext_CALC_PERMS;
187
188 /*****************************************
189 *
190 * Renderings
191 *
192 *****************************************/
193 /**
194 * Adds the code of a single table
195 *
196 * @param string $table Table name
197 * @param int $id Current page id
198 * @return string HTML for listing.
199 */
200 public function getTable($table, $id) {
201 if (isset($this->externalTables[$table])) {
202 return $this->getExternalTables($id, $table);
203 } else {
204 // Branch out based on table name:
205 switch ($table) {
206 case 'pages':
207 return $this->getTable_pages($id);
208 break;
209 case 'tt_content':
210 return $this->getTable_tt_content($id);
211 break;
212 default:
213 return '';
214 }
215 }
216 }
217
218 /**
219 * Renders an external table from page id
220 *
221 * @param int $id Page id
222 * @param string $table Name of the table
223 * @return string HTML for the listing
224 */
225 public function getExternalTables($id, $table) {
226 $type = $this->getPageLayoutController()->MOD_SETTINGS[$table];
227 if (!isset($type)) {
228 $type = 0;
229 }
230 // eg. "name;title;email;company,image"
231 $fList = $this->externalTables[$table][$type]['fList'];
232 // The columns are separeted by comma ','.
233 // Values separated by semicolon ';' are shown in the same column.
234 $icon = $this->externalTables[$table][$type]['icon'];
235 $addWhere = $this->externalTables[$table][$type]['addWhere'];
236 // Create listing
237 $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
238 return $out;
239 }
240
241 /**
242 * Renders records from the pages table from page id
243 * (Used to get information about the page tree content by "Web>Info"!)
244 *
245 * @param int $id Page id
246 * @return string HTML for the listing
247 */
248 public function getTable_pages($id) {
249 // Initializing:
250 $out = '';
251 // Select clause for pages:
252 $delClause = BackendUtility::deleteClause('pages') . ' AND ' . $this->getBackendUser()->getPagePermsClause(1);
253 // Select current page:
254 if (!$id) {
255 // The root has a pseudo record in pageinfo...
256 $row = $this->getPageLayoutController()->pageinfo;
257 } else {
258 $result = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'uid=' . (int)$id . $delClause);
259 $row = $this->getDatabase()->sql_fetch_assoc($result);
260 BackendUtility::workspaceOL('pages', $row);
261 }
262 // If there was found a page:
263 if (is_array($row)) {
264 // Select which fields to show:
265 $pKey = $this->getPageLayoutController()->MOD_SETTINGS['pages'];
266 switch ($pKey) {
267 case 1:
268 $this->fieldArray = array('title','uid') + array_keys($this->cleanTableNames());
269 break;
270 case 2:
271 $this->fieldArray = array(
272 'title',
273 'uid',
274 'lastUpdated',
275 'newUntil',
276 'no_cache',
277 'cache_timeout',
278 'php_tree_stop',
279 'TSconfig',
280 'storage_pid',
281 'is_siteroot',
282 'fe_login_mode'
283 );
284 break;
285 default:
286 $this->fieldArray = array(
287 'title',
288 'uid',
289 'alias',
290 'starttime',
291 'endtime',
292 'fe_group',
293 'target',
294 'url',
295 'shortcut',
296 'shortcut_mode'
297 );
298 }
299 // Getting select-depth:
300 $depth = (int)$this->getPageLayoutController()->MOD_SETTINGS['pages_levels'];
301 // Overriding a few things:
302 $this->no_noWrap = 0;
303 // Items
304 $this->eCounter = $this->firstElementNumber;
305 // Creating elements:
306 list($flag, $code) = $this->fwd_rwd_nav();
307 $out .= $code;
308 $editUids = array();
309 if ($flag) {
310 // Getting children:
311 $theRows = array();
312 $theRows = $this->pages_getTree($theRows, $row['uid'], $delClause . BackendUtility::versioningPlaceholderClause('pages'), '', $depth);
313 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
314 $editUids[] = $row['uid'];
315 }
316 $out .= $this->pages_drawItem($row, $this->fieldArray);
317 // Traverse all pages selected:
318 foreach ($theRows as $sRow) {
319 if ($this->getBackendUser()->doesUserHaveAccess($sRow, 2)) {
320 $editUids[] = $sRow['uid'];
321 }
322 $out .= $this->pages_drawItem($sRow, $this->fieldArray);
323 }
324 $this->eCounter++;
325 }
326 // Header line is drawn
327 $theData = array();
328 $editIdList = implode(',', $editUids);
329 // Traverse fields (as set above) in order to create header values:
330 foreach ($this->fieldArray as $field) {
331 if ($editIdList && isset($GLOBALS['TCA']['pages']['columns'][$field]) && $field != 'uid' && !$this->pages_noEditColumns) {
332 $params = '&edit[pages][' . $editIdList . ']=edit&columnsOnly=' . $field;
333 $iTitle = sprintf(
334 $this->getLanguageService()->getLL('editThisColumn'),
335 rtrim(trim($this->getLanguageService()->sL(BackendUtility::getItemLabel('pages', $field))), ':')
336 );
337 $eI = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
338 . '" title="' . htmlspecialchars($iTitle) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
339 } else {
340 $eI = '';
341 }
342 switch ($field) {
343 case 'title':
344 $theData[$field] = '&nbsp;<strong>'
345 . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'])
346 . '</strong>' . $eI;
347 break;
348 case 'uid':
349 $theData[$field] = '&nbsp;<strong>ID:</strong>';
350 break;
351 default:
352 if (substr($field, 0, 6) == 'table_') {
353 $f2 = substr($field, 6);
354 if ($GLOBALS['TCA'][$f2]) {
355 $theData[$field] = '&nbsp;' . IconUtility::getSpriteIconForRecord($f2, array(), array(
356 'title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$f2]['ctrl']['title'], TRUE)
357 ));
358 }
359 } else {
360 $theData[$field] = '&nbsp;&nbsp;<strong>'
361 . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'], TRUE)
362 . '</strong>' . $eI;
363 }
364 }
365 }
366 // CSH:
367 $out = BackendUtility::cshItem($this->descrTable, ('func_' . $pKey)) . '
368 <div class="table-fit">
369 <table class="table table-striped table-hover typo3-page-pages">' .
370 '<thead>' .
371 $this->addelement(1, '', $theData) .
372 '</thead>' .
373 '<tbody>' .
374 $out .
375 '</tbody>' .
376 '</table>
377 </div>';
378 }
379 return $out;
380 }
381
382 /**
383 * Renders Content Elements from the tt_content table from page id
384 *
385 * @param int $id Page id
386 * @return string HTML for the listing
387 */
388 public function getTable_tt_content($id) {
389 $this->initializeLanguages();
390 $this->initializeClipboard();
391 // Initialize:
392 $RTE = $this->getBackendUser()->isRTE();
393 $lMarg = 1;
394 $showHidden = $this->tt_contentConfig['showHidden'] ? '' : BackendUtility::BEenableFields('tt_content');
395 $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility::getRecordTitle('pages', BackendUtility::getRecordWSOL('pages', $id), TRUE));
396 /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
397 $pageRenderer = $this->getPageLayoutController()->doc->getPageRenderer();
398 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
399 $userCanEditPage = $this->ext_CALC_PERMS & Permission::PAGE_EDIT && !empty($this->id);
400 if ($this->tt_contentConfig['languageColsPointer'] > 0) {
401 $userCanEditPage = $this->getBackendUser()->check('tables_modify', 'pages_language_overlay');
402 }
403 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) {
404 PageActions.setPageId(' . (int)$this->id . ');
405 PageActions.setCanEditPage(' . ($userCanEditPage ? 'true' : 'false') . ');
406 PageActions.setLanguageOverlayId(' . $this->tt_contentConfig['languageColsPointer'] . ');
407 PageActions.initializePageTitleRenaming();
408 }');
409 // Get labels for CTypes and tt_content element fields in general:
410 $this->CType_labels = array();
411 foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
412 $this->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]);
413 }
414 $this->itemLabels = array();
415 foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
416 $this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
417 }
418 $languageColumn = array();
419 $out = '';
420 // Select display mode:
421 // MULTIPLE column display mode, side by side:
422 if (!$this->tt_contentConfig['single']) {
423 // Setting language list:
424 $langList = $this->tt_contentConfig['sys_language_uid'];
425 if ($this->tt_contentConfig['languageMode']) {
426 if ($this->tt_contentConfig['languageColsPointer']) {
427 $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
428 } else {
429 $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
430 }
431 $languageColumn = array();
432 }
433 $langListArr = GeneralUtility::intExplode(',', $langList);
434 $defLanguageCount = array();
435 $defLangBinding = array();
436 // For each languages... :
437 // If not languageMode, then we'll only be through this once.
438 foreach ($langListArr as $lP) {
439 $lP = (int)$lP;
440 if (count($langListArr) === 1 || $lP === 0) {
441 $showLanguage = ' AND sys_language_uid IN (' . $lP . ',-1)';
442 } else {
443 $showLanguage = ' AND sys_language_uid=' . $lP;
444 }
445 $cList = explode(',', $this->tt_contentConfig['cols']);
446 $content = array();
447 $head = array();
448
449 // Select content records per column
450 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showHidden . $showLanguage);
451 // For each column, render the content into a variable:
452 foreach ($cList as $key) {
453 if (!$lP) {
454 $defLanguageCount[$key] = array();
455 }
456 // Start wrapping div
457 $content[$key] .= '<div data-colpos="' . $key . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
458 if (empty($contentRecordsPerColumn[$key])) {
459 $content[$key] .= ' t3-page-ce-empty';
460 }
461 $content[$key] .= '">';
462 // Add new content at the top most position
463 $content[$key] .= '
464 <div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . str_replace('.', '', uniqid('', TRUE)) . '">
465 <div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id . '-' . uniqid('', TRUE) . '">
466 <a href="#" onclick="' . htmlspecialchars($this->newContentElementOnClick($id, $key, $lP))
467 . '" title="' . $this->getLanguageService()->getLL('newContentElement', TRUE) . '" class="btn btn-default btn-sm">'
468 . IconUtility::getSpriteIcon('actions-document-new')
469 . ' '
470 . $this->getLanguageService()->getLL('content', TRUE) . '</a>
471 </div>
472 <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
473 </div>
474 ';
475 $editUidList = '';
476 $rowArr = $contentRecordsPerColumn[$key];
477 $this->generateTtContentDataArray($rowArr);
478 foreach ((array)$rowArr as $rKey => $row) {
479 if ($this->tt_contentConfig['languageMode']) {
480 $languageColumn[$key][$lP] = $head[$key] . $content[$key];
481 if (!$this->defLangBinding) {
482 $languageColumn[$key][$lP] .= $this->newLanguageButton(
483 $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
484 $lP
485 );
486 }
487 }
488 if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
489 $singleElementHTML = '';
490 if (!$lP && ($this->defLangBinding || $row['sys_language_uid'] != -1)) {
491 $defLanguageCount[$key][] = $row['uid'];
492 }
493 $editUidList .= $row['uid'] . ',';
494 $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0;
495 if (!$this->tt_contentConfig['languageMode']) {
496 $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . str_replace('.', '', uniqid('', TRUE)) . '">';
497 }
498 $singleElementHTML .= $this->tt_content_drawHeader(
499 $row,
500 $this->tt_contentConfig['showInfo'] ? 15 : 5,
501 $disableMoveAndNewButtons,
502 TRUE,
503 !$this->tt_contentConfig['languageMode']
504 );
505 $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
506 $innerContent = '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>'
507 . $this->tt_content_drawItem($row, $isRTE) . '</div>';
508 $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div>'
509 . $this->tt_content_drawFooter($row);
510 $statusHidden = $this->isDisabled('tt_content', $row) ? ' t3-page-ce-hidden' : '';
511 $singleElementHTML = '<div class="t3-page-ce t3js-page-ce t3js-page-ce-sortable ' . $statusHidden . '" id="element-tt_content-'
512 . $row['uid'] . '" data-table="tt_content" data-uid="' . $row['uid'] . '">' . $singleElementHTML . '</div>';
513 if ($this->tt_contentConfig['languageMode']) {
514 $singleElementHTML .= '<div class="t3-page-ce t3js-page-ce">';
515 }
516 $singleElementHTML .= '<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id .
517 '-' . str_replace('.', '', uniqid('', TRUE)) . '">';
518 // Add icon "new content element below"
519 if (!$disableMoveAndNewButtons) {
520 // New content element:
521 if ($this->option_newWizard) {
522 $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('new_content_element') . '&id=' . $row['pid']
523 . '&sys_language_uid=' . $row['sys_language_uid'] . '&colPos=' . $row['colPos']
524 . '&uid_pid=' . -$row['uid'] .
525 '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';';
526 } else {
527 $params = '&edit[tt_content][' . -$row['uid'] . ']=new';
528 $onClick = BackendUtility::editOnClick($params, $this->backPath);
529 }
530 $singleElementHTML .= '
531 <a href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
532 . $this->getLanguageService()->getLL('newContentElement', TRUE) . '" class="btn btn-default btn-sm">'
533 . IconUtility::getSpriteIcon('actions-document-new')
534 . ' '
535 . $this->getLanguageService()->getLL('content', TRUE) . '</a>
536 ';
537 }
538 $singleElementHTML .= '</div></div><div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div></div>';
539 if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
540 $defLangBinding[$key][$lP][$row[$lP ? 'l18n_parent' : 'uid']] = $singleElementHTML;
541 } else {
542 $content[$key] .= $singleElementHTML;
543 }
544 } else {
545 unset($rowArr[$rKey]);
546 }
547 }
548 $content[$key] .= '</div>';
549 // Add new-icon link, header:
550 $newP = $this->newContentElementOnClick($id, $key, $lP);
551 $colTitle = BackendUtility::getProcessedValue('tt_content', 'colPos', $key);
552 $tcaItems = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $id, $this);
553 foreach ($tcaItems as $item) {
554 if ($item[1] == $key) {
555 $colTitle = $this->getLanguageService()->sL($item[0]);
556 }
557 }
558
559 $pasteP = array('colPos' => $key, 'sys_language_uid' => $lP);
560 $editParam = $this->doEdit && count($rowArr)
561 ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
562 : '';
563 $head[$key] .= $this->tt_content_drawColHeader($colTitle, $editParam, $newP, $pasteP);
564 }
565 // For each column, fit the rendered content into a table cell:
566 $out = '';
567 if ($this->tt_contentConfig['languageMode']) {
568 // in language mode process the content elements, but only fill $languageColumn. output will be generated later
569 $sortedLanguageColumn = array();
570 foreach ($cList as $key) {
571 $languageColumn[$key][$lP] = $head[$key] . $content[$key];
572 if (!$this->defLangBinding) {
573 $languageColumn[$key][$lP] .= $this->newLanguageButton(
574 $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
575 $lP
576 );
577 }
578 // We sort $languageColumn again according to $cList as it may contain data already from above.
579 $sortedLanguageColumn[$key] = $languageColumn[$key];
580 }
581 $languageColumn = $sortedLanguageColumn;
582 } else {
583 $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id);
584 // GRID VIEW:
585 $grid = '<div class="t3-grid-container"><table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%" class="t3-page-columns t3-grid-table t3js-page-columns">';
586 // Add colgroups
587 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
588 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
589 $grid .= '<colgroup>';
590 for ($i = 0; $i < $colCount; $i++) {
591 $grid .= '<col style="width:' . 100 / $colCount . '%"></col>';
592 }
593 $grid .= '</colgroup>';
594 // Cycle through rows
595 for ($row = 1; $row <= $rowCount; $row++) {
596 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
597 if (!isset($rowConfig)) {
598 continue;
599 }
600 $grid .= '<tr>';
601 for ($col = 1; $col <= $colCount; $col++) {
602 $columnConfig = $rowConfig['columns.'][$col . '.'];
603 if (!isset($columnConfig)) {
604 continue;
605 }
606 // Which tt_content colPos should be displayed inside this cell
607 $columnKey = (int)$columnConfig['colPos'];
608 // Render the grid cell
609 $colSpan = (int)$columnConfig['colspan'];
610 $rowSpan = (int)$columnConfig['rowspan'];
611 $grid .= '<td valign="top"' .
612 ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') .
613 ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') .
614 ' data-colpos="' . (int)$columnConfig['colPos'] . '" data-language-uid="' . $lP . '" class="t3js-page-lang-column-' . $lP . ' t3js-page-column t3-grid-cell t3-page-column t3-page-column-' . $columnKey .
615 ((!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '') ? ' t3-grid-cell-unassigned' : '') .
616 ((isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !$head[$columnKey]) || !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos']) ? ' t3-grid-cell-restricted' : '') .
617 ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') .
618 ($rowSpan > 0 ? ' t3-gridCell-height' . $rowSpan : '') . '">';
619
620 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
621 // If not, a new header without any buttons will be generated.
622 if (
623 isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey]
624 && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
625 ) {
626 $grid .= $head[$columnKey] . $content[$columnKey];
627 } elseif (
628 isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
629 && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
630 ) {
631 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'), '', '');
632 } elseif (
633 isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
634 && !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
635 ) {
636 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
637 ' (' . $this->getLanguageService()->getLL('noAccess') . ')', '', '');
638 } elseif (isset($columnConfig['name']) && $columnConfig['name'] !== '') {
639 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
640 . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '');
641 } else {
642 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'), '', '');
643 }
644
645 $grid .= '</td>';
646 }
647 $grid .= '</tr>';
648 }
649 $out .= $grid . '</table></div>';
650 }
651 // CSH:
652 $out .= BackendUtility::cshItem($this->descrTable, 'columns_multi');
653 }
654 // If language mode, then make another presentation:
655 // Notice that THIS presentation will override the value of $out!
656 // But it needs the code above to execute since $languageColumn is filled with content we need!
657 if ($this->tt_contentConfig['languageMode']) {
658 // Get language selector:
659 $languageSelector = $this->languageSelector($id);
660 // Reset out - we will make new content here:
661 $out = '';
662 // Traverse languages found on the page and build up the table displaying them side by side:
663 $cCont = array();
664 $sCont = array();
665 foreach ($langListArr as $lP) {
666 // Header:
667 $lP = (int)$lP;
668 $cCont[$lP] = '
669 <td valign="top" class="t3-page-column" data-language-uid="' . $lP . '">
670 <h2>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</h2>
671 </td>';
672
673 // "View page" icon is added:
674 $onClick = BackendUtility::viewOnClick($this->id, $this->backPath, BackendUtility::BEgetRootLine($this->id), '', '', ('&L=' . $lP));
675 $viewLink = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
676 // Language overlay page header:
677 if ($lP) {
678 list($lpRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . $lP);
679 BackendUtility::workspaceOL('pages_language_overlay', $lpRecord);
680 $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
681 $lPLabel = $this->getPageLayoutController()->doc->wrapClickMenuOnIcon(
682 IconUtility::getSpriteIconForRecord('pages_language_overlay', $lpRecord),
683 'pages_language_overlay',
684 $lpRecord['uid']
685 ) . $viewLink . ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
686 ? '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
687 . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">'
688 . IconUtility::getSpriteIcon('actions-document-open') . '</a>'
689 : ''
690 ) . htmlspecialchars(GeneralUtility::fixed_lgd_cs($lpRecord['title'], 20));
691 } else {
692 $lPLabel = $viewLink;
693 }
694 $sCont[$lP] = '
695 <td nowrap="nowrap" class="t3-page-column t3-page-lang-label">' . $lPLabel . '</td>';
696 }
697 // Add headers:
698 $out .= '<tr>' . implode($cCont) . '</tr>';
699 $out .= '<tr>' . implode($sCont) . '</tr>';
700 unset($cCont, $sCont);
701
702 // Traverse previously built content for the columns:
703 foreach ($languageColumn as $cKey => $cCont) {
704 $out .= '<tr>';
705 foreach ($cCont as $languageId => $columnContent) {
706 $out .= '<td valign="top" class="t3-grid-cell t3-page-column t3js-page-column t3js-page-lang-column t3js-page-lang-column-' . $languageId . '">' . $columnContent . '</td>';
707 }
708 $out .= '</tr>';
709 if ($this->defLangBinding) {
710 // "defLangBinding" mode
711 foreach ($defLanguageCount[$cKey] as $defUid) {
712 $cCont = array();
713 foreach ($langListArr as $lP) {
714 $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton(
715 $this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP),
716 $lP
717 );
718 }
719 $out .= '
720 <tr>
721 <td valign="top" class="t3-grid-cell">' . implode(('</td>' . '
722 <td valign="top" class="t3-grid-cell">'), $cCont) . '</td>
723 </tr>';
724 }
725 }
726 }
727 // Finally, wrap it all in a table and add the language selector on top of it:
728 $out = $languageSelector . '
729 <div class="t3-grid-container">
730 <table cellpadding="0" cellspacing="0" class="t3-page-columns t3-grid-table t3js-page-columns">
731 ' . $out . '
732 </table>
733 </div>';
734 // CSH:
735 $out .= BackendUtility::cshItem($this->descrTable, 'language_list');
736 }
737 } else {
738 // SINGLE column mode (columns shown beneath each other):
739 if ($this->tt_contentConfig['sys_language_uid'] == 0 || !$this->defLangBinding) {
740 // Initialize:
741 if ($this->defLangBinding && $this->tt_contentConfig['sys_language_uid'] == 0) {
742 $showLanguage = ' AND sys_language_uid IN (0,-1)';
743 $lP = 0;
744 } else {
745 $showLanguage = ' AND sys_language_uid=' . $this->tt_contentConfig['sys_language_uid'];
746 $lP = $this->tt_contentConfig['sys_language_uid'];
747 }
748 $cList = explode(',', $this->tt_contentConfig['showSingleCol']);
749 $out = '';
750 // Expand the table to some preset dimensions:
751 $out .= '
752 <tr>
753 <td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>
754 <td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td>
755 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
756 <td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td>
757 </tr>';
758
759 // Select content records per column
760 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('tt_content', $id, array_values($cList), $showHidden . $showLanguage);
761 // Traverse columns to display top-on-top
762 foreach ($cList as $counter => $key) {
763 $c = 0;
764 $rowArr = $contentRecordsPerColumn[$key];
765 $this->generateTtContentDataArray($rowArr);
766 $numberOfContentElementsInColumn = count($rowArr);
767 $rowOut = '';
768 // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
769 if ($this->doEdit && $this->option_showBigButtons && !(int)$key && $numberOfContentElementsInColumn == 0) {
770 $onClick = 'window.location.href='
771 . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('new_content_element') . '&id=' . $id . '&colPos=' . (int)$key
772 . '&sys_language_uid=' . $lP . '&uid_pid=' . $id . '&returnUrl='
773 . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';';
774 $theNewButton = $this->getPageLayoutController()->doc->t3Button($onClick, $this->getLanguageService()->getLL('newPageContent'));
775 $theNewButton = '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton;
776 } else {
777 $theNewButton = '';
778 }
779 $editUidList = '';
780 // Traverse any selected elements:
781 foreach ($rowArr as $rKey => $row) {
782 if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
783 $c++;
784 $editUidList .= $row['uid'] . ',';
785 $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
786 // Create row output:
787 $rowOut .= '
788 <tr>
789 <td></td>
790 <td valign="top">' . $this->tt_content_drawHeader($row) . '</td>
791 <td>&nbsp;</td>
792 <td' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . ' valign="top">'
793 . $this->tt_content_drawItem($row, $isRTE) . '</td>
794 </tr>';
795 // If the element was not the last element, add a divider line:
796 if ($c != $numberOfContentElementsInColumn) {
797 $rowOut .= '
798 <tr>
799 <td></td>
800 <td colspan="3"><img'
801 . IconUtility::skinImg($this->backPath, 'gfx/stiblet_medium2.gif', 'width="468" height="1"')
802 . ' class="c-divider" alt="" /></td>
803 </tr>';
804 }
805 } else {
806 unset($rowArr[$rKey]);
807 }
808 }
809 // Add spacer between sections in the vertical list
810 if ($counter) {
811 $out .= '
812 <tr>
813 <td></td>
814 <td colspan="3"><br /><br /><br /><br /></td>
815 </tr>';
816 }
817 // Add section header:
818 $newP = $this->newContentElementOnClick($id, $key, $this->tt_contentConfig['sys_language_uid']);
819 $pasteP = array('colPos' => $key, 'sys_language_uid' => $this->tt_contentConfig['sys_language_uid']);
820 $out .= '
821
822 <!-- Column header: -->
823 <tr>
824 <td></td>
825 <td valign="top" colspan="3">' . $this->tt_content_drawColHeader(
826 BackendUtility::getProcessedValue('tt_content', 'colPos', $key),
827 $this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '',
828 $newP,
829 $pasteP
830 ) . $theNewButton . '<br /></td>
831 </tr>';
832 // Finally, add the content from the records in this column:
833 $out .= $rowOut;
834 }
835 // Finally, wrap all table rows in one, big table:
836 $out = '
837 <table border="0" cellpadding="0" cellspacing="0" width="400" class="t3-page-columns-mode">
838 ' . $out . '
839 </table>';
840 // CSH:
841 $out .= BackendUtility::cshItem($this->descrTable, 'columns_single');
842 } else {
843 $out = '<br/><br/>' . $this->getPageLayoutController()->doc->icons(1)
844 . 'Sorry, you cannot view a single language in this localization mode (Default Language Binding is enabled)<br/><br/>';
845 }
846 }
847 // Add the big buttons to page:
848 if ($this->option_showBigButtons) {
849 $bArray = array();
850 if (!$this->getPageLayoutController()->current_sys_language) {
851 if ($this->ext_CALC_PERMS & Permission::PAGE_EDIT) {
852 $bArray[0] = $this->getPageLayoutController()->doc->t3Button(
853 BackendUtility::editOnClick('&edit[pages][' . $id . ']=edit'),
854 $this->getLanguageService()->getLL('editPageProperties')
855 );
856 }
857 } else {
858 if ($this->doEdit && $this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
859 list($languageOverlayRecord) = BackendUtility::getRecordsByField(
860 'pages_language_overlay',
861 'pid',
862 $id,
863 'AND sys_language_uid=' . (int)$this->getPageLayoutController()->current_sys_language
864 );
865 $bArray[0] = $this->getPageLayoutController()->doc->t3Button(
866 BackendUtility::editOnClick('&edit[pages_language_overlay][' . $languageOverlayRecord['uid'] . ']=edit'),
867 $this->getLanguageService()->getLL('editPageProperties_curLang')
868 );
869 }
870 }
871 if ($this->ext_CALC_PERMS & Permission::PAGE_DELETE || $this->ext_CALC_PERMS & Permission::PAGE_EDIT) {
872 $bArray[1] = $this->getPageLayoutController()->doc->t3Button(
873 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('move_element', ['table' => 'pages', 'uid' => $id, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')])) . ';',
874 $this->getLanguageService()->getLL('move_page')
875 );
876 }
877 if ($this->ext_CALC_PERMS & Permission::PAGE_NEW) {
878 $parameters = [
879 'id' => $id,
880 'pagesOnly' => 1,
881 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
882 ];
883 $bArray[2] = $this->getPageLayoutController()->doc->t3Button(
884 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', $parameters)) . ';',
885 $this->getLanguageService()->getLL('newPage2')
886 );
887 }
888 if ($this->doEdit && $this->ext_function == 1) {
889 $bArray[3] = $this->getPageLayoutController()->doc->t3Button(
890 'window.location.href='
891 . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('new_content_element') . '&id=' . $id
892 . '&sys_language_uid=' . $this->getPageLayoutController()->current_sys_language
893 . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';',
894 $this->getLanguageService()->getLL('newPageContent2')
895 );
896 }
897 $out = '
898 <table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons">
899 <tr>
900 <td>' . implode('</td>
901 <td>', $bArray) . '</td>
902 <td>' . BackendUtility::cshItem($this->descrTable, 'button_panel') . '</td>
903 </tr>
904 </table>
905 <br />
906 ' . $out;
907 }
908 // Return content:
909 return $out;
910 }
911
912 /**********************************
913 *
914 * Generic listing of items
915 *
916 **********************************/
917 /**
918 * Creates a standard list of elements from a table.
919 *
920 * @param string $table Table name
921 * @param int $id Page id.
922 * @param string $fList Comma list of fields to display
923 * @param bool $icon If TRUE, icon is shown
924 * @param string $addWhere Additional WHERE-clauses.
925 * @return string HTML table
926 */
927 public function makeOrdinaryList($table, $id, $fList, $icon = FALSE, $addWhere = '') {
928 // Initialize
929 $queryParts = $this->makeQueryArray($table, $id, $addWhere);
930 $this->setTotalItems($queryParts);
931 $dbCount = 0;
932 $result = FALSE;
933 // Make query for records if there were any records found in the count operation
934 if ($this->totalItems) {
935 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
936 // Will return FALSE, if $result is invalid
937 $dbCount = $this->getDatabase()->sql_num_rows($result);
938 }
939 // If records were found, render the list
940 if (!$dbCount) {
941 return '';
942 }
943 // Set fields
944 $out = '';
945 $this->fieldArray = GeneralUtility::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', TRUE);
946 $theData = array();
947 $theData = $this->headerFields($this->fieldArray, $table, $theData);
948 // Title row
949 $localizedTableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
950 $out .= '<tr class="t3-row-header">' . '<td nowrap="nowrap" class="col-icon"></td>'
951 . '<td nowrap="nowrap" colspan="' . (count($theData) - 2) . '"><span class="c-table">'
952 . $localizedTableTitle . '</span> (' . $dbCount . ')</td>' . '<td nowrap="nowrap" class="col-icon"></td>'
953 . '</tr>';
954 // Column's titles
955 if ($this->doEdit) {
956 $onClick = BackendUtility::editOnClick('&edit[' . $table . '][' . $this->id . ']=new');
957 $theData['__cmds__'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" '
958 . 'title="' . $this->getLanguageService()->getLL('new', TRUE) . '">'
959 . IconUtility::getSpriteIcon('actions-document-new') . '</a>';
960 }
961 $out .= $this->addelement(1, '', $theData, ' class="c-headLine"', 15);
962 // Render Items
963 $this->eCounter = $this->firstElementNumber;
964 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
965 BackendUtility::workspaceOL($table, $row);
966 if (is_array($row)) {
967 list($flag, $code) = $this->fwd_rwd_nav();
968 $out .= $code;
969 if ($flag) {
970 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
971 $Nrow = array();
972 // Setting icons links
973 if ($icon) {
974 $Nrow['__cmds__'] = $this->getIcon($table, $row);
975 }
976 // Get values:
977 $Nrow = $this->dataFields($this->fieldArray, $table, $row, $Nrow);
978 // Attach edit icon
979 if ($this->doEdit) {
980 $Nrow['__editIconLink__'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
981 . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">'
982 . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
983 } else {
984 $Nrow['__editIconLink__'] = $this->noEditIcon();
985 }
986 $out .= $this->addelement(1, '', $Nrow);
987 }
988 $this->eCounter++;
989 }
990 }
991 // Wrap it all in a table:
992 $out = '
993 <!--
994 Standard list of table "' . $table . '"
995 -->
996 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
997 ' . $out . '
998 </table>';
999 return $out;
1000 }
1001
1002 /**
1003 * Adds content to all data fields in $out array
1004 *
1005 * Each field name in $fieldArr has a special feature which is that the field name can be specified as more field names.
1006 * Eg. "field1,field2;field3".
1007 * Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
1008 *
1009 * @param array $fieldArr Array of fields to display
1010 * @param string $table Table name
1011 * @param array $row Record array
1012 * @param array $out Array to which the data is added
1013 * @return array $out array returned after processing.
1014 * @see makeOrdinaryList()
1015 */
1016 public function dataFields($fieldArr, $table, $row, $out = array()) {
1017 // Check table validity
1018 if (!isset($GLOBALS['TCA'][$table])) {
1019 return $out;
1020 }
1021
1022 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
1023 // Traverse fields
1024 foreach ($fieldArr as $fieldName) {
1025 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
1026 // Each field has its own cell (if configured in TCA)
1027 // If the column is a thumbnail column:
1028 if ($fieldName == $thumbsCol) {
1029 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
1030 } else {
1031 // ... otherwise just render the output:
1032 $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility::fixed_lgd_cs(
1033 BackendUtility::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
1034 250)
1035 )));
1036 }
1037 } else {
1038 // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
1039 // the field name with ";" and check each value there as a TCA configured field)
1040 $theFields = explode(';', $fieldName);
1041 // Traverse fields, separated by ";" (displayed in a single cell).
1042 foreach ($theFields as $fName2) {
1043 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
1044 $out[$fieldName] .= '<strong>' . $this->getLanguageService()->sL(
1045 $GLOBALS['TCA'][$table]['columns'][$fName2]['label'],
1046 TRUE
1047 ) . '</strong>' . '&nbsp;&nbsp;' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(
1048 BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
1049 25
1050 )) . '<br />';
1051 }
1052 }
1053 }
1054 // If no value, add a nbsp.
1055 if (!$out[$fieldName]) {
1056 $out[$fieldName] = '&nbsp;';
1057 }
1058 // Wrap in dimmed-span tags if record is "disabled"
1059 if ($this->isDisabled($table, $row)) {
1060 $out[$fieldName] = '<span class="text-muted">' . $out[$fieldName] . '</span>';
1061 }
1062 }
1063 return $out;
1064 }
1065
1066 /**
1067 * Header fields made for the listing of records
1068 *
1069 * @param array $fieldArr Field names
1070 * @param string $table The table name
1071 * @param array $out Array to which the headers are added.
1072 * @return array $out returned after addition of the header fields.
1073 * @see makeOrdinaryList()
1074 */
1075 public function headerFields($fieldArr, $table, $out = array()) {
1076 foreach ($fieldArr as $fieldName) {
1077 $ll = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label'], TRUE);
1078 $out[$fieldName] = $ll ? $ll : '&nbsp;';
1079 }
1080 return $out;
1081 }
1082
1083 /**
1084 * Gets content records per column.
1085 * This is required for correct workspace overlays.
1086 *
1087 * @param string $table UNUSED (will always be queried from tt_content)
1088 * @param int $id Page Id to be used (not used at all, but part of the API, see $this->pidSelect)
1089 * @param array $columns colPos values to be considered to be shown
1090 * @param string $additionalWhereClause Additional where clause for database select
1091 * @return array Associative array for each column (colPos)
1092 */
1093 protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '') {
1094 $columns = array_map('intval', $columns);
1095 $contentRecordsPerColumn = array_fill_keys($columns, array());
1096
1097 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos IN (' . implode(',', $columns) . ')' . $additionalWhereClause);
1098 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1099 // Traverse any selected elements and render their display code:
1100 $rowArr = $this->getResult($result);
1101
1102 foreach ($rowArr as $record) {
1103 $columnValue = $record['colPos'];
1104 $contentRecordsPerColumn[$columnValue][] = $record;
1105 }
1106
1107 return $contentRecordsPerColumn;
1108 }
1109
1110 /**********************************
1111 *
1112 * Additional functions; Pages
1113 *
1114 **********************************/
1115 /**
1116 * Adds pages-rows to an array, selecting recursively in the page tree.
1117 *
1118 * @param array $theRows Array which will accumulate page rows
1119 * @param int $pid Pid to select from
1120 * @param string $qWhere Query-where clause
1121 * @param string $treeIcons Prefixed icon code.
1122 * @param int $depth Depth (decreasing)
1123 * @return array $theRows, but with added rows.
1124 */
1125 public function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth) {
1126 $depth--;
1127 if ($depth >= 0) {
1128 $res = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'pid=' . (int)$pid . $qWhere, '', 'sorting');
1129 $c = 0;
1130 $rc = $this->getDatabase()->sql_num_rows($res);
1131 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1132 BackendUtility::workspaceOL('pages', $row);
1133 if (is_array($row)) {
1134 $c++;
1135 $row['treeIcons'] = $treeIcons . '<img' . IconUtility::skinImg(
1136 $this->backPath,
1137 'gfx/ol/join' . ($rc == $c ? 'bottom' : '') . '.gif',
1138 'width="18" height="16"'
1139 ) . ' alt="" />';
1140 $theRows[] = $row;
1141 // Get the branch
1142 $spaceOutIcons = '<img' . IconUtility::skinImg(
1143 $this->backPath,
1144 'gfx/ol/' . ($rc == $c ? 'blank.gif' : 'line.gif'),
1145 'width="18" height="16"'
1146 ) . ' alt="" />';
1147 $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons, $row['php_tree_stop'] ? 0 : $depth);
1148 }
1149 }
1150 } else {
1151 $count = $this->getDatabase()->exec_SELECTcountRows('uid', 'pages', 'pid=' . (int)$pid . $qWhere);
1152 if ($count) {
1153 $this->plusPages[$pid] = $count;
1154 }
1155 }
1156 return $theRows;
1157 }
1158
1159 /**
1160 * Adds a list item for the pages-rendering
1161 *
1162 * @param array $row Record array
1163 * @param array $fieldArr Field list
1164 * @return string HTML for the item
1165 */
1166 public function pages_drawItem($row, $fieldArr) {
1167 // Initialization
1168 $theIcon = $this->getIcon('pages', $row);
1169 // Preparing and getting the data-array
1170 $theData = array();
1171 foreach ($fieldArr as $field) {
1172 switch ($field) {
1173 case 'title':
1174 $red = $this->plusPages[$row['uid']] ? '<font color="red"><strong>+&nbsp;</strong></font>' : '';
1175 $pTitle = htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field], 20));
1176 if ($red) {
1177 $pTitle = '<a href="'
1178 . htmlspecialchars($this->script . ((strpos($this->script, '?') !== FALSE) ? '&' : '?')
1179 . 'id=' . $row['uid']) . '">' . $pTitle . '</a>';
1180 }
1181 $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . '&nbsp;&nbsp;';
1182 break;
1183 case 'php_tree_stop':
1184 // Intended fall through
1185 case 'TSconfig':
1186 $theData[$field] = $row[$field] ? '&nbsp;<strong>x</strong>' : '&nbsp;';
1187 break;
1188 case 'uid':
1189 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
1190 $params = '&edit[pages][' . $row['uid'] . ']=edit';
1191 $eI = '<a href="#" onclick="'
1192 . htmlspecialchars(BackendUtility::editOnClick($params))
1193 . '" title="' . $this->getLanguageService()->getLL('editThisPage', TRUE) . '">'
1194 . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1195 } else {
1196 $eI = '';
1197 }
1198 $theData[$field] = '<span align="right">' . $row['uid'] . $eI . '</span>';
1199 break;
1200 default:
1201 if (substr($field, 0, 6) == 'table_') {
1202 $f2 = substr($field, 6);
1203 if ($GLOBALS['TCA'][$f2]) {
1204 $c = $this->numberOfRecords($f2, $row['uid']);
1205 $theData[$field] = '&nbsp;&nbsp;' . ($c ? $c : '');
1206 }
1207 } else {
1208 $theData[$field] = '&nbsp;&nbsp;'
1209 . htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field]));
1210 }
1211 }
1212 }
1213 $this->addElement_tdParams['title'] = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : '';
1214 return $this->addelement(1, '', $theData);
1215 }
1216
1217 /**********************************
1218 *
1219 * Additional functions; Content Elements
1220 *
1221 **********************************/
1222 /**
1223 * Draw header for a content element column:
1224 *
1225 * @param string $colName Column name
1226 * @param string $editParams Edit params (Syntax: &edit[...] for FormEngine)
1227 * @param string $newParams New element params (Syntax: &edit[...] for FormEngine) OBSOLETE
1228 * @param array|NULL $pasteParams Paste element params (i.e. array(colPos => 1, sys_language_uid => 2))
1229 * @return string HTML table
1230 */
1231 public function tt_content_drawColHeader($colName, $editParams, $newParams, array $pasteParams = NULL) {
1232 $iconsArr = array();
1233 // Create command links:
1234 if ($this->tt_contentConfig['showCommands']) {
1235 // Edit whole of column:
1236 if ($editParams) {
1237 $iconsArr['edit'] = '<a href="#" onclick="'
1238 . htmlspecialchars(BackendUtility::editOnClick($editParams)) . '" title="'
1239 . $this->getLanguageService()->getLL('editColumn', TRUE) . '">'
1240 . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1241 }
1242 if ($pasteParams) {
1243 $elFromTable = $this->clipboard->elFromTable('tt_content');
1244 if (!empty($elFromTable)) {
1245 $iconsArr['paste'] = '<a href="'
1246 . htmlspecialchars($this->clipboard->pasteUrl('tt_content', $this->id, TRUE, $pasteParams))
1247 . '" onclick="' . htmlspecialchars(('return '
1248 . $this->clipboard->confirmMsg('pages', $this->pageRecord, 'into', $elFromTable, $colName)))
1249 . '" title="' . $this->getLanguageService()->getLL('clip_paste', TRUE) . '">'
1250 . IconUtility::getSpriteIcon('actions-document-paste-into') . '</a>';
1251 }
1252 }
1253 }
1254 $icons = '';
1255 if (!empty($iconsArr)) {
1256 $icons = '<div class="t3-page-column-header-icons">' . implode('', $iconsArr) . '</div>';
1257 }
1258 // Create header row:
1259 $out = '<div class="t3-page-column-header">
1260 ' . $icons . '
1261 <div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
1262 </div>';
1263 return $out;
1264 }
1265
1266 /**
1267 * Draw the footer for a single tt_content element
1268 *
1269 * @param array $row Record array
1270 * @return string HTML of the footer
1271 */
1272 protected function tt_content_drawFooter(array $row) {
1273 $content = '';
1274 // Get processed values:
1275 $info = array();
1276 $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
1277
1278 // Call drawFooter hooks
1279 $drawFooterHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'];
1280 if (is_array($drawFooterHooks)) {
1281 foreach ($drawFooterHooks as $hookClass) {
1282 $hookObject = GeneralUtility::getUserObj($hookClass);
1283 if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
1284 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\View\\PageLayoutViewDrawFooterHookInterface', 1404378171);
1285 }
1286 $hookObject->preProcess($this, $info, $row);
1287 }
1288 }
1289
1290 // Display info from records fields:
1291 if (!empty($info)) {
1292 $content = '<div class="t3-page-ce-info">
1293 ' . implode('<br>', $info) . '
1294 </div>';
1295 }
1296 // Wrap it
1297 if (!empty($content)) {
1298 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1299 }
1300 return $content;
1301 }
1302
1303 /**
1304 * Draw the header for a single tt_content element
1305 *
1306 * @param array $row Record array
1307 * @param int $space Amount of pixel space above the header. UNUSED
1308 * @param bool $disableMoveAndNewButtons If set the buttons for creating new elements and moving up and down are not shown.
1309 * @param bool $langMode If set, we are in language mode and flags will be shown for languages
1310 * @param bool $dragDropEnabled If set the move button must be hidden
1311 * @return string HTML table with the record header.
1312 */
1313 public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = FALSE, $langMode = FALSE, $dragDropEnabled = FALSE) {
1314 $out = '';
1315 // If show info is set...;
1316 if ($this->tt_contentConfig['showInfo'] && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1317 // Render control panel for the element:
1318 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1319 // Edit content element:
1320 $params = '&edit[tt_content][' . $this->tt_contentData['nextThree'][$row['uid']] . ']=edit';
1321 $out .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
1322 $params,
1323 '',
1324 GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
1325 )) . '" title="' . htmlspecialchars($this->nextThree > 1
1326 ? sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree)
1327 : $this->getLanguageService()->getLL('edit'))
1328 . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1329 // Hide element:
1330 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1331 if (
1332 $hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1333 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1334 || $this->getBackendUser()->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1335 ) {
1336 if ($row[$hiddenField]) {
1337 $value = 0;
1338 $label = 'unHide';
1339 } else {
1340 $value = 1;
1341 $label = 'hide';
1342 }
1343 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid'])
1344 . '][' . $hiddenField . ']=' . $value;
1345 $out .= '<a class="btn btn-default" href="' . htmlspecialchars($this->getPageLayoutController()->doc->issueCommand($params))
1346 . '" title="' . $this->getLanguageService()->getLL($label, TRUE) . '">'
1347 . IconUtility::getSpriteIcon('actions-edit-' . strtolower($label)) . '</a>';
1348 }
1349 // Delete
1350 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1351 $confirm = GeneralUtility::quoteJSvalue($this->getLanguageService()->getLL('deleteWarning')
1352 . BackendUtility::translationCount('tt_content', $row['uid'], (' '
1353 . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')))
1354 );
1355 $out .= '<a class="btn btn-default" href="' . htmlspecialchars($this->getPageLayoutController()->doc->issueCommand($params))
1356 . '" onclick="' . htmlspecialchars(('return confirm(' . $confirm . ');')) . '" title="'
1357 . $this->getLanguageService()->getLL('deleteItem', TRUE) . '">'
1358 . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
1359 if ($out) {
1360 $out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>';
1361 }
1362 if (!$disableMoveAndNewButtons) {
1363 $moveButtonContent = '';
1364 $displayMoveButtons = FALSE;
1365 // Move element up:
1366 if ($this->tt_contentData['prev'][$row['uid']]) {
1367 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']];
1368 $moveButtonContent .= '<a class="btn btn-default" href="'
1369 . htmlspecialchars($this->getPageLayoutController()->doc->issueCommand($params))
1370 . '" title="' . $this->getLanguageService()->getLL('moveUp', TRUE) . '">'
1371 . IconUtility::getSpriteIcon('actions-move-up') . '</a>';
1372 if (!$dragDropEnabled) {
1373 $displayMoveButtons = TRUE;
1374 }
1375 } else {
1376 $moveButtonContent .= '<span class="btn btn-default disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
1377 }
1378 // Move element down:
1379 if ($this->tt_contentData['next'][$row['uid']]) {
1380 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']];
1381 $moveButtonContent .= '<a class="btn btn-default" href="'
1382 . htmlspecialchars($this->getPageLayoutController()->doc->issueCommand($params))
1383 . '" title="' . $this->getLanguageService()->getLL('moveDown', TRUE) . '">'
1384 . IconUtility::getSpriteIcon('actions-move-down') . '</a>';
1385 if (!$dragDropEnabled) {
1386 $displayMoveButtons = TRUE;
1387 }
1388 } else {
1389 $moveButtonContent .= '<span class="btn btn-default disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
1390 }
1391 if ($displayMoveButtons) {
1392 $out .= '<div class="btn-group btn-group-sm" role="group">' . $moveButtonContent . '</div>';
1393 }
1394 }
1395 }
1396 }
1397 $additionalIcons = array();
1398 $additionalIcons[] = $this->getIcon('tt_content', $row) . ' ';
1399 $additionalIcons[] = $langMode ? $this->languageFlag($row['sys_language_uid'], FALSE) : '';
1400 // Get record locking status:
1401 if ($lockInfo = BackendUtility::isRecordLocked('tt_content', $row['uid'])) {
1402 $additionalIcons[] = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg'])
1403 . ');return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">'
1404 . IconUtility::getSpriteIcon('status-warning-in-use') . '</a>';
1405 }
1406 // Call stats information hook
1407 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1408 $_params = array('tt_content', $row['uid'], &$row);
1409 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1410 $additionalIcons[] = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1411 }
1412 }
1413 // Wrap the whole header
1414 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
1415 return '<div class="t3-page-ce-header t3js-page-ce-draghandle">
1416 <div class="t3-page-ce-header-icons-left">' . implode('', $additionalIcons) . '</div>
1417 <div class="t3-page-ce-header-icons-right">' . ($out ? '<div class="btn-toolbar">' .$out . '</div>' : '') . '</div>
1418 </div>
1419 <div class="t3-page-ce-body">';
1420 }
1421
1422 /**
1423 * Draws the preview content for a content element
1424 *
1425 * @param string $row Content element
1426 * @param bool $isRTE Set if the RTE link can be created.
1427 * @return string HTML
1428 * @throws \UnexpectedValueException
1429 */
1430 public function tt_content_drawItem($row, $isRTE = FALSE) {
1431 $out = '';
1432 $outHeader = '';
1433 // Make header:
1434 if ($row['header']) {
1435 $infoArr = array();
1436 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
1437 $hiddenHeaderNote = '';
1438 // If header layout is set to 'hidden', display an accordant note:
1439 if ($row['header_layout'] == 100) {
1440 $hiddenHeaderNote = ' <em>[' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.hidden', TRUE) . ']</em>';
1441 }
1442 $outHeader = $row['date']
1443 ? htmlspecialchars($this->itemLabels['date'] . ' ' . BackendUtility::date($row['date'])) . '<br />'
1444 : '';
1445 $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
1446 . $hiddenHeaderNote . '</strong><br />';
1447 }
1448 // Make content:
1449 $infoArr = array();
1450 $drawItem = TRUE;
1451 // Hook: Render an own preview of a record
1452 $drawItemHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1453 if (is_array($drawItemHooks)) {
1454 foreach ($drawItemHooks as $hookClass) {
1455 $hookObject = GeneralUtility::getUserObj($hookClass);
1456 if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) {
1457 throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface::class, 1218547409);
1458 }
1459 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1460 }
1461 }
1462 // Draw preview of the item depending on its CType (if not disabled by previous hook):
1463 if ($drawItem) {
1464 switch ($row['CType']) {
1465 case 'header':
1466 if ($row['subheader']) {
1467 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
1468 }
1469 break;
1470 case 'bullets':
1471 case 'table':
1472 if ($row['bodytext']) {
1473 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1474 }
1475 break;
1476 case 'uploads':
1477 if ($row['media']) {
1478 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'media'), $row) . '<br />';
1479 }
1480 break;
1481 case 'menu':
1482 $contentType = $this->CType_labels[$row['CType']];
1483 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1484 // Add Menu Type
1485 $menuTypeLabel = $this->getLanguageService()->sL(
1486 BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
1487 );
1488 $menuTypeLabel = $menuTypeLabel ?: 'invalid menu type';
1489 $out .= $this->linkEditContent($menuTypeLabel, $row);
1490 if ($row['menu_type'] !== '2' && ($row['pages'] || $row['selected_categories'])) {
1491 // Show pages if menu type is not "Sitemap"
1492 $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
1493 }
1494 break;
1495 case 'shortcut':
1496 if (!empty($row['records'])) {
1497 $shortcutContent = array();
1498 $recordList = explode(',', $row['records']);
1499 foreach ($recordList as $recordIdentifier) {
1500 $split = BackendUtility::splitTable_Uid($recordIdentifier);
1501 $tableName = empty($split[0]) ? 'tt_content' : $split[0];
1502 $shortcutRecord = BackendUtility::getRecord($tableName, $split[1]);
1503 if (is_array($shortcutRecord)) {
1504 $icon = IconUtility::getSpriteIconForRecord($tableName, $shortcutRecord);
1505 $icon = $this->getPageLayoutController()->doc->wrapClickMenuOnIcon($icon, $tableName,
1506 $shortcutRecord['uid'], 1, '', '+copy,info,edit,view');
1507 $shortcutContent[] = $icon
1508 . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord));
1509 }
1510 }
1511 $out .= implode('<br />', $shortcutContent) . '<br />';
1512 }
1513 break;
1514 case 'list':
1515 $hookArr = array();
1516 $hookOut = '';
1517 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1518 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1519 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1520 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1521 }
1522 if (!empty($hookArr)) {
1523 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1524 foreach ($hookArr as $_funcRef) {
1525 $hookOut .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1526 }
1527 }
1528 if ((string)$hookOut !== '') {
1529 $out .= $hookOut;
1530 } elseif (!empty($row['list_type'])) {
1531 $label = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
1532 if (!empty($label)) {
1533 $out .= $this->linkEditContent('<strong>' . $this->getLanguageService()->sL($label, TRUE) . '</strong>', $row) . '<br />';
1534 } else {
1535 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
1536 $out .= GeneralUtility::makeInstance(
1537 FlashMessage::class,
1538 htmlspecialchars($message),
1539 '',
1540 FlashMessage::WARNING
1541 )->render();
1542 }
1543 } elseif (!empty($row['select_key'])) {
1544 $out .= $this->getLanguageService()->sL(BackendUtility::getItemLabel('tt_content', 'select_key'), TRUE)
1545 . ' ' . $row['select_key'] . '<br />';
1546 } else {
1547 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
1548 }
1549 $out .= $this->getLanguageService()->sL(
1550 BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages']),
1551 TRUE
1552 ) . '<br />';
1553 break;
1554 default:
1555 $contentType = $this->CType_labels[$row['CType']];
1556
1557 if (isset($contentType)) {
1558 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1559 if ($row['bodytext']) {
1560 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1561 }
1562 if ($row['image']) {
1563 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'image'), $row) . '<br />';
1564 }
1565 } else {
1566 $message = sprintf(
1567 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'),
1568 $row['CType']
1569 );
1570 $out .= GeneralUtility::makeInstance(
1571 FlashMessage::class,
1572 htmlspecialchars($message),
1573 '',
1574 FlashMessage::WARNING
1575 )->render();
1576 }
1577 }
1578 }
1579 // Wrap span-tags:
1580 $out = '
1581 <span class="exampleContent">' . $out . '</span>';
1582 // Add header:
1583 $out = $outHeader . $out;
1584 // Add RTE button:
1585 if ($isRTE) {
1586 $out .= $this->linkRTEbutton($row);
1587 }
1588 // Return values:
1589 if ($this->isDisabled('tt_content', $row)) {
1590 return '<span class="text-muted">' . $out . '</span>';
1591 } else {
1592 return $out;
1593 }
1594 }
1595
1596 /**
1597 * Generates a list of selected pages or categories for the CType menu
1598 *
1599 * @param array $row row from pages
1600 * @return string
1601 */
1602 protected function generateListForCTypeMenu(array $row) {
1603 $table = 'pages';
1604 $field = 'pages';
1605 // get categories instead of pages
1606 if (strpos($row['menu_type'], 'categorized_') !== FALSE) {
1607 $table = 'sys_category';
1608 $field = 'selected_categories';
1609 }
1610 if (trim($row[$field]) === '') {
1611 return '';
1612 }
1613 $content = '';
1614 $uidList = explode(',', $row[$field]);
1615 foreach ($uidList as $uid) {
1616 $uid = (int)$uid;
1617 $record = BackendUtility::getRecord($table, $uid, 'title');
1618 $content .= '<br>' . $record['title'] . ' (' .$uid. ')';
1619 }
1620 return $content;
1621 }
1622
1623 /**
1624 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1625 * Selects across columns, but within in the same PID. Columns are expect to be the same
1626 * for translations and original but this may be a conceptual error (?)
1627 *
1628 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1629 * @param int $id Page pid
1630 * @param int $lP Sys language UID
1631 * @return array Modified $defLanguageCount
1632 */
1633 public function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP) {
1634 if ($lP && !empty($defLanguageCount)) {
1635 // Select all translations here:
1636 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid=' . (int)$lP
1637 . ' AND l18n_parent IN (' . implode(',', $defLanguageCount) . ')');
1638 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1639 // Flip uids:
1640 $defLanguageCount = array_flip($defLanguageCount);
1641 // Traverse any selected elements and unset original UID if any:
1642 $rowArr = $this->getResult($result);
1643 foreach ($rowArr as $row) {
1644 unset($defLanguageCount[$row['l18n_parent']]);
1645 }
1646 // Flip again:
1647 $defLanguageCount = array_keys($defLanguageCount);
1648 }
1649 return $defLanguageCount;
1650 }
1651
1652 /**
1653 * Creates button which is used to create copies of records..
1654 *
1655 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1656 * @param int $lP Sys language UID
1657 * @return string "Copy languages" button, if available.
1658 */
1659 public function newLanguageButton($defLanguageCount, $lP) {
1660 if (!$this->doEdit || empty($defLanguageCount) || !$lP) {
1661 return '';
1662 }
1663 $params = '';
1664 foreach ($defLanguageCount as $uidVal) {
1665 $params .= '&cmd[tt_content][' . $uidVal . '][localize]=' . $lP;
1666 }
1667 // Copy for language:
1668 $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue($this->getPageLayoutController()->doc->issueCommand($params)) . '; return false;';
1669 $theNewButton = '<div class="t3-page-lang-copyce">' .
1670 $this->getPageLayoutController()->doc->t3Button(
1671 $onClick,
1672 $this->getLanguageService()->getLL('newPageContent_copyForLang') . ' [' . count($defLanguageCount) . ']'
1673 ) . '</div>';
1674 return $theNewButton;
1675 }
1676
1677 /**
1678 * Creates onclick-attribute content for a new content element
1679 *
1680 * @param int $id Page id where to create the element.
1681 * @param int $colPos Preset: Column position value
1682 * @param int $sys_language Preset: Sys langauge value
1683 * @return string String for onclick attribute.
1684 * @see getTable_tt_content()
1685 */
1686 public function newContentElementOnClick($id, $colPos, $sys_language) {
1687 if ($this->option_newWizard) {
1688 $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('new_content_element') . '&id=' . $id . '&colPos=' . $colPos
1689 . '&sys_language_uid=' . $sys_language . '&uid_pid=' . $id
1690 . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';';
1691 } else {
1692 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
1693 . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language);
1694 }
1695 return $onClick;
1696 }
1697
1698 /**
1699 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
1700 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1701 *
1702 * @param string $str String to link. Must be prepared for HTML output.
1703 * @param array $row The row.
1704 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1705 * @see getTable_tt_content()
1706 */
1707 public function linkEditContent($str, $row) {
1708 $addButton = '';
1709 $onClick = '';
1710 if ($this->doEdit && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1711 // Setting onclick action for content link:
1712 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit');
1713 }
1714 // Return link
1715 return $onClick ? '<a href="#" onclick="' . htmlspecialchars($onClick)
1716 . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">' . $str . '</a>' . $addButton : $str;
1717 }
1718
1719 /**
1720 * Adds a button to edit the row in RTE wizard
1721 *
1722 * @param array $row The row of tt_content element
1723 * @return string Button to click if you want to edit in RTE wizard.
1724 */
1725 public function linkRTEbutton($row) {
1726 $params = array();
1727 $params['table'] = 'tt_content';
1728 $params['uid'] = $row['uid'];
1729 $params['pid'] = $row['pid'];
1730 $params['field'] = 'bodytext';
1731 $params['returnUrl'] = GeneralUtility::linkThisScript();
1732 $RTEonClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_rte', array('P' => $params))) . ';return false;';
1733 $addButton = $this->option_showBigButtons && $this->doEdit
1734 ? $this->getPageLayoutController()->doc->t3Button($RTEonClick, $this->getLanguageService()->getLL('editInRTE'))
1735 : '';
1736 return $addButton;
1737 }
1738
1739 /**
1740 * Make selector box for creating new translation in a language
1741 * Displays only languages which are not yet present for the current page and
1742 * that are not disabled with page TS.
1743 *
1744 * @param int $id Page id for which to create a new language (pages_language_overlay record)
1745 * @return string <select> HTML element (if there were items for the box anyways...)
1746 * @see getTable_tt_content()
1747 */
1748 public function languageSelector($id) {
1749 if ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
1750 // First, select all
1751 $res = $this->getPageLayoutController()->exec_languageQuery(0);
1752 $langSelItems = array();
1753 $langSelItems[0] = '
1754 <option value="0"></option>';
1755 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1756 if ($this->getBackendUser()->checkLanguageAccess($row['uid'])) {
1757 $langSelItems[$row['uid']] = '
1758 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1759 }
1760 }
1761 // Then, subtract the languages which are already on the page:
1762 $res = $this->getPageLayoutController()->exec_languageQuery($id);
1763 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1764 unset($langSelItems[$row['uid']]);
1765 }
1766 // Remove disallowed languages
1767 if (count($langSelItems) > 1
1768 && !$this->getBackendUser()->user['admin']
1769 && $this->getBackendUser()->groupData['allowed_languages'] !== ''
1770 ) {
1771 $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
1772 if (!empty($allowed_languages)) {
1773 foreach ($langSelItems as $key => $value) {
1774 if (!isset($allowed_languages[$key]) && $key != 0) {
1775 unset($langSelItems[$key]);
1776 }
1777 }
1778 }
1779 }
1780 // Remove disabled languages
1781 $modSharedTSconfig = BackendUtility::getModTSconfig($id, 'mod.SHARED');
1782 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages'])
1783 ? GeneralUtility::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], TRUE)
1784 : array();
1785 if (!empty($langSelItems) && !empty($disableLanguages)) {
1786 foreach ($disableLanguages as $language) {
1787 if ($language != 0 && isset($langSelItems[$language])) {
1788 unset($langSelItems[$language]);
1789 }
1790 }
1791 }
1792 // If any languages are left, make selector:
1793 if (count($langSelItems) > 1) {
1794 $url = BackendUtility::getModuleUrl('record_edit', array(
1795 'edit[pages_language_overlay]['. $id . ']' => 'new',
1796 'overrideVals[pages_language_overlay][doktype]' => (int)$this->pageRecord['doktype'],
1797 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1798 ));
1799 $onChangeContent = 'window.location.href=' . GeneralUtility::quoteJSvalue($url . '&overrideVals[pages_language_overlay][sys_language_uid]=') . '+this.options[this.selectedIndex].value';
1800 return '<div class="form-inline form-inline-spaced">'
1801 . '<div class="form-group">'
1802 . '<label for="createNewLanguage">'
1803 . $this->getLanguageService()->getLL('new_language', TRUE)
1804 . '</label>'
1805 . '<select class="form-control input-sm" name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">'
1806 . implode('', $langSelItems)
1807 . '</select></div></div>';
1808 }
1809 }
1810 return '';
1811 }
1812
1813 /**
1814 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1815 *
1816 * @param bool|\mysqli_result|object $result MySQLi result object / DBAL object
1817 * @param string $table Table name defaulting to tt_content
1818 * @return array The selected rows returned in this array.
1819 */
1820 public function getResult($result, $table = 'tt_content') {
1821 $output = array();
1822 // Traverse the result:
1823 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
1824 BackendUtility::workspaceOL($table, $row, -99, TRUE);
1825 if ($row) {
1826 // Add the row to the array:
1827 $output[] = $row;
1828 }
1829 }
1830 $this->generateTtContentDataArray($output);
1831 // Return selected records
1832 return $output;
1833 }
1834
1835 /********************************
1836 *
1837 * Various helper functions
1838 *
1839 ********************************/
1840
1841 /**
1842 * Initializes the clipboard for generating paste links
1843 *
1844 * @return void
1845 *
1846 * @see \TYPO3\CMS\Recordlist\RecordList::main()
1847 * @see \TYPO3\CMS\Backend\Controller\ClickMenuController::main()
1848 * @see \TYPO3\CMS\Filelist\Controller\FileListController::main()
1849 */
1850 protected function initializeClipboard() {
1851 // Start clipboard
1852 $this->clipboard = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class);
1853
1854 // Initialize - reads the clipboard content from the user session
1855 $this->clipboard->initializeClipboard();
1856
1857 // This locks the clipboard to the Normal for this request.
1858 $this->clipboard->lockToNormal();
1859
1860 // Clean up pad
1861 $this->clipboard->cleanCurrent();
1862
1863 // Save the clipboard content
1864 $this->clipboard->endClipboard();
1865 }
1866
1867 /**
1868 * Generates the data for previous and next elements which is needed for movements.
1869 *
1870 * @param array $rowArray
1871 * @return void
1872 */
1873 protected function generateTtContentDataArray(array $rowArray) {
1874 if (empty($this->tt_contentData)) {
1875 $this->tt_contentData = array(
1876 'nextThree' => array(),
1877 'next' => array(),
1878 'prev' => array(),
1879 );
1880 }
1881 foreach ($rowArray as $key => $value) {
1882 // Create the list of the next three ids (for editing links...)
1883 for ($i = 0; $i < $this->nextThree; $i++) {
1884 if (isset($rowArray[$key - $i])
1885 && !GeneralUtility::inList($this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
1886 ) {
1887 $this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
1888 }
1889 }
1890
1891 // Create information for next and previous content elements
1892 if (isset($rowArray[$key - 1])) {
1893 if (isset($rowArray[$key - 2])) {
1894 $this->tt_contentData['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
1895 } else {
1896 $this->tt_contentData['prev'][$value['uid']] = $value['pid'];
1897 }
1898 $this->tt_contentData['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
1899 }
1900 }
1901 }
1902
1903 /**
1904 * Counts and returns the number of records on the page with $pid
1905 *
1906 * @param string $table Table name
1907 * @param int $pid Page id
1908 * @return int Number of records.
1909 */
1910 public function numberOfRecords($table, $pid) {
1911 $count = 0;
1912 if ($GLOBALS['TCA'][$table]) {
1913 $where = 'pid=' . (int)$pid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table);
1914 $count = $this->getDatabase()->exec_SELECTcountRows('uid', $table, $where);
1915 }
1916 return (int)$count;
1917 }
1918
1919 /**
1920 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
1921 *
1922 * @param string $input Input string
1923 * @return string Output string
1924 */
1925 public function renderText($input) {
1926 $input = strip_tags($input);
1927 $input = GeneralUtility::fixed_lgd_cs($input, 1500);
1928 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8', FALSE));
1929 }
1930
1931 /**
1932 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
1933 *
1934 * @param string $table Table name
1935 * @param array $row Record array
1936 * @return string HTML for the icon
1937 */
1938 public function getIcon($table, $row) {
1939 // Initialization
1940 $altText = BackendUtility::getRecordIconAltText($row, $table);
1941 $icon = IconUtility::getSpriteIconForRecord($table, $row, array('title' => $altText));
1942 $this->counter++;
1943 // The icon with link
1944 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
1945 $icon = $this->getPageLayoutController()->doc->wrapClickMenuOnIcon($icon, $table, $row['uid']);
1946 }
1947 return $icon;
1948 }
1949
1950 /**
1951 * Creates processed values for all field names in $fieldList based on values from $row array.
1952 * The result is 'returned' through $info which is passed as a reference
1953 *
1954 * @param string $table Table name
1955 * @param string $fieldList Comma separated list of fields.
1956 * @param array $row Record from which to take values for processing.
1957 * @param array $info Array to which the processed values are added.
1958 * @return void
1959 */
1960 public function getProcessedValue($table, $fieldList, array $row, array &$info) {
1961 // Splitting values from $fieldList
1962 $fieldArr = explode(',', $fieldList);
1963 // Traverse fields from $fieldList
1964 foreach ($fieldArr as $field) {
1965 if ($row[$field]) {
1966 $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> '
1967 . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field]));
1968 }
1969 }
1970 }
1971
1972 /**
1973 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
1974 *
1975 * @param string $table Tablename of table to test
1976 * @param array $row Record row.
1977 * @return bool Returns TRUE, if disabled.
1978 */
1979 public function isDisabled($table, $row) {
1980 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
1981 return $enableCols['disabled'] && $row[$enableCols['disabled']]
1982 || $enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
1983 || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
1984 }
1985
1986 /**
1987 * Returns icon for "no-edit" of a record.
1988 * Basically, the point is to signal that this record could have had an edit link if
1989 * the circumstances were right. A placeholder for the regular edit icon...
1990 *
1991 * @param string $label Label key from LOCAL_LANG
1992 * @return string IMG tag for icon.
1993 */
1994 public function noEditIcon($label = 'noEditItems') {
1995 return IconUtility::getSpriteIcon(
1996 'status-edit-read-only',
1997 array('title' => $this->getLanguageService()->getLL($label, TRUE))
1998 );
1999 }
2000
2001 /**
2002 * Function, which fills in the internal array, $this->allowedTableNames with all tables to
2003 * which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...)
2004 * are filtered out. So what is left is basically all tables which makes sense to list content from.
2005 *
2006 * @return array
2007 */
2008 protected function cleanTableNames() {
2009 // Get all table names:
2010 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
2011 // Unset common names:
2012 unset($tableNames['pages']);
2013 unset($tableNames['static_template']);
2014 unset($tableNames['sys_filemounts']);
2015 unset($tableNames['sys_action']);
2016 unset($tableNames['sys_workflows']);
2017 unset($tableNames['be_users']);
2018 unset($tableNames['be_groups']);
2019 $allowedTableNames = array();
2020 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2021 if (is_array($tableNames)) {
2022 foreach ($tableNames as $k => $v) {
2023 if ($this->getBackendUser()->check('tables_select', $k)) {
2024 $allowedTableNames['table_' . $k] = $k;
2025 }
2026 }
2027 }
2028 return $allowedTableNames;
2029 }
2030
2031 /**
2032 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns TRUE.
2033 * Used to determine if the RTE button should be displayed.
2034 *
2035 * @param string $table Table name
2036 * @param array $row Record row (needed, if there are RTE dependencies based on other fields in the record)
2037 * @param string $field Field name
2038 * @return bool Returns TRUE if the rich text editor would be enabled/available for the field name specified.
2039 */
2040 public function isRTEforField($table, $row, $field) {
2041 $specConf = $this->getSpecConfForField($table, $row, $field);
2042 if (empty($specConf)) {
2043 return FALSE;
2044 }
2045 $p = BackendUtility::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
2046 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
2047 BackendUtility::fixVersioningPid($table, $row);
2048 list($tscPID, $thePidValue) = BackendUtility::getTSCpid($table, $row['uid'], $row['pid']);
2049 // If the pid-value is not negative (that is, a pid could NOT be fetched)
2050 if ($thePidValue >= 0) {
2051 if (!isset($this->rteSetup[$tscPID])) {
2052 $this->rteSetup[$tscPID] = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
2053 }
2054 $RTEtypeVal = BackendUtility::getTCAtypeValue($table, $row);
2055 $thisConfig = BackendUtility::RTEsetup($this->rteSetup[$tscPID]['properties'], $table, $field, $RTEtypeVal);
2056 if (!$thisConfig['disabled']) {
2057 return TRUE;
2058 }
2059 }
2060 }
2061 return FALSE;
2062 }
2063
2064 /**
2065 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname.
2066 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not.
2067 *
2068 * @param string $table Table name
2069 * @param array $row Record array
2070 * @param string $field Field name
2071 * @return array Spec. conf (if available)
2072 * @access private
2073 * @see isRTEforField()
2074 */
2075 public function getSpecConfForField($table, $row, $field) {
2076 // Get types-configuration for the record:
2077 $types_fieldConfig = BackendUtility::getTCAtypes($table, $row);
2078 // Find the given field and return the spec key value if found:
2079 if (is_array($types_fieldConfig)) {
2080 foreach ($types_fieldConfig as $vConf) {
2081 if ($vConf['field'] == $field) {
2082 return $vConf['spec'];
2083 }
2084 }
2085 }
2086 return array();
2087 }
2088
2089 /*****************************************
2090 *
2091 * External renderings
2092 *
2093 *****************************************/
2094
2095 /**
2096 * Creates a menu of the tables that can be listed by this function
2097 * Only tables which has records on the page will be included.
2098 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2099 *
2100 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2101 * @return string HTML output.
2102 */
2103 public function getTableMenu($id) {
2104 // Initialize:
2105 $this->activeTables = array();
2106 $theTables = array('tt_content');
2107 // External tables:
2108 if (is_array($this->externalTables)) {
2109 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2110 }
2111 $out = '';
2112 // Traverse tables to check:
2113 foreach ($theTables as $tName) {
2114 // Check access and whether the proper extensions are loaded:
2115 if ($this->getBackendUser()->check('tables_select', $tName)
2116 && (isset($this->externalTables[$tName])
2117 || GeneralUtility::inList('fe_users,tt_content', $tName)
2118 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName)
2119 )
2120 ) {
2121 // Make query to count records from page:
2122 $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int)$id
2123 . BackendUtility::deleteClause($tName) . BackendUtility::versioningPlaceholderClause($tName));
2124 // If records were found (or if "tt_content" is the table...):
2125 if ($c || GeneralUtility::inList('tt_content', $tName)) {
2126 // Add row to menu:
2127 $out .= '
2128 <td><a href="#' . $tName . '"></a>' . IconUtility::getSpriteIconForRecord(
2129 $tName,
2130 array(),
2131 array('title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE))
2132 ) . '</td>';
2133 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2134 $this->activeTables[$tName] = IconUtility::getSpriteIconForRecord(
2135 $tName,
2136 array(),
2137 array('title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE)
2138 . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', TRUE))
2139 ) . '&nbsp;' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE);
2140 }
2141 }
2142 }
2143 // Wrap cells in table tags:
2144 $out = '
2145 <!--
2146 Menu of tables on the page (table menu)
2147 -->
2148 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2149 <tr>' . $out . '
2150 </tr>
2151 </table>';
2152 // Return the content:
2153 return $out;
2154 }
2155
2156 /**
2157 * Create thumbnail code for record/field but not linked
2158 *
2159 * @param mixed[] $row Record array
2160 * @param string $table Table (record is from)
2161 * @param string $field Field name for which thumbnail are to be rendered.
2162 * @return string HTML for thumbnails, if any.
2163 */
2164 public function getThumbCodeUnlinked($row, $table, $field) {
2165 return BackendUtility::thumbCode($row, $table, $field, $this->backPath, '', NULL, 0, '', '', FALSE);
2166 }
2167
2168 /**
2169 * @return BackendLayoutView
2170 */
2171 protected function getBackendLayoutView() {
2172 return GeneralUtility::makeInstance(BackendLayoutView::class);
2173 }
2174
2175 /**
2176 * @return BackendUserAuthentication
2177 */
2178 protected function getBackendUser() {
2179 return $GLOBALS['BE_USER'];
2180 }
2181
2182 /**
2183 * @return DatabaseConnection
2184 */
2185 protected function getDatabase() {
2186 return $GLOBALS['TYPO3_DB'];
2187 }
2188
2189 /**
2190 * @return PageLayoutController
2191 */
2192 protected function getPageLayoutController() {
2193 return $GLOBALS['SOBE'];
2194 }
2195
2196 }