Skip to content

Commit

Permalink
Do not add all translation ids if tree is not open
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolineus committed May 12, 2020
1 parent 57adb60 commit 17f3687
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Contao\CoreBundle\Exception\AccessDeniedException;
use Contao\CoreBundle\Exception\InternalServerErrorException;
use Contao\System;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

Expand Down Expand Up @@ -838,12 +839,18 @@ protected function generateTree($table, $id, $arrPrevNext, $blnHasSorting, $intM
// Now that there's $arrFound we can just add all that main languages to the found array
// so it will never show translated items and we don't have to override the whole method
// anymore - hurray!
$translationIds = \Database::getInstance()->prepare(
"SELECT id FROM " . $table . " WHERE pid=? AND $langColumn=''")
->execute($id)
->fetchEach('id');

$arrFound = array_merge($arrFound, $translationIds);
$objSessionBag = System::getContainer()->get('session')->getBag('contao_backend');
$session = $objSessionBag->all();
$node = ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6) ? $this->strTable . '_' . $table . '_tree' : $this->strTable . '_tree';
$blnIsOpen = (!empty($arrFound) || $session[$node][$id] == 1);
if ($blnIsOpen) {
$translationIds = \Database::getInstance()->prepare(
"SELECT id FROM " . $table . " WHERE pid=? AND $langColumn=''")
->execute($id)
->fetchEach('id');

$arrFound = array_merge($arrFound, $translationIds);
}

// Do not display the language records in the child list
if ($table === $this->strTable && $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] === 6) {
Expand Down

0 comments on commit 17f3687

Please sign in to comment.