diff --git a/src/Driver.php b/src/Driver.php index 903b57a..396118a 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -740,8 +740,10 @@ public function treeView() // Child mode if ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6) { $table = $GLOBALS['TL_DCA'][$this->strTable]['config']['ptable']; + $drivers = ['Multilingual', __CLASS__, \DC_Multilingual::class]; + $dataContainer = $GLOBALS['TL_DCA'][$table]['config']['dataContainer'] ?? null; - if ($GLOBALS['TL_DCA'][$table]['config']['dataContainer'] == 'Multilingual') { + if (isset($dataContainer) && \in_array($dataContainer, $drivers, true)) { $where[] = "$this->langColumnName=''"; } @@ -866,8 +868,10 @@ protected function generateTree($table, $id, $arrPrevNext, $blnHasSorting, $intM // Check whether there are child records if (!$blnNoRecursion) { Controller::loadDataContainer($table); + $drivers = ['Multilingual', __CLASS__, \DC_Multilingual::class]; + $dataContainer = $GLOBALS['TL_DCA'][$table]['config']['dataContainer'] ?? null; - if ($GLOBALS['TL_DCA'][$table]['config']['dataContainer'] === 'Multilingual' + if (isset($dataContainer) && \in_array($dataContainer, $drivers, true) && ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] === 5 || $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] === 6 || $this->strTable != $table) ) { $langColumn = $GLOBALS['TL_DCA'][$table]['config']['langColumnName'] ?? 'language'; @@ -1126,6 +1130,14 @@ public function deleteChilds($table, $id, &$delete) { parent::deleteChilds($table, $id, $delete); + // Do not delete record if it is not a multilingual dataContainer + $drivers = ['Multilingual', __CLASS__, \DC_Multilingual::class]; + $dataContainer = $GLOBALS['TL_DCA'][$table]['config']['dataContainer'] ?? null; + + if (!(isset($dataContainer) && \in_array($dataContainer, $drivers, true))) { + return; + } + // Do not delete record if there is no parent table if (empty($GLOBALS['TL_DCA'][$table]['config']['ptable'])) { return; @@ -1252,6 +1264,18 @@ protected function handleLanguageOperation() } elseif ($this->strTable === $request->request->get('FORM_SUBMIT') && $request->request->has('deleteLanguage') ) { + // Trigger the ondelete_callback + if (\is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['ondelete_callback'])) { + foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['ondelete_callback'] as $callback) { + if (\is_array($callback)) { + $this->import($callback[0]); + $this->{$callback[0]}->{$callback[1]}($this, ''); + } elseif (\is_callable($callback)) { + $callback($this, ''); + } + } + } + Database::getInstance() ->prepare( "DELETE FROM " . $this->strTable . " @@ -1268,6 +1292,7 @@ protected function handleLanguageOperation() if ($needsReload) { $_SESSION['TL_INFO'] = ''; + Message::reset(); Controller::reload(); } }