Skip to content

Commit

Permalink
Merge pull request terminal42#65 from dmolineus/fix/collapsed-tree
Browse files Browse the repository at this point in the history
Fix tree view for collapsed nodes
  • Loading branch information
qzminski authored May 22, 2020
2 parents 57adb60 + 17f3687 commit 1668a77
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 1668a77

Please sign in to comment.