diff --git a/Classes/Helper/InlineHelper.php b/Classes/Helper/InlineHelper.php index 2dfcd5fd..9a752c1e 100644 --- a/Classes/Helper/InlineHelper.php +++ b/Classes/Helper/InlineHelper.php @@ -175,7 +175,7 @@ public function getInlineElements($data, $name, $cType, $parentid = "parentid", // fetching the inline elements if ($childTable == "tt_content") { - $sql = $GLOBALS["TYPO3_DB"]->exec_SELECTquery( + $queryResult = $GLOBALS["TYPO3_DB"]->exec_SELECTquery( "*", $childTable, $parentid . " = '" . $parentUid . "' AND sys_language_uid IN (-1," . $sysLangUid . ")" . ' AND (' @@ -186,21 +186,47 @@ public function getInlineElements($data, $name, $cType, $parentid = "parentid", . $enableFields, "", "sorting" ); } else { - $sql = $GLOBALS["TYPO3_DB"]->exec_SELECTquery( - "*", $childTable, $parentid . " = '" . $parentUid . - "' AND parenttable = '" . $parenttable . - "' AND sys_language_uid IN (-1," . $sysLangUid . ")" - . ' AND (' - . $childTable . '.t3ver_wsid=0 OR ' - . $childTable . '.t3ver_wsid=' . (int)$GLOBALS['BE_USER']->workspace - . ' AND ' . $childTable . '.pid<>-1' - . ')' - . $enableFields, "", "sorting" + $queryResult = $this->getQueryResult( + $parentid, + $parenttable, + $childTable, + $parentUid, + $sysLangUid, + $enableFields ); } // and recursively add them to an array - $elements = array(); + $elements = $this->fetchElements($name, $cType, $childTable, $queryResult); + + if (empty($elements) && $GLOBALS['TSFE']->sys_language_mode == 'content_fallback') { + + $queryResult = $this->getQueryResult( + $parentid, + $parenttable, + $childTable, + $parentUid, + $GLOBALS['TSFE']->sys_language_content, + $enableFields + ); + + $elements = $this->fetchElements($name, $cType, $childTable, $queryResult); + } + + return $elements; + } + + /** + * and recursively add them to an array + * @param $name + * @param $cType + * @param $childTable + * @param $sql + * @return array + */ + protected function fetchElements($name, $cType, $childTable, $sql) + { + $elements = []; while ($element = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($sql)) { if (TYPO3_MODE == 'FE') { $GLOBALS['TSFE']->sys_page->versionOL($childTable, $element); @@ -216,4 +242,32 @@ public function getInlineElements($data, $name, $cType, $parentid = "parentid", return $elements; } + + /** + * @param $parentid + * @param $parenttable + * @param $childTable + * @param $parentUid + * @param $sysLangUid + * @param $enableFields + * @return bool|\mysqli_result|object MySQLi result object / DBAL object + */ + protected function getQueryResult($parentid, $parenttable, $childTable, $parentUid, $sysLangUid, $enableFields) + { + return $GLOBALS["TYPO3_DB"]->exec_SELECTquery( + "*", + $childTable, + $parentid . " = '" . $parentUid . + "' AND parenttable = '" . $parenttable . + "' AND sys_language_uid IN (-1," . $sysLangUid . ")" + . ' AND (' + . $childTable . '.t3ver_wsid=0 OR ' + . $childTable . '.t3ver_wsid=' . (int)$GLOBALS['BE_USER']->workspace + . ' AND ' . $childTable . '.pid<>-1' + . ')' + . $enableFields, + "", + "sorting" + ); + } } diff --git a/composer.json b/composer.json index df201623..ebbbbd8c 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "license": "GPL-2.0+", - "version": "3.0.2", + "version": "3.0.3", "require": { "php": "^7.0", "typo3/cms-core": "^8.7"