Skip to content

Commit

Permalink
[BUGFIX] Respect TSconfig when adding page translations to recordlist
Browse files Browse the repository at this point in the history
Since #27471 it's possible to hide all or specific tables within
the recordlist. However, the special "page translations" table
did not respect those settings, making it impossible to hide
this table.

This is now fixed by respecting the corresponding settings.

Resolves: #94386
Releases: master, 10.4
Change-Id: I33575624ade9ecf840b6fde713a7d3214d6506be
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69540
Tested-by: core-ci <typo3@b13.com>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
o-ba authored and bmack committed Jun 28, 2021
1 parent 4761152 commit 550c4be
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions typo3/sysext/recordlist/Classes/Controller/RecordListController.php
Expand Up @@ -409,19 +409,21 @@ function editRecords(table,idList,addParams,CBflag) {
$this->moduleTemplate->setTitle($title);

$output = '';
// Show the selector to add page translations and the list of translations of the current page
// but only when in "default" mode
// Show the selector to add page translations, but only when in "default" mode.
// If not disabled via module TSconfig and the user is allowed, also show the page translations table.
if ($this->id && !$dblist->csvOutput && !$this->search_field && !$this->cmd && !$this->table) {
$output .= $this->languageSelector($this->id);
$pageTranslationsDatabaseRecordList = clone $dblist;
$pageTranslationsDatabaseRecordList->listOnlyInSingleTableMode = false;
$pageTranslationsDatabaseRecordList->disableSingleTableView = true;
$pageTranslationsDatabaseRecordList->deniedNewTables = ['pages'];
$pageTranslationsDatabaseRecordList->hideTranslations = '';
$pageTranslationsDatabaseRecordList->iLimit = $pageTranslationsDatabaseRecordList->itemsLimitPerTable;
$pageTranslationsDatabaseRecordList->setLanguagesAllowedForUser($this->siteLanguages);
$pageTranslationsDatabaseRecordList->showOnlyTranslatedRecords(true);
$output .= $pageTranslationsDatabaseRecordList->getTable('pages', $this->id);
if ($this->showPageTranslations()) {
$pageTranslationsDatabaseRecordList = clone $dblist;
$pageTranslationsDatabaseRecordList->listOnlyInSingleTableMode = false;
$pageTranslationsDatabaseRecordList->disableSingleTableView = true;
$pageTranslationsDatabaseRecordList->deniedNewTables = ['pages'];
$pageTranslationsDatabaseRecordList->hideTranslations = '';
$pageTranslationsDatabaseRecordList->iLimit = $pageTranslationsDatabaseRecordList->itemsLimitPerTable;
$pageTranslationsDatabaseRecordList->setLanguagesAllowedForUser($this->siteLanguages);
$pageTranslationsDatabaseRecordList->showOnlyTranslatedRecords(true);
$output .= $pageTranslationsDatabaseRecordList->getTable('pages', $this->id);
}
}

if (!empty($dblist->HTMLcode)) {
Expand Down Expand Up @@ -623,6 +625,22 @@ protected function languageSelector(int $id): string
return '';
}

protected function showPageTranslations(): bool
{
if (!$this->getBackendUserAuthentication()->check('tables_select', 'pages')) {
return false;
}

if (isset($this->modTSconfig['properties']['table.']['pages.']['hideTable'])) {
return !$this->modTSconfig['properties']['table.']['pages.']['hideTable'];
}

$hideTables = $this->modTSconfig['properties']['hideTables'] ?? '';
return !($GLOBALS['TCA']['pages']['ctrl']['hideTable'] ?? false)
&& $hideTables !== '*'
&& !in_array('pages', GeneralUtility::trimExplode(',', $hideTables), true);
}

/**
* @return ModuleTemplate
*/
Expand Down

0 comments on commit 550c4be

Please sign in to comment.