2 namespace TYPO3\CMS\Backend\View
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use Doctrine\DBAL\Driver\Statement
;
18 use TYPO3\CMS\Backend\Controller\Page\LocalizationController
;
19 use TYPO3\CMS\Backend\Controller\PageLayoutController
;
20 use TYPO3\CMS\Backend\Utility\BackendUtility
;
21 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
22 use TYPO3\CMS\Core\Database\Connection
;
23 use TYPO3\CMS\Core\Database\ConnectionPool
;
24 use TYPO3\CMS\Core\Database\Query\QueryHelper
;
25 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction
;
26 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
;
27 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction
;
28 use TYPO3\CMS\Core\Imaging\Icon
;
29 use TYPO3\CMS\Core\Imaging\IconFactory
;
30 use TYPO3\CMS\Core\Messaging\FlashMessage
;
31 use TYPO3\CMS\Core\Messaging\FlashMessageService
;
32 use TYPO3\CMS\Core\Page\PageRenderer
;
33 use TYPO3\CMS\Core\Type\Bitmask\Permission
;
34 use TYPO3\CMS\Core\Utility\GeneralUtility
;
35 use TYPO3\CMS\Core\Utility\StringUtility
;
36 use TYPO3\CMS\Core\Versioning\VersionState
;
37 use TYPO3\CMS\Extbase\Service\FlexFormService
;
38 use TYPO3\CMS\Fluid\View\StandaloneView
;
41 * Child class for the Web > Page module
43 class PageLayoutView
extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList
46 * If TRUE, users/groups are shown in the page info box.
50 public $pI_showUser = 0;
53 * The number of successive records to edit when showing content elements.
57 public $nextThree = 3;
60 * If TRUE, disables the edit-column icon for tt_content elements
64 public $pages_noEditColumns = 0;
67 * If TRUE, new-wizards are linked to rather than the regular new-element list.
71 public $option_newWizard = 1;
74 * If set to "1", will link a big button to content element wizard.
78 public $ext_function = 0;
81 * If TRUE, elements will have edit icons (probably this is whether the user has permission to edit the page content). Set externally.
88 * Age prefixes for displaying times. May be set externally to localized values.
92 public $agePrefixes = ' min| hrs| days| yrs| min| hour| day| year';
95 * Array of tables to be listed by the Web > Page module in addition to the default tables.
99 public $externalTables = [];
102 * "Pseudo" Description -table name
109 * If set TRUE, the language mode of tt_content elements will be rendered with hard binding between
110 * default language content elements and their translations!
114 public $defLangBinding = false;
117 * External, static: Configuration of tt_content element display:
121 public $tt_contentConfig = [
122 // Boolean: Display info-marks or not
124 // Boolean: Display up/down arrows and edit icons for tt_content records
128 'languageColsPointer' => 0,
130 // Displays hidden records as well
131 'sys_language_uid' => 0,
134 'activeCols' => '1,0,2,3'
135 // Which columns can be accessed by current BE user
139 * Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
143 public $activeTables = [];
148 public $tt_contentData = [
155 * Used to store labels for CTypes for tt_content elements
159 public $CType_labels = [];
162 * Used to store labels for the various fields in tt_content elements
166 public $itemLabels = [];
169 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
171 protected $clipboard;
176 protected $plusPages = [];
183 public $ext_CALC_PERMS;
186 * Current ids page record
193 * Caches the available languages in a colPos
197 protected $languagesInColumnCache = [];
200 * Caches the amount of content elements as a matrix
205 protected $contentElementCache = [];
210 protected $iconFactory;
213 * Stores whether a certain language has translations in it
217 protected $languageHasTranslationsCache = [];
220 * @var LocalizationController
222 protected $localizationController;
225 * Construct to initialize class variables.
227 public function __construct()
229 parent
::__construct();
230 $this->localizationController
= GeneralUtility
::makeInstance(LocalizationController
::class);
231 $this->iconFactory
= GeneralUtility
::makeInstance(IconFactory
::class);
232 $pageRenderer = GeneralUtility
::makeInstance(PageRenderer
::class);
233 $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
234 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
235 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Localization');
238 /*****************************************
242 *****************************************/
244 * Adds the code of a single table
246 * @param string $table Table name
247 * @param int $id Current page id
248 * @param string $fields
249 * @return string HTML for listing.
251 public function getTable($table, $id, $fields = '')
253 if (isset($this->externalTables
[$table])) {
254 return $this->getExternalTables($id, $table);
256 // Branch out based on table name:
259 return $this->getTable_pages($id);
262 return $this->getTable_tt_content($id);
271 * Renders an external table from page id
273 * @param int $id Page id
274 * @param string $table Name of the table
275 * @return string HTML for the listing
277 public function getExternalTables($id, $table)
279 $this->pageinfo
= BackendUtility
::readPageAccess($id, '');
280 $type = $this->getPageLayoutController()->MOD_SETTINGS
[$table];
284 // eg. "name;title;email;company,image"
285 $fList = $this->externalTables
[$table][$type]['fList'];
286 // The columns are separeted by comma ','.
287 // Values separated by semicolon ';' are shown in the same column.
288 $icon = $this->externalTables
[$table][$type]['icon'];
289 $addWhere = $this->externalTables
[$table][$type]['addWhere'];
291 $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
296 * Renders records from the pages table from page id
297 * (Used to get information about the page tree content by "Web>Info"!)
299 * @param int $id Page id
300 * @return string HTML for the listing
302 public function getTable_pages($id)
306 $lang = $this->getLanguageService();
307 // Select current page:
309 // The root has a pseudo record in pageinfo...
310 $row = $this->getPageLayoutController()->pageinfo
;
312 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
313 ->getQueryBuilderForTable('pages');
314 $queryBuilder->getRestrictions()
316 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class));
321 $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, \PDO
::PARAM_INT
)),
322 $this->getBackendUser()->getPagePermsClause(1)
326 BackendUtility
::workspaceOL('pages', $row);
328 // If there was found a page:
329 if (is_array($row)) {
330 // Getting select-depth:
331 $depth = (int)$this->getPageLayoutController()->MOD_SETTINGS
['pages_levels'];
332 // Overriding a few things:
333 $this->no_noWrap
= 0;
335 $this->eCounter
= $this->firstElementNumber
;
336 // Creating elements:
337 list($flag, $code) = $this->fwd_rwd_nav();
342 $theRows = $this->getPageRecordsRecursive($row['uid'], $depth);
343 if ($this->getBackendUser()->doesUserHaveAccess($row, 2) && $row['uid'] > 0) {
344 $editUids[] = $row['uid'];
346 $out .= $this->pages_drawItem($row, $this->fieldArray
);
347 // Traverse all pages selected:
348 foreach ($theRows as $sRow) {
349 if ($this->getBackendUser()->doesUserHaveAccess($sRow, 2)) {
350 $editUids[] = $sRow['uid'];
352 $out .= $this->pages_drawItem($sRow, $this->fieldArray
);
356 // Header line is drawn
358 $editIdList = implode(',', $editUids);
359 // Traverse fields (as set above) in order to create header values:
360 foreach ($this->fieldArray
as $field) {
362 && isset($GLOBALS['TCA']['pages']['columns'][$field])
364 && !$this->pages_noEditColumns
367 $lang->getLL('editThisColumn'),
368 rtrim(trim($lang->sL(BackendUtility
::getItemLabel('pages', $field))), ':')
373 $editIdList => 'edit'
376 'columnsOnly' => $field,
377 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
379 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
380 $eI = '<a class="btn btn-default" href="' . htmlspecialchars($url)
381 . '" title="' . htmlspecialchars($iTitle) . '">'
382 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
388 $theData[$field] = ' ' . $eI . '<strong>'
389 . $lang->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'])
393 $theData[$field] = ' <strong>ID:</strong>';
396 if (substr($field, 0, 6) === 'table_') {
397 $f2 = substr($field, 6);
398 if ($GLOBALS['TCA'][$f2]) {
399 $theData[$field] = ' ' .
401 htmlspecialchars($lang->sL($GLOBALS['TCA'][$f2]['ctrl']['title'])) .
403 $this->iconFactory
->getIconForRecord($f2, [], Icon
::SIZE_SMALL
)->render() .
407 $theData[$field] = ' ' . $eI . '<strong>'
408 . htmlspecialchars($lang->sL($GLOBALS['TCA']['pages']['columns'][$field]['label']))
414 $optionKey = $this->getPageLayoutController()->MOD_SETTINGS
['pages'];
415 $out = BackendUtility
::cshItem($this->descrTable
, ('func_' . $optionKey), null, '<span class="btn btn-default btn-sm">|</span>') . '
416 <div class="table-fit">
417 <table class="table table-striped table-hover typo3-page-pages">' .
419 $this->addElement(1, '', $theData) .
431 * Renders Content Elements from the tt_content table from page id
433 * @param int $id Page id
434 * @return string HTML for the listing
436 public function getTable_tt_content($id)
438 $backendUser = $this->getBackendUser();
439 $expressionBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
440 ->getConnectionForTable('tt_content')
441 ->getExpressionBuilder();
442 $this->pageinfo
= BackendUtility
::readPageAccess($this->id
, '');
443 $this->initializeLanguages();
444 $this->initializeClipboard();
445 $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility
::getRecordTitle('pages', BackendUtility
::getRecordWSOL('pages', $id), true));
446 /** @var $pageRenderer PageRenderer */
447 $pageRenderer = GeneralUtility
::makeInstance(PageRenderer
::class);
448 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
449 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
450 $userCanEditPage = $this->ext_CALC_PERMS
& Permission
::PAGE_EDIT
&& !empty($this->id
) && ($backendUser->isAdmin() ||
(int)$this->pageinfo
['editlock'] === 0);
451 if ($this->tt_contentConfig
['languageColsPointer'] > 0) {
452 $userCanEditPage = $this->getBackendUser()->check('tables_modify', 'pages_language_overlay');
454 if ($userCanEditPage) {
455 $languageOverlayId = 0;
456 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
457 ->getConnectionForTable('pages_language_overlay')
458 ->createQueryBuilder();
459 $constraint = $queryBuilder->expr()->eq(
461 $queryBuilder->createNamedParameter($this->tt_contentConfig
['sys_language_uid'], \PDO
::PARAM_INT
)
463 $pageOverlayRecord = BackendUtility
::getRecordsByField(
464 'pages_language_overlay',
474 if (!empty($pageOverlayRecord[0]['uid'])) {
475 $languageOverlayId = $pageOverlayRecord[0]['uid'];
477 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) {
478 PageActions.setPageId(' . (int)$this->id
. ');
479 PageActions.setLanguageOverlayId(' . $languageOverlayId . ');
480 PageActions.initializePageTitleRenaming();
483 // Get labels for CTypes and tt_content element fields in general:
484 $this->CType_labels
= [];
485 foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
486 $this->CType_labels
[$val[1]] = $this->getLanguageService()->sL($val[0]);
488 $this->itemLabels
= [];
489 foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
490 $this->itemLabels
[$name] = $this->getLanguageService()->sL($val['label']);
492 $languageColumn = [];
495 // Setting language list:
496 $langList = $this->tt_contentConfig
['sys_language_uid'];
497 if ($this->tt_contentConfig
['languageMode']) {
498 if ($this->tt_contentConfig
['languageColsPointer']) {
499 $langList = '0,' . $this->tt_contentConfig
['languageColsPointer'];
501 $langList = implode(',', array_keys($this->tt_contentConfig
['languageCols']));
503 $languageColumn = [];
505 $langListArr = GeneralUtility
::intExplode(',', $langList);
506 $defaultLanguageElementsByColumn = [];
507 $defLangBinding = [];
508 // For each languages... :
509 // If not languageMode, then we'll only be through this once.
510 foreach ($langListArr as $lP) {
513 if (!isset($this->contentElementCache
[$lP])) {
514 $this->contentElementCache
[$lP] = [];
517 if (count($langListArr) === 1 ||
$lP === 0) {
518 $showLanguage = $expressionBuilder->in('sys_language_uid', [$lP, -1]);
520 $showLanguage = $expressionBuilder->eq('sys_language_uid', $lP);
522 $cList = explode(',', $this->tt_contentConfig
['cols']);
526 // Select content records per column
527 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showLanguage);
528 // For each column, render the content into a variable:
529 foreach ($cList as $columnId) {
530 if (!isset($this->contentElementCache
[$lP][$columnId])) {
531 $this->contentElementCache
[$lP][$columnId] = [];
535 $defaultLanguageElementsByColumn[$columnId] = [];
537 // Start wrapping div
538 $content[$columnId] .= '<div data-colpos="' . $columnId . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
539 if (empty($contentRecordsPerColumn[$columnId])) {
540 $content[$columnId] .= ' t3-page-ce-empty';
542 $content[$columnId] .= '">';
543 // Add new content at the top most position
545 if ($this->getPageLayoutController()->contentIsNotLockedForEditors()
546 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
548 if ($this->option_newWizard
) {
551 'sys_language_uid' => $lP,
552 'colPos' => $columnId,
554 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
556 $tsConfig = BackendUtility
::getModTSconfig($id, 'mod');
557 $moduleName = isset($tsConfig['properties']['newContentElementWizard.']['override'])
558 ?
$tsConfig['properties']['newContentElementWizard.']['override']
559 : 'new_content_element';
560 $url = BackendUtility
::getModuleUrl($moduleName, $urlParameters);
570 'colPos' => $columnId,
571 'sys_language_uid' => $lP
574 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
576 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
579 $link = '<a href="' . htmlspecialchars($url) . '" title="'
580 . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '" class="btn btn-default btn-sm">'
581 . $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
)->render()
583 . htmlspecialchars($this->getLanguageService()->getLL('content')) . '</a>';
585 if ($this->getBackendUser()->checkLanguageAccess($lP)) {
586 $content[$columnId] .= '
587 <div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . StringUtility
::getUniqueId() . '">
588 <div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $columnId . '-' . 'page-' . $id . '-' . StringUtility
::getUniqueId() . '">'
591 <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
596 if (!isset($contentRecordsPerColumn[$columnId]) ||
!is_array($contentRecordsPerColumn[$columnId])) {
597 $message = GeneralUtility
::makeInstance(
599 $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:error.invalidBackendLayout'),
601 FlashMessage
::WARNING
603 $service = GeneralUtility
::makeInstance(FlashMessageService
::class);
604 $queue = $service->getMessageQueueByIdentifier();
605 $queue->addMessage($message);
607 $rowArr = $contentRecordsPerColumn[$columnId];
608 $this->generateTtContentDataArray($rowArr);
610 foreach ((array)$rowArr as $rKey => $row) {
611 $this->contentElementCache
[$lP][$columnId][$row['uid']] = $row;
612 if ($this->tt_contentConfig
['languageMode']) {
613 $languageColumn[$columnId][$lP] = $head[$columnId] . $content[$columnId];
614 if (!$this->defLangBinding
) {
615 $languageColumn[$columnId][$lP] .= $this->newLanguageButton(
616 $this->getNonTranslatedTTcontentUids($defaultLanguageElementsByColumn[$columnId], $id, $lP),
622 if (is_array($row) && !VersionState
::cast($row['t3ver_state'])->equals(VersionState
::DELETE_PLACEHOLDER
)) {
623 $singleElementHTML = '';
624 if (!$lP && ($this->defLangBinding ||
$row['sys_language_uid'] != -1)) {
625 $defaultLanguageElementsByColumn[$columnId][] = (isset($row['_ORIG_uid']) ?
$row['_ORIG_uid'] : $row['uid']);
627 $editUidList .= $row['uid'] . ',';
628 $disableMoveAndNewButtons = $this->defLangBinding
&& $lP > 0;
629 if (!$this->tt_contentConfig
['languageMode']) {
630 $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . StringUtility
::getUniqueId() . '">';
632 $singleElementHTML .= $this->tt_content_drawHeader(
634 $this->tt_contentConfig
['showInfo'] ?
15 : 5,
635 $disableMoveAndNewButtons,
637 $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)
639 $innerContent = '<div ' . ($row['_ORIG_uid'] ?
' class="ver-element"' : '') . '>'
640 . $this->tt_content_drawItem($row) . '</div>';
641 $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div>'
642 . $this->tt_content_drawFooter($row);
643 $isDisabled = $this->isDisabled('tt_content', $row);
644 $statusHidden = $isDisabled ?
' t3-page-ce-hidden t3js-hidden-record' : '';
645 $displayNone = !$this->tt_contentConfig
['showHidden'] && $isDisabled ?
' style="display: none;"' : '';
646 $highlightHeader = false;
647 if ($this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid']) && (int)$row['l18n_parent'] === 0) {
648 $highlightHeader = true;
650 $singleElementHTML = '<div class="t3-page-ce ' . ($highlightHeader ?
't3-page-ce-danger' : '') . ' t3js-page-ce t3js-page-ce-sortable ' . $statusHidden . '" id="element-tt_content-'
651 . $row['uid'] . '" data-table="tt_content" data-uid="' . $row['uid'] . '"' . $displayNone . '>' . $singleElementHTML . '</div>';
653 if ($this->tt_contentConfig
['languageMode']) {
654 $singleElementHTML .= '<div class="t3-page-ce t3js-page-ce">';
656 $singleElementHTML .= '<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $columnId . '-' . 'page-' . $id .
657 '-' . StringUtility
::getUniqueId() . '">';
658 // Add icon "new content element below"
659 if (!$disableMoveAndNewButtons
660 && $this->getPageLayoutController()->contentIsNotLockedForEditors()
661 && $this->getBackendUser()->checkLanguageAccess($lP)
662 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
664 // New content element:
665 if ($this->option_newWizard
) {
668 'sys_language_uid' => $row['sys_language_uid'],
669 'colPos' => $row['colPos'],
670 'uid_pid' => -$row['uid'],
671 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
673 $tsConfig = BackendUtility
::getModTSconfig($row['pid'], 'mod');
674 $moduleName = isset($tsConfig['properties']['newContentElementWizard.']['override'])
675 ?
$tsConfig['properties']['newContentElementWizard.']['override']
676 : 'new_content_element';
677 $url = BackendUtility
::getModuleUrl($moduleName, $urlParameters);
682 -$row['uid'] => 'new'
685 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
687 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
689 $singleElementHTML .= '
690 <a href="' . htmlspecialchars($url) . '" title="'
691 . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '" class="btn btn-default btn-sm">'
692 . $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
)->render()
694 . htmlspecialchars($this->getLanguageService()->getLL('content')) . '</a>
697 $singleElementHTML .= '</div></div><div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div></div>';
698 if ($this->defLangBinding
&& $this->tt_contentConfig
['languageMode']) {
699 $defLangBinding[$columnId][$lP][$row[$lP ?
'l18n_parent' : 'uid']] = $singleElementHTML;
701 $content[$columnId] .= $singleElementHTML;
704 unset($rowArr[$rKey]);
707 $content[$columnId] .= '</div>';
708 $colTitle = BackendUtility
::getProcessedValue('tt_content', 'colPos', $columnId);
709 $tcaItems = GeneralUtility
::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView
::class . '->getColPosListItemsParsed', $id, $this);
710 foreach ($tcaItems as $item) {
711 if ($item[1] == $columnId) {
712 $colTitle = $this->getLanguageService()->sL($item[0]);
716 $pasteP = ['colPos' => $columnId, 'sys_language_uid' => $lP];
717 $editParam = $this->doEdit
&& !empty($rowArr)
718 ?
'&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
720 $head[$columnId] .= $this->tt_content_drawColHeader($colTitle, $editParam, '', $pasteP);
723 // For each column, fit the rendered content into a table cell:
725 if ($this->tt_contentConfig
['languageMode']) {
726 // in language mode process the content elements, but only fill $languageColumn. output will be generated later
727 $sortedLanguageColumn = [];
728 foreach ($cList as $columnId) {
729 $languageColumn[$columnId][$lP] = $head[$columnId] . $content[$columnId];
730 if (!$this->defLangBinding
) {
731 $languageColumn[$columnId][$lP] .= $this->newLanguageButton(
732 $this->getNonTranslatedTTcontentUids($defaultLanguageElementsByColumn[$columnId], $id, $lP),
737 // We sort $languageColumn again according to $cList as it may contain data already from above.
738 $sortedLanguageColumn[$columnId] = $languageColumn[$columnId];
740 $languageColumn = $sortedLanguageColumn;
742 $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id
);
744 $grid = '<div class="t3-grid-container"><table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table t3js-page-columns">';
746 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
747 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
748 $grid .= '<colgroup>';
749 for ($i = 0; $i < $colCount; $i++
) {
752 $grid .= '</colgroup>';
753 // Cycle through rows
754 for ($row = 1; $row <= $rowCount; $row++
) {
755 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
756 if (!isset($rowConfig)) {
760 for ($col = 1; $col <= $colCount; $col++
) {
761 $columnConfig = $rowConfig['columns.'][$col . '.'];
762 if (!isset($columnConfig)) {
765 // Which tt_content colPos should be displayed inside this cell
766 $columnKey = (int)$columnConfig['colPos'];
767 // Render the grid cell
768 $colSpan = (int)$columnConfig['colspan'];
769 $rowSpan = (int)$columnConfig['rowspan'];
770 $grid .= '<td valign="top"' .
771 ($colSpan > 0 ?
' colspan="' . $colSpan . '"' : '') .
772 ($rowSpan > 0 ?
' rowspan="' . $rowSpan . '"' : '') .
773 ' 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 .
774 ((!isset($columnConfig['colPos']) ||
$columnConfig['colPos'] === '') ?
' t3-grid-cell-unassigned' : '') .
775 ((isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !$head[$columnKey]) ||
!GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos']) ?
' t3-grid-cell-restricted' : '') .
776 ($colSpan > 0 ?
' t3-gridCell-width' . $colSpan : '') .
777 ($rowSpan > 0 ?
' t3-gridCell-height' . $rowSpan : '') . '">';
779 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
780 // If not, a new header without any buttons will be generated.
781 if (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey]
782 && GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
784 $grid .= $head[$columnKey] . $content[$columnKey];
785 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
786 && GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
788 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'), '', '');
789 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
790 && !GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
792 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
793 ' (' . $this->getLanguageService()->getLL('noAccess') . ')', '', '');
794 } elseif (isset($columnConfig['name']) && $columnConfig['name'] !== '') {
795 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
796 . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '');
798 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'), '', '');
805 $out .= $grid . '</table></div>';
808 $out .= BackendUtility
::cshItem($this->descrTable
, 'columns_multi', null, '<span class="btn btn-default btn-sm">|</span>');
810 // If language mode, then make another presentation:
811 // Notice that THIS presentation will override the value of $out!
812 // But it needs the code above to execute since $languageColumn is filled with content we need!
813 if ($this->tt_contentConfig
['languageMode']) {
814 // Get language selector:
815 $languageSelector = $this->languageSelector($id);
816 // Reset out - we will make new content here:
818 // Traverse languages found on the page and build up the table displaying them side by side:
821 foreach ($langListArr as $lP) {
825 <td valign="top" class="t3-page-column" data-language-uid="' . $lP . '">
826 <h2>' . htmlspecialchars($this->tt_contentConfig
['languageCols'][$lP]) . '</h2>
829 // "View page" icon is added:
831 if (!VersionState
::cast($this->getPageLayoutController()->pageinfo
['t3ver_state'])->equals(VersionState
::DELETE_PLACEHOLDER
)) {
832 $onClick = BackendUtility
::viewOnClick($this->id
, '', BackendUtility
::BEgetRootLine($this->id
), '', '', ('&L=' . $lP));
833 $viewLink = '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">' . $this->iconFactory
->getIcon('actions-view', Icon
::SIZE_SMALL
)->render() . '</a>';
835 // Language overlay page header:
837 list($lpRecord) = BackendUtility
::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . $lP);
838 BackendUtility
::workspaceOL('pages_language_overlay', $lpRecord);
839 $recordIcon = BackendUtility
::wrapClickMenuOnIcon(
840 $this->iconFactory
->getIconForRecord('pages_language_overlay', $lpRecord, Icon
::SIZE_SMALL
)->render(),
841 'pages_language_overlay',
846 'pages_language_overlay' => [
847 $lpRecord['uid'] => 'edit'
851 'pages_language_overlay' => [
852 'sys_language_uid' => $lP
855 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
857 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
858 $editLink = ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
859 ?
'<a href="' . htmlspecialchars($url) . '" class="btn btn-default btn-sm"'
860 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
861 . $this->iconFactory
->getIcon('actions-open', Icon
::SIZE_SMALL
)->render() . '</a>'
866 '<div class="btn-group">'
870 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($lpRecord['title'], 20));
874 if ($this->getBackendUser()->checkLanguageAccess(0)) {
875 $recordIcon = BackendUtility
::wrapClickMenuOnIcon(
876 $this->iconFactory
->getIconForRecord('pages', $this->pageRecord
, Icon
::SIZE_SMALL
)->render(), 'pages', $this->id
);
883 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
885 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
886 $editLink = ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
887 ?
'<a href="' . htmlspecialchars($url) . '" class="btn btn-default btn-sm"'
888 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
889 . $this->iconFactory
->getIcon('actions-open', Icon
::SIZE_SMALL
)->render() . '</a>'
895 '<div class="btn-group">'
899 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($this->pageRecord
['title'], 20));
902 <td nowrap="nowrap" class="t3-page-column t3-page-lang-label">' . $lPLabel . '</td>';
905 $out .= '<tr>' . implode($cCont) . '</tr>';
906 $out .= '<tr>' . implode($sCont) . '</tr>';
907 unset($cCont, $sCont);
909 // Traverse previously built content for the columns:
910 foreach ($languageColumn as $cKey => $cCont) {
912 foreach ($cCont as $languageId => $columnContent) {
913 $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>';
916 if ($this->defLangBinding
) {
917 // "defLangBinding" mode
918 foreach ($defaultLanguageElementsByColumn[$cKey] as $defUid) {
920 foreach ($langListArr as $lP) {
921 $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton(
922 $this->getNonTranslatedTTcontentUids([$defUid], $id, $lP),
929 <td valign="top" class="t3-grid-cell">' . implode(('</td>' . '
930 <td valign="top" class="t3-grid-cell">'), $cCont) . '</td>
935 // Finally, wrap it all in a table and add the language selector on top of it:
936 $out = $languageSelector . '
937 <div class="t3-grid-container">
938 <table cellpadding="0" cellspacing="0" class="t3-page-columns t3-grid-table t3js-page-columns">
943 $out .= BackendUtility
::cshItem($this->descrTable
, 'language_list', null, '<span class="btn btn-default btn-sm">|</span>');
949 /**********************************
951 * Generic listing of items
953 **********************************/
955 * Creates a standard list of elements from a table.
957 * @param string $table Table name
958 * @param int $id Page id.
959 * @param string $fList Comma list of fields to display
960 * @param bool $icon If TRUE, icon is shown
961 * @param string $addWhere Additional WHERE-clauses.
962 * @return string HTML table
964 public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = '')
967 $addWhere = empty($addWhere) ?
[] : [QueryHelper
::stripLogicalOperatorPrefix($addWhere)];
968 $queryBuilder = $this->getQueryBuilder($table, $id, $addWhere);
969 $this->setTotalItems($table, $id, $addWhere);
972 // Make query for records if there were any records found in the count operation
973 if ($this->totalItems
) {
974 $result = $queryBuilder->execute();
975 // Will return FALSE, if $result is invalid
976 $dbCount = $result->rowCount();
978 // If records were found, render the list
984 $this->fieldArray
= GeneralUtility
::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', true);
986 $theData = $this->headerFields($this->fieldArray
, $table, $theData);
988 $localizedTableTitle = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
989 $out .= '<tr><th class="col-icon"></th>'
990 . '<th colspan="' . (count($theData) - 2) . '"><span class="c-table">'
991 . $localizedTableTitle . '</span> (' . $dbCount . ')</td>' . '<td class="col-icon"></td>'
1001 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1003 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
1004 $theData['__cmds__'] = '<a href="' . htmlspecialchars($url) . '" '
1005 . 'title="' . htmlspecialchars($this->getLanguageService()->getLL('new')) . '">'
1006 . $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
)->render() . '</a>';
1008 $out .= $this->addElement(1, '', $theData, ' class="c-headLine"', 15, '', 'th');
1010 $this->eCounter
= $this->firstElementNumber
;
1011 while ($row = $result->fetch()) {
1012 BackendUtility
::workspaceOL($table, $row);
1013 if (is_array($row)) {
1014 list($flag, $code) = $this->fwd_rwd_nav();
1018 // Setting icons links
1020 $Nrow['__cmds__'] = $this->getIcon($table, $row);
1023 $Nrow = $this->dataFields($this->fieldArray
, $table, $row, $Nrow);
1025 if ($this->doEdit
&& $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)) {
1029 $row['uid'] => 'edit'
1032 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1034 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
1035 $Nrow['__editIconLink__'] = '<a class="btn btn-default" href="' . htmlspecialchars($url)
1036 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
1037 . $this->iconFactory
->getIcon('actions-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1039 $Nrow['__editIconLink__'] = $this->noEditIcon();
1041 $out .= $this->addElement(1, '', $Nrow);
1046 // Wrap it all in a table:
1049 Standard list of table "' . $table . '"
1051 <div class="table-fit"><table class="table table-hover table-striped">
1058 * Adds content to all data fields in $out array
1060 * Each field name in $fieldArr has a special feature which is that the field name can be specified as more field names.
1061 * Eg. "field1,field2;field3".
1062 * Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
1064 * @param array $fieldArr Array of fields to display
1065 * @param string $table Table name
1066 * @param array $row Record array
1067 * @param array $out Array to which the data is added
1068 * @return array $out array returned after processing.
1069 * @see makeOrdinaryList()
1071 public function dataFields($fieldArr, $table, $row, $out = [])
1073 // Check table validity
1074 if (!isset($GLOBALS['TCA'][$table])) {
1078 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
1080 foreach ($fieldArr as $fieldName) {
1081 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
1082 // Each field has its own cell (if configured in TCA)
1083 // If the column is a thumbnail column:
1084 if ($fieldName == $thumbsCol) {
1085 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
1087 // ... otherwise just render the output:
1088 $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility
::fixed_lgd_cs(
1089 BackendUtility
::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
1094 // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
1095 // the field name with ";" and check each value there as a TCA configured field)
1096 $theFields = explode(';', $fieldName);
1097 // Traverse fields, separated by ";" (displayed in a single cell).
1098 foreach ($theFields as $fName2) {
1099 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
1100 $out[$fieldName] .= '<strong>' . htmlspecialchars($this->getLanguageService()->sL(
1101 $GLOBALS['TCA'][$table]['columns'][$fName2]['label']
1102 )) . '</strong>' . ' ' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs(
1103 BackendUtility
::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
1109 // If no value, add a nbsp.
1110 if (!$out[$fieldName]) {
1111 $out[$fieldName] = ' ';
1113 // Wrap in dimmed-span tags if record is "disabled"
1114 if ($this->isDisabled($table, $row)) {
1115 $out[$fieldName] = '<span class="text-muted">' . $out[$fieldName] . '</span>';
1122 * Header fields made for the listing of records
1124 * @param array $fieldArr Field names
1125 * @param string $table The table name
1126 * @param array $out Array to which the headers are added.
1127 * @return array $out returned after addition of the header fields.
1128 * @see makeOrdinaryList()
1130 public function headerFields($fieldArr, $table, $out = [])
1132 foreach ($fieldArr as $fieldName) {
1133 $ll = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']));
1134 $out[$fieldName] = $ll ?
$ll : ' ';
1140 * Gets content records per column.
1141 * This is required for correct workspace overlays.
1143 * @param string $table UNUSED (will always be queried from tt_content)
1144 * @param int $id Page Id to be used (not used at all, but part of the API, see $this->pidSelect)
1145 * @param array $columns colPos values to be considered to be shown
1146 * @param string $additionalWhereClause Additional where clause for database select
1147 * @return array Associative array for each column (colPos)
1149 protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '')
1151 $columns = array_map('intval', $columns);
1152 $contentRecordsPerColumn = array_fill_keys($columns, []);
1154 $expressionBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
1155 ->getQueryBuilderForTable('tt_content')
1158 $queryBuilder = $this->getQueryBuilder(
1162 $expressionBuilder->in('colPos', $columns),
1163 $additionalWhereClause
1167 // Traverse any selected elements and render their display code:
1168 $results = $this->getResult($queryBuilder->execute());
1170 foreach ($results as $record) {
1171 $columnValue = $record['colPos'];
1172 $contentRecordsPerColumn[$columnValue][] = $record;
1175 return $contentRecordsPerColumn;
1178 /**********************************
1180 * Additional functions; Pages
1182 **********************************/
1185 * Adds pages-rows to an array, selecting recursively in the page tree.
1187 * @param int $pid Starting page id to select from
1188 * @param string $iconPrefix Prefix for icon code.
1189 * @param int $depth Depth (decreasing)
1190 * @param array $rows Array which will accumulate page rows
1191 * @return array $rows with added rows.
1193 protected function getPageRecordsRecursive(int $pid, int $depth, string $iconPrefix = '', array $rows = []): array
1196 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)->getQueryBuilderForTable('pages');
1197 $queryBuilder->getRestrictions()
1199 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class))
1200 ->add(GeneralUtility
::makeInstance(BackendWorkspaceRestriction
::class));
1206 $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO
::PARAM_INT
)),
1207 $this->getBackendUser()->getPagePermsClause(1)
1210 if (!empty($GLOBALS['TCA']['pages']['ctrl']['sortby'])) {
1211 $queryBuilder->orderBy($GLOBALS['TCA']['pages']['ctrl']['sortby']);
1215 $result = $queryBuilder->execute();
1216 $rowCount = $result->rowCount();
1218 while ($row = $result->fetch()) {
1219 BackendUtility
::workspaceOL('pages', $row);
1220 if (is_array($row)) {
1222 $row['treeIcons'] = $iconPrefix
1223 . '<span class="treeline-icon treeline-icon-join'
1224 . ($rowCount === $count ?
'bottom' : '')
1228 $spaceOutIcons = '<span class="treeline-icon treeline-icon-'
1229 . ($rowCount === $count ?
'clear' : 'line')
1231 $rows = $this->getPageRecordsRecursive(
1233 $row['php_tree_stop'] ?
0 : $depth,
1234 $iconPrefix . $spaceOutIcons,
1240 $count = (int)$queryBuilder->count('uid')->execute()->fetchColumn(0);
1242 $this->plusPages
[$pid] = $count;
1250 * Adds pages-rows to an array, selecting recursively in the page tree.
1252 * @param array $theRows Array which will accumulate page rows
1253 * @param int $pid Pid to select from
1254 * @param string $qWhere Query-where clause
1255 * @param string $treeIcons Prefixed icon code.
1256 * @param int $depth Depth (decreasing)
1257 * @return array $theRows, but with added rows.
1258 * @deprecated since TYPO3 v8, will be removed in TYPO3 v9
1260 public function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth)
1262 GeneralUtility
::logDeprecatedFunction();
1264 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)->getQueryBuilderForTable('pages');
1265 $queryBuilder->getRestrictions()
1270 ->where($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO
::PARAM_INT
)));
1272 if (!empty($GLOBALS['TCA']['pages']['ctrl']['sortby'])) {
1273 $queryBuilder->orderBy($GLOBALS['TCA']['pages']['ctrl']['sortby']);
1276 if (!empty($qWhere)) {
1277 $queryBuilder->andWhere(QueryHelper
::stripLogicalOperatorPrefix($qWhere));
1281 $result = $queryBuilder->execute();
1282 $rc = $result->rowCount();
1284 while ($row = $result->fetch()) {
1285 BackendUtility
::workspaceOL('pages', $row);
1286 if (is_array($row)) {
1288 $row['treeIcons'] = $treeIcons . '<span class="treeline-icon treeline-icon-join' . ($rc === $c ?
'bottom' : '') . '"></span>';
1291 $spaceOutIcons = '<span class="treeline-icon treeline-icon-' . ($rc === $c ?
'clear' : 'line') . '"></span>';
1292 $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons,
1293 $row['php_tree_stop'] ?
0 : $depth);
1297 $count = (int)$queryBuilder->count('uid')->execute()->fetchColumn(0);
1299 $this->plusPages
[$pid] = $count;
1306 * Adds a list item for the pages-rendering
1308 * @param array $row Record array
1309 * @param array $fieldArr Field list
1310 * @return string HTML for the item
1312 public function pages_drawItem($row, $fieldArr)
1315 $theIcon = $this->getIcon('pages', $row);
1316 // Preparing and getting the data-array
1318 foreach ($fieldArr as $field) {
1321 $red = $this->plusPages
[$row['uid']] ?
'<span class="text-danger"><strong>+</strong></span>' : '';
1322 $pTitle = htmlspecialchars(BackendUtility
::getProcessedValue('pages', $field, $row[$field], 20));
1324 $pTitle = '<a href="'
1325 . htmlspecialchars($this->script
. ((strpos($this->script
, '?') !== false) ?
'&' : '?')
1326 . 'id=' . $row['uid']) . '">' . $pTitle . '</a>';
1328 $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . ' ';
1330 case 'php_tree_stop':
1331 // Intended fall through
1333 $theData[$field] = $row[$field] ?
' <strong>x</strong>' : ' ';
1336 if ($this->getBackendUser()->doesUserHaveAccess($row, 2) && $row['uid'] > 0) {
1340 $row['uid'] => 'edit'
1343 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1345 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
1346 $eI = '<a class="btn btn-default" href="' . htmlspecialchars($url)
1347 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('editThisPage')) . '">'
1348 . $this->iconFactory
->getIcon('actions-page-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1352 $theData[$field] = $eI . '<span align="right">' . $row['uid'] . '</span>';
1355 case 'shortcut_mode':
1356 if ((int)$row['doktype'] === \TYPO3\CMS\Frontend\Page\PageRepository
::DOKTYPE_SHORTCUT
) {
1357 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1361 if (substr($field, 0, 6) === 'table_') {
1362 $f2 = substr($field, 6);
1363 if ($GLOBALS['TCA'][$f2]) {
1364 $c = $this->numberOfRecords($f2, $row['uid']);
1365 $theData[$field] = ' ' . ($c ?
$c : '');
1368 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1372 $this->addElement_tdParams
['title'] = $row['_CSSCLASS'] ?
' class="' . $row['_CSSCLASS'] . '"' : '';
1373 return $this->addElement(1, '', $theData);
1377 * Returns the HTML code for rendering a field in the pages table.
1378 * The row value is processed to a human readable form and the result is parsed through htmlspecialchars().
1380 * @param string $field The name of the field of which the value should be rendered.
1381 * @param array $row The pages table row as an associative array.
1382 * @return string The rendered table field value.
1384 protected function getPagesTableFieldValue($field, array $row)
1386 return ' ' . htmlspecialchars(BackendUtility
::getProcessedValue('pages', $field, $row[$field]));
1389 /**********************************
1391 * Additional functions; Content Elements
1393 **********************************/
1395 * Draw header for a content element column:
1397 * @param string $colName Column name
1398 * @param string $editParams Edit params (Syntax: &edit[...] for FormEngine)
1399 * @param string $newParams New element params (Syntax: &edit[...] for FormEngine) OBSOLETE
1400 * @param array|NULL $pasteParams Paste element params (i.e. array(colPos => 1, sys_language_uid => 2))
1401 * @return string HTML table
1403 public function tt_content_drawColHeader($colName, $editParams, $newParams, array $pasteParams = null)
1406 // Create command links:
1407 if ($this->tt_contentConfig
['showCommands']) {
1408 // Edit whole of column:
1409 if ($editParams && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
) && $this->getBackendUser()->checkLanguageAccess(0)) {
1410 $iconsArr['edit'] = '<a href="#" onclick="'
1411 . htmlspecialchars(BackendUtility
::editOnClick($editParams)) . '" title="'
1412 . htmlspecialchars($this->getLanguageService()->getLL('editColumn')) . '">'
1413 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1416 $elFromTable = $this->clipboard
->elFromTable('tt_content');
1417 if (!empty($elFromTable) && $this->getPageLayoutController()->pageIsNotLockedForEditors()) {
1418 $iconsArr['paste'] =
1419 '<a href="' . htmlspecialchars($this->clipboard
->pasteUrl('tt_content', $this->id
, true, $pasteParams)) . '"'
1420 . ' class="t3js-modal-trigger"'
1421 . ' data-severity="warning"'
1422 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('pasteIntoColumn')) . '"'
1423 . ' data-content="' . htmlspecialchars($this->clipboard
->confirmMsgText('pages', $this->pageRecord
, 'into', $elFromTable, $colName)) . '"'
1424 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('pasteIntoColumn')) . '">'
1425 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render()
1431 if (!empty($iconsArr)) {
1432 $icons = '<div class="t3-page-column-header-icons">' . implode('', $iconsArr) . '</div>';
1434 // Create header row:
1435 $out = '<div class="t3-page-column-header">
1437 <div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
1443 * Draw the footer for a single tt_content element
1445 * @param array $row Record array
1446 * @return string HTML of the footer
1447 * @throws \UnexpectedValueException
1449 protected function tt_content_drawFooter(array $row)
1452 // Get processed values:
1454 $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
1456 // Content element annotation
1457 if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn'])) {
1458 $info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]);
1461 // Call drawFooter hooks
1462 $drawFooterHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'];
1463 if (is_array($drawFooterHooks)) {
1464 foreach ($drawFooterHooks as $hookClass) {
1465 $hookObject = GeneralUtility
::getUserObj($hookClass);
1466 if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface
) {
1467 throw new \
UnexpectedValueException($hookClass . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface
::class, 1404378171);
1469 $hookObject->preProcess($this, $info, $row);
1473 // Display info from records fields:
1474 if (!empty($info)) {
1475 $content = '<div class="t3-page-ce-info">
1476 ' . implode('<br>', $info) . '
1480 if (!empty($content)) {
1481 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1487 * Draw the header for a single tt_content element
1489 * @param array $row Record array
1490 * @param int $space Amount of pixel space above the header. UNUSED
1491 * @param bool $disableMoveAndNewButtons If set the buttons for creating new elements and moving up and down are not shown.
1492 * @param bool $langMode If set, we are in language mode and flags will be shown for languages
1493 * @param bool $dragDropEnabled If set the move button must be hidden
1494 * @return string HTML table with the record header.
1496 public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = false, $langMode = false, $dragDropEnabled = false)
1499 // If show info is set...;
1500 if ($this->tt_contentConfig
['showInfo'] && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1501 // Render control panel for the element:
1502 if ($this->tt_contentConfig
['showCommands'] && $this->doEdit
) {
1503 // Edit content element:
1507 $this->tt_contentData
['nextThree'][$row['uid']] => 'edit'
1510 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid'],
1512 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters) . '#element-tt_content-' . $row['uid'];
1514 $out .= '<a class="btn btn-default" href="' . htmlspecialchars($url)
1515 . '" title="' . htmlspecialchars($this->nextThree
> 1
1516 ?
sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree
)
1517 : $this->getLanguageService()->getLL('edit'))
1518 . '">' . $this->iconFactory
->getIcon('actions-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1520 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1521 if ($hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1522 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1523 ||
$this->getBackendUser()->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1525 if ($row[$hiddenField]) {
1532 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ?
$row['_ORIG_uid'] : $row['uid'])
1533 . '][' . $hiddenField . ']=' . $value;
1534 $out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility
::getLinkToDataHandlerAction($params))
1535 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($label)) . '">'
1536 . $this->iconFactory
->getIcon('actions-edit-' . strtolower($label), Icon
::SIZE_SMALL
)->render() . '</a>';
1539 $disableDeleteTS = $this->getBackendUser()->getTSConfig('options.disableDelete');
1540 $disableDelete = (bool) trim(isset($disableDeleteTS['properties']['tt_content']) ?
$disableDeleteTS['properties']['tt_content'] : $disableDeleteTS['value']);
1541 if (!$disableDelete) {
1542 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1543 $confirm = $this->getLanguageService()->getLL('deleteWarning')
1544 . BackendUtility
::translationCount('tt_content', $row['uid'], (' '
1545 . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')));
1546 $out .= '<a class="btn btn-default t3js-modal-trigger" href="' . htmlspecialchars(BackendUtility
::getLinkToDataHandlerAction($params)) . '"'
1547 . ' data-severity="warning"'
1548 . ' data-title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf:label.confirm.delete_record.title')) . '"'
1549 . ' data-content="' . htmlspecialchars($confirm) . '" '
1550 . ' data-button-close-text="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:cancel')) . '"'
1551 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('deleteItem')) . '">'
1552 . $this->iconFactory
->getIcon('actions-edit-delete', Icon
::SIZE_SMALL
)->render() . '</a>';
1553 if ($out && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)) {
1554 $out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>';
1559 if (!$disableMoveAndNewButtons) {
1560 $moveButtonContent = '';
1561 $displayMoveButtons = false;
1563 if ($this->tt_contentData
['prev'][$row['uid']]) {
1564 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData
['prev'][$row['uid']];
1565 $moveButtonContent .= '<a class="btn btn-default" href="'
1566 . htmlspecialchars(BackendUtility
::getLinkToDataHandlerAction($params))
1567 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
1568 . $this->iconFactory
->getIcon('actions-move-up', Icon
::SIZE_SMALL
)->render() . '</a>';
1569 if (!$dragDropEnabled) {
1570 $displayMoveButtons = true;
1573 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory
->getIcon('empty-empty', Icon
::SIZE_SMALL
)->render() . '</span>';
1575 // Move element down:
1576 if ($this->tt_contentData
['next'][$row['uid']]) {
1577 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData
['next'][$row['uid']];
1578 $moveButtonContent .= '<a class="btn btn-default" href="'
1579 . htmlspecialchars(BackendUtility
::getLinkToDataHandlerAction($params))
1580 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
1581 . $this->iconFactory
->getIcon('actions-move-down', Icon
::SIZE_SMALL
)->render() . '</a>';
1582 if (!$dragDropEnabled) {
1583 $displayMoveButtons = true;
1586 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory
->getIcon('empty-empty', Icon
::SIZE_SMALL
)->render() . '</span>';
1588 if ($displayMoveButtons) {
1589 $out .= '<div class="btn-group btn-group-sm" role="group">' . $moveButtonContent . '</div>';
1594 $allowDragAndDrop = $this->isDragAndDropAllowed($row);
1595 $additionalIcons = [];
1596 if ($row['sys_language_uid'] > 0 && $this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid'])) {
1597 $disabledClickMenuItems = 'new,move';
1598 $allowDragAndDrop = false;
1600 $additionalIcons[] = $this->getIcon('tt_content', $row, $disabledClickMenuItems) . ' ';
1601 $additionalIcons[] = $langMode ?
$this->languageFlag($row['sys_language_uid'], false) : '';
1602 // Get record locking status:
1603 if ($lockInfo = BackendUtility
::isRecordLocked('tt_content', $row['uid'])) {
1604 $additionalIcons[] = '<a href="#" data-toggle="tooltip" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
1605 . $this->iconFactory
->getIcon('status-warning-in-use', Icon
::SIZE_SMALL
)->render() . '</a>';
1607 // Call stats information hook
1608 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1609 $_params = ['tt_content', $row['uid'], &$row];
1610 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1611 $additionalIcons[] = GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
1614 // Wrap the whole header
1615 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
1616 return '<div class="t3-page-ce-header ' . ($allowDragAndDrop ?
't3-page-ce-header-draggable t3js-page-ce-draghandle' : '') . '">
1617 <div class="t3-page-ce-header-icons-left">' . implode('', $additionalIcons) . '</div>
1618 <div class="t3-page-ce-header-icons-right">' . ($out ?
'<div class="btn-toolbar">' . $out . '</div>' : '') . '</div>
1620 <div class="t3-page-ce-body">';
1624 * Determine whether Drag & Drop should be allowed
1629 protected function isDragAndDropAllowed(array $row)
1631 if ($this->getBackendUser()->user
['admin']
1632 ||
((int)$row['editlock'] === 0 && (int)$this->pageinfo
['editlock'] === 0)
1633 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)
1634 && $this->getBackendUser()->checkAuthMode('tt_content', 'CType', $row['CType'], $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'])
1642 * Draws the preview content for a content element
1644 * @param array $row Content element
1645 * @return string HTML
1646 * @throws \UnexpectedValueException
1648 public function tt_content_drawItem($row)
1654 if ($row['header']) {
1656 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
1657 $hiddenHeaderNote = '';
1658 // If header layout is set to 'hidden', display an accordant note:
1659 if ($row['header_layout'] == 100) {
1660 $hiddenHeaderNote = ' <em>[' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.hidden')) . ']</em>';
1662 $outHeader = $row['date']
1663 ?
htmlspecialchars($this->itemLabels
['date'] . ' ' . BackendUtility
::date($row['date'])) . '<br />'
1665 $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
1666 . $hiddenHeaderNote . '</strong><br />';
1671 // Hook: Render an own preview of a record
1672 $drawItemHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1673 if (is_array($drawItemHooks)) {
1674 foreach ($drawItemHooks as $hookClass) {
1675 $hookObject = GeneralUtility
::getUserObj($hookClass);
1676 if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface
) {
1677 throw new \
UnexpectedValueException($hookClass . ' must implement interface ' . PageLayoutViewDrawItemHookInterface
::class, 1218547409);
1679 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1683 // If the previous hook did not render something,
1684 // then check if a Fluid-based preview template was defined for this CType
1685 // and render it via Fluid. Possible option:
1686 // mod.web_layout.tt_content.preview.media = EXT:site_mysite/Resources/Private/Templates/Preview/Media.html
1688 $tsConfig = BackendUtility
::getModTSconfig($row['pid'], 'mod.web_layout.tt_content.preview');
1689 $fluidTemplateFile = '';
1692 $row['CType'] === 'list' && !empty($row['list_type'])
1693 && !empty($tsConfig['properties']['list.'][$row['list_type']])
1695 $fluidTemplateFile = $tsConfig['properties']['list.'][$row['list_type']];
1696 } elseif (!empty($tsConfig['properties'][$row['CType']])) {
1697 $fluidTemplateFile = $tsConfig['properties'][$row['CType']];
1700 if ($fluidTemplateFile) {
1701 $fluidTemplateFile = GeneralUtility
::getFileAbsFileName($fluidTemplateFile);
1702 if ($fluidTemplateFile) {
1704 /** @var StandaloneView $view */
1705 $view = GeneralUtility
::makeInstance(StandaloneView
::class);
1706 $view->setTemplatePathAndFilename($fluidTemplateFile);
1707 $view->assignMultiple($row);
1708 if (!empty($row['pi_flexform'])) {
1709 /** @var FlexFormService $flexFormService */
1710 $flexFormService = GeneralUtility
::makeInstance(FlexFormService
::class);
1711 $view->assign('pi_flexform_transformed', $flexFormService->convertFlexFormContentToArray($row['pi_flexform']));
1713 $out = $view->render();
1715 } catch (\Exception
$e) {
1716 // Catch any exception to avoid breaking the view
1722 // Draw preview of the item depending on its CType (if not disabled by previous hook):
1724 switch ($row['CType']) {
1726 if ($row['subheader']) {
1727 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
1732 if ($row['bodytext']) {
1733 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1737 if ($row['media']) {
1738 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'media'), $row) . '<br />';
1742 $contentType = $this->CType_labels
[$row['CType']];
1743 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1745 $menuTypeLabel = $this->getLanguageService()->sL(
1746 BackendUtility
::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
1748 $menuTypeLabel = $menuTypeLabel ?
: 'invalid menu type';
1749 $out .= $this->linkEditContent($menuTypeLabel, $row);
1750 if ($row['menu_type'] !== '2' && ($row['pages'] ||
$row['selected_categories'])) {
1751 // Show pages if menu type is not "Sitemap"
1752 $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
1756 if (!empty($row['records'])) {
1757 $shortcutContent = [];
1758 $recordList = explode(',', $row['records']);
1759 foreach ($recordList as $recordIdentifier) {
1760 $split = BackendUtility
::splitTable_Uid($recordIdentifier);
1761 $tableName = empty($split[0]) ?
'tt_content' : $split[0];
1762 $shortcutRecord = BackendUtility
::getRecord($tableName, $split[1]);
1763 if (is_array($shortcutRecord)) {
1764 $icon = $this->iconFactory
->getIconForRecord($tableName, $shortcutRecord, Icon
::SIZE_SMALL
)->render();
1765 $icon = BackendUtility
::wrapClickMenuOnIcon(
1768 $shortcutRecord['uid'],
1771 '+copy,info,edit,view'
1773 $shortcutContent[] = $icon
1774 . htmlspecialchars(BackendUtility
::getRecordTitle($tableName, $shortcutRecord));
1777 $out .= implode('<br />', $shortcutContent) . '<br />';
1783 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1784 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1785 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1786 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1788 if (!empty($hookArr)) {
1789 $_params = ['pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr];
1790 foreach ($hookArr as $_funcRef) {
1791 $hookOut .= GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
1794 if ((string)$hookOut !== '') {
1796 } elseif (!empty($row['list_type'])) {
1797 $label = BackendUtility
::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
1798 if (!empty($label)) {
1799 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($this->getLanguageService()->sL($label)) . '</strong>', $row) . '<br />';
1801 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
1802 $out .= '<span class="label label-warning">' . htmlspecialchars($message) . '</span>';
1805 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
1807 $out .= htmlspecialchars($this->getLanguageService()->sL(
1808 BackendUtility
::getLabelFromItemlist('tt_content', 'pages', $row['pages'])
1812 $contentType = $this->CType_labels
[$row['CType']];
1814 if (isset($contentType)) {
1815 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1816 if ($row['bodytext']) {
1817 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1819 if ($row['image']) {
1820 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'image'), $row) . '<br />';
1824 $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'),
1827 $out .= '<span class="label label-warning">' . htmlspecialchars($message) . '</span>';
1833 <span class="exampleContent">' . $out . '</span>';
1835 $out = $outHeader . $out;
1837 if ($this->isDisabled('tt_content', $row)) {
1838 return '<span class="text-muted">' . $out . '</span>';
1845 * Generates a list of selected pages or categories for the CType menu
1847 * @param array $row row from pages
1850 protected function generateListForCTypeMenu(array $row)
1854 // get categories instead of pages
1855 if (strpos($row['menu_type'], 'categorized_') !== false) {
1856 $table = 'sys_category';
1857 $field = 'selected_categories';
1859 if (trim($row[$field]) === '') {
1863 $uidList = explode(',', $row[$field]);
1864 foreach ($uidList as $uid) {
1866 $record = BackendUtility
::getRecord($table, $uid, 'title');
1867 $content .= '<br>' . $record['title'] . ' (' . $uid . ')';
1873 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1874 * Selects across columns, but within in the same PID. Columns are expect to be the same
1875 * for translations and original but this may be a conceptual error (?)
1877 * @param array $defaultLanguageUids Numeric array with uids of tt_content elements in the default language
1878 * @param int $id Page pid
1879 * @param int $lP Sys language UID
1880 * @return array Modified $defLanguageCount
1882 public function getNonTranslatedTTcontentUids($defaultLanguageUids, $id, $lP)
1884 if ($lP && !empty($defaultLanguageUids)) {
1885 // Select all translations here:
1886 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
1887 ->getQueryBuilderForTable('tt_content');
1888 $queryBuilder->getRestrictions()
1890 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class));
1893 ->from('tt_content')
1895 $queryBuilder->expr()->eq(
1897 $queryBuilder->createNamedParameter($lP, \PDO
::PARAM_INT
)
1899 $queryBuilder->expr()->in(
1901 $queryBuilder->createNamedParameter($defaultLanguageUids, Connection
::PARAM_INT_ARRAY
)
1905 $result = $queryBuilder->execute();
1908 $defaultLanguageUids = array_flip($defaultLanguageUids);
1909 // Traverse any selected elements and unset original UID if any:
1910 while ($row = $result->fetch()) {
1911 BackendUtility
::workspaceOL('tt_content', $row);
1912 unset($defaultLanguageUids[$row['l18n_parent']]);
1915 $defaultLanguageUids = array_keys($defaultLanguageUids);
1917 return $defaultLanguageUids;
1921 * Creates button which is used to create copies of records..
1923 * @param array $defaultLanguageUids Numeric array with uids of tt_content elements in the default language
1924 * @param int $lP Sys language UID
1925 * @param int $colPos Column position
1926 * @return string "Copy languages" button, if available.
1928 public function newLanguageButton($defaultLanguageUids, $lP, $colPos = 0)
1931 if (!$this->doEdit ||
!$lP) {
1937 $allowTranslate = true;
1938 if (!empty($this->languageHasTranslationsCache
[$lP])) {
1939 if (isset($this->languageHasTranslationsCache
[$lP]['hasStandAloneContent'])) {
1940 $allowTranslate = false;
1942 if (isset($this->languageHasTranslationsCache
[$lP]['hasTranslations'])) {
1947 if (isset($this->contentElementCache
[$lP][$colPos]) && is_array($this->contentElementCache
[$lP][$colPos])) {
1948 foreach ($this->contentElementCache
[$lP][$colPos] as $record) {
1949 $key = array_search($record['t3_origuid'], $defaultLanguageUids);
1950 if ($key !== false) {
1951 unset($defaultLanguageUids[$key]);
1956 if (!empty($defaultLanguageUids)) {
1959 . ' class="btn btn-default t3js-localize"'
1962 . ' value="' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate')) . '"'
1963 . ' data-has-elements="' . (int)!empty($this->contentElementCache
[$lP][$colPos]) . '"'
1964 . ' data-allow-copy="' . (int)$allowCopy . '"'
1965 . ' data-allow-translate="' . (int)$allowTranslate . '"'
1966 . ' data-table="tt_content"'
1967 . ' data-page-id="' . (int)GeneralUtility
::_GP('id') . '"'
1968 . ' data-language-id="' . $lP . '"'
1969 . ' data-language-name="' . htmlspecialchars($this->tt_contentConfig
['languageCols'][$lP]) . '"'
1970 . ' data-colpos-id="' . $colPos . '"'
1971 . ' data-colpos-name="' . BackendUtility
::getProcessedValue('tt_content', 'colPos', $colPos) . '"'
1975 return '<div class="t3-page-lang-copyce">' . $theNewButton . '</div>';
1979 * Creates onclick-attribute content for a new content element
1981 * @param int $id Page id where to create the element.
1982 * @param int $colPos Preset: Column position value
1983 * @param int $sys_language Preset: Sys langauge value
1984 * @return string String for onclick attribute.
1985 * @see getTable_tt_content()
1987 public function newContentElementOnClick($id, $colPos, $sys_language)
1989 if ($this->option_newWizard
) {
1990 $tsConfig = BackendUtility
::getModTSconfig($id, 'mod');
1991 $moduleName = isset($tsConfig['properties']['newContentElementWizard.']['override'])
1992 ?
$tsConfig['properties']['newContentElementWizard.']['override']
1993 : 'new_content_element';
1994 $onClick = 'window.location.href=' . GeneralUtility
::quoteJSvalue(BackendUtility
::getModuleUrl($moduleName) . '&id=' . $id . '&colPos=' . $colPos
1995 . '&sys_language_uid=' . $sys_language . '&uid_pid=' . $id
1996 . '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI'))) . ';';
1998 $onClick = BackendUtility
::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
1999 . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language);
2005 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
2006 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
2008 * @param string $str String to link. Must be prepared for HTML output.
2009 * @param array $row The row.
2010 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
2011 * @see getTable_tt_content()
2013 public function linkEditContent($str, $row)
2015 if ($this->doEdit
&& $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
2019 $row['uid'] => 'edit'
2022 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
2024 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
2026 return '<a href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $str . '</a>';
2033 * Make selector box for creating new translation in a language
2034 * Displays only languages which are not yet present for the current page and
2035 * that are not disabled with page TS.
2037 * @param int $id Page id for which to create a new language (pages_language_overlay record)
2038 * @return string <select> HTML element (if there were items for the box anyways...)
2039 * @see getTable_tt_content()
2041 public function languageSelector($id)
2043 if ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
2044 // First, select all
2045 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)->getQueryBuilderForTable('sys_language');
2046 $queryBuilder->getRestrictions()->removeAll();
2047 $queryBuilder->getRestrictions()->add(GeneralUtility
::makeInstance(HiddenRestriction
::class));
2048 $statement = $queryBuilder->select('uid', 'title')
2049 ->from('sys_language')
2050 ->orderBy('sorting')
2053 $langSelItems[0] = '
2054 <option value="0"></option>';
2055 while ($row = $statement->fetch()) {
2056 if ($this->getBackendUser()->checkLanguageAccess($row['uid'])) {
2057 $langSelItems[$row['uid']] = '
2058 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
2061 // Then, subtract the languages which are already on the page:
2062 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)->getQueryBuilderForTable('sys_language');
2063 $queryBuilder->getRestrictions()->removeAll();
2064 $queryBuilder->select('sys_language.uid AS uid', 'sys_language.title AS title')
2065 ->from('sys_language')
2068 'pages_language_overlay',
2069 'pages_language_overlay',
2070 $queryBuilder->expr()->eq('sys_language.uid', $queryBuilder->quoteIdentifier('pages_language_overlay.sys_language_uid'))
2073 $queryBuilder->expr()->eq(
2074 'pages_language_overlay.deleted', $queryBuilder->createNamedParameter(0, \PDO
::PARAM_INT
)
2076 $queryBuilder->expr()->eq(
2077 'pages_language_overlay.pid',
2078 $queryBuilder->createNamedParameter($this->id
, \PDO
::PARAM_INT
)
2080 $queryBuilder->expr()->orX(
2081 $queryBuilder->expr()->gte(
2082 'pages_language_overlay.t3ver_state',
2083 $queryBuilder->createNamedParameter(
2084 (string)new VersionState(VersionState
::DEFAULT_STATE
),
2088 $queryBuilder->expr()->eq(
2089 'pages_language_overlay.t3ver_wsid',
2090 $queryBuilder->createNamedParameter($this->getBackendUser()->workspace
, \PDO
::PARAM_INT
)
2094 ->groupBy('pages_language_overlay.sys_language_uid', 'sys_language.uid', 'sys_language.pid',
2095 'sys_language.tstamp', 'sys_language.hidden', 'sys_language.title',
2096 'sys_language.language_isocode', 'sys_language.static_lang_isocode', 'sys_language.flag')
2097 ->orderBy('sys_language.sorting');
2098 if (!$this->getBackendUser()->isAdmin()) {
2099 $queryBuilder->andWhere(
2100 $queryBuilder->expr()->eq(
2101 'sys_language.hidden',
2102 $queryBuilder->createNamedParameter(0, \PDO
::PARAM_INT
)
2106 $statement = $queryBuilder->execute();
2107 while ($row = $statement->fetch()) {
2108 unset($langSelItems[$row['uid']]);
2110 // Remove disallowed languages
2111 if (count($langSelItems) > 1
2112 && !$this->getBackendUser()->user
['admin']
2113 && $this->getBackendUser()->groupData
['allowed_languages'] !== ''
2115 $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData
['allowed_languages']));
2116 if (!empty($allowed_languages)) {
2117 foreach ($langSelItems as $key => $value) {
2118 if (!isset($allowed_languages[$key]) && $key != 0) {
2119 unset($langSelItems[$key]);
2124 // Remove disabled languages
2125 $modSharedTSconfig = BackendUtility
::getModTSconfig($id, 'mod.SHARED');
2126 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages'])
2127 ? GeneralUtility
::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], true)
2129 if (!empty($langSelItems) && !empty($disableLanguages)) {
2130 foreach ($disableLanguages as $language) {
2131 if ($language != 0 && isset($langSelItems[$language])) {
2132 unset($langSelItems[$language]);
2136 // If any languages are left, make selector:
2137 if (count($langSelItems) > 1) {
2138 $url = BackendUtility
::getModuleUrl('record_edit', [
2139 'edit[pages_language_overlay][' . $id . ']' => 'new',
2140 'overrideVals[pages_language_overlay][doktype]' => (int)$this->pageRecord
['doktype'],
2141 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
2143 $onChangeContent = 'window.location.href=' . GeneralUtility
::quoteJSvalue($url . '&overrideVals[pages_language_overlay][sys_language_uid]=') . '+this.options[this.selectedIndex].value';
2144 return '<div class="form-inline form-inline-spaced">'
2145 . '<div class="form-group">'
2146 . '<label for="createNewLanguage">'
2147 . htmlspecialchars($this->getLanguageService()->getLL('new_language'))
2149 . '<select class="form-control input-sm" name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">'
2150 . implode('', $langSelItems)
2151 . '</select></div></div>';
2158 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
2160 * @param Statement|\mysqli_result $result DBAL Statement or MySQLi result object
2161 * @param string $table Table name defaulting to tt_content
2162 * @return array The selected rows returned in this array.
2164 public function getResult($result, string $table = 'tt_content'): array
2166 if ($result instanceof \mysqli_result
) {
2167 GeneralUtility
::deprecationLog('Using \TYPO3\CMS\Backend\View\PageLayoutView::getResult with a mysqli_result object is deprecated since TYPO3 CMS 8 and will be removed in TYPO3 CMS 9');
2170 // Traverse the result:
2171 while ($row = ($result instanceof Statement ?
$result->fetch() : $result->fetch_assoc())) {
2172 BackendUtility
::workspaceOL($table, $row, -99, true);
2174 // Add the row to the array:
2178 $this->generateTtContentDataArray($output);
2179 // Return selected records
2183 /********************************
2185 * Various helper functions
2187 ********************************/
2190 * Initializes the clipboard for generating paste links
2194 * @see \TYPO3\CMS\Recordlist\RecordList::main()
2195 * @see \TYPO3\CMS\Backend\Controller\ClickMenuController::main()
2196 * @see \TYPO3\CMS\Filelist\Controller\FileListController::main()
2198 protected function initializeClipboard()
2201 $this->clipboard
= GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard
::class);
2203 // Initialize - reads the clipboard content from the user session
2204 $this->clipboard
->initializeClipboard();
2206 // This locks the clipboard to the Normal for this request.
2207 $this->clipboard
->lockToNormal();
2210 $this->clipboard
->cleanCurrent();
2212 // Save the clipboard content
2213 $this->clipboard
->endClipboard();
2217 * Generates the data for previous and next elements which is needed for movements.
2219 * @param array $rowArray
2222 protected function generateTtContentDataArray(array $rowArray)
2224 if (empty($this->tt_contentData
)) {
2225 $this->tt_contentData
= [
2231 foreach ($rowArray as $key => $value) {
2232 // Create the list of the next three ids (for editing links...)
2233 for ($i = 0; $i < $this->nextThree
; $i++
) {
2234 if (isset($rowArray[$key - $i])
2235 && !GeneralUtility
::inList($this->tt_contentData
['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
2237 $this->tt_contentData
['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
2241 // Create information for next and previous content elements
2242 if (isset($rowArray[$key - 1])) {
2243 if (isset($rowArray[$key - 2])) {
2244 $this->tt_contentData
['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
2246 $this->tt_contentData
['prev'][$value['uid']] = $value['pid'];
2248 $this->tt_contentData
['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
2254 * Counts and returns the number of records on the page with $pid
2256 * @param string $table Table name
2257 * @param int $pid Page id
2258 * @return int Number of records.
2260 public function numberOfRecords($table, $pid)
2263 if ($GLOBALS['TCA'][$table]) {
2264 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
2265 ->getQueryBuilderForTable($table);
2266 $queryBuilder->getRestrictions()
2268 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class))
2269 ->add(GeneralUtility
::makeInstance(BackendWorkspaceRestriction
::class));
2270 $count = (int)$queryBuilder->count('uid')
2273 $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO
::PARAM_INT
))
2283 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
2285 * @param string $input Input string
2286 * @return string Output string
2288 public function renderText($input)
2290 $input = strip_tags($input);
2291 $input = GeneralUtility
::fixed_lgd_cs($input, 1500);
2292 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES
, 'UTF-8', false));
2296 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
2298 * @param string $table Table name
2299 * @param array $row Record array
2300 * @param string $enabledClickMenuItems Passthrough to wrapClickMenuOnIcon
2301 * @return string HTML for the icon
2303 public function getIcon($table, $row, $enabledClickMenuItems = '')
2306 $toolTip = BackendUtility
::getRecordToolTip($row, 'tt_content');
2307 $icon = '<span ' . $toolTip . '>' . $this->iconFactory
->getIconForRecord($table, $row, Icon
::SIZE_SMALL
)->render() . '</span>';
2309 // The icon with link
2310 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
2311 $icon = BackendUtility
::wrapClickMenuOnIcon($icon, $table, $row['uid'], true, '', $enabledClickMenuItems);
2317 * Creates processed values for all field names in $fieldList based on values from $row array.
2318 * The result is 'returned' through $info which is passed as a reference
2320 * @param string $table Table name
2321 * @param string $fieldList Comma separated list of fields.
2322 * @param array $row Record from which to take values for processing.
2323 * @param array $info Array to which the processed values are added.
2326 public function getProcessedValue($table, $fieldList, array $row, array &$info)
2328 // Splitting values from $fieldList
2329 $fieldArr = explode(',', $fieldList);
2330 // Traverse fields from $fieldList
2331 foreach ($fieldArr as $field) {
2333 $info[] = '<strong>' . htmlspecialchars($this->itemLabels
[$field]) . '</strong> '
2334 . htmlspecialchars(BackendUtility
::getProcessedValue($table, $field, $row[$field]));
2340 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
2342 * @param string $table Tablename of table to test
2343 * @param array $row Record row.
2344 * @return bool Returns TRUE, if disabled.
2346 public function isDisabled($table, $row)
2348 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
2349 return $enableCols['disabled'] && $row[$enableCols['disabled']]
2350 ||
$enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
2351 ||
$enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
2355 * Returns icon for "no-edit" of a record.
2356 * Basically, the point is to signal that this record could have had an edit link if
2357 * the circumstances were right. A placeholder for the regular edit icon...
2359 * @param string $label Label key from LOCAL_LANG
2360 * @return string IMG tag for icon.
2362 public function noEditIcon($label = 'noEditItems')
2364 $title = htmlspecialchars($this->getLanguageService()->getLL($label));
2365 return '<span title="' . $title . '">' . $this->iconFactory
->getIcon('status-status-edit-read-only', Icon
::SIZE_SMALL
)->render() . '</span>';
2368 /*****************************************
2370 * External renderings
2372 *****************************************/
2375 * Creates a menu of the tables that can be listed by this function
2376 * Only tables which has records on the page will be included.
2377 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2379 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2380 * @return string HTML output.
2382 public function getTableMenu($id)
2385 $this->activeTables
= [];
2386 $theTables = ['tt_content'];
2388 if (is_array($this->externalTables
)) {
2389 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables
)));
2392 // Traverse tables to check:
2393 foreach ($theTables as $tName) {
2394 // Check access and whether the proper extensions are loaded:
2395 if ($this->getBackendUser()->check('tables_select', $tName)
2396 && (isset($this->externalTables
[$tName])
2397 ||
$tName === 'fe_users' ||
$tName === 'tt_content'
2398 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::isLoaded($tName)
2401 // Make query to count records from page:
2402 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
2403 ->getQueryBuilderForTable($tName);
2404 $queryBuilder->getRestrictions()
2406 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class))
2407 ->add(GeneralUtility
::makeInstance(BackendWorkspaceRestriction
::class));
2408 $count = $queryBuilder->count('uid')
2410 ->where($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($id, \PDO
::PARAM_INT
)))
2413 // If records were found (or if "tt_content" is the table...):
2414 if ($count ||
$tName === 'tt_content') {
2417 <td><a href="#' . $tName . '" title="' . htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'])) . '"></a>'
2418 . $this->iconFactory
->getIconForRecord($tName, [], Icon
::SIZE_SMALL
)->render()
2420 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2421 $title = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title']))
2422 . ': ' . $count . ' ' . htmlspecialchars($this->getLanguageService()->getLL('records'));
2423 $this->activeTables
[$tName] = '<span title="' . $title . '">'
2424 . $this->iconFactory
->getIconForRecord($tName, [], Icon
::SIZE_SMALL
)->render()
2426 . ' ' . htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title']));
2430 // Wrap cells in table tags:
2433 Menu of tables on the page (table menu)
2435 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2439 // Return the content:
2444 * Create thumbnail code for record/field but not linked
2446 * @param mixed[] $row Record array
2447 * @param string $table Table (record is from)
2448 * @param string $field Field name for which thumbnail are to be rendered.
2449 * @return string HTML for thumbnails, if any.
2451 public function getThumbCodeUnlinked($row, $table, $field)
2453 return BackendUtility
::thumbCode($row, $table, $field, '', '', null, 0, '', '', false);
2457 * Checks whether translated Content Elements exist in the desired language
2458 * If so, deny creating new ones via the UI
2460 * @param array $contentElements
2461 * @param int $language
2464 protected function checkIfTranslationsExistInLanguage(array $contentElements, $language)
2466 // If in default language, you may always create new entries
2467 // Also, you may override this strict behavior via user TS Config
2468 // If you do so, you're on your own and cannot rely on any support by the TYPO3 core
2469 // We jump out here since we don't need to do the expensive loop operations
2470 $allowInconsistentLanguageHandling = BackendUtility
::getModTSconfig($this->id
, 'mod.web_layout.allowInconsistentLanguageHandling');
2471 if ($language === 0 ||
$allowInconsistentLanguageHandling['value'] === '1') {
2477 if (!isset($this->languageHasTranslationsCache
[$language])) {
2478 foreach ($contentElements as $columns) {
2479 foreach ($columns as $contentElement) {
2480 if ((int)$contentElement['l18n_parent'] === 0) {
2481 $this->languageHasTranslationsCache
[$language]['hasStandAloneContent'] = true;
2483 if ((int)$contentElement['l18n_parent'] > 0) {
2484 $this->languageHasTranslationsCache
[$language]['hasTranslations'] = true;
2488 // Check whether we have a mix of both
2489 if ($this->languageHasTranslationsCache
[$language]['hasStandAloneContent']
2490 && $this->languageHasTranslationsCache
[$language]['hasTranslations']
2492 $message = GeneralUtility
::makeInstance(
2493 FlashMessage
::class,
2494 sprintf($this->getLanguageService()->getLL('staleTranslationWarning'), $this->languageIconTitles
[$language]['title']),
2495 sprintf($this->getLanguageService()->getLL('staleTranslationWarningTitle'), $this->languageIconTitles
[$language]['title']),
2496 FlashMessage
::WARNING
2498 $service = GeneralUtility
::makeInstance(FlashMessageService
::class);
2499 $queue = $service->getMessageQueueByIdentifier();
2500 $queue->addMessage($message);
2503 if ($this->languageHasTranslationsCache
[$language]['hasTranslations']) {
2510 * @return BackendLayoutView
2512 protected function getBackendLayoutView()
2514 return GeneralUtility
::makeInstance(BackendLayoutView
::class);
2518 * @return BackendUserAuthentication
2520 protected function getBackendUser()
2522 return $GLOBALS['BE_USER'];
2526 * @return PageLayoutController
2528 protected function getPageLayoutController()
2530 return $GLOBALS['SOBE'];