From 1241858a7af8d436eaf67ac0507ec814b46047a0 Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Tue, 9 Apr 2024 18:22:26 +0700 Subject: [PATCH] 41951 add condition show property status for unit detail --- plugin/EstateList.php | 7 ++++++- plugin/EstateUnits.php | 8 ++++++++ .../ScriptLoaderGenericConfigurationDefault.php | 5 +++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugin/EstateList.php b/plugin/EstateList.php index 522c40560..93b0a4301 100644 --- a/plugin/EstateList.php +++ b/plugin/EstateList.php @@ -490,7 +490,12 @@ public function estateIterator($modifier = EstateViewFieldModifierTypes::MODIFIE } $recordRaw = $this->_recordsRaw[$this->_currentEstate['id']]['elements'] ?? []; - if ($this->getShowEstateMarketingStatus()) { + $showEstateMarketingStatusOfUnitList = false; + if ($this->_unitsViewName != null) { + $showEstateMarketingStatusOfUnitList = $this->_pEnvironment->getEstateUnitsByName($this->_unitsViewName)->getShowEstateMarketingStatus(); + } + + if ($this->getShowEstateMarketingStatus() || $showEstateMarketingStatusOfUnitList) { $pEstateStatusLabel = $this->_pEnvironment->getEstateStatusLabel(); $recordModified['vermarktungsstatus'] = $pEstateStatusLabel->getLabel($recordRaw); } diff --git a/plugin/EstateUnits.php b/plugin/EstateUnits.php index 64a3159ce..3372893a1 100644 --- a/plugin/EstateUnits.php +++ b/plugin/EstateUnits.php @@ -100,6 +100,14 @@ public function getSubEstateIds(int $estateId): array return $this->_estateUnits[$estateId] ?? []; } + /** + * @return bool + */ + public function getShowEstateMarketingStatus(): bool + { + return $this->_pEstateUnitsConfiguration->getEstateList()->getShowEstateMarketingStatus(); + } + /** * @param int $estateId * @return int diff --git a/plugin/ScriptLoader/ScriptLoaderGenericConfigurationDefault.php b/plugin/ScriptLoader/ScriptLoaderGenericConfigurationDefault.php index 2bf7e0ad2..723c2c50f 100644 --- a/plugin/ScriptLoader/ScriptLoaderGenericConfigurationDefault.php +++ b/plugin/ScriptLoader/ScriptLoaderGenericConfigurationDefault.php @@ -152,7 +152,8 @@ private function isEstateListPage(string $content): bool { return $this->matchesShortcode($content, self::ESTATE_TAG, 'view', '[^"]*') && !$this->matchesShortcode($content, self::ESTATE_TAG, 'view', 'detail') || - $this->matchesShortcode($content, self::ESTATE_TAG, 'units', '[^"]*'); + $this->matchesShortcode($content, self::ESTATE_TAG, 'units', '[^"]*') && + !$this->matchesShortcode($content, self::ESTATE_TAG, 'units', '.*detail.*'); } /** @@ -182,7 +183,7 @@ private function isFormPage(string $content): bool */ private function matchesShortcode(string $content, string $tag, string $attribute, string $valuePattern): bool { - $pattern = '/\[' . $tag . '\s+' . $attribute . '="' . $valuePattern . '"\]/'; + $pattern = '/\[' . preg_quote($tag, '/') . '\s+.*?' . preg_quote($attribute, '/') . '="' . $valuePattern . '".*?\]/'; return (bool) preg_match($pattern, $content); }