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 TYPO3\CMS\Backend\Controller\PageLayoutController
;
18 use TYPO3\CMS\Backend\Utility\BackendUtility
;
19 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
20 use TYPO3\CMS\Core\Database\DatabaseConnection
;
21 use TYPO3\CMS\Core\Imaging\Icon
;
22 use TYPO3\CMS\Core\Imaging\IconFactory
;
23 use TYPO3\CMS\Core\Messaging\FlashMessage
;
24 use TYPO3\CMS\Core\Messaging\FlashMessageService
;
25 use TYPO3\CMS\Core\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
;
34 * Child class for the Web > Page module
36 class PageLayoutView
extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList
39 * If TRUE, users/groups are shown in the page info box.
43 public $pI_showUser = 0;
46 * The number of successive records to edit when showing content elements.
50 public $nextThree = 3;
53 * If TRUE, disables the edit-column icon for tt_content elements
57 public $pages_noEditColumns = 0;
60 * If TRUE, new-wizards are linked to rather than the regular new-element list.
64 public $option_newWizard = 1;
67 * If set to "1", will link a big button to content element wizard.
71 public $ext_function = 0;
74 * If TRUE, elements will have edit icons (probably this is whether the user has permission to edit the page content). Set externally.
81 * Age prefixes for displaying times. May be set externally to localized values.
85 public $agePrefixes = ' min| hrs| days| yrs| min| hour| day| year';
88 * Array of tables to be listed by the Web > Page module in addition to the default tables.
92 public $externalTables = array();
95 * "Pseudo" Description -table name
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!
107 public $defLangBinding = false;
110 * External, static: Configuration of tt_content element display:
114 public $tt_contentConfig = array(
115 // Boolean: Display info-marks or not
117 // Boolean: Display up/down arrows and edit icons for tt_content records
121 'languageColsPointer' => 0,
123 // Displays hidden records as well
124 'sys_language_uid' => 0,
127 'activeCols' => '1,0,2,3'
128 // Which columns can be accessed by current BE user
132 * Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
136 public $activeTables = array();
141 public $tt_contentData = array(
142 'nextThree' => array(),
148 * Used to store labels for CTypes for tt_content elements
152 public $CType_labels = array();
155 * Used to store labels for the various fields in tt_content elements
159 public $itemLabels = array();
162 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
164 protected $clipboard;
169 protected $plusPages = array();
176 public $ext_CALC_PERMS;
179 * Current ids page record
186 * Caches the available languages in a colPos
190 protected $languagesInColumnCache = array();
193 * Caches the amount of content elements as a matrix
198 protected $contentElementCache = array();
203 protected $iconFactory;
206 * Stores whether a certain language has translations in it
210 protected $languageHasTranslationsCache = array();
213 * Construct to initialize class variables.
215 public function __construct()
217 parent
::__construct();
218 $this->iconFactory
= GeneralUtility
::makeInstance(IconFactory
::class);
219 $pageRenderer = GeneralUtility
::makeInstance(PageRenderer
::class);
220 $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
221 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
222 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Localization');
225 /*****************************************
229 *****************************************/
231 * Adds the code of a single table
233 * @param string $table Table name
234 * @param int $id Current page id
235 * @param string $fields
236 * @return string HTML for listing.
238 public function getTable($table, $id, $fields = '')
240 if (isset($this->externalTables
[$table])) {
241 return $this->getExternalTables($id, $table);
243 // Branch out based on table name:
246 return $this->getTable_pages($id);
249 return $this->getTable_tt_content($id);
258 * Renders an external table from page id
260 * @param int $id Page id
261 * @param string $table Name of the table
262 * @return string HTML for the listing
264 public function getExternalTables($id, $table)
266 $type = $this->getPageLayoutController()->MOD_SETTINGS
[$table];
270 // eg. "name;title;email;company,image"
271 $fList = $this->externalTables
[$table][$type]['fList'];
272 // The columns are separeted by comma ','.
273 // Values separated by semicolon ';' are shown in the same column.
274 $icon = $this->externalTables
[$table][$type]['icon'];
275 $addWhere = $this->externalTables
[$table][$type]['addWhere'];
277 $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
282 * Renders records from the pages table from page id
283 * (Used to get information about the page tree content by "Web>Info"!)
285 * @param int $id Page id
286 * @return string HTML for the listing
288 public function getTable_pages($id)
292 // Select clause for pages:
293 $delClause = BackendUtility
::deleteClause('pages') . ' AND ' . $this->getBackendUser()->getPagePermsClause(1);
294 // Select current page:
296 // The root has a pseudo record in pageinfo...
297 $row = $this->getPageLayoutController()->pageinfo
;
299 $result = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'uid=' . (int)$id . $delClause);
300 $row = $this->getDatabase()->sql_fetch_assoc($result);
301 BackendUtility
::workspaceOL('pages', $row);
303 // If there was found a page:
304 if (is_array($row)) {
305 // Select which fields to show:
306 $pKey = $this->getPageLayoutController()->MOD_SETTINGS
['pages'];
309 $this->fieldArray
= array('title','uid') +
array_keys($this->cleanTableNames());
312 $this->fieldArray
= array(
326 $this->fieldArray
= array(
339 // Getting select-depth:
340 $depth = (int)$this->getPageLayoutController()->MOD_SETTINGS
['pages_levels'];
341 // Overriding a few things:
342 $this->no_noWrap
= 0;
344 $this->eCounter
= $this->firstElementNumber
;
345 // Creating elements:
346 list($flag, $code) = $this->fwd_rwd_nav();
352 $theRows = $this->pages_getTree($theRows, $row['uid'], $delClause . BackendUtility
::versioningPlaceholderClause('pages'), '', $depth);
353 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
354 $editUids[] = $row['uid'];
356 $out .= $this->pages_drawItem($row, $this->fieldArray
);
357 // Traverse all pages selected:
358 foreach ($theRows as $sRow) {
359 if ($this->getBackendUser()->doesUserHaveAccess($sRow, 2)) {
360 $editUids[] = $sRow['uid'];
362 $out .= $this->pages_drawItem($sRow, $this->fieldArray
);
366 // Header line is drawn
368 $editIdList = implode(',', $editUids);
369 // Traverse fields (as set above) in order to create header values:
370 foreach ($this->fieldArray
as $field) {
371 if ($editIdList && isset($GLOBALS['TCA']['pages']['columns'][$field]) && $field != 'uid' && !$this->pages_noEditColumns
) {
373 $this->getLanguageService()->getLL('editThisColumn'),
374 rtrim(trim($this->getLanguageService()->sL(BackendUtility
::getItemLabel('pages', $field))), ':')
379 $editIdList => 'edit'
382 'columnsOnly' => $field,
383 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
385 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
386 $eI = '<a href="' . htmlspecialchars($url)
387 . '" title="' . htmlspecialchars($iTitle) . '">'
388 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
394 $theData[$field] = ' <strong>'
395 . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'])
399 $theData[$field] = ' <strong>ID:</strong>';
402 if (substr($field, 0, 6) == 'table_') {
403 $f2 = substr($field, 6);
404 if ($GLOBALS['TCA'][$f2]) {
405 $theData[$field] = ' ' . '<span title="' . $this->getLanguageService()->sL($GLOBALS['TCA'][$f2]['ctrl']['title'], true) . '">' . $this->iconFactory
->getIconForRecord($f2, array(), Icon
::SIZE_SMALL
)->render() . '</span>';
408 $theData[$field] = ' <strong>'
409 . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'], true)
415 $out = BackendUtility
::cshItem($this->descrTable
, ('func_' . $pKey)) . '
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 $this->pageinfo
= BackendUtility
::readPageAccess($this->id
, '');
440 $this->initializeLanguages();
441 $this->initializeClipboard();
442 $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility
::getRecordTitle('pages', BackendUtility
::getRecordWSOL('pages', $id), true));
443 /** @var $pageRenderer PageRenderer */
444 $pageRenderer = GeneralUtility
::makeInstance(PageRenderer
::class);
445 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
446 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
447 $userCanEditPage = $this->ext_CALC_PERMS
& Permission
::PAGE_EDIT
&& !empty($this->id
) && ($backendUser->isAdmin() ||
(int)$this->pageinfo
['editlock'] === 0);
448 if ($this->tt_contentConfig
['languageColsPointer'] > 0) {
449 $userCanEditPage = $this->getBackendUser()->check('tables_modify', 'pages_language_overlay');
451 if ($userCanEditPage) {
452 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) {
453 PageActions.setPageId(' . (int)$this->id
. ');
454 PageActions.setLanguageOverlayId(' . $this->tt_contentConfig
['languageColsPointer'] . ');
455 PageActions.initializePageTitleRenaming();
458 // Get labels for CTypes and tt_content element fields in general:
459 $this->CType_labels
= array();
460 foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
461 $this->CType_labels
[$val[1]] = $this->getLanguageService()->sL($val[0]);
463 $this->itemLabels
= array();
464 foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
465 $this->itemLabels
[$name] = $this->getLanguageService()->sL($val['label']);
467 $languageColumn = array();
470 // Setting language list:
471 $langList = $this->tt_contentConfig
['sys_language_uid'];
472 if ($this->tt_contentConfig
['languageMode']) {
473 if ($this->tt_contentConfig
['languageColsPointer']) {
474 $langList = '0,' . $this->tt_contentConfig
['languageColsPointer'];
476 $langList = implode(',', array_keys($this->tt_contentConfig
['languageCols']));
478 $languageColumn = array();
480 $langListArr = GeneralUtility
::intExplode(',', $langList);
481 $defLanguageCount = array();
482 $defLangBinding = array();
483 // For each languages... :
484 // If not languageMode, then we'll only be through this once.
485 foreach ($langListArr as $lP) {
488 if (!isset($this->contentElementCache
[$lP])) {
489 $this->contentElementCache
[$lP] = array();
492 if (count($langListArr) === 1 ||
$lP === 0) {
493 $showLanguage = ' AND sys_language_uid IN (' . $lP . ',-1)';
495 $showLanguage = ' AND sys_language_uid=' . $lP;
497 $cList = explode(',', $this->tt_contentConfig
['cols']);
501 // Select content records per column
502 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showLanguage);
503 // For each column, render the content into a variable:
504 foreach ($cList as $key) {
505 if (!isset($this->contentElementCache
[$lP][$key])) {
506 $this->contentElementCache
[$lP][$key] = array();
510 $defLanguageCount[$key] = array();
512 // Start wrapping div
513 $content[$key] .= '<div data-colpos="' . $key . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
514 if (empty($contentRecordsPerColumn[$key])) {
515 $content[$key] .= ' t3-page-ce-empty';
517 $content[$key] .= '">';
518 // Add new content at the top most position
520 if ($this->getPageLayoutController()->pageIsNotLockedForEditors()
521 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)
522 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
524 if ($this->option_newWizard
) {
527 'sys_language_uid' => $lP,
530 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
532 $url = BackendUtility
::getModuleUrl('new_content_element', $urlParameters);
543 'sys_language_uid' => $lP
546 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
548 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
551 $link = '<a href="' . htmlspecialchars($url) . '" title="'
552 . $this->getLanguageService()->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">'
553 . $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
)->render()
555 . $this->getLanguageService()->getLL('content', true) . '</a>';
558 <div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . StringUtility
::getUniqueId() . '">
559 <div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id . '-' . StringUtility
::getUniqueId() . '">'
562 <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
566 if (!isset($contentRecordsPerColumn[$key]) ||
!is_array($contentRecordsPerColumn[$key])) {
567 $message = GeneralUtility
::makeInstance(
569 $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:error.invalidBackendLayout'),
571 FlashMessage
::WARNING
573 $service = GeneralUtility
::makeInstance(FlashMessageService
::class);
574 $queue = $service->getMessageQueueByIdentifier();
575 $queue->addMessage($message);
577 $rowArr = $contentRecordsPerColumn[$key];
578 $this->generateTtContentDataArray($rowArr);
580 foreach ((array)$rowArr as $rKey => $row) {
581 $this->contentElementCache
[$lP][$key][$row['uid']] = $row;
582 if ($this->tt_contentConfig
['languageMode']) {
583 $languageColumn[$key][$lP] = $head[$key] . $content[$key];
584 if (!$this->defLangBinding
) {
585 $languageColumn[$key][$lP] .= $this->newLanguageButton(
586 $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
592 if (is_array($row) && !VersionState
::cast($row['t3ver_state'])->equals(VersionState
::DELETE_PLACEHOLDER
)) {
593 $singleElementHTML = '';
594 if (!$lP && ($this->defLangBinding ||
$row['sys_language_uid'] != -1)) {
595 $defLanguageCount[$key][] = (isset($row['_ORIG_uid']) ?
$row['_ORIG_uid'] : $row['uid']);
597 $editUidList .= $row['uid'] . ',';
598 $disableMoveAndNewButtons = $this->defLangBinding
&& $lP > 0;
599 if (!$this->tt_contentConfig
['languageMode']) {
600 $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . StringUtility
::getUniqueId() . '">';
602 $singleElementHTML .= $this->tt_content_drawHeader(
604 $this->tt_contentConfig
['showInfo'] ?
15 : 5,
605 $disableMoveAndNewButtons,
606 !$this->tt_contentConfig
['languageMode'],
607 $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)
609 $innerContent = '<div ' . ($row['_ORIG_uid'] ?
' class="ver-element"' : '') . '>'
610 . $this->tt_content_drawItem($row) . '</div>';
611 $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div>'
612 . $this->tt_content_drawFooter($row);
613 $isDisabled = $this->isDisabled('tt_content', $row);
614 $statusHidden = $isDisabled ?
' t3-page-ce-hidden t3js-hidden-record' : '';
615 $displayNone = !$this->tt_contentConfig
['showHidden'] && $isDisabled ?
' style="display: none;"' : '';
616 $highlightHeader = false;
617 if ($this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid']) && (int)$row['l18n_parent'] === 0) {
618 $highlightHeader = true;
620 $singleElementHTML = '<div class="t3-page-ce ' . ($highlightHeader ?
't3-page-ce-danger' : '') . ' t3js-page-ce t3js-page-ce-sortable ' . $statusHidden . '" id="element-tt_content-'
621 . $row['uid'] . '" data-table="tt_content" data-uid="' . $row['uid'] . '"' . $displayNone . '>' . $singleElementHTML . '</div>';
623 if ($this->tt_contentConfig
['languageMode']) {
624 $singleElementHTML .= '<div class="t3-page-ce t3js-page-ce">';
626 $singleElementHTML .= '<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id .
627 '-' . StringUtility
::getUniqueId() . '">';
628 // Add icon "new content element below"
629 if (!$disableMoveAndNewButtons
630 && $this->getPageLayoutController()->pageIsNotLockedForEditors()
631 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)
632 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
634 // New content element:
635 if ($this->option_newWizard
) {
638 'sys_language_uid' => $row['sys_language_uid'],
639 'colPos' => $row['colPos'],
640 'uid_pid' => -$row['uid'],
641 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
643 $url = BackendUtility
::getModuleUrl('new_content_element', $urlParameters);
648 -$row['uid'] => 'new'
651 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
653 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
655 $singleElementHTML .= '
656 <a href="' . htmlspecialchars($url) . '" title="'
657 . $this->getLanguageService()->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">'
658 . $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
)->render()
660 . $this->getLanguageService()->getLL('content', true) . '</a>
663 $singleElementHTML .= '</div></div><div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div></div>';
664 if ($this->defLangBinding
&& $this->tt_contentConfig
['languageMode']) {
665 $defLangBinding[$key][$lP][$row[$lP ?
'l18n_parent' : 'uid']] = $singleElementHTML;
667 $content[$key] .= $singleElementHTML;
670 unset($rowArr[$rKey]);
673 $content[$key] .= '</div>';
674 $colTitle = BackendUtility
::getProcessedValue('tt_content', 'colPos', $key);
675 $tcaItems = GeneralUtility
::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView
::class . '->getColPosListItemsParsed', $id, $this);
676 foreach ($tcaItems as $item) {
677 if ($item[1] == $key) {
678 $colTitle = $this->getLanguageService()->sL($item[0]);
682 $pasteP = array('colPos' => $key, 'sys_language_uid' => $lP);
683 $editParam = $this->doEdit
&& !empty($rowArr)
684 ?
'&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
686 $head[$key] .= $this->tt_content_drawColHeader($colTitle, $editParam, '', $pasteP);
689 // For each column, fit the rendered content into a table cell:
691 if ($this->tt_contentConfig
['languageMode']) {
692 // in language mode process the content elements, but only fill $languageColumn. output will be generated later
693 $sortedLanguageColumn = array();
694 foreach ($cList as $key) {
695 $languageColumn[$key][$lP] = $head[$key] . $content[$key];
696 if (!$this->defLangBinding
) {
697 $languageColumn[$key][$lP] .= $this->newLanguageButton(
698 $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
703 // We sort $languageColumn again according to $cList as it may contain data already from above.
704 $sortedLanguageColumn[$key] = $languageColumn[$key];
706 $languageColumn = $sortedLanguageColumn;
708 $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id
);
710 $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">';
712 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
713 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
714 $grid .= '<colgroup>';
715 for ($i = 0; $i < $colCount; $i++
) {
716 $grid .= '<col style="width:' . 100 / $colCount . '%"></col>';
718 $grid .= '</colgroup>';
719 // Cycle through rows
720 for ($row = 1; $row <= $rowCount; $row++
) {
721 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
722 if (!isset($rowConfig)) {
726 for ($col = 1; $col <= $colCount; $col++
) {
727 $columnConfig = $rowConfig['columns.'][$col . '.'];
728 if (!isset($columnConfig)) {
731 // Which tt_content colPos should be displayed inside this cell
732 $columnKey = (int)$columnConfig['colPos'];
733 // Render the grid cell
734 $colSpan = (int)$columnConfig['colspan'];
735 $rowSpan = (int)$columnConfig['rowspan'];
736 $grid .= '<td valign="top"' .
737 ($colSpan > 0 ?
' colspan="' . $colSpan . '"' : '') .
738 ($rowSpan > 0 ?
' rowspan="' . $rowSpan . '"' : '') .
739 ' 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 .
740 ((!isset($columnConfig['colPos']) ||
$columnConfig['colPos'] === '') ?
' t3-grid-cell-unassigned' : '') .
741 ((isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !$head[$columnKey]) ||
!GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos']) ?
' t3-grid-cell-restricted' : '') .
742 ($colSpan > 0 ?
' t3-gridCell-width' . $colSpan : '') .
743 ($rowSpan > 0 ?
' t3-gridCell-height' . $rowSpan : '') . '">';
745 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
746 // If not, a new header without any buttons will be generated.
747 if (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey]
748 && GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
750 $grid .= $head[$columnKey] . $content[$columnKey];
751 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
752 && GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
754 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'), '', '');
755 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
756 && !GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
758 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
759 ' (' . $this->getLanguageService()->getLL('noAccess') . ')', '', '');
760 } elseif (isset($columnConfig['name']) && $columnConfig['name'] !== '') {
761 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
762 . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '');
764 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'), '', '');
771 $out .= $grid . '</table></div>';
774 $out .= BackendUtility
::cshItem($this->descrTable
, 'columns_multi');
776 // If language mode, then make another presentation:
777 // Notice that THIS presentation will override the value of $out!
778 // But it needs the code above to execute since $languageColumn is filled with content we need!
779 if ($this->tt_contentConfig
['languageMode']) {
780 // Get language selector:
781 $languageSelector = $this->languageSelector($id);
782 // Reset out - we will make new content here:
784 // Traverse languages found on the page and build up the table displaying them side by side:
787 foreach ($langListArr as $lP) {
791 <td valign="top" class="t3-page-column" data-language-uid="' . $lP . '">
792 <h2>' . htmlspecialchars($this->tt_contentConfig
['languageCols'][$lP]) . '</h2>
795 // "View page" icon is added:
797 if (!VersionState
::cast($this->getPageLayoutController()->pageinfo
['t3ver_state'])->equals(VersionState
::DELETE_PLACEHOLDER
)) {
798 $onClick = BackendUtility
::viewOnClick($this->id
, '', BackendUtility
::BEgetRootLine($this->id
), '', '', ('&L=' . $lP));
799 $viewLink = '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true) . '">' . $this->iconFactory
->getIcon('actions-view', Icon
::SIZE_SMALL
)->render() . '</a>';
801 // Language overlay page header:
803 list($lpRecord) = BackendUtility
::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . $lP);
804 BackendUtility
::workspaceOL('pages_language_overlay', $lpRecord);
805 $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
806 $recordIcon = BackendUtility
::wrapClickMenuOnIcon(
807 $this->iconFactory
->getIconForRecord('pages_language_overlay', $lpRecord, Icon
::SIZE_SMALL
)->render(),
808 'pages_language_overlay',
813 'pages_language_overlay' => [
814 $lpRecord['uid'] => 'edit'
818 'pages_language_overlay' => [
819 'sys_language_uid' => $lP
822 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
824 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
825 $editLink = ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
826 ?
'<a href="' . htmlspecialchars($url) . '" class="btn btn-default btn-sm"'
827 . ' title="' . $this->getLanguageService()->getLL('edit', true) . '">'
828 . $this->iconFactory
->getIcon('actions-open', Icon
::SIZE_SMALL
)->render() . '</a>'
833 '<div class="btn-group">'
837 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($lpRecord['title'], 20));
841 if ($this->getBackendUser()->checkLanguageAccess(0)) {
842 $recordIcon = BackendUtility
::wrapClickMenuOnIcon(
843 $this->iconFactory
->getIconForRecord('pages', $this->pageRecord
,
844 Icon
::SIZE_SMALL
)->render(),
854 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
856 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
857 $editLink = ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
858 ?
'<a href="' . htmlspecialchars($url) . '" class="btn btn-default btn-sm"'
859 . ' title="' . $this->getLanguageService()->getLL('edit', true) . '">'
860 . $this->iconFactory
->getIcon('actions-open', Icon
::SIZE_SMALL
)->render() . '</a>'
866 '<div class="btn-group">'
870 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($this->pageRecord
['title'], 20));
873 <td nowrap="nowrap" class="t3-page-column t3-page-lang-label">' . $lPLabel . '</td>';
876 $out .= '<tr>' . implode($cCont) . '</tr>';
877 $out .= '<tr>' . implode($sCont) . '</tr>';
878 unset($cCont, $sCont);
880 // Traverse previously built content for the columns:
881 foreach ($languageColumn as $cKey => $cCont) {
883 foreach ($cCont as $languageId => $columnContent) {
884 $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>';
887 if ($this->defLangBinding
) {
888 // "defLangBinding" mode
889 foreach ($defLanguageCount[$cKey] as $defUid) {
891 foreach ($langListArr as $lP) {
892 $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton(
893 $this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP),
900 <td valign="top" class="t3-grid-cell">' . implode(('</td>' . '
901 <td valign="top" class="t3-grid-cell">'), $cCont) . '</td>
906 // Finally, wrap it all in a table and add the language selector on top of it:
907 $out = $languageSelector . '
908 <div class="t3-grid-container">
909 <table cellpadding="0" cellspacing="0" class="t3-page-columns t3-grid-table t3js-page-columns">
914 $out .= BackendUtility
::cshItem($this->descrTable
, 'language_list');
920 /**********************************
922 * Generic listing of items
924 **********************************/
926 * Creates a standard list of elements from a table.
928 * @param string $table Table name
929 * @param int $id Page id.
930 * @param string $fList Comma list of fields to display
931 * @param bool $icon If TRUE, icon is shown
932 * @param string $addWhere Additional WHERE-clauses.
933 * @return string HTML table
935 public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = '')
938 $queryParts = $this->makeQueryArray($table, $id, $addWhere);
939 $this->setTotalItems($queryParts);
942 // Make query for records if there were any records found in the count operation
943 if ($this->totalItems
) {
944 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
945 // Will return FALSE, if $result is invalid
946 $dbCount = $this->getDatabase()->sql_num_rows($result);
948 // If records were found, render the list
954 $this->fieldArray
= GeneralUtility
::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', true);
956 $theData = $this->headerFields($this->fieldArray
, $table, $theData);
958 $localizedTableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title'], true);
959 $out .= '<tr class="t3-row-header">' . '<th class="col-icon"></th>'
960 . '<th colspan="' . (count($theData) - 2) . '"><span class="c-table">'
961 . $localizedTableTitle . '</span> (' . $dbCount . ')</td>' . '<td class="col-icon"></td>'
971 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
973 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
974 $theData['__cmds__'] = '<a href="' . htmlspecialchars($url) . '" '
975 . 'title="' . $this->getLanguageService()->getLL('new', true) . '">'
976 . $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
)->render() . '</a>';
978 $out .= $this->addElement(1, '', $theData, ' class="c-headLine"', 15, '', 'th');
980 $this->eCounter
= $this->firstElementNumber
;
981 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
982 BackendUtility
::workspaceOL($table, $row);
983 if (is_array($row)) {
984 list($flag, $code) = $this->fwd_rwd_nav();
988 // Setting icons links
990 $Nrow['__cmds__'] = $this->getIcon($table, $row);
993 $Nrow = $this->dataFields($this->fieldArray
, $table, $row, $Nrow);
995 if ($this->doEdit
&& $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)) {
1002 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1004 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
1005 $Nrow['__editIconLink__'] = '<a href="' . htmlspecialchars($url)
1006 . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">'
1007 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1009 $Nrow['__editIconLink__'] = $this->noEditIcon();
1011 $out .= $this->addElement(1, '', $Nrow);
1016 $this->getDatabase()->sql_free_result($result);
1017 // Wrap it all in a table:
1020 Standard list of table "' . $table . '"
1022 <div class="table-fit"><table class="table table-striped">
1029 * Adds content to all data fields in $out array
1031 * Each field name in $fieldArr has a special feature which is that the field name can be specified as more field names.
1032 * Eg. "field1,field2;field3".
1033 * Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
1035 * @param array $fieldArr Array of fields to display
1036 * @param string $table Table name
1037 * @param array $row Record array
1038 * @param array $out Array to which the data is added
1039 * @return array $out array returned after processing.
1040 * @see makeOrdinaryList()
1042 public function dataFields($fieldArr, $table, $row, $out = array())
1044 // Check table validity
1045 if (!isset($GLOBALS['TCA'][$table])) {
1049 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
1051 foreach ($fieldArr as $fieldName) {
1052 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
1053 // Each field has its own cell (if configured in TCA)
1054 // If the column is a thumbnail column:
1055 if ($fieldName == $thumbsCol) {
1056 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
1058 // ... otherwise just render the output:
1059 $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility
::fixed_lgd_cs(
1060 BackendUtility
::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
1065 // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
1066 // the field name with ";" and check each value there as a TCA configured field)
1067 $theFields = explode(';', $fieldName);
1068 // Traverse fields, separated by ";" (displayed in a single cell).
1069 foreach ($theFields as $fName2) {
1070 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
1071 $out[$fieldName] .= '<strong>' . $this->getLanguageService()->sL(
1072 $GLOBALS['TCA'][$table]['columns'][$fName2]['label'],
1074 ) . '</strong>' . ' ' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs(
1075 BackendUtility
::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
1081 // If no value, add a nbsp.
1082 if (!$out[$fieldName]) {
1083 $out[$fieldName] = ' ';
1085 // Wrap in dimmed-span tags if record is "disabled"
1086 if ($this->isDisabled($table, $row)) {
1087 $out[$fieldName] = '<span class="text-muted">' . $out[$fieldName] . '</span>';
1094 * Header fields made for the listing of records
1096 * @param array $fieldArr Field names
1097 * @param string $table The table name
1098 * @param array $out Array to which the headers are added.
1099 * @return array $out returned after addition of the header fields.
1100 * @see makeOrdinaryList()
1102 public function headerFields($fieldArr, $table, $out = array())
1104 foreach ($fieldArr as $fieldName) {
1105 $ll = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label'], true);
1106 $out[$fieldName] = $ll ?
$ll : ' ';
1112 * Gets content records per column.
1113 * This is required for correct workspace overlays.
1115 * @param string $table UNUSED (will always be queried from tt_content)
1116 * @param int $id Page Id to be used (not used at all, but part of the API, see $this->pidSelect)
1117 * @param array $columns colPos values to be considered to be shown
1118 * @param string $additionalWhereClause Additional where clause for database select
1119 * @return array Associative array for each column (colPos)
1121 protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '')
1123 $columns = array_map('intval', $columns);
1124 $contentRecordsPerColumn = array_fill_keys($columns, array());
1126 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos IN (' . implode(',', $columns) . ')' . $additionalWhereClause);
1127 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1128 // Traverse any selected elements and render their display code:
1129 $rowArr = $this->getResult($result);
1131 foreach ($rowArr as $record) {
1132 $columnValue = $record['colPos'];
1133 $contentRecordsPerColumn[$columnValue][] = $record;
1136 return $contentRecordsPerColumn;
1139 /**********************************
1141 * Additional functions; Pages
1143 **********************************/
1145 * Adds pages-rows to an array, selecting recursively in the page tree.
1147 * @param array $theRows Array which will accumulate page rows
1148 * @param int $pid Pid to select from
1149 * @param string $qWhere Query-where clause
1150 * @param string $treeIcons Prefixed icon code.
1151 * @param int $depth Depth (decreasing)
1152 * @return array $theRows, but with added rows.
1154 public function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth)
1158 $res = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'pid=' . (int)$pid . $qWhere, '', 'sorting');
1160 $rc = $this->getDatabase()->sql_num_rows($res);
1161 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1162 BackendUtility
::workspaceOL('pages', $row);
1163 if (is_array($row)) {
1165 $row['treeIcons'] = $treeIcons . '<span class="treeline-icon treeline-icon-join' . ($rc === $c ?
'bottom' : '') . '"></span>';
1168 $spaceOutIcons = '<span class="treeline-icon treeline-icon-' . ($rc === $c ?
'clear' : 'line') . '"></span>';
1169 $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons, $row['php_tree_stop'] ?
0 : $depth);
1173 $count = $this->getDatabase()->exec_SELECTcountRows('uid', 'pages', 'pid=' . (int)$pid . $qWhere);
1175 $this->plusPages
[$pid] = $count;
1182 * Adds a list item for the pages-rendering
1184 * @param array $row Record array
1185 * @param array $fieldArr Field list
1186 * @return string HTML for the item
1188 public function pages_drawItem($row, $fieldArr)
1191 $theIcon = $this->getIcon('pages', $row);
1192 // Preparing and getting the data-array
1194 foreach ($fieldArr as $field) {
1197 $red = $this->plusPages
[$row['uid']] ?
'<span class="text-danger"><strong>+</strong></span>' : '';
1198 $pTitle = htmlspecialchars(BackendUtility
::getProcessedValue('pages', $field, $row[$field], 20));
1200 $pTitle = '<a href="'
1201 . htmlspecialchars($this->script
. ((strpos($this->script
, '?') !== false) ?
'&' : '?')
1202 . 'id=' . $row['uid']) . '">' . $pTitle . '</a>';
1204 $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . ' ';
1206 case 'php_tree_stop':
1207 // Intended fall through
1209 $theData[$field] = $row[$field] ?
' <strong>x</strong>' : ' ';
1212 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
1216 $row['uid'] => 'edit'
1219 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1221 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
1222 $eI = '<a href="' . htmlspecialchars($url)
1223 . '" title="' . $this->getLanguageService()->getLL('editThisPage', true) . '">'
1224 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1228 $theData[$field] = '<span align="right">' . $row['uid'] . $eI . '</span>';
1231 case 'shortcut_mode':
1232 if ((int)$row['doktype'] === \TYPO3\CMS\Frontend\Page\PageRepository
::DOKTYPE_SHORTCUT
) {
1233 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1237 if (substr($field, 0, 6) == 'table_') {
1238 $f2 = substr($field, 6);
1239 if ($GLOBALS['TCA'][$f2]) {
1240 $c = $this->numberOfRecords($f2, $row['uid']);
1241 $theData[$field] = ' ' . ($c ?
$c : '');
1244 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1248 $this->addElement_tdParams
['title'] = $row['_CSSCLASS'] ?
' class="' . $row['_CSSCLASS'] . '"' : '';
1249 return $this->addElement(1, '', $theData);
1253 * Returns the HTML code for rendering a field in the pages table.
1254 * The row value is processed to a human readable form and the result is parsed through htmlspecialchars().
1256 * @param string $field The name of the field of which the value should be rendered.
1257 * @param array $row The pages table row as an associative array.
1258 * @return string The rendered table field value.
1260 protected function getPagesTableFieldValue($field, array $row)
1262 return ' ' . htmlspecialchars(BackendUtility
::getProcessedValue('pages', $field, $row[$field]));
1265 /**********************************
1267 * Additional functions; Content Elements
1269 **********************************/
1271 * Draw header for a content element column:
1273 * @param string $colName Column name
1274 * @param string $editParams Edit params (Syntax: &edit[...] for FormEngine)
1275 * @param string $newParams New element params (Syntax: &edit[...] for FormEngine) OBSOLETE
1276 * @param array|NULL $pasteParams Paste element params (i.e. array(colPos => 1, sys_language_uid => 2))
1277 * @return string HTML table
1279 public function tt_content_drawColHeader($colName, $editParams, $newParams, array $pasteParams = null)
1281 $iconsArr = array();
1282 // Create command links:
1283 if ($this->tt_contentConfig
['showCommands']) {
1284 // Edit whole of column:
1285 if ($editParams && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
) && $this->getBackendUser()->checkLanguageAccess(0)) {
1286 $iconsArr['edit'] = '<a href="#" onclick="'
1287 . htmlspecialchars(BackendUtility
::editOnClick($editParams)) . '" title="'
1288 . $this->getLanguageService()->getLL('editColumn', true) . '">'
1289 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1292 $elFromTable = $this->clipboard
->elFromTable('tt_content');
1293 if (!empty($elFromTable) && $this->getPageLayoutController()->pageIsNotLockedForEditors()) {
1294 $iconsArr['paste'] = '<a href="'
1295 . htmlspecialchars($this->clipboard
->pasteUrl('tt_content', $this->id
, true, $pasteParams))
1296 . '" onclick="' . htmlspecialchars(('return '
1297 . $this->clipboard
->confirmMsg('pages', $this->pageRecord
, 'into', $elFromTable, $colName)))
1298 . '" title="' . $this->getLanguageService()->getLL('pasteIntoColumn', true) . '">'
1299 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render() . '</a>';
1304 if (!empty($iconsArr)) {
1305 $icons = '<div class="t3-page-column-header-icons">' . implode('', $iconsArr) . '</div>';
1307 // Create header row:
1308 $out = '<div class="t3-page-column-header">
1310 <div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
1316 * Draw the footer for a single tt_content element
1318 * @param array $row Record array
1319 * @return string HTML of the footer
1320 * @throws \UnexpectedValueException
1322 protected function tt_content_drawFooter(array $row)
1325 // Get processed values:
1327 $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
1329 // Content element annotation
1330 if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn'])) {
1331 $info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]);
1334 // Call drawFooter hooks
1335 $drawFooterHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'];
1336 if (is_array($drawFooterHooks)) {
1337 foreach ($drawFooterHooks as $hookClass) {
1338 $hookObject = GeneralUtility
::getUserObj($hookClass);
1339 if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface
) {
1340 throw new \
UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\View\\PageLayoutViewDrawFooterHookInterface', 1404378171);
1342 $hookObject->preProcess($this, $info, $row);
1346 // Display info from records fields:
1347 if (!empty($info)) {
1348 $content = '<div class="t3-page-ce-info">
1349 ' . implode('<br>', $info) . '
1353 if (!empty($content)) {
1354 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1360 * Draw the header for a single tt_content element
1362 * @param array $row Record array
1363 * @param int $space Amount of pixel space above the header. UNUSED
1364 * @param bool $disableMoveAndNewButtons If set the buttons for creating new elements and moving up and down are not shown.
1365 * @param bool $langMode If set, we are in language mode and flags will be shown for languages
1366 * @param bool $dragDropEnabled If set the move button must be hidden
1367 * @return string HTML table with the record header.
1369 public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = false, $langMode = false, $dragDropEnabled = false)
1372 // If show info is set...;
1373 if ($this->tt_contentConfig
['showInfo'] && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1374 // Render control panel for the element:
1375 if ($this->tt_contentConfig
['showCommands'] && $this->doEdit
) {
1376 // Edit content element:
1380 $this->tt_contentData
['nextThree'][$row['uid']] => 'edit'
1383 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1385 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters) . '#element-tt_content-' . $row['uid'];
1387 $out .= '<a class="btn btn-default" href="' . htmlspecialchars($url)
1388 . '" title="' . htmlspecialchars($this->nextThree
> 1
1389 ?
sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree
)
1390 : $this->getLanguageService()->getLL('edit'))
1391 . '">' . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1393 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1394 if ($hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1395 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1396 ||
$this->getBackendUser()->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1398 if ($row[$hiddenField]) {
1405 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ?
$row['_ORIG_uid'] : $row['uid'])
1406 . '][' . $hiddenField . ']=' . $value;
1407 $out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility
::getLinkToDataHandlerAction($params))
1408 . '" title="' . $this->getLanguageService()->getLL($label, true) . '">'
1409 . $this->iconFactory
->getIcon('actions-edit-' . strtolower($label), Icon
::SIZE_SMALL
)->render() . '</a>';
1412 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1413 $confirm = $this->getLanguageService()->getLL('deleteWarning')
1414 . BackendUtility
::translationCount('tt_content', $row['uid'], (' '
1415 . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')));
1416 $out .= '<a class="btn btn-default t3js-modal-trigger" href="' . htmlspecialchars(BackendUtility
::getLinkToDataHandlerAction($params)) . '"'
1417 . ' data-severity="warning"'
1418 . ' data-title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_alt_doc.xlf:label.confirm.delete_record.title')) . '"'
1419 . ' data-content="' . htmlspecialchars($confirm) . '" '
1420 . ' data-button-close-text="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:cancel')) . '"'
1421 . ' title="' . $this->getLanguageService()->getLL('deleteItem', true) . '">'
1422 . $this->iconFactory
->getIcon('actions-edit-delete', Icon
::SIZE_SMALL
)->render() . '</a>';
1423 if ($out && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)) {
1424 $out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>';
1428 if (!$disableMoveAndNewButtons) {
1429 $moveButtonContent = '';
1430 $displayMoveButtons = false;
1432 if ($this->tt_contentData
['prev'][$row['uid']]) {
1433 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData
['prev'][$row['uid']];
1434 $moveButtonContent .= '<a class="btn btn-default" href="'
1435 . htmlspecialchars(BackendUtility
::getLinkToDataHandlerAction($params))
1436 . '" title="' . $this->getLanguageService()->getLL('moveUp', true) . '">'
1437 . $this->iconFactory
->getIcon('actions-move-up', Icon
::SIZE_SMALL
)->render() . '</a>';
1438 if (!$dragDropEnabled) {
1439 $displayMoveButtons = true;
1442 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory
->getIcon('empty-empty', Icon
::SIZE_SMALL
)->render() . '</span>';
1444 // Move element down:
1445 if ($this->tt_contentData
['next'][$row['uid']]) {
1446 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData
['next'][$row['uid']];
1447 $moveButtonContent .= '<a class="btn btn-default" href="'
1448 . htmlspecialchars(BackendUtility
::getLinkToDataHandlerAction($params))
1449 . '" title="' . $this->getLanguageService()->getLL('moveDown', true) . '">'
1450 . $this->iconFactory
->getIcon('actions-move-down', Icon
::SIZE_SMALL
)->render() . '</a>';
1451 if (!$dragDropEnabled) {
1452 $displayMoveButtons = true;
1455 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory
->getIcon('empty-empty', Icon
::SIZE_SMALL
)->render() . '</span>';
1457 if ($displayMoveButtons) {
1458 $out .= '<div class="btn-group btn-group-sm" role="group">' . $moveButtonContent . '</div>';
1463 $allowDragAndDrop = $this->isDragAndDropAllowed($row);
1464 $additionalIcons = array();
1465 if ($row['sys_language_uid'] > 0 && $this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid'])) {
1466 $disabledClickMenuItems = 'new,move';
1467 $allowDragAndDrop = false;
1469 $additionalIcons[] = $this->getIcon('tt_content', $row, $disabledClickMenuItems) . ' ';
1470 $additionalIcons[] = $langMode ?
$this->languageFlag($row['sys_language_uid'], false) : '';
1471 // Get record locking status:
1472 if ($lockInfo = BackendUtility
::isRecordLocked('tt_content', $row['uid'])) {
1473 $additionalIcons[] = '<a href="#" onclick="alert(' . GeneralUtility
::quoteJSvalue($lockInfo['msg'])
1474 . ');return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">'
1475 . $this->iconFactory
->getIcon('status-warning-in-use', Icon
::SIZE_SMALL
)->render() . '</a>';
1477 // Call stats information hook
1478 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1479 $_params = array('tt_content', $row['uid'], &$row);
1480 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1481 $additionalIcons[] = GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
1484 // Wrap the whole header
1485 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
1486 return '<div class="t3-page-ce-header ' . ($allowDragAndDrop ?
't3-page-ce-header-draggable t3js-page-ce-draghandle' : '') . '">
1487 <div class="t3-page-ce-header-icons-left">' . implode('', $additionalIcons) . '</div>
1488 <div class="t3-page-ce-header-icons-right">' . ($out ?
'<div class="btn-toolbar">' . $out . '</div>' : '') . '</div>
1490 <div class="t3-page-ce-body">';
1494 * Determine whether Drag & Drop should be allowed
1499 protected function isDragAndDropAllowed(array $row)
1501 if ($this->getBackendUser()->user
['admin']
1502 ||
((int)$row['editlock'] === 0 && (int)$this->pageinfo
['editlock'] === 0)
1503 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo
, Permission
::CONTENT_EDIT
)
1511 * Draws the preview content for a content element
1513 * @param array $row Content element
1514 * @return string HTML
1515 * @throws \UnexpectedValueException
1517 public function tt_content_drawItem($row)
1523 if ($row['header']) {
1525 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
1526 $hiddenHeaderNote = '';
1527 // If header layout is set to 'hidden', display an accordant note:
1528 if ($row['header_layout'] == 100) {
1529 $hiddenHeaderNote = ' <em>[' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.hidden', true) . ']</em>';
1531 $outHeader = $row['date']
1532 ?
htmlspecialchars($this->itemLabels
['date'] . ' ' . BackendUtility
::date($row['date'])) . '<br />'
1534 $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
1535 . $hiddenHeaderNote . '</strong><br />';
1540 // Hook: Render an own preview of a record
1541 $drawItemHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1542 if (is_array($drawItemHooks)) {
1543 foreach ($drawItemHooks as $hookClass) {
1544 $hookObject = GeneralUtility
::getUserObj($hookClass);
1545 if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface
) {
1546 throw new \
UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface
::class, 1218547409);
1548 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1552 // If the previous hook did not render something,
1553 // then check if a Fluid-based preview template was defined for this CType
1554 // and render it via Fluid. Possible option:
1555 // mod.web_layout.tt_content.preview.media = EXT:site_mysite/Resources/Private/Templates/Preview/Media.html
1557 $tsConfig = BackendUtility
::getModTSconfig($row['pid'], 'mod.web_layout.tt_content.preview');
1558 if (!empty($tsConfig['properties'][$row['CType']])) {
1559 $fluidTemplateFile = $tsConfig['properties'][$row['CType']];
1560 $fluidTemplateFile = GeneralUtility
::getFileAbsFileName($fluidTemplateFile);
1561 if ($fluidTemplateFile) {
1563 /** @var StandaloneView $view */
1564 $view = GeneralUtility
::makeInstance(StandaloneView
::class);
1565 $view->setTemplatePathAndFilename($fluidTemplateFile);
1566 $view->assignMultiple($row);
1567 if (!empty($row['pi_flexform'])) {
1568 /** @var FlexFormService $flexFormService */
1569 $flexFormService = GeneralUtility
::makeInstance(FlexFormService
::class);
1570 $view->assign('pi_flexform_transformed', $flexFormService->convertFlexFormContentToArray($row['pi_flexform']));
1572 $out = $view->render();
1574 } catch (\Exception
$e) {
1575 // Catch any exception to avoid breaking the view
1581 // Draw preview of the item depending on its CType (if not disabled by previous hook):
1583 switch ($row['CType']) {
1585 if ($row['subheader']) {
1586 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
1591 if ($row['bodytext']) {
1592 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1596 if ($row['media']) {
1597 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'media'), $row) . '<br />';
1601 $contentType = $this->CType_labels
[$row['CType']];
1602 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1604 $menuTypeLabel = $this->getLanguageService()->sL(
1605 BackendUtility
::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
1607 $menuTypeLabel = $menuTypeLabel ?
: 'invalid menu type';
1608 $out .= $this->linkEditContent($menuTypeLabel, $row);
1609 if ($row['menu_type'] !== '2' && ($row['pages'] ||
$row['selected_categories'])) {
1610 // Show pages if menu type is not "Sitemap"
1611 $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
1615 if (!empty($row['records'])) {
1616 $shortcutContent = array();
1617 $recordList = explode(',', $row['records']);
1618 foreach ($recordList as $recordIdentifier) {
1619 $split = BackendUtility
::splitTable_Uid($recordIdentifier);
1620 $tableName = empty($split[0]) ?
'tt_content' : $split[0];
1621 $shortcutRecord = BackendUtility
::getRecord($tableName, $split[1]);
1622 if (is_array($shortcutRecord)) {
1623 $icon = $this->iconFactory
->getIconForRecord($tableName, $shortcutRecord, Icon
::SIZE_SMALL
)->render();
1624 $icon = BackendUtility
::wrapClickMenuOnIcon(
1627 $shortcutRecord['uid'],
1630 '+copy,info,edit,view'
1632 $shortcutContent[] = $icon
1633 . htmlspecialchars(BackendUtility
::getRecordTitle($tableName, $shortcutRecord));
1636 $out .= implode('<br />', $shortcutContent) . '<br />';
1642 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1643 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1644 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1645 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1647 if (!empty($hookArr)) {
1648 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1649 foreach ($hookArr as $_funcRef) {
1650 $hookOut .= GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
1653 if ((string)$hookOut !== '') {
1655 } elseif (!empty($row['list_type'])) {
1656 $label = BackendUtility
::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
1657 if (!empty($label)) {
1658 $out .= $this->linkEditContent('<strong>' . $this->getLanguageService()->sL($label, true) . '</strong>', $row) . '<br />';
1660 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
1661 $out .= GeneralUtility
::makeInstance(
1662 FlashMessage
::class,
1663 htmlspecialchars($message),
1665 FlashMessage
::WARNING
1668 } elseif (!empty($row['select_key'])) {
1669 $out .= $this->getLanguageService()->sL(BackendUtility
::getItemLabel('tt_content', 'select_key'), true)
1670 . ' ' . $row['select_key'] . '<br />';
1672 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
1674 $out .= $this->getLanguageService()->sL(
1675 BackendUtility
::getLabelFromItemlist('tt_content', 'pages', $row['pages']),
1680 $contentType = $this->CType_labels
[$row['CType']];
1682 if (isset($contentType)) {
1683 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1684 if ($row['bodytext']) {
1685 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1687 if ($row['image']) {
1688 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'image'), $row) . '<br />';
1692 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'),
1695 $out .= GeneralUtility
::makeInstance(
1696 FlashMessage
::class,
1697 htmlspecialchars($message),
1699 FlashMessage
::WARNING
1706 <span class="exampleContent">' . $out . '</span>';
1708 $out = $outHeader . $out;
1710 if ($this->isDisabled('tt_content', $row)) {
1711 return '<span class="text-muted">' . $out . '</span>';
1718 * Generates a list of selected pages or categories for the CType menu
1720 * @param array $row row from pages
1723 protected function generateListForCTypeMenu(array $row)
1727 // get categories instead of pages
1728 if (strpos($row['menu_type'], 'categorized_') !== false) {
1729 $table = 'sys_category';
1730 $field = 'selected_categories';
1732 if (trim($row[$field]) === '') {
1736 $uidList = explode(',', $row[$field]);
1737 foreach ($uidList as $uid) {
1739 $record = BackendUtility
::getRecord($table, $uid, 'title');
1740 $content .= '<br>' . $record['title'] . ' (' . $uid . ')';
1746 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1747 * Selects across columns, but within in the same PID. Columns are expect to be the same
1748 * for translations and original but this may be a conceptual error (?)
1750 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1751 * @param int $id Page pid
1752 * @param int $lP Sys language UID
1753 * @return array Modified $defLanguageCount
1755 public function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP)
1757 if ($lP && !empty($defLanguageCount)) {
1758 // Select all translations here:
1759 $where = 'sys_language_uid=' . intval($lP) . ' AND l18n_parent IN ('
1760 . implode(',', $defLanguageCount) . ')'
1761 . BackendUtility
::deleteClause('tt_content');
1762 $rowArr = $this->getDatabase()->exec_SELECTgetRows('*', 'tt_content', $where);
1765 $defLanguageCount = array_flip($defLanguageCount);
1766 // Traverse any selected elements and unset original UID if any:
1767 foreach ($rowArr as $row) {
1768 BackendUtility
::workspaceOL('tt_content', $row);
1769 unset($defLanguageCount[$row['l18n_parent']]);
1772 $defLanguageCount = array_keys($defLanguageCount);
1774 return $defLanguageCount;
1778 * Creates button which is used to create copies of records..
1780 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1781 * @param int $lP Sys language UID
1782 * @param int $colPos Column position
1783 * @return string "Copy languages" button, if available.
1785 public function newLanguageButton($defLanguageCount, $lP, $colPos = 0)
1788 if (!$this->doEdit ||
!$lP) {
1793 if (!empty($defLanguageCount)) {
1796 . ' class="btn btn-default t3js-localize"'
1799 . ' value="' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate', true)) . '"'
1800 . ' data-has-elements="' . (int)!empty($this->contentElementCache
[$lP][$colPos]) . '"'
1801 . ' data-table="tt_content"'
1802 . ' data-page-id="' . (int)GeneralUtility
::_GP('id') . '"'
1803 . ' data-language-id="' . $lP . '"'
1804 . ' data-language-name="' . htmlspecialchars($this->tt_contentConfig
['languageCols'][$lP]) . '"'
1805 . ' data-colpos-id="' . $colPos . '"'
1806 . ' data-colpos-name="' . BackendUtility
::getProcessedValue('tt_content', 'colPos', $colPos) . '"'
1810 return '<div class="t3-page-lang-copyce">' . $theNewButton . '</div>';
1814 * Creates onclick-attribute content for a new content element
1816 * @param int $id Page id where to create the element.
1817 * @param int $colPos Preset: Column position value
1818 * @param int $sys_language Preset: Sys langauge value
1819 * @return string String for onclick attribute.
1820 * @see getTable_tt_content()
1822 public function newContentElementOnClick($id, $colPos, $sys_language)
1824 if ($this->option_newWizard
) {
1825 $onClick = 'window.location.href=' . GeneralUtility
::quoteJSvalue(BackendUtility
::getModuleUrl('new_content_element') . '&id=' . $id . '&colPos=' . $colPos
1826 . '&sys_language_uid=' . $sys_language . '&uid_pid=' . $id
1827 . '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI'))) . ';';
1829 $onClick = BackendUtility
::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
1830 . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language);
1836 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
1837 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1839 * @param string $str String to link. Must be prepared for HTML output.
1840 * @param array $row The row.
1841 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1842 * @see getTable_tt_content()
1844 public function linkEditContent($str, $row)
1846 if ($this->doEdit
&& $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1850 $row['uid'] => 'edit'
1853 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1855 $url = BackendUtility
::getModuleUrl('record_edit', $urlParameters);
1857 return '<a href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">' . $str . '</a>';
1864 * Make selector box for creating new translation in a language
1865 * Displays only languages which are not yet present for the current page and
1866 * that are not disabled with page TS.
1868 * @param int $id Page id for which to create a new language (pages_language_overlay record)
1869 * @return string <select> HTML element (if there were items for the box anyways...)
1870 * @see getTable_tt_content()
1872 public function languageSelector($id)
1874 if ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
1875 // First, select all
1876 $res = $this->getPageLayoutController()->exec_languageQuery(0);
1877 $langSelItems = array();
1878 $langSelItems[0] = '
1879 <option value="0"></option>';
1880 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1881 if ($this->getBackendUser()->checkLanguageAccess($row['uid'])) {
1882 $langSelItems[$row['uid']] = '
1883 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1886 // Then, subtract the languages which are already on the page:
1887 $res = $this->getPageLayoutController()->exec_languageQuery($id);
1888 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1889 unset($langSelItems[$row['uid']]);
1891 // Remove disallowed languages
1892 if (count($langSelItems) > 1
1893 && !$this->getBackendUser()->user
['admin']
1894 && $this->getBackendUser()->groupData
['allowed_languages'] !== ''
1896 $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData
['allowed_languages']));
1897 if (!empty($allowed_languages)) {
1898 foreach ($langSelItems as $key => $value) {
1899 if (!isset($allowed_languages[$key]) && $key != 0) {
1900 unset($langSelItems[$key]);
1905 // Remove disabled languages
1906 $modSharedTSconfig = BackendUtility
::getModTSconfig($id, 'mod.SHARED');
1907 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages'])
1908 ? GeneralUtility
::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], true)
1910 if (!empty($langSelItems) && !empty($disableLanguages)) {
1911 foreach ($disableLanguages as $language) {
1912 if ($language != 0 && isset($langSelItems[$language])) {
1913 unset($langSelItems[$language]);
1917 // If any languages are left, make selector:
1918 if (count($langSelItems) > 1) {
1919 $url = BackendUtility
::getModuleUrl('record_edit', array(
1920 'edit[pages_language_overlay][' . $id . ']' => 'new',
1921 'overrideVals[pages_language_overlay][doktype]' => (int)$this->pageRecord
['doktype'],
1922 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1924 $onChangeContent = 'window.location.href=' . GeneralUtility
::quoteJSvalue($url . '&overrideVals[pages_language_overlay][sys_language_uid]=') . '+this.options[this.selectedIndex].value';
1925 return '<div class="form-inline form-inline-spaced">'
1926 . '<div class="form-group">'
1927 . '<label for="createNewLanguage">'
1928 . $this->getLanguageService()->getLL('new_language', true)
1930 . '<select class="form-control input-sm" name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">'
1931 . implode('', $langSelItems)
1932 . '</select></div></div>';
1939 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1941 * @param bool|\mysqli_result|object $result MySQLi result object / DBAL object
1942 * @param string $table Table name defaulting to tt_content
1943 * @return array The selected rows returned in this array.
1945 public function getResult($result, $table = 'tt_content')
1948 // Traverse the result:
1949 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
1950 BackendUtility
::workspaceOL($table, $row, -99, true);
1952 // Add the row to the array:
1956 $this->generateTtContentDataArray($output);
1957 // Return selected records
1961 /********************************
1963 * Various helper functions
1965 ********************************/
1968 * Initializes the clipboard for generating paste links
1972 * @see \TYPO3\CMS\Recordlist\RecordList::main()
1973 * @see \TYPO3\CMS\Backend\Controller\ClickMenuController::main()
1974 * @see \TYPO3\CMS\Filelist\Controller\FileListController::main()
1976 protected function initializeClipboard()
1979 $this->clipboard
= GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard
::class);
1981 // Initialize - reads the clipboard content from the user session
1982 $this->clipboard
->initializeClipboard();
1984 // This locks the clipboard to the Normal for this request.
1985 $this->clipboard
->lockToNormal();
1988 $this->clipboard
->cleanCurrent();
1990 // Save the clipboard content
1991 $this->clipboard
->endClipboard();
1995 * Generates the data for previous and next elements which is needed for movements.
1997 * @param array $rowArray
2000 protected function generateTtContentDataArray(array $rowArray)
2002 if (empty($this->tt_contentData
)) {
2003 $this->tt_contentData
= array(
2004 'nextThree' => array(),
2009 foreach ($rowArray as $key => $value) {
2010 // Create the list of the next three ids (for editing links...)
2011 for ($i = 0; $i < $this->nextThree
; $i++
) {
2012 if (isset($rowArray[$key - $i])
2013 && !GeneralUtility
::inList($this->tt_contentData
['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
2015 $this->tt_contentData
['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
2019 // Create information for next and previous content elements
2020 if (isset($rowArray[$key - 1])) {
2021 if (isset($rowArray[$key - 2])) {
2022 $this->tt_contentData
['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
2024 $this->tt_contentData
['prev'][$value['uid']] = $value['pid'];
2026 $this->tt_contentData
['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
2032 * Counts and returns the number of records on the page with $pid
2034 * @param string $table Table name
2035 * @param int $pid Page id
2036 * @return int Number of records.
2038 public function numberOfRecords($table, $pid)
2041 if ($GLOBALS['TCA'][$table]) {
2042 $where = 'pid=' . (int)$pid . BackendUtility
::deleteClause($table) . BackendUtility
::versioningPlaceholderClause($table);
2043 $count = $this->getDatabase()->exec_SELECTcountRows('uid', $table, $where);
2049 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
2051 * @param string $input Input string
2052 * @return string Output string
2054 public function renderText($input)
2056 $input = strip_tags($input);
2057 $input = GeneralUtility
::fixed_lgd_cs($input, 1500);
2058 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES
, 'UTF-8', false));
2062 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
2064 * @param string $table Table name
2065 * @param array $row Record array
2066 * @param string $enabledClickMenuItems Passthrough to wrapClickMenuOnIcon
2067 * @return string HTML for the icon
2069 public function getIcon($table, $row, $enabledClickMenuItems = '')
2072 $toolTip = BackendUtility
::getRecordToolTip($row, 'tt_content');
2073 $icon = '<span ' . $toolTip . '>' . $this->iconFactory
->getIconForRecord($table, $row, Icon
::SIZE_SMALL
)->render() . '</span>';
2075 // The icon with link
2076 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
2077 $icon = BackendUtility
::wrapClickMenuOnIcon($icon, $table, $row['uid'], true, '', $enabledClickMenuItems);
2083 * Creates processed values for all field names in $fieldList based on values from $row array.
2084 * The result is 'returned' through $info which is passed as a reference
2086 * @param string $table Table name
2087 * @param string $fieldList Comma separated list of fields.
2088 * @param array $row Record from which to take values for processing.
2089 * @param array $info Array to which the processed values are added.
2092 public function getProcessedValue($table, $fieldList, array $row, array &$info)
2094 // Splitting values from $fieldList
2095 $fieldArr = explode(',', $fieldList);
2096 // Traverse fields from $fieldList
2097 foreach ($fieldArr as $field) {
2099 $info[] = '<strong>' . htmlspecialchars($this->itemLabels
[$field]) . '</strong> '
2100 . htmlspecialchars(BackendUtility
::getProcessedValue($table, $field, $row[$field]));
2106 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
2108 * @param string $table Tablename of table to test
2109 * @param array $row Record row.
2110 * @return bool Returns TRUE, if disabled.
2112 public function isDisabled($table, $row)
2114 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
2115 return $enableCols['disabled'] && $row[$enableCols['disabled']]
2116 ||
$enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
2117 ||
$enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
2121 * Returns icon for "no-edit" of a record.
2122 * Basically, the point is to signal that this record could have had an edit link if
2123 * the circumstances were right. A placeholder for the regular edit icon...
2125 * @param string $label Label key from LOCAL_LANG
2126 * @return string IMG tag for icon.
2128 public function noEditIcon($label = 'noEditItems')
2130 $title = $this->getLanguageService()->getLL($label, true);
2131 return '<span title="' . $title . '">' . $this->iconFactory
->getIcon('status-status-edit-read-only', Icon
::SIZE_SMALL
)->render() . '</span>';
2135 * Function, which fills in the internal array, $this->allowedTableNames with all tables to
2136 * which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...)
2137 * are filtered out. So what is left is basically all tables which makes sense to list content from.
2141 protected function cleanTableNames()
2143 // Get all table names:
2144 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
2145 // Unset common names:
2146 unset($tableNames['pages']);
2147 unset($tableNames['static_template']);
2148 unset($tableNames['sys_filemounts']);
2149 unset($tableNames['sys_action']);
2150 unset($tableNames['sys_workflows']);
2151 unset($tableNames['be_users']);
2152 unset($tableNames['be_groups']);
2153 $allowedTableNames = array();
2154 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2155 if (is_array($tableNames)) {
2156 foreach ($tableNames as $k => $v) {
2157 if (!$GLOBALS['TCA'][$k]['ctrl']['hideTable'] && $this->getBackendUser()->check('tables_select', $k)) {
2158 $allowedTableNames['table_' . $k] = $k;
2162 return $allowedTableNames;
2165 /*****************************************
2167 * External renderings
2169 *****************************************/
2172 * Creates a menu of the tables that can be listed by this function
2173 * Only tables which has records on the page will be included.
2174 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2176 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2177 * @return string HTML output.
2179 public function getTableMenu($id)
2182 $this->activeTables
= array();
2183 $theTables = array('tt_content');
2185 if (is_array($this->externalTables
)) {
2186 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables
)));
2189 // Traverse tables to check:
2190 foreach ($theTables as $tName) {
2191 // Check access and whether the proper extensions are loaded:
2192 if ($this->getBackendUser()->check('tables_select', $tName)
2193 && (isset($this->externalTables
[$tName])
2194 || GeneralUtility
::inList('fe_users,tt_content', $tName)
2195 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::isLoaded($tName)
2198 // Make query to count records from page:
2199 $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int)$id
2200 . BackendUtility
::deleteClause($tName) . BackendUtility
::versioningPlaceholderClause($tName));
2201 // If records were found (or if "tt_content" is the table...):
2202 if ($c || GeneralUtility
::inList('tt_content', $tName)) {
2205 <td><a href="#' . $tName . '" title="' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true) . '"></a>'
2206 . $this->iconFactory
->getIconForRecord($tName, array(), Icon
::SIZE_SMALL
)->render()
2208 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2209 $title = $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true)
2210 . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', true);
2211 $this->activeTables
[$tName] = '<span title="' . $title . '">'
2212 . $this->iconFactory
->getIconForRecord($tName, array(), Icon
::SIZE_SMALL
)->render()
2214 . ' ' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true);
2218 // Wrap cells in table tags:
2221 Menu of tables on the page (table menu)
2223 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2227 // Return the content:
2232 * Create thumbnail code for record/field but not linked
2234 * @param mixed[] $row Record array
2235 * @param string $table Table (record is from)
2236 * @param string $field Field name for which thumbnail are to be rendered.
2237 * @return string HTML for thumbnails, if any.
2239 public function getThumbCodeUnlinked($row, $table, $field)
2241 return BackendUtility
::thumbCode($row, $table, $field, '', '', null, 0, '', '', false);
2245 * Checks whether translated Content Elements exist in the desired language
2246 * If so, deny creating new ones via the UI
2248 * @param array $contentElements
2249 * @param int $language
2252 protected function checkIfTranslationsExistInLanguage(array $contentElements, $language)
2254 // If in default language, you may always create new entries
2255 // Also, you may override this strict behavior via user TS Config
2256 // If you do so, you're on your own and cannot rely on any support by the TYPO3 core
2257 // We jump out here since we don't need to do the expensive loop operations
2258 $allowInconsistentLanguageHandling = BackendUtility
::getModTSconfig($this->id
, 'mod.web_layout.allowInconsistentLanguageHandling');
2259 if ($language === 0 ||
$allowInconsistentLanguageHandling['value'] === '1') {
2265 if (!isset($this->languageHasTranslationsCache
[$language])) {
2266 foreach ($contentElements as $columns) {
2267 foreach ($columns as $contentElement) {
2268 if ((int)$contentElement['l18n_parent'] === 0) {
2269 $this->languageHasTranslationsCache
[$language]['hasStandAloneContent'] = true;
2271 if ((int)$contentElement['l18n_parent'] > 0) {
2272 $this->languageHasTranslationsCache
[$language]['hasTranslations'] = true;
2276 // Check whether we have a mix of both
2277 if ($this->languageHasTranslationsCache
[$language]['hasStandAloneContent']
2278 && $this->languageHasTranslationsCache
[$language]['hasTranslations']
2280 $message = GeneralUtility
::makeInstance(
2281 FlashMessage
::class,
2282 sprintf($this->getLanguageService()->getLL('staleTranslationWarning'), $this->languageIconTitles
[$language]['title']),
2283 sprintf($this->getLanguageService()->getLL('staleTranslationWarningTitle'), $this->languageIconTitles
[$language]['title']),
2284 FlashMessage
::WARNING
2286 $service = GeneralUtility
::makeInstance(FlashMessageService
::class);
2287 $queue = $service->getMessageQueueByIdentifier();
2288 $queue->addMessage($message);
2291 if ($this->languageHasTranslationsCache
[$language]['hasTranslations']) {
2298 * @return BackendLayoutView
2300 protected function getBackendLayoutView()
2302 return GeneralUtility
::makeInstance(BackendLayoutView
::class);
2306 * @return BackendUserAuthentication
2308 protected function getBackendUser()
2310 return $GLOBALS['BE_USER'];
2314 * @return DatabaseConnection
2316 protected function getDatabase()
2318 return $GLOBALS['TYPO3_DB'];
2322 * @return PageLayoutController
2324 protected function getPageLayoutController()
2326 return $GLOBALS['SOBE'];