diff --git a/includes/basetype.class.php b/includes/basetype.class.php index a772355b..e4b9cb0a 100644 --- a/includes/basetype.class.php +++ b/includes/basetype.class.php @@ -318,7 +318,7 @@ abstract class BaseType break; } while (next($this->templates)); - } + } protected function reset() { @@ -461,17 +461,20 @@ abstract class BaseType trait listviewHelper { - public function hasSetFields($fields) + public function hasSetFields(?string ...$fields) : int { - if (!is_array($fields)) - return 0x0; - $result = 0x0; foreach ($this->iterate() as $__) { foreach ($fields as $k => $str) { + if (!$str) + { + unset($fields[$k]); + continue; + } + if ($this->getField($str)) { $result |= 1 << $k; @@ -489,11 +492,8 @@ trait listviewHelper return $result; } - public function hasDiffFields($fields) + public function hasDiffFields(?string ...$fields) : int { - if (!is_array($fields)) - return 0x0; - $base = []; $result = 0x0; @@ -504,6 +504,12 @@ trait listviewHelper { foreach ($fields as $k => $str) { + if (!$str) + { + unset($fields[$k]); + continue; + } + if ($base[$str] != $this->getField($str)) { $result |= 1 << $k; diff --git a/includes/loot.class.php b/includes/loot.class.php index 2c4b9614..3a04a3f8 100644 --- a/includes/loot.class.php +++ b/includes/loot.class.php @@ -574,7 +574,7 @@ class Loot if (!empty($result)) $tabsFinal[16][4][] = '$Listview.extraCols.percent'; - if ($srcObj->hasSetFields(['reagent1'])) + if ($srcObj->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8')) $tabsFinal[16][6][] = 'reagents'; foreach ($srcObj->iterate() as $_) diff --git a/pages/achievements.php b/pages/achievements.php index 4872ec84..51f4b404 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -98,7 +98,7 @@ class AchievementsPage extends GenericPage $this->extendGlobalData($acvList->getJSGlobals()); // if we are have different cats display field - if ($acvList->hasDiffFields(['category'])) + if ($acvList->hasDiffFields('category')) $tabData['visibleCols'] = ['category']; if (!empty($this->filter['fi']['extraCols'])) diff --git a/pages/arenateams.php b/pages/arenateams.php index 21cea897..655afde5 100644 --- a/pages/arenateams.php +++ b/pages/arenateams.php @@ -104,7 +104,7 @@ class ArenaTeamsPage extends GenericPage { $teams->initializeLocalEntries(); - $dFields = $teams->hasDiffFields(['faction', 'type']); + $dFields = $teams->hasDiffFields('faction', 'type'); if (!($dFields & 0x1)) $tabData['hiddenCols'][] = 'faction'; diff --git a/pages/class.php b/pages/class.php index 57b03e78..6cf02990 100644 --- a/pages/class.php +++ b/pages/class.php @@ -162,7 +162,7 @@ class ClassPage extends GenericPage $this->extendGlobalData($items->getJSGlobals()); $hiddenCols = null; - if ($items->hasDiffFields(['requiredRace'])) + if ($items->hasDiffFields('requiredRace')) $hiddenCols = ['side']; $this->lvTabs[] = [ItemList::$brickFile, array( diff --git a/pages/currency.php b/pages/currency.php index 33e70a1c..ed05afd5 100644 --- a/pages/currency.php +++ b/pages/currency.php @@ -180,7 +180,7 @@ class CurrencyPage extends GenericPage 'id' => 'created-by', ); - if ($createdBy->hasSetFields(['reagent1'])) + if ($createdBy->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8')) $tabData['visibleCols'] = ['reagents']; $this->lvTabs[] = [SpellList::$brickFile, $tabData]; diff --git a/pages/enchantments.php b/pages/enchantments.php index 5c2125e3..e9ed6e7a 100644 --- a/pages/enchantments.php +++ b/pages/enchantments.php @@ -81,7 +81,7 @@ class EnchantmentsPage extends GenericPage if (array_filter(array_column($tabData['data'], 'spells'))) $tabData['visibleCols'] = ['trigger']; - if (!$ench->hasSetFields(['skillLine'])) + if (!$ench->hasSetFields('skillLine')) $tabData['hiddenCols'] = ['skill']; if ($this->filterObj->error) diff --git a/pages/guilds.php b/pages/guilds.php index 3615f284..61c5d572 100644 --- a/pages/guilds.php +++ b/pages/guilds.php @@ -97,7 +97,7 @@ class GuildsPage extends GenericPage { $guilds->initializeLocalEntries(); - $dFields = $guilds->hasDiffFields(['faction', 'type']); + $dFields = $guilds->hasDiffFields('faction', 'type'); if (!($dFields & 0x1)) $tabData['hiddenCols'][] = 'faction'; diff --git a/pages/item.php b/pages/item.php index 33d90007..b7b4cd6b 100644 --- a/pages/item.php +++ b/pages/item.php @@ -571,7 +571,7 @@ class ItemPage extends genericPage $this->extendGlobalData($contains->getJSGlobals(GLOBALINFO_SELF)); $hCols = ['side']; - if (!$contains->hasSetFields(['slot'])) + if (!$contains->hasSetFields('slot')) $hCols[] = 'slot'; $this->lvTabs[] = [ItemList::$brickFile, array( @@ -618,7 +618,7 @@ class ItemPage extends genericPage 'visibleCols' => ['category'] ); - if (!$criteriaOf->hasSetFields(['reward_loc0'])) + if (!$criteriaOf->hasSetFields('reward_loc0')) $tabData['hiddenCols'] = ['rewards']; $this->lvTabs[] = [AchievementList::$brickFile, $tabData]; @@ -927,7 +927,7 @@ class ItemPage extends genericPage $this->extendGlobalData($taughtSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $visCols = ['level', 'schools']; - if ($taughtSpells->hasSetFields(['reagent1'])) + if ($taughtSpells->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8')) $visCols[] = 'reagents'; $this->lvTabs[] = [SpellList::$brickFile, array( diff --git a/pages/items.php b/pages/items.php index e510b67d..e4dcd2c8 100644 --- a/pages/items.php +++ b/pages/items.php @@ -370,7 +370,7 @@ class ItemsPage extends GenericPage } if (!empty($this->filterObj->getSetWeights())) - if ($items->hasSetFields(['armor'])) + if ($items->hasSetFields('armor')) $tabData['visibleCols'][] = 'armor'; // create note if search limit was exceeded; overwriting 'note' is intentional diff --git a/pages/itemset.php b/pages/itemset.php index bdae580d..99aeab07 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -229,7 +229,7 @@ class ItemsetPage extends GenericPage 'name' => '$LANG.tab_seealso' ); - if (!$relSets->hasDiffFields(['classMask'])) + if (!$relSets->hasDiffFields('classMask')) $tabData['hiddenCols'] = ['classes']; $this->lvTabs[] = [ItemsetList::$brickFile, $tabData]; diff --git a/pages/npc.php b/pages/npc.php index 81a8ad6b..cd9b5694 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -639,7 +639,7 @@ class NpcPage extends GenericPage { $colAddIn = null; $extraCols = ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost']; - if ($soldItems->hasSetFields(['condition'])) + if ($soldItems->hasSetFields('condition')) $extraCols[] = '$Listview.extraCols.condition'; $lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [Type::NPC => [$this->typeId]]); diff --git a/pages/objects.php b/pages/objects.php index 345c3b31..4dab6eac 100644 --- a/pages/objects.php +++ b/pages/objects.php @@ -59,7 +59,7 @@ class ObjectsPage extends GenericPage if (!$objects->error) { $tabData['data'] = array_values($objects->getListviewData()); - if ($objects->hasSetFields(['reqSkill'])) + if ($objects->hasSetFields('reqSkill')) $tabData['visibleCols'] = ['skill']; // create note if search limit was exceeded diff --git a/pages/pets.php b/pages/pets.php index cdf941a0..8787b020 100644 --- a/pages/pets.php +++ b/pages/pets.php @@ -48,7 +48,7 @@ class PetsPage extends GenericPage 'computeDataFunc' => '$_' ); - if (!$pets->hasDiffFields(['type'])) + if (!$pets->hasDiffFields('type')) $data['hiddenCols'] = ['type']; }; $this->lvTabs[] = [PetList::$brickFile, $data, 'petFoodCol']; diff --git a/pages/profiles.php b/pages/profiles.php index 91e2dabe..3c81fd87 100644 --- a/pages/profiles.php +++ b/pages/profiles.php @@ -140,7 +140,7 @@ class ProfilesPage extends GenericPage // init roster-listview // $_GET['roster'] = 1|2|3|4 originally supplemented this somehow .. 2,3,4 arenateam-size (4 => 5-man), 1 guild - if ($this->roster == 1 && !$profiles->hasDiffFields(['guild']) && $profiles->getField('guild')) + if ($this->roster == 1 && !$profiles->hasDiffFields('guild') && $profiles->getField('guild')) { $tabData['roster'] = $this->roster; $tabData['visibleCols'][] = 'guildrank'; @@ -148,7 +148,7 @@ class ProfilesPage extends GenericPage $this->roster = Lang::profiler('guildRoster', [$profiles->getField('guildname')]); } - else if ($this->roster && !$profiles->hasDiffFields(['arenateam']) && $profiles->getField('arenateam')) + else if ($this->roster && !$profiles->hasDiffFields('arenateam') && $profiles->getField('arenateam')) { $tabData['roster'] = $this->roster; $tabData['visibleCols'][] = 'rating'; diff --git a/pages/search.php b/pages/search.php index 6d172344..15cca1f1 100644 --- a/pages/search.php +++ b/pages/search.php @@ -647,7 +647,7 @@ class SearchPage extends GenericPage } $vis = ['level', 'schools']; - if ($abilities->hasSetFields(['reagent1'])) + if ($abilities->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8')) $vis[] = 'reagents'; $vis[] = $multiClass > 1 ? 'classes' : 'singleclass'; @@ -700,7 +700,7 @@ class SearchPage extends GenericPage $this->extendGlobalData($talents->getJSGlobals()); $vis = ['level', 'singleclass', 'schools']; - if ($talents->hasSetFields(['reagent1'])) + if ($talents->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8')) $vis[] = 'reagents'; $osInfo = [Type::SPELL, ' (Talent)', $talents->getMatches(), [], []]; @@ -1353,7 +1353,7 @@ class SearchPage extends GenericPage if (array_filter(array_column($result['data'], 'spells'))) $result['visibleCols'] = ['trigger']; - if (!$enchantment->hasSetFields(['skillLine'])) + if (!$enchantment->hasSetFields('skillLine')) $result['hiddenCols'] = ['skill']; if ($enchantment->getMatches() > $this->maxResults) diff --git a/pages/spell.php b/pages/spell.php index e0b5e7a0..6b8b50ba 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -374,7 +374,7 @@ class SpellPage extends GenericPage 'visibleCols' => ['level'], ); - if (!$abilities->hasSetFields(['skillLines'])) + if (!$abilities->hasSetFields('skillLines')) $tabData['hiddenCols'] = ['skill']; $this->lvTabs[] = [SpellList::$brickFile, $tabData]; @@ -432,7 +432,7 @@ class SpellPage extends GenericPage } $modifiesData += $modSpells->getListviewData(); - if ($modSpells->hasSetFields(['skillLines'])) + if ($modSpells->hasSetFields('skillLines')) $hideSkillCol = false; $this->extendGlobalData($modSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); @@ -500,7 +500,7 @@ class SpellPage extends GenericPage 'visibleCols' => ['level'], ); - if (!$modsSpell->hasSetFields(['skillLines'])) + if (!$modsSpell->hasSetFields('skillLines')) $tabData['hiddenCols'] = ['skill']; $this->lvTabs[] = [SpellList::$brickFile, $tabData]; @@ -562,7 +562,7 @@ class SpellPage extends GenericPage 'visibleCols' => ['level'], ); - if (!$saSpells->hasSetFields(['skillLines'])) + if (!$saSpells->hasSetFields('skillLines')) $tabData['hiddenCols'] = ['skill']; if (isset($saE)) @@ -812,7 +812,7 @@ class SpellPage extends GenericPage foreach ($data as $k => $d) $data[$k]['stackRule'] = $groups[$k]; - if (!$stacks->hasSetFields(['skillLines'])) + if (!$stacks->hasSetFields('skillLines')) $sH = ['skill']; $tabData = array( @@ -1100,7 +1100,7 @@ class SpellPage extends GenericPage 'visibleCols' => $vis, ); - if (!$teaches->hasSetFields(['skillLines'])) + if (!$teaches->hasSetFields('skillLines')) $tabData['hiddenCols'] = ['skill']; $this->lvTabs[] = [SpellList::$brickFile, $tabData]; diff --git a/pages/spells.php b/pages/spells.php index f19ad75a..36e56c25 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -446,15 +446,15 @@ class SpellsPage extends GenericPage $tabData['_errors'] = 1; - $mask = $spells->hasSetFields(['reagent1', 'skillLines', 'trainingCost', 'reqClassMask']); - if ($mask & 0x1) - $visibleCols[] = 'reagents'; - if (!($mask & 0x2) && $this->category && !in_array($this->category[0], [9, 11])) + $mask = $spells->hasSetFields('skillLines', 'trainingCost', 'reqClassMask', null, 'reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8'); + if (!($mask & 0x1) && $this->category && !in_array($this->category[0], [9, 11])) $hiddenCols[] = 'skill'; - if ($mask & 0x4) + if ($mask & 0x2) $visibleCols[] = 'trainingcost'; - if (($mask & 0x8) && !in_array('singleclass', $visibleCols)) + if (($mask & 0x4) && !in_array('singleclass', $visibleCols)) $visibleCols[] = 'classes'; + if ($mask & 0xFF0) + $visibleCols[] = 'reagents'; if ($visibleCols) diff --git a/pages/titles.php b/pages/titles.php index 6983ac59..ad1e4255 100644 --- a/pages/titles.php +++ b/pages/titles.php @@ -42,7 +42,7 @@ class TitlesPage extends GenericPage { $tabData['data'] = array_values($titles->getListviewData()); - if ($titles->hasDiffFields(['category'])) + if ($titles->hasDiffFields('category')) $tabData['visibleCols'] = ['category']; if (!$titles->hasAnySource()) diff --git a/pages/zones.php b/pages/zones.php index 8cf95c40..b1effd6e 100644 --- a/pages/zones.php +++ b/pages/zones.php @@ -73,7 +73,7 @@ class ZonesPage extends GenericPage $zones = new ZoneList($conditions); - if (!$zones->hasSetFields(['type'])) + if (!$zones->hasSetFields('type')) $hiddenCols[] = 'instancetype'; $tabData = ['data' => array_values($zones->getListviewData())];