From 0753bfbcf6c0330e824e2b5c9e15bccbaeb9b439 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 6 Aug 2025 13:43:12 +0200 Subject: [PATCH] ItemFilter/Fixup 16eabb90b63af99ecf63e2ea285ab53c1e181d9b * fix lost item grouping * fix type selector in filter form * fix item upgrade search --- includes/components/filter.class.php | 2 +- pages/items.php | 22 +++++++++++++--------- template/pages/items.tpl.php | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/includes/components/filter.class.php b/includes/components/filter.class.php index b139b444..361b2361 100644 --- a/includes/components/filter.class.php +++ b/includes/components/filter.class.php @@ -292,7 +292,7 @@ abstract class Filter { // quirk: in the POST step criteria can be [[''], null, null] if not selected. $buff = []; - foreach ($val as $v) + foreach ((array)$val as $v) // can be string|int in POST step if only one value present if ($v !== '' && $this->checkInput($type, $valid, $v)) $buff[] = $v; diff --git a/pages/items.php b/pages/items.php index 23502445..60f4fd6e 100644 --- a/pages/items.php +++ b/pages/items.php @@ -188,11 +188,11 @@ class ItemsPage extends GenericPage break; } - if ($singleSlot && empty($this->filter['gb'])) // enforce group by slot - $this->filter['gb'] = 1; + if ($singleSlot && empty($fiForm['gb'])) // enforce group by slot + $fiForm['gb'] = 1; else if (!$singleSlot) // multiples can only be grouped by slot { - $this->filter['gb'] = 1; + $fiForm['gb'] = 1; $maxResults = 25; $this->sharedLV['customFilter'] = '$fi_filterUpgradeListview'; } @@ -221,7 +221,7 @@ class ItemsPage extends GenericPage ); $groups = []; $nameSource = []; - $grouping = $this->filter['gb'] ?? 0; + $grouping = $fiForm['gb'] ?? 0; $extraOpts = []; $maxResults = Cfg::get('SQL_LIMIT_DEFAULT'); @@ -237,10 +237,10 @@ class ItemsPage extends GenericPage else $groups = array_merge($availableSlots[ITEM_CLASS_ARMOR], $availableSlots[ITEM_CLASS_WEAPON]); - if (isset($this->filter['sl'])) // skip lookups for unselected slots - $groups = array_intersect($groups, $this->filter['sl']); + if ($fiForm['sl']) // skip lookups for unselected slots + $groups = array_intersect($groups, $fiForm['sl']); - if (!empty($this->filterObj->upgrades)) // skip lookups for slots we dont have items to upgrade for + if (!empty($this->filterObj->upgrades)) // skip lookups for slots we dont have items to upgrade for $groups = array_intersect($groups, $this->filterObj->upgrades); if ($groups) @@ -286,6 +286,10 @@ class ItemsPage extends GenericPage $groups[0] = null; } + // write back 'gb' to filter + if ($grouping) + $this->filterObj->values['gb'] = $grouping; + /*****************************/ /* create lv-tabs for groups */ @@ -444,8 +448,8 @@ class ItemsPage extends GenericPage $tPart = Lang::item('cat', $this->category[0], 1, $this->category[1], 1, $this->category[2]); else if (isset($this->category[1]) && is_array(Lang::item('cat', $this->category[0]))) $tPart = Lang::item('cat', $this->category[0], 1, $this->category[1]); - else if ($this->category[0] == 0 && isset($this->filter['ty']) && !is_array($this->filter['ty'])) - $tPart = Lang::item('cat', 0, 1, $this->filter['ty']); + else if ($this->category[0] == 0 && count($this->filterObj->values['ty']) == 1) + $tPart = Lang::item('cat', 0, 1, $this->filterObj->values['ty'][0]); else $tPart = Lang::item('cat', $this->category[0]); diff --git a/template/pages/items.tpl.php b/template/pages/items.tpl.php index 7bcfd170..30253058 100644 --- a/template/pages/items.tpl.php +++ b/template/pages/items.tpl.php @@ -56,7 +56,7 @@ if ($this->typeList):
- /> + />