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