Skip to content

Commit

Permalink
Merge branch 'hotfix/fix_language_for_be_panels' into 'release/2.3.0'
Browse files Browse the repository at this point in the history
Hotfix/fix language for be panels

See merge request metamodels/core!343
  • Loading branch information
zonky2 committed Oct 14, 2024
2 parents 0e3cd16 + 1dcba53 commit ee9dc6e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Attribute/TranslatedReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ public function getFilterOptions($idList, $usedOnly, &$arrCount = null)
while ($objValue = $statement->fetchAssociative()) {
$arrReturn[$objValue[$arrOptionizer['key']]] = $objValue[$arrOptionizer['value']];
}

return $arrReturn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,12 @@ private function setExplanation(PropertyInterface $property, array $propInfo): v
*/
private function setEval(PropertyInterface $property, array $propInfo, bool $isTranslated): void
{
$extra = $propInfo['eval'] ?? [];
$extra = $propInfo['eval'] ?? [];
$classes = ($extra['tl_class'] ?? '') . ' ' . ($property->getExtra()['tl_class'] ?? '');
if ($isTranslated) {
$extra['tl_class'] = 'translat-attr' . (!empty($extra['tl_class']) ? ' ' . $extra['tl_class'] : '');
$classes .= ' translat-attr';
}
$extra['tl_class'] = \implode(' ', \array_unique(preg_split('#(\s*,*\s*)*,+(\s*,*\s*)*#', $classes)));

$property->setExtra(\array_merge($property->getExtra(), $extra));
}
Expand Down
2 changes: 2 additions & 0 deletions src/DcGeneral/Data/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,10 @@ public function getFilterOptions(ConfigInterface $config)
$metaModel = $this->getMetaModel();
assert($metaModel instanceof IMetaModel);

$backupLanguage = $this->setLanguage($this->getCurrentLanguage());
$arrValues = $metaModel
->getAttributeOptions($arrProperties[0] ?? '', $objFilter);
$this->setLanguage($backupLanguage);

$objCollection = new DefaultFilterOptionCollection();
foreach ($arrValues as $strKey => $strValue) {
Expand Down
6 changes: 3 additions & 3 deletions src/DcGeneral/Data/FilterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,12 @@ private function buildSearchAttributeFilterRule(IAttribute $attribute, string $v
$languages = [];
$metaModel = $attribute->getMetaModel();
if ($metaModel instanceof ITranslatedMetaModel) {
$languages = $metaModel->getLanguages();
$languages[] = $metaModel->getLanguage();
} elseif ($metaModel->isTranslated(false)) {
$languages = $this->getMetaModel()->getAvailableLanguages() ?? [];
$languages[] = $metaModel->getActiveLanguage();
}

return new SearchAttribute($attribute, $value, \array_values(\array_filter($languages)));
return new SearchAttribute($attribute, $value, \array_filter($languages));
}

/** @psalm-assert TFilterANDOR $filter */
Expand Down

0 comments on commit ee9dc6e

Please sign in to comment.