ItemFilter/TabLinks

* always display FilterResult prompt on currency-for tabs
 * fixed display of FilterResult prompt on item currency-for tab
This commit is contained in:
Sarjuuk
2024-03-09 22:30:52 +01:00
parent 88b62730e1
commit 25b5928a22
3 changed files with 17 additions and 10 deletions

View File

@@ -2052,6 +2052,11 @@ class ItemListFilter extends Filter
return $this->wtCnd; return $this->wtCnd;
} }
public function isCurrencyFor(int $itemId) : bool
{
return in_array($itemId, self::ENUM_CURRENCY);
}
protected function createSQLForValues() protected function createSQLForValues()
{ {
$parts = []; $parts = [];

View File

@@ -188,6 +188,7 @@ class CurrencyPage extends GenericPage
} }
// tab: currency for // tab: currency for
$n = $w = null;
if ($this->typeId == 103) if ($this->typeId == 103)
{ {
$n = '?items&filter=cr=145;crs=1;crv=0'; $n = '?items&filter=cr=145;crs=1;crv=0';
@@ -199,10 +200,10 @@ class CurrencyPage extends GenericPage
$w = 'reqHonorPoints > 0'; $w = 'reqHonorPoints > 0';
} }
else 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; $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); $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) : []; $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])), 'data' => array_values($boughtBy->getListviewData(ITEMINFO_VENDOR, [Type::CURRENCY => $this->typeId])),
'name' => '$LANG.tab_currencyfor', 'name' => '$LANG.tab_currencyfor',
'id' => 'currency-for', '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); $tabData['note'] = sprintf(Util::$filterResultString, $n);
$this->lvTabs[] = [ItemList::$brickFile, $tabData]; $this->lvTabs[] = [ItemList::$brickFile, $tabData];

View File

@@ -849,6 +849,7 @@ class ItemPage extends genericPage
// tab: currency for // tab: currency for
// some minor trickery: get arenaPoints(43307) and honorPoints(43308) directly // some minor trickery: get arenaPoints(43307) and honorPoints(43308) directly
$n = $w = null;
if ($this->typeId == 43307) if ($this->typeId == 43307)
{ {
$n = '?items&filter=cr=145;crs=1;crv=0'; $n = '?items&filter=cr=145;crs=1;crv=0';
@@ -860,10 +861,10 @@ class ItemPage extends genericPage
$w = 'reqHonorPoints > 0'; $w = 'reqHonorPoints > 0';
} }
else 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; $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); $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; $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)), 'data' => array_values($boughtBy->getListviewData(ITEMINFO_VENDOR, $filter)),
'name' => '$LANG.tab_currencyfor', 'name' => '$LANG.tab_currencyfor',
'id' => 'currency-for', '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); $tabData['note'] = sprintf(Util::$filterResultString, $n);
$this->lvTabs[] = [ItemList::$brickFile, $tabData]; $this->lvTabs[] = [ItemList::$brickFile, $tabData];