Commit 060b8fa9 authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Andreas Fernandez
Browse files

[TASK] Highlight invalid backend layout value

In #89700, the page information view in the info
module was extended for a new type, which displays
the layout related (backend_layout, ..) fields for the
corresponding pages.

Since there might be field values which are not longer
valid, because the referenced backend layout does not
longer exist, the new type does  now highlight such values
with the already known `INVALID VALUE ("<value>")` string.

Resolves: #94674
Releases: master
Change-Id: I342fff7b8d76694831fa839901250b7d5da7e973
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70194

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Simon Gilli's avatarSimon Gilli <typo3@gilbertsoft.org>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 4586d38c
......@@ -25,6 +25,9 @@ This is especially useful for editors to determine the actually used
backend layout, which was previously often difficult. For example in
installations with large page trees and highly developed inheritance.
In case the current field value is invalid, e.g. referencing a non-existent
backend layout, this is now also shown to the editor.
Impact
======
......
......@@ -417,12 +417,12 @@ class PageInformationController
: '';
break;
case 'backend_layout':
$layout = $backendLayouts[$row[$field]] ?? null;
$theData[$field] = $layout ? htmlspecialchars($layout) : $this->getPagesTableFieldValue($field, $row);
$layoutValue = $backendLayouts[$row[$field]] ?? null;
$theData[$field] = $this->resolveBackendLayoutValue($layoutValue, $field, $row);
break;
case 'backend_layout_next_level':
$layout = $backendLayoutsNextLevel[$row[$field]] ?? null;
$theData[$field] = $layout ? htmlspecialchars($layout) : $this->getPagesTableFieldValue($field, $row);
$layoutValue = $backendLayoutsNextLevel[$row[$field]] ?? null;
$theData[$field] = $this->resolveBackendLayoutValue($layoutValue, $field, $row);
break;
case 'uid':
$uid = 0;
......@@ -631,4 +631,25 @@ class PageInformationController
}
return $backendLayouts;
}
protected function resolveBackendLayoutValue(?string $layoutValue, string $field, array $row): string
{
if ($layoutValue !== null) {
// Directly return the resolved layout value from BackendLayoutView
return htmlspecialchars($layoutValue);
}
// Fetch field value from database (this is already htmlspecialchared')
$layoutValue = $this->getPagesTableFieldValue($field, $row);
if ($layoutValue !== '') {
// In case getPagesTableFieldValue returns a non-empty string, the database field
// is filled with an invalid value (the backend layout does not longer exists).
$layoutValue = sprintf(
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'),
$this->getPagesTableFieldValue($field, $row)
);
}
return $layoutValue;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment