From 25b5928a22694d0b138c8ceac266263e9ebadbda Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sat, 9 Mar 2024 22:30:52 +0100 Subject: [PATCH] ItemFilter/TabLinks * always display FilterResult prompt on currency-for tabs * fixed display of FilterResult prompt on item currency-for tab --- includes/types/item.class.php | 5 +++++ pages/currency.php | 11 ++++++----- pages/item.php | 11 ++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/includes/types/item.class.php b/includes/types/item.class.php index b19f3f04..643611ce 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -2052,6 +2052,11 @@ class ItemListFilter extends Filter return $this->wtCnd; } + public function isCurrencyFor(int $itemId) : bool + { + return in_array($itemId, self::ENUM_CURRENCY); + } + protected function createSQLForValues() { $parts = []; diff --git a/pages/currency.php b/pages/currency.php index a0525058..33e70a1c 100644 --- a/pages/currency.php +++ b/pages/currency.php @@ -188,6 +188,7 @@ class CurrencyPage extends GenericPage } // tab: currency for + $n = $w = null; if ($this->typeId == 103) { $n = '?items&filter=cr=145;crs=1;crv=0'; @@ -199,10 +200,10 @@ class CurrencyPage extends GenericPage $w = 'reqHonorPoints > 0'; } else - { - $n = in_array($this->typeId, [42, 61, 81, 241, 121, 122, 123, 125, 126, 161, 201, 101, 102, 221, 301, 341]) ? '?items&filter=cr=158;crs='.$_itemId.';crv=0' : null; $w = 'reqItemId1 = '.$_itemId.' OR reqItemId2 = '.$_itemId.' OR reqItemId3 = '.$_itemId.' OR reqItemId4 = '.$_itemId.' OR reqItemId5 = '.$_itemId; - } + + if (!$n && (new ItemListFilter())->isCurrencyFor($_itemId)) + $n = '?items&filter=cr=158;crs='.$_itemId.';crv=0'; $xCosts = DB::Aowow()->selectCol('SELECT id FROM ?_itemextendedcost WHERE '.$w); $boughtBy = $xCosts ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE extendedCost IN (?a) UNION SELECT item FROM game_event_npc_vendor WHERE extendedCost IN (?a)', $xCosts, $xCosts) : []; @@ -215,10 +216,10 @@ class CurrencyPage extends GenericPage 'data' => array_values($boughtBy->getListviewData(ITEMINFO_VENDOR, [Type::CURRENCY => $this->typeId])), 'name' => '$LANG.tab_currencyfor', 'id' => 'currency-for', - 'extraCols' => ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'], + 'extraCols' => ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'] ); - if ($boughtBy->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($n) $tabData['note'] = sprintf(Util::$filterResultString, $n); $this->lvTabs[] = [ItemList::$brickFile, $tabData]; diff --git a/pages/item.php b/pages/item.php index 414d47ab..c3a17928 100644 --- a/pages/item.php +++ b/pages/item.php @@ -849,6 +849,7 @@ class ItemPage extends genericPage // tab: currency for // some minor trickery: get arenaPoints(43307) and honorPoints(43308) directly + $n = $w = null; if ($this->typeId == 43307) { $n = '?items&filter=cr=145;crs=1;crv=0'; @@ -860,10 +861,10 @@ class ItemPage extends genericPage $w = 'reqHonorPoints > 0'; } else - { - $n = in_array($this->typeId, [42, 61, 81, 241, 121, 122, 123, 125, 126, 161, 201, 101, 102, 221, 301, 341]) ? '?items&filter=cr=158;crs='.$this->typeId.';crv=0' : null; $w = 'reqItemId1 = '.$this->typeId.' OR reqItemId2 = '.$this->typeId.' OR reqItemId3 = '.$this->typeId.' OR reqItemId4 = '.$this->typeId.' OR reqItemId5 = '.$this->typeId; - } + + if (!$n && (new ItemListFilter())->isCurrencyFor($this->typeId)) + $n = '?items&filter=cr=158;crs='.$this->typeId.';crv=0'; $xCosts = DB::Aowow()->selectCol('SELECT id FROM ?_itemextendedcost WHERE '.$w); $boughtBy = $xCosts ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE extendedCost IN (?a) UNION SELECT item FROM game_event_npc_vendor WHERE extendedCost IN (?a)', $xCosts, $xCosts) : null; @@ -879,10 +880,10 @@ class ItemPage extends genericPage 'data' => array_values($boughtBy->getListviewData(ITEMINFO_VENDOR, $filter)), 'name' => '$LANG.tab_currencyfor', 'id' => 'currency-for', - 'extraCols' => ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'], + 'extraCols' => ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'] ); - if ($boughtBy->getMatches() > CFG_SQL_LIMIT_DEFAULT && $n) + if ($n) $tabData['note'] = sprintf(Util::$filterResultString, $n); $this->lvTabs[] = [ItemList::$brickFile, $tabData];