';
break;
case $languageFieldName:
if (count($siteLanguages) === 1) {
$theData[$field] = '';
break;
}
$siteLanguage = $siteLanguages[$row[$languageFieldName]] ?? null;
if (!$siteLanguage) {
$theData[$field] = '';
break;
}
$theData[$field] = $this->iconFactory->getIcon($siteLanguage->getFlagIdentifier(), IconSize::SMALL)->setTitle($siteLanguage->getTitle())->render()
. ' ' . $siteLanguage->getTitle();
break;
case 'php_tree_stop':
// Intended fall through
case 'TSconfig':
$theData[$field] = $row[$field] ? 'x' : ' ';
break;
case 'actual_backend_layout':
$backendLayout = $this->backendLayoutView->getBackendLayoutForPage((int)$row['uid']);
$theData[$field] = htmlspecialchars($languageService->sL($backendLayout->getTitle()));
break;
case 'backend_layout':
$layoutValue = $backendLayouts[$row[$field]] ?? null;
$theData[$field] = $this->resolveBackendLayoutValue($layoutValue, $field, $row);
break;
case 'backend_layout_next_level':
$layoutValue = $backendLayoutsNextLevel[$row[$field]] ?? null;
$theData[$field] = $this->resolveBackendLayoutValue($layoutValue, $field, $row);
break;
case 'uid':
$uid = 0;
$editButton = '';
$viewButton = '';
if ($backendUser->doesUserHaveAccess($row, 2) && $row['uid'] > 0) {
$uid = (int)$row['uid'];
$urlParameters = [
'edit' => [
'pages' => [
$row['uid'] => 'edit',
],
],
'module' => 'web_info_overview',
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri(),
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$previewDataAttributes = PreviewUriBuilder::create($row)
->withRootLine(BackendUtility::BEgetRootLine($row['uid']))
->serializeDispatcherAttributes();
$viewButton
= '';
if ($backendUser->check('tables_modify', 'pages')) {
$editButton
= ''
. $this->iconFactory->getIcon('actions-page-open', IconSize::SMALL)->render()
. '';
}
}
// Since the uid is overwritten with the edit button markup, we need to store
// the actual uid to be able to add it as data attribute to the table data cell.
// This also makes the distinction between record rows and the header line simpler.
$theData['_UID_'] = $uid;
$theData[$field] = '
' . $viewButton . $editButton . '
';
break;
case 'shortcut':
case 'shortcut_mode':
if ((int)$row['doktype'] === PageRepository::DOKTYPE_SHORTCUT) {
$theData[$field] = htmlspecialchars((string)BackendUtility::getProcessedValue('pages', $field, $row[$field], 0, false, false, 0, true, 0, $row));
}
break;
default:
if (str_starts_with($field, 'table_')) {
$f2 = substr($field, 6);
if ($this->tcaSchemaFactory->has($f2)) {
$c = $this->numberOfRecords($f2, (int)$row['uid']);
$theData[$field] = ($c ?: '');
}
} else {
$theData[$field] = htmlspecialchars((string)BackendUtility::getProcessedValue('pages', $field, $row[$field], 0, false, false, 0, true, 0, $row));
}
}
}
return $this->addElement($theData, $fieldArray);
}
/**
* Creates the icon image tag for the page and wraps it in a link which will trigger the click menu.
*/
protected function getIcon(array $row): string
{
$backendUser = $this->getBackendUser();
$icon = '' . $this->iconFactory->getIconForRecord('pages', $row, IconSize::SMALL)->render() . '';
// The icon with link
if ($backendUser->checkRecordEditAccess('pages', $row)->isAllowed) {
$icon = BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']);
}
return $icon;
}
/**
* Counts and returns the number of records on the page with $pid
*/
protected function numberOfRecords(string $table, int $pid): int
{
if (!$this->tcaSchemaFactory->has($table)) {
return 0;
}
$queryBuilder = $this->connectionPool->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, $this->getBackendUser()->workspace));
return (int)$queryBuilder->count('uid')
->from($table)
->where($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, Connection::PARAM_INT)))
->executeQuery()
->fetchOne();
}
/**
* Returns a table-row with the content from the fields in the input data array.
*
* @param array $data Record with field values, NOT htmlspecialchar'ed
* @return string HTML content for the table row
*/
protected function addElement(array $data, array $fieldArray): string
{
// Start up:
$attributes = '';
$rowTag = 'th';
if (isset($data['_UID_'])) {
$l10nParent = isset($data['_l10nparent_']) ? (int)$data['_l10nparent_'] : 0;
$attributes = ' data-uid="' . $data['_UID_'] . '" data-l10nparent="' . $l10nParent . '"';
$rowTag = 'td';
}
$out = '
';
// Init rendering.
$colsp = '';
$lastKey = '';
$c = 0;
// __label is used as the label key to circumvent problems with uid used as label (see #67756)
// as it was introduced later on, check if it really exists before using it
if (array_key_exists('__label', $data)) {
$fieldArray[0] = '__label';
}
// Traverse field array which contains the data to present:
foreach ($fieldArray as $vKey) {
if (isset($data[$vKey])) {
$cssClass = '';
if ($lastKey === 'title') {
$cssClass = 'col-title col-responsive';
}
if ($lastKey) {
$out .= '<' . $rowTag . ' class="' . $cssClass . '"' . $colsp . '>' . $data[$lastKey] . '' . $rowTag . '>';
}
$lastKey = $vKey;
$c = 1;
} else {
if (!$lastKey) {
$lastKey = $vKey;
}
$c++;
}
if ($c > 1) {
$colsp = ' colspan="' . $c . '"';
} else {
$colsp = '';
}
}
if ($lastKey) {
$cssClass = '';
if ($lastKey === 'title') {
$cssClass = 'col-title-flexible';
}
$out .= '<' . $rowTag . ' class="' . $cssClass . ' nowrap"' . $colsp . '>' . $data[$lastKey] . '' . $rowTag . '>';
}
$out .= '
';
return $out;
}
protected function getBackendLayouts(array $row, string $field): array
{
$languageService = $this->getLanguageService();
$configuration = ['row' => $row, 'table' => 'pages', 'field' => $field, 'items' => []];
// Below we call the itemsProcFunc to retrieve properly resolved backend layout items,
// including the translated labels and the correct field values (backend layout identifiers).
$this->backendLayoutView->addBackendLayoutItems($configuration);
$backendLayouts = [];
foreach ($configuration['items'] ?? [] as $backendLayout) {
if (($backendLayout['label'] ?? false) && ($backendLayout['value'] ?? false)) {
$backendLayouts[$backendLayout['value']] = $languageService->sL($backendLayout['label']) ?: $backendLayout['label'];
}
}
return $backendLayouts;
}
protected function resolveBackendLayoutValue(?string $layoutValue, string $field, array $row): string
{
$languageService = $this->getLanguageService();
if ($layoutValue !== null) {
// Directly return the resolved layout value from BackendLayoutView
return htmlspecialchars($layoutValue);
}
$layoutValue = htmlspecialchars((string)BackendUtility::getProcessedValue('pages', $field, $row[$field], 0, false, false, 0, true, 0, $row));
if ($layoutValue !== '') {
// If getProcessedValue() returns a non-empty string, the database field
// is filled with an invalid value (the backend layout does no longer exist).
return sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'), $layoutValue);
}
return '';
}
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
}