From c741fb02d2d8213a069b9d766d81c6824c17dca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 2 Aug 2026 21:25:13 +0200 Subject: [PATCH] Added mechanism to parse inch and metric footprints from PR #1447 --- .../Providers/TMEProvider.php | 24 +++++++++++++++---- .../InfoProviderSystem/TMESettings.php | 3 +++ translations/messages.en.xlf | 6 +++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/Services/InfoProviderSystem/Providers/TMEProvider.php b/src/Services/InfoProviderSystem/Providers/TMEProvider.php index 8a8fde3b..ff1abaa0 100644 --- a/src/Services/InfoProviderSystem/Providers/TMEProvider.php +++ b/src/Services/InfoProviderSystem/Providers/TMEProvider.php @@ -252,12 +252,22 @@ class TMEProvider implements InfoProviderInterface, URLHandlerInfoProviderInterf $result = []; - $footprint_name = null; + $footprint = null; + $footprint_imperial = null; + $footprint_metric = null; foreach ($element['elements'] as $parameter) { - //Check if the parameter is the case/footprint - if ($parameter['id'] === 35) { - $footprint_name = $parameter['values'][0]['value']; + $id = $parameter['id']; + $value = $parameter['values'][0]['value'] ?? null; + + // Check if the parameter is the case/footprint + // id 35 is Case, id 2932 is Case-inch, id 2931 is Case-mm + if ($id === 35) { + $footprint = $value; + } else if ($id === 2932) { + $footprint_imperial = $value; + } else if ($id === 2931) { + $footprint_metric = $value; } //Skip related items parameter @@ -274,10 +284,14 @@ class TMEProvider implements InfoProviderInterface, URLHandlerInfoProviderInterf ); } else if (count($parameter['values']) === 1) { $result[] = ParameterDTO::parseValueIncludingUnit($parameter['name'], $parameter['values'][0]['value']); - } } + //Assign the footprint name based on the user preference and available values + $footprint_name = $this->settings->preferMetricFootprint ? + ($footprint_metric ?? $footprint ?? $footprint_imperial) : + ($footprint_imperial ?? $footprint ?? $footprint_metric); + return $result; } diff --git a/src/Settings/InfoProviderSystem/TMESettings.php b/src/Settings/InfoProviderSystem/TMESettings.php index 8d57c124..692d3187 100644 --- a/src/Settings/InfoProviderSystem/TMESettings.php +++ b/src/Settings/InfoProviderSystem/TMESettings.php @@ -68,4 +68,7 @@ class TMESettings envVar: "PROVIDER_TME_COUNTRY", envVarMode: EnvVarMode::OVERWRITE)] #[Assert\Country] public string $country = "DE"; + + #[SettingsParameter(label: new TM("settings.ips.tme.preferMetricFootprint"))] + public bool $preferMetricFootprint = false; } diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index af992867..17f27dd5 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -13877,5 +13877,11 @@ Buerklin-API Authentication server: Using this info provider can cause additional costs, or has very strict rate limits. + + + settings.ips.tme.preferMetricFootprint + Prefer metric footprint when both metric and imperial are available + +