diff --git a/includes/loot.class.php b/includes/loot.class.php index dcf2f631..8b9a2b4e 100644 --- a/includes/loot.class.php +++ b/includes/loot.class.php @@ -312,10 +312,10 @@ class Loot break; } - $this->extraCols[] = "Listview.funcBox.createSimpleCol('group', 'Group', '7%', 'group')"; + $this->extraCols[] = "\$Listview.funcBox.createSimpleCol('group', 'Group', '7%', 'group')"; foreach ($fields as $idx => $field) if ($set & (1 << $idx)) - $this->extraCols[] = "Listview.funcBox.createSimpleCol('".$field."', '".Util::ucFirst($field)."', '7%', '".$field."')"; + $this->extraCols[] = "\$Listview.funcBox.createSimpleCol('".$field."', '".Util::ucFirst($field)."', '7%', '".$field."')"; } return true; @@ -505,7 +505,7 @@ class Loot } $tabsFinal[$tabId][1][] = array_merge($srcData[$srcObj->id], $result[$srcObj->getField('lootId')]); - $tabsFinal[$tabId][4][] = 'Listview.extraCols.percent'; + $tabsFinal[$tabId][4][] = '$Listview.extraCols.percent'; if ($tabId != 15) $tabsFinal[$tabId][6][] = 'skill'; } @@ -563,7 +563,7 @@ class Loot $srcData = $srcObj->getListviewData(); if (!empty($result)) - $tabsFinal[16][4][] = 'Listview.extraCols.percent'; + $tabsFinal[16][4][] = '$Listview.extraCols.percent'; if ($srcObj->hasSetFields(['reagent1'])) $tabsFinal[16][6][] = 'reagents'; @@ -601,14 +601,33 @@ class Loot $tabId = abs($tabId); // general case (skinning) $tabsFinal[$tabId][1][] = array_merge($srcData[$srcObj->id], $result[$srcObj->getField($field)]); - $tabsFinal[$tabId][4][] = 'Listview.extraCols.percent'; + $tabsFinal[$tabId][4][] = '$Listview.extraCols.percent'; } } break; } } - $this->results = $tabsFinal; + foreach ($tabsFinal as $tabId => $data) + { + $tabData = array( + 'data' => $data[1], + 'name' => $data[2], + 'id' => $data[3] + ); + + if ($data[4]) + $tabData['extraCols'] = array_unique($data[4]); + + if ($data[5]) + $tabData['hiddenCols'] = array_unique($data[5]); + + if ($data[6]) + $tabData['visibleCols'] = array_unique($data[6]); + + $this->results[$tabId] = [$data[0], $tabData]; + } + return true; } diff --git a/includes/shared.php b/includes/shared.php index 1f4c8eb1..95ff3ce5 100644 --- a/includes/shared.php +++ b/includes/shared.php @@ -1,6 +1,6 @@ curTpl['requiredLevel'] > 1 ? $this->curTpl['requiredLevel'] : MAX_LEVEL; $level = min(max($reqLvl, $ssdLvl), MAX_LEVEL); - if (!Lang::item('statType', $type)) // unknown rating - return sprintf(Lang::item('statType', count(Lang::item('statType')) - 1), $type, $value); - else if (in_array($type, Util::$lvlIndepRating)) // level independant Bonus + // unknown rating + if (in_array($type, [2, 8, 9, 10, 11]) || $type > ITEM_MOD_BLOCK_VALUE || $type < 0) + { + if (User::isInGroup(U_GROUP_EMPLOYEE)) + return sprintf(Lang::item('statType', count(Lang::item('statType')) - 1), $type, $value); + else + return null; + } + // level independant Bonus + else if (in_array($type, Util::$lvlIndepRating)) return Lang::item('trigger', 1).str_replace('%d', ''.$value, Lang::item('statType', $type)); - else // rating-Bonuses + // rating-Bonuses + else { $scaling = true; diff --git a/includes/types/quest.class.php b/includes/types/quest.class.php index 1a3ac60a..018659ab 100644 --- a/includes/types/quest.class.php +++ b/includes/types/quest.class.php @@ -400,10 +400,8 @@ class QuestList extends BaseType // currencies if (!empty($this->rewards[$this->id][TYPE_CURRENCY])) - { - $_ = $this->rewards[$this->id][TYPE_CURRENCY]; - $data[TYPE_CURRENCY] = array_combine(array_keys($_), array_keys($_)); - } + foreach ($this->rewards[$this->id][TYPE_CURRENCY] as $id => $__) + $data[TYPE_CURRENCY][$id] = $id; } if ($addMask & GLOBALINFO_SELF) diff --git a/includes/utilities.php b/includes/utilities.php index fd9d346c..b5cc06b7 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1576,10 +1576,13 @@ class Util if (CFG_DEBUG) $flags |= JSON_PRETTY_PRINT; - // just a thought: .. about prefixing variables with $ to mark them as function code and retroactively stripping escapes from them - // like it's done already in with listviews for example + $json = json_encode($data, $flags); - return json_encode($data, $flags); + // handle strings prefixed with $ as js-variables + // literal: match everything (lazy) between first pair of unescaped double quotes. First character must be $. + $json = preg_replace_callback('/(? "Ihr erlernt", 'bonusTalents' => "Talentpunkte", 'spellDisplayed'=> ' (%s wird angezeigt)', + 'attachment' => "Anlage", 'questInfo' => array( 0 => "Normal", 1 => "Gruppe", 21 => "Leben", 41 => "PvP", 62 => "Schlachtzug", 81 => "Dungeon", 82 => "Weltereignis", 83 => "Legendär", 84 => "Eskorte", 85 => "Heroisch", 88 => "Schlachtzug (10)", 89 => "Schlachtzug (25)" @@ -761,6 +762,8 @@ $lang = array( 'pctCostOf' => "vom Grund%s", 'costPerSec' => ", plus %s pro Sekunde", 'costPerLevel' => ", plus %s pro Stufe", + 'stackGroup' => "Stack Gruppierung", + 'linkedWith' => "Verknüpft mit", '_scaling' => "Skalierung", 'scaling' => array( 'directSP' => "+%.2f%% der Zaubermacht zum direkten Effekt", 'directAP' => "+%.2f%% der Angriffskraft zum direkten Effekt", diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 3fd469af..f51930b8 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -573,6 +573,7 @@ $lang = array( 'spellLearn' => "You will learn", 'bonusTalents' => "talent points", 'spellDisplayed'=> ' (%s is displayed)', + 'attachment' => "Attachment", 'questInfo' => array( 0 => "Normal", 1 => "Group", 21 => "Life", 41 => "PvP", 62 => "Raid", 81 => "Dungeon", 82 => "World Event", 83 => "Legendary", 84 => "Escort", 85 => "Heroic", 88 => "Raid (10)", 89 => "Raid (25)" @@ -756,6 +757,8 @@ $lang = array( 'pctCostOf' => "of base %s", 'costPerSec' => ", plus %s per sec", 'costPerLevel' => ", plus %s per level", + 'stackGroup' => "Stack Group", + 'linkedWith' => "Linked with", '_scaling' => "Scaling", 'scaling' => array( 'directSP' => "+%.2f%% of spell power to direct component", 'directAP' => "+%.2f%% of attack power to direct component", diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 8e9b6096..ba6b7001 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -577,6 +577,7 @@ $lang = array( 'spellLearn' => "Aprenderás", 'bonusTalents' => "puntos de talento", 'spellDisplayed'=> ' (mostrando %s)', + 'attachment' => "[Attachment]", 'questInfo' => array( 0 => "Normal", 1 => "Élite", 21 => "Vida", 41 => "JcJ", 62 => "Banda", 81 => "Mazmorra", 82 => "Evento del mundo", 83 => "Legendaria", 84 => "Escolta", 85 => "Heroica", 88 => "Banda (10)", 89 => "Banda (25)" @@ -760,6 +761,8 @@ $lang = array( 'pctCostOf' => "del %s base", 'costPerSec' => ", mas %s por segundo", 'costPerLevel' => ", mas %s por nivel", + 'stackGroup' => "[Stack Group]", + 'linkedWith' => "[Linked with]", '_scaling' => "[Scaling]", 'scaling' => array( 'directSP' => "[+%.2f%% of spell power to direct component]", 'directAP' => "[+%.2f%% of attack power to direct component]", diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 2533368c..64e024a5 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -576,6 +576,7 @@ $lang = array( 'spellLearn' => "Vous apprendrez", 'bonusTalents' => "points de talent", 'spellDisplayed'=> ' (%s affichés)', + 'attachment' => "[Attachment]", 'questInfo' => array( 0 => "Standard", 1 => "Groupe", 21 => "Vie", 41 => "JcJ", 62 => "Raid", 81 => "Donjon", 82 => "Évènement mondial", 83 => "Légendaire", 84 => "Escorte", 85 => "Héroïque", 88 => "Raid (10)", 89 => "Raid (25)" @@ -758,6 +759,8 @@ $lang = array( 'pctCostOf' => "de la %s de base", 'costPerSec' => ", plus %s par seconde", 'costPerLevel' => ", plus %s par niveau", + 'stackGroup' => "[Stack Group]", + 'linkedWith' => "[Linked with]", '_scaling' => "[Scaling]", 'scaling' => array( 'directSP' => "+%.2f%% de la puissance des sorts directe", 'directAP' => "+%.2f%% de la puissance d'attaque directe", diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 74d4d3ae..cf1dc087 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -576,6 +576,7 @@ $lang = array( 'spellLearn' => "Вы изучите", 'bonusTalents' => "очков талантов", 'spellDisplayed'=> ' (показано: %s)', + 'attachment' => "[Attachment]", 'questInfo' => array( 0 => "Обычный", 1 => "Группа", 21 => "Жизнь", 41 => "PvP", 62 => "Рейд", 81 => "Подземелье", 82 => "Игровое событие", 83 => "Легенда", 84 => "Сопровождение", 85 => "Героическое", 88 => "Рейд (10)", 89 => "Рейд (25)" @@ -760,6 +761,8 @@ $lang = array( 'pctCostOf' => "от базовой %s", 'costPerSec' => ", плюс %s в секунду", 'costPerLevel' => ", плюс %s за уровень", + 'stackGroup' => "[Stack Group]", + 'linkedWith' => "[Linked with]", '_scaling' => "[Scaling]", 'scaling' => array( 'directSP' => "[+%.2f%% of spell power to direct component]", 'directAP' => "[+%.2f%% of attack power to direct component]", diff --git a/pages/account.php b/pages/account.php index 5f87f98b..fdc5e8c8 100644 --- a/pages/account.php +++ b/pages/account.php @@ -218,7 +218,6 @@ class AccountPage extends GenericPage /* Listview */ /************/ - $this->lvTabs = []; $this->forceTabs = true; // Reputation changelog (params only for comment-events) @@ -227,11 +226,7 @@ class AccountPage extends GenericPage foreach ($repData as &$r) $r['when'] = date(Util::$dateFormatInternal, $r['when']); - $this->lvTabs[] = array( - 'file' => 'reputationhistory', - 'data' => $repData, - 'params' => [] - ); + $this->lvTabs[] = ['reputationhistory', ['data' => $repData]]; } // comments @@ -241,14 +236,11 @@ class AccountPage extends GenericPage // _totalCount: 377, // note: $WH.sprintf(LANG.lvnote_usercomments, 377), - $this->lvTabs[] = array( - 'file' => 'commentpreview', - 'data' => $_, - 'params' => array( - 'hiddenCols' => "$['author']", - 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments' - ) - ); + $this->lvTabs[] = ['commentpreview', array( + 'data' => $_, + 'hiddenCols' => ['author'], + 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments' + )]; } // replies @@ -259,13 +251,10 @@ class AccountPage extends GenericPage // _totalCount: 377, // note: $WH.sprintf(LANG.lvnote_usercomments, 377), - $this->lvTabs[] = array( - 'file' => 'replypreview', - 'data' => $_, - 'params' => array( - 'hiddenCols' => "$['author']" - ) - ); + $this->lvTabs[] = ['replypreview', array( + 'data' => $_, + 'hiddenCols' => ['author'] + )]; } /* diff --git a/pages/achievement.php b/pages/achievement.php index 26a98e33..705a4d5b 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -219,15 +219,12 @@ class AchievementPage extends GenericPage ['id', $this->typeId, '!'] ); $saList = new AchievementList($conditions); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $saList->getListviewData(), - 'params' => array( - 'id' => 'see-also', - 'name' => '$LANG.tab_seealso', - 'visibleCols' => "$['category']" - ) - ); + $this->lvTabs[] = ['achievement', array( + 'data' => array_values($saList->getListviewData()), + 'id' => 'see-also', + 'name' => '$LANG.tab_seealso', + 'visibleCols' => ['category'] + )]; $this->extendGlobalData($saList->getJSGlobals()); // tab: criteria of @@ -238,15 +235,12 @@ class AchievementPage extends GenericPage if (!empty($refs)) { $coList = new AchievementList(array(['id', $refs])); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $coList->getListviewData(), - 'params' => array( - 'id' => 'criteria-of', - 'name' => '$LANG.tab_criteriaof', - 'visibleCols' => "$['category']" - ) - ); + $this->lvTabs[] = ['achievement', array( + 'data' => array_values($coList->getListviewData()), + 'id' => 'criteria-of', + 'name' => '$LANG.tab_criteriaof', + 'visibleCols' => ['category'] + )]; $this->extendGlobalData($coList->getJSGlobals()); } diff --git a/pages/achievements.php b/pages/achievements.php index ffc95e2b..0c92f28b 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -88,37 +88,33 @@ class AchievementsPage extends GenericPage $acvList = new AchievementList($conditions); } - $params = $data = []; + $tabData = []; if (!$acvList->error) { - $data = $acvList->getListviewData(); + $tabData['data'] = array_values($acvList->getListviewData()); // fill g_items, g_titles, g_achievements $this->extendGlobalData($acvList->getJSGlobals()); // if we are have different cats display field if ($acvList->hasDiffFields(['category'])) - $params['visibleCols'] = "$['category']"; + $tabData['visibleCols'] = ['category']; if (!empty($this->filter['fi']['extraCols'])) - $params['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; + $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; // create note if search limit was exceeded if ($acvList->getMatches() > CFG_SQL_LIMIT_DEFAULT) { - $params['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), CFG_SQL_LIMIT_DEFAULT); - $params['_truncated'] = 1; + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['_truncated'] = 1; } if ($this->filterObj->error) - $params['_errors'] = '$1'; + $tabData['_errors'] = 1; } - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $data, - 'params' => $params - ); + $this->lvTabs[] = ['achievement', $tabData]; // sort for dropdown-menus in filter Lang::sort('game', 'si'); diff --git a/pages/admin.php b/pages/admin.php index a4f022a7..b9b68481 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -362,24 +362,18 @@ class AdminPage extends GenericPage } foreach ($mainTab as $n => $t) - $this->lvTabs[] = array( - 'file' => null, - 'data' => $t, - 'params' => array( - 'name' => $n, - 'id' => Util::urlize($n) - ) - ); + $this->lvTabs[] = [null, array( + 'data' => $t, + 'name' => $n, + 'id' => Util::urlize($n) + )]; foreach ($miscTab as $n => $t) - $this->lvTabs[] = array( - 'file' => null, - 'data' => $t, - 'params' => array( - 'name' => $n, - 'id' => Util::urlize($n) - ) - ); + $this->lvTabs[] = [null, array( + 'data' => $t, + 'name' => $n, + 'id' => Util::urlize($n) + )]; } private function handlePhpInfo() @@ -428,26 +422,20 @@ class AdminPage extends GenericPage else $name .= $p[0]; - $this->lvTabs[] = array( - 'file' => null, - 'data' => $body, - 'params' => array( - 'id' => strtolower(strtr($name, [' ' => ''])), - 'name' => $name - ) - ); + $this->lvTabs[] = [null, array( + 'data' => $body, + 'id' => strtolower(strtr($name, [' ' => ''])), + 'name' => $name + )]; } } else { - $this->lvTabs[] = array( - 'file' => null, - 'data' => $buff, - 'params' => array( - 'id' => strtolower($names[$i]), - 'name' => $names[$i] - ) - ); + $this->lvTabs[] = [null, array( + 'data' => $buff, + 'id' => strtolower($names[$i]), + 'name' => $names[$i] + )]; } } } diff --git a/pages/class.php b/pages/class.php index d52d1925..b5352966 100644 --- a/pages/class.php +++ b/pages/class.php @@ -135,19 +135,16 @@ class ClassPage extends GenericPage { $this->extendGlobalData($genSpells->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $genSpells->getListviewData(), - 'params' => array( - 'id' => 'spells', - 'name' => '$LANG.tab_spells', - 'visibleCols' => "$['level', 'schools', 'type', 'classes']", - 'hiddenCols' => "$['reagents', 'skill']", - 'sort' => "$['-level', 'type', 'name']", - 'computeDataFunc' => '$Listview.funcBox.initSpellFilter', - 'onAfterCreate' => '$Listview.funcBox.addSpellIndicator' - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($genSpells->getListviewData()), + 'id' => 'spells', + 'name' => '$LANG.tab_spells', + 'visibleCols' => ['level', 'schools', 'type', 'classes'], + 'hiddenCols' => ['reagents', 'skill'], + 'sort' => ['-level', 'type', 'name'], + 'computeDataFunc' => '$Listview.funcBox.initSpellFilter', + 'onAfterCreate' => '$Listview.funcBox.addSpellIndicator' + )]; } // Tab: Items (grouped) @@ -156,7 +153,7 @@ class ClassPage extends GenericPage ['requiredClass', $_mask, '&'], [['requiredClass', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'], ['itemset', 0], // hmm, do or dont..? - 0 + CFG_SQL_LIMIT_NONE ); $items = new ItemList($conditions); @@ -164,23 +161,21 @@ class ClassPage extends GenericPage { $this->extendGlobalData($items->getJSGlobals()); - if (!$items->hasDiffFields(['requiredRace'])) - $hidden = "$['side']"; + $hiddenCols = null; + if ($items->hasDiffFields(['requiredRace'])) + $hiddenCols = ['side']; - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $items->getListviewData(), - 'params' => array( - 'id' => 'items', - 'name' => '$LANG.tab_items', - 'visibleCols' => "$['dps', 'armor', 'slot']", - 'hiddenCols' => isset($hidden) ? $hidden : null, - 'computeDataFunc' => '$Listview.funcBox.initSubclassFilter', - 'onAfterCreate' => '$Listview.funcBox.addSubclassIndicator', - 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=152;crs='.$this->typeId.';crv=0'), - '_truncated' => 1 - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($items->getListviewData()), + 'id' => 'items', + 'name' => '$LANG.tab_items', + 'visibleCols' => ['dps', 'armor', 'slot'], + 'hiddenCols' => $hiddenCols, + 'computeDataFunc' => '$Listview.funcBox.initSubclassFilter', + 'onAfterCreate' => '$Listview.funcBox.addSubclassIndicator', + 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=152;crs='.$this->typeId.';crv=0'), + '_truncated' => 1 + )]; } // Tab: Quests @@ -194,11 +189,10 @@ class ClassPage extends GenericPage { $this->extendGlobalData($quests->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $quests->getListviewData(), - 'params' => ['sort' => "$['reqlevel', 'name']"] - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($quests->getListviewData()), + 'sort' => ['reqlevel', 'name'] + )]; } // Tab: Itemsets @@ -207,15 +201,12 @@ class ClassPage extends GenericPage { $this->extendGlobalData($sets->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'itemset', - 'data' => $sets->getListviewData(), - 'params' => array( - 'note' => sprintf(Util::$filterResultString, '?itemsets&filter=cl='.$this->typeId), - 'hiddenCols' => "$['classes']", - 'sort' => "$['-level', 'name']" - ) - ); + $this->lvTabs[] = ['itemset', array( + 'data' => array_values($sets->getListviewData()), + 'note' => sprintf(Util::$filterResultString, '?itemsets&filter=cl='.$this->typeId), + 'hiddenCols' => ['classes'], + 'sort' => ['-level', 'name'] + )]; } // Tab: Trainer @@ -228,26 +219,17 @@ class ClassPage extends GenericPage $trainer = new CreatureList($conditions); if (!$trainer->error) { - $this->lvTabs[] = array( - 'file' => 'creature', - 'data' => $trainer->getListviewData(), - 'params' => array( - 'id' => 'trainers', - 'name' => '$LANG.tab_trainers' - ) - ); + $this->lvTabs[] = ['creature', array( + 'data' => array_values($trainer->getListviewData()), + 'id' => 'trainers', + 'name' => '$LANG.tab_trainers' + )]; } // Tab: Races $races = new CharRaceList(array(['classMask', $_mask, '&'])); if (!$races->error) - { - $this->lvTabs[] = array( - 'file' => 'race', - 'data' => $races->getListviewData(), - 'params' => [] - ); - } + $this->lvTabs[] = ['race', ['data' => array_values($races->getListviewData())]]; } } diff --git a/pages/classes.php b/pages/classes.php index 5b7da124..9b8a2448 100644 --- a/pages/classes.php +++ b/pages/classes.php @@ -27,13 +27,7 @@ class ClassesPage extends GenericPage { $classes = new CharClassList(); if (!$classes->error) - { - $this->lvTabs[] = array( - 'file' => 'class', - 'data' => $classes->getListviewData(), - 'params' => [] - ); - } + $this->lvTabs[] = ['class', ['data' => array_values($classes->getListviewData())]]; } protected function generateTitle() diff --git a/pages/compare.php b/pages/compare.php index cdd5c6fa..7817378c 100644 --- a/pages/compare.php +++ b/pages/compare.php @@ -64,7 +64,12 @@ class ComparePage extends GenericPage $outSet[] = $outString; } - $this->summary = $outSet; + $this->summary = array( + 'template' => 'compare', + 'id' => 'compare', + 'parent' => 'compare-generic', + 'groups' => $outSet + ); $iList = new ItemList(array(['i.id', $items])); $data = $iList->getListviewData(ITEMINFO_SUBITEMS | ITEMINFO_JSON); @@ -78,12 +83,11 @@ class ComparePage extends GenericPage foreach ($data[$itemId]['subitems'] as &$si) $si['enchantment'] = implode(', ', $si['enchantment']); - $this->cmpItems[] = [ - $itemId, - $iList->getField('name', true), - $iList->getField('quality'), - $iList->getField('iconString'), - $data[$itemId] + $this->cmpItems[$itemId] = [ + 'name_'.User::$localeString => $iList->getField('name', true), + 'quality' => $iList->getField('quality'), + 'icon' => $iList->getField('iconString'), + 'jsonequip' => $data[$itemId] ]; } } diff --git a/pages/currencies.php b/pages/currencies.php index ba788a59..33179b6a 100644 --- a/pages/currencies.php +++ b/pages/currencies.php @@ -37,11 +37,7 @@ class CurrenciesPage extends GenericPage $conditions[] = ['category', (int)$this->category[0]]; $money = new CurrencyList($conditions); - $this->lvTabs[] = array( - 'file' => 'currency', - 'data' => $money->getListviewData(), - 'params' => [] - ); + $this->lvTabs[] = ['currency', ['data' => array_values($money->getListviewData())]]; } protected function generateTitle() diff --git a/pages/currency.php b/pages/currency.php index 2e4510f8..e8092c19 100644 --- a/pages/currency.php +++ b/pages/currency.php @@ -87,20 +87,8 @@ class CurrencyPage extends GenericPage { $this->extendGlobalData($lootTabs->jsGlobals); - foreach ($lootTabs->iterate() as $tab) - { - $this->lvTabs[] = array( - 'file' => $tab[0], - 'data' => $tab[1], - 'params' => [ - 'name' => $tab[2], - 'id' => $tab[3], - 'extraCols' => $tab[4] ? '$['.implode(', ', array_unique($tab[4])).']' : null, - 'hiddenCols' => $tab[5] ? '$['.implode(', ', array_unique($tab[5])).']' : null, - 'visibleCols' => $tab[6] ? '$'. Util::toJSON( array_unique($tab[6])) : null - ] - ); - } + foreach ($lootTabs->iterate() as list($file, $tabData)) + $this->lvTabs[] = [$file, $tabData]; } // tab: sold by @@ -114,7 +102,7 @@ class CurrencyPage extends GenericPage if (!$soldBy->error) { $sbData = $soldBy->getListviewData(); - $extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost']; + $extraCols = ['$Listview.extraCols.stock', "\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost']; $holidays = []; foreach ($sbData as $k => &$row) @@ -135,7 +123,7 @@ class CurrencyPage extends GenericPage if ($vendors[$k]['event']) { if (count($extraCols) == 3) // not already pushed - $extraCols[] = 'Listview.extraCols.condition'; + $extraCols[] = '$Listview.extraCols.condition'; $this->extendGlobalIds(TYPE_WORLDEVENT, $vendors[$k]['event']); $row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $vendors[$k]['event']]]; @@ -150,16 +138,13 @@ class CurrencyPage extends GenericPage ); } - $this->lvTabs[] = array( - 'file' => 'creature', - 'data' => $sbData, - 'params' => [ - 'name' => '$LANG.tab_soldby', - 'id' => 'sold-by-npc', - 'extraCols' => '$['.implode(', ', $extraCols).']', - 'hiddenCols' => "$['level', 'type']" - ] - ); + $this->lvTabs[] = ['creature', array( + 'data' => array_values($sbData), + 'name' => '$LANG.tab_soldby', + 'id' => 'sold-by-npc', + 'extraCols' => $extraCols, + 'hiddenCols' => ['level', 'type'] + )]; } } } @@ -172,18 +157,16 @@ class CurrencyPage extends GenericPage { $this->extendGlobalData($createdBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - if ($createdBy->hasSetFields(['reagent1'])) - $visCols = ['reagents']; - - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $createdBy->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_createdby', - 'id' => 'created-by', - 'visibleCols' => isset($visCols) ? '$'.Util::toJSON($visCols) : null - ] + $tabData = array( + 'data' => array_values($createdBy->getListviewData()), + 'name' => '$LANG.tab_createdby', + 'id' => 'created-by', ); + + if ($createdBy->hasSetFields(['reagent1'])) + $tabData['visibleCols'] = ['reagents']; + + $this->lvTabs[] = ['spell', $tabData]; } } @@ -211,20 +194,18 @@ class CurrencyPage extends GenericPage $boughtBy = new ItemList(array(['id', $boughtBy])); if (!$boughtBy->error) { - if ($boughtBy->getMatches() <= CFG_SQL_LIMIT_DEFAULT) - $n = null; - - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, [TYPE_CURRENCY => $this->typeId]), - 'params' => [ - 'name' => '$LANG.tab_currencyfor', - 'id' => 'currency-for', - 'extraCols' => "$[Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')]", - 'note' => $n ? sprintf(Util::$filterResultString, $n) : null - ] + $tabData = array( + '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')"], ); + if ($boughtBy->getMatches() > CFG_SQL_LIMIT_DEFAULT) + $tabData['note'] = sprintf(Util::$filterResultString, $n); + + $this->lvTabs[] = ['item', $tabData]; + $this->extendGlobalData($boughtBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } diff --git a/pages/emote.php b/pages/emote.php index 9d78a2f0..ec25689f 100644 --- a/pages/emote.php +++ b/pages/emote.php @@ -93,11 +93,7 @@ class EmotePage extends GenericPage ); $acv = new AchievementList($condition); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $acv->getListviewData(), - 'params' => [] - ); + $this->lvTabs[] = ['achievement', ['data' => array_values($acv->getListviewData())]]; $this->extendGlobalData($acv->getJsGlobals()); } diff --git a/pages/emotes.php b/pages/emotes.php index 68a3bcfe..68a3a37a 100644 --- a/pages/emotes.php +++ b/pages/emotes.php @@ -25,11 +25,12 @@ class EmotesPage extends GenericPage protected function generateContent() { - $this->lvTabs[] = array( - 'file' => 'emote', - 'data' => (new EmoteList())->getListviewData(), - 'params' => [] + $tabData = array( + 'data' => array_values((new EmoteList())->getListviewData()), + 'name' => Util::ucFirst(Lang::game('emotes')) ); + + $this->lvTabs[] = ['emote', $tabData, 'emote']; } protected function generateTitle() diff --git a/pages/enchantment.php b/pages/enchantment.php index a964b57a..47fc5e32 100644 --- a/pages/enchantment.php +++ b/pages/enchantment.php @@ -175,14 +175,11 @@ class EnchantmentPage extends GenericPage $gemList = new ItemList(array(['gemEnchantmentId', $this->typeId])); if (!$gemList->error) { - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $gemList->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_usedby + \' \' + LANG.gems', - 'id' => 'used-by-gem', - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($gemList->getListviewData()), + 'name' => '$LANG.tab_usedby + \' \' + LANG.gems', + 'id' => 'used-by-gem', + )]; $this->extendGlobalData($gemList->getJsGlobals()); } @@ -191,14 +188,11 @@ class EnchantmentPage extends GenericPage $socketsList = new ItemList(array(['socketBonus', $this->typeId])); if (!$socketsList->error) { - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $socketsList->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_usedby + \' \' + \''.Lang::item('socketBonus').'\'', - 'id' => 'used-by-socketbonus', - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($socketsList->getListviewData()), + 'name' => '$LANG.tab_usedby + \' \' + \''.Lang::item('socketBonus').'\'', + 'id' => 'used-by-socketbonus', + )]; $this->extendGlobalData($socketsList->getJsGlobals()); } @@ -230,14 +224,11 @@ class EnchantmentPage extends GenericPage $ubItems = new ItemList($conditions); if (!$ubItems->error) { - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $ubItems->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_usedby + \' \' + LANG.types[3][0]', - 'id' => 'used-by-item', - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($ubItems->getListviewData()), + 'name' => '$LANG.tab_usedby + \' \' + LANG.types[3][0]', + 'id' => 'used-by-item', + )]; $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF)); } @@ -266,14 +257,11 @@ class EnchantmentPage extends GenericPage } } - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $spellData, - 'params' => array( - 'name' => '$LANG.tab_usedby + \' \' + LANG.types[6][0]', - 'id' => 'used-by-spell', - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($spellData), + 'name' => '$LANG.tab_usedby + \' \' + LANG.types[6][0]', + 'id' => 'used-by-spell', + )]; } // used by randomAttrItem @@ -303,15 +291,12 @@ class EnchantmentPage extends GenericPage $data[$iId]['name'] .= ' '.Util::localizedString($ire[$iet[abs($re)]['ench']], 'name'); } - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $data, - 'params' => array( - 'id' => 'used-by-rand', - 'name' => '$LANG.tab_usedby + \' \' + \''.Lang::item('_rndEnchants').'\'', - 'extraCols' => '$[Listview.extraCols.percent]' - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($data), + 'id' => 'used-by-rand', + 'name' => '$LANG.tab_usedby + \' \' + \''.Lang::item('_rndEnchants').'\'', + 'extraCols' => ['$Listview.extraCols.percent'] + )]; $this->extendGlobalData($randItems->getJSGlobals(GLOBALINFO_SELF)); } diff --git a/pages/enchantments.php b/pages/enchantments.php index 961c5cc3..1052eee8 100644 --- a/pages/enchantments.php +++ b/pages/enchantments.php @@ -30,10 +30,9 @@ class EnchantmentsPage extends GenericPage protected function generateContent() { - $tab = array( - 'file' => 'enchantment', - 'data' => [], - 'params' => [] + $tabData = array( + 'data' => [], + 'name' => Util::ucFirst(Lang::game('enchantments')) ); $conditions = []; @@ -46,7 +45,7 @@ class EnchantmentsPage extends GenericPage $ench = new EnchantmentList($conditions); - $tab['data'] = $ench->getListviewData(); + $tabData['data'] = array_values($ench->getListviewData()); $this->extendGlobalData($ench->getJSGlobals()); // recreate form selection @@ -56,34 +55,34 @@ class EnchantmentsPage extends GenericPage $xCols = $this->filterObj->getForm('extraCols', true); foreach (Util::$itemFilter as $fiId => $str) - if (array_column($tab['data'], $str)) + if (array_column($tabData['data'], $str)) $xCols[] = $fiId; - if (array_column($tab['data'], 'dmg')) + if (array_column($tabData['data'], 'dmg')) $xCols[] = 34; if ($xCols) $this->filter['fi']['extraCols'] = "fi_extraCols = ".Util::toJSON(array_values(array_unique($xCols))).";"; if (!empty($this->filter['fi']['extraCols'])) - $tab['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; + $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; if ($ench->getMatches() > CFG_SQL_LIMIT_DEFAULT) { - $tab['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_enchantmentsfound', $ench->getMatches(), CFG_SQL_LIMIT_DEFAULT); - $tab['params']['_truncated'] = 1; + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_enchantmentsfound', $ench->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['_truncated'] = 1; } - if (array_filter(array_column($tab['data'], 'spells'))) - $tab['params']['visibleCols'] = '$[\'trigger\']'; + if (array_filter(array_column($tabData['data'], 'spells'))) + $tabData['visibleCols'] = ['trigger']; if (!$ench->hasSetFields(['skillLine'])) - $tab['params']['hiddenCols'] = '$[\'skill\']'; + $tabData['hiddenCols'] = ['skill']; if ($this->filterObj->error) - $tab['params']['_errors'] = '$1'; + $tabData['_errors'] = '$1'; - $this->lvTabs[] = $tab; + $this->lvTabs[] = ['enchantment', $tabData, 'enchantment']; } protected function generateTitle() diff --git a/pages/event.php b/pages/event.php index 5a6b570d..63178976 100644 --- a/pages/event.php +++ b/pages/event.php @@ -112,11 +112,12 @@ class EventPage extends GenericPage foreach ($data as &$d) $d['method'] = $npcIds[$d['id']]; - $this->lvTabs[] = array( - 'file' => CreatureList::$brickFile, - 'data' => $data, - 'params' => ['note' => $hasFilter ? sprintf(Util::$filterResultString, '?npcs&filter=cr=38;crs='.$this->hId.';crv=0') : null] - ); + $tabData = ['data' => array_values($data)]; + + if ($hasFilter) + $tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=38;crs='.$this->hId.';crv=0'); + + $this->lvTabs[] = ['creature', $tabData]; } } @@ -130,11 +131,12 @@ class EventPage extends GenericPage foreach ($data as &$d) $d['method'] = $objectIds[$d['id']]; - $this->lvTabs[] = array( - 'file' => GameObjectList::$brickFile, - 'data' => $data, - 'params' => ['note' => $hasFilter ? sprintf(Util::$filterResultString, '?objects&filter=cr=16;crs='.$this->hId.';crv=0') : null] - ); + $tabData = ['data' => array_values($data)]; + + if ($hasFilter) + $tabData['note'] = sprintf(Util::$filterResultString, '?objects&filter=cr=16;crs='.$this->hId.';crv=0'); + + $this->lvTabs[] = ['object', $tabData]; } } @@ -147,14 +149,15 @@ class EventPage extends GenericPage { $this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $this->lvTabs[] = array( - 'file' => AchievementList::$brickFile, - 'data' => $acvs->getListviewData(), - 'params' => array( - 'note' => $hasFilter ? sprintf(Util::$filterResultString, '?achievements&filter=cr=11;crs='.$this->hId.';crv=0') : null, - 'visibleCols' => "$['category']" - ) + $tabData = array( + 'data' => array_values($acvs->getListviewData()), + 'visibleCols' => ['category'] ); + + if ($hasFilter) + $tabData['note'] = sprintf(Util::$filterResultString, '?achievements&filter=cr=11;crs='.$this->hId.';crv=0'); + + $this->lvTabs[] = ['achievement', $tabData]; } } @@ -172,11 +175,12 @@ class EventPage extends GenericPage { $this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); - $this->lvTabs[] = array( - 'file' => QuestList::$brickFile, - 'data' => $quests->getListviewData(), - 'params' => ['note' => $hasFilter ? sprintf(Util::$filterResultString, '?quests&filter=cr=33;crs='.$this->hId.';crv=0') : null] - ); + $tabData = ['data'=> array_values($quests->getListviewData())]; + + if ($hasFilter) + $tabData['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=33;crs='.$this->hId.';crv=0'); + + $this->lvTabs[] = ['quest', $tabData]; $questItems = []; foreach (array_column($quests->rewards, TYPE_ITEM) as $arr) @@ -208,11 +212,12 @@ class EventPage extends GenericPage { $this->extendGlobalData($eventItems->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => ItemList::$brickFile, - 'data' => $eventItems->getListviewData(), - 'params' => ['note' => $hasFilter ? sprintf(Util::$filterResultString, '?items&filter=cr=160;crs='.$this->hId.';crv=0') : null] - ); + $tabData = ['data'=> array_values($eventItems->getListviewData())]; + + if ($hasFilter) + $tabData['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=160;crs='.$this->hId.';crv=0'); + + $this->lvTabs[] = ['item', $tabData]; } } @@ -249,16 +254,13 @@ class EventPage extends GenericPage $relData = array_merge($relData, $d); } - $this->lvTabs[] = array( - 'file' => WorldEventList::$brickFile, - 'data' => $relData, - 'params' => array( - 'id' => 'see-also', - 'name' => '$LANG.tab_seealso', - 'hiddenCols' => "$['date']", - 'extraCols' => '$[Listview.extraCols.condition]' - ) - ); + $this->lvTabs[] = ['event', array( + 'data' => array_values($relData), + 'id' => 'see-also', + 'name' => '$LANG.tab_seealso', + 'hiddenCols' => ['date'], + 'extraCols' => ['$Listview.extraCols.condition'] + )]; } } } @@ -308,10 +310,10 @@ class EventPage extends GenericPage foreach ($this->lvTabs as &$view) { - if ($view['file'] != WorldEventList::$brickFile) + if ($view[0] != WorldEventList::$brickFile) continue; - foreach ($view['data'] as &$data) + foreach ($view[1]['data'] as &$data) { $updated = WorldEventList::updateDates($data['_date']); unset($data['_date']); diff --git a/pages/events.php b/pages/events.php index 2d510fad..3726604c 100644 --- a/pages/events.php +++ b/pages/events.php @@ -52,19 +52,16 @@ class EventsPage extends GenericPage if ($d = $events->getField('requires')) $this->deps[$events->id] = $d; - $this->lvTabs[] = array( - 'file' => 'event', - 'data' => $events->getListviewData(), - 'params' => [] - ); + $data = array_values($events->getListviewData()); - if ($_ = array_filter($events->getListviewData(), function($x) {return $x['id'] > 0;})) + $this->lvTabs[] = ['event', ['data' => $data]]; + + if ($_ = array_filter($data, function($x) {return $x['id'] > 0;})) { - $this->lvTabs[] = array( - 'file' => 'calendar', - 'data' => $_, - 'params' => ['hideCount' => 1] - ); + $this->lvTabs[] = ['calendar', array( + 'data' => $_, + 'hideCount' => 1 + )]; } } @@ -86,7 +83,7 @@ class EventsPage extends GenericPage // recalculate dates with now() foreach ($this->lvTabs as &$views) { - foreach ($views['data'] as &$data) + foreach ($views[1]['data'] as &$data) { // is a followUp-event if (!empty($this->deps[$data['id']])) diff --git a/pages/faction.php b/pages/faction.php index f0cfc50e..5ad439a8 100644 --- a/pages/faction.php +++ b/pages/faction.php @@ -175,20 +175,16 @@ class FactionPage extends GenericPage { $this->extendGlobalData($items->getJSGlobals(GLOBALINFO_SELF)); - $tab = array( - 'file' => 'item', - 'data' => $items->getListviewData(), - 'showRep' => true, - 'params' => array( - 'extraCols' => '$_', - 'sort' => "$['standing', 'name']" - ) + $tabData = array( + 'data' => array_values($items->getListviewData()), + 'extraCols' => '$_', + 'sort' => ['standing', 'name'] ); if ($items->getMatches() > CFG_SQL_LIMIT_DEFAULT) - $tab['params']['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=17;crs='.$this->typeId.';crv=0'); + $tabData['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=17;crs='.$this->typeId.';crv=0'); - $this->lvTabs[] = $tab; + $this->lvTabs[] = ['item', $tabData, 'itemStandingCol']; } // tab: creatures with onKill reputation @@ -212,20 +208,16 @@ class FactionPage extends GenericPage foreach ($data as $id => &$d) $d['reputation'] = $cRep[$id]; - $tab = array( - 'file' => 'creature', - 'data' => $data, - 'showRep' => true, - 'params' => array( - 'extraCols' => '$_', - 'sort' => "$['-reputation', 'name']" - ) + $tabData = array( + 'data' => array_values($data), + 'extraCols' => '$_', + 'sort' => ['-reputation', 'name'] ); if ($killCreatures->getMatches() > CFG_SQL_LIMIT_DEFAULT) - $tab['params']['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=42;crs='.$this->typeId.';crv=0'); + $tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=42;crs='.$this->typeId.';crv=0'); - $this->lvTabs[] = $tab; + $this->lvTabs[] = ['creature', $tabData, 'npcRepCol']; } } } @@ -236,20 +228,16 @@ class FactionPage extends GenericPage $members = new CreatureList(array(['faction', $_])); if (!$members->error) { - $tab = array( - 'file' => 'creature', - 'data' => $members->getListviewData(), - 'showRep' => true, - 'params' => array( - 'id' => 'member', - 'name' => '$LANG.tab_members' - ) + $tabData = array( + 'data' => array_values($members->getListviewData()), + 'id' => 'member', + 'name' => '$LANG.tab_members' ); if ($members->getMatches() > CFG_SQL_LIMIT_DEFAULT) - $tab['params']['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=3;crs='.$this->typeId.';crv=0'); + $tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=3;crs='.$this->typeId.';crv=0'); - $this->lvTabs[] = $tab; + $this->lvTabs[] = ['creature', $tabData]; } } @@ -258,13 +246,7 @@ class FactionPage extends GenericPage { $objects = new GameObjectList(array(['faction', $_])); if (!$objects->error) - { - $this->lvTabs[] = array( - 'file' => 'object', - 'data' => $objects->getListviewData(), - 'params' => [] - ); - } + $this->lvTabs[] = ['object', ['data' => array_values($objects->getListviewData())]]; } // tab: quests @@ -281,17 +263,15 @@ class FactionPage extends GenericPage { $this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_ANY)); - $tab = array( - 'file' => 'quest', - 'data' => $quests->getListviewData($this->typeId), - 'showRep' => true, - 'params' => ['extraCols' => '$_'] + $tabData = array( + 'data' => array_values($quests->getListviewData($this->typeId)), + 'extraCols' => '$_' ); if ($quests->getMatches() > CFG_SQL_LIMIT_DEFAULT) - $tab['params']['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=1;crs='.$this->typeId.';crv=0'); + $tabData['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=1;crs='.$this->typeId.';crv=0'); - $this->lvTabs[] = $tab; + $this->lvTabs[] = ['quest', $tabData, 'questRepCol']; } // tab: achievements @@ -304,15 +284,12 @@ class FactionPage extends GenericPage { $this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_ANY)); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $acvs->getListviewData(), - 'params' => array( - 'id' => 'criteria-of', - 'name' => '$LANG.tab_criteriaof', - 'visibleCols' => "$['category']" - ) - ); + $this->lvTabs[] = ['achievement', array( + 'data' => array_values($acvs->getListviewData()), + 'id' => 'criteria-of', + 'name' => '$LANG.tab_criteriaof', + 'visibleCols' => ['category'] + )]; } } } diff --git a/pages/factions.php b/pages/factions.php index 1323c72a..e25b32f9 100644 --- a/pages/factions.php +++ b/pages/factions.php @@ -53,13 +53,9 @@ class FactionsPage extends GenericPage $data = []; $factions = new FactionList($conditions); if (!$factions->error) - $data = $factions->getListviewData(); + $data = array_values($factions->getListviewData()); - $this->lvTabs[] = array( - 'file' => 'faction', - 'data' => $data, - 'params' => [] - ); + $this->lvTabs[] = ['faction', ['data' => $data]]; } protected function generateTitle() diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index 87cf58b2..35f9b6bf 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -103,6 +103,36 @@ class GenericPage private $memcached = null; private $mysql = ['time' => 0, 'count' => 0]; + private $lvTemplates = array( + 'achievement' => ['template' => 'achievement', 'id' => 'achievements', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_achievements' ], + 'calendar' => ['template' => 'holidaycal', 'id' => 'calendar', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_calendar' ], + 'class' => ['template' => 'classs', 'id' => 'classes', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_classes' ], + 'commentpreview' => ['template' => 'commentpreview', 'id' => 'comments', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_comments' ], + 'creature' => ['template' => 'npc', 'id' => 'npcs', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_npcs' ], + 'currency' => ['template' => 'currency', 'id' => 'currencies', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_currencies' ], + 'emote' => ['template' => 'emote', 'id' => 'emotes', 'parent' => 'lv-generic', 'data' => [] ], + 'enchantment' => ['template' => 'enchantment', 'id' => 'enchantments', 'parent' => 'lv-generic', 'data' => [] ], + 'event' => ['template' => 'holiday', 'id' => 'holidays', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_holidays' ], + 'faction' => ['template' => 'faction', 'id' => 'factions', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_factions' ], + 'genericmodel' => ['template' => 'genericmodel', 'id' => 'same-model-as', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_samemodelas' ], + 'item' => ['template' => 'item', 'id' => 'items', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_items' ], + 'itemset' => ['template' => 'itemset', 'id' => 'itemsets', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_itemsets' ], + 'model' => ['template' => 'model', 'id' => 'gallery', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_gallery' ], + 'object' => ['template' => 'object', 'id' => 'objects', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_objects' ], + 'pet' => ['template' => 'pet', 'id' => 'hunter-pets', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_pets' ], + 'profile' => ['template' => 'profile', 'id' => 'profiles', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_profiles' ], + 'quest' => ['template' => 'quest', 'id' => 'quests', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_quests' ], + 'race' => ['template' => 'race', 'id' => 'races', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_races' ], + 'replypreview' => ['template' => 'replypreview', 'id' => 'comment-replies', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_commentreplies'], + 'reputationhistory' => ['template' => 'reputationhistory', 'id' => 'reputation', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_reputation' ], + 'screenshot' => ['template' => 'screenshot', 'id' => 'screenshots', 'parent' => 'lv-generic', 'data' => [] ], + 'skill' => ['template' => 'skill', 'id' => 'skills', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_skills' ], + 'spell' => ['template' => 'spell', 'id' => 'spells', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_spells' ], + 'title' => ['template' => 'title', 'id' => 'titles', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_titles' ], + 'video' => ['template' => 'video', 'id' => 'videos', 'parent' => 'lv-generic', 'data' => [], ], + 'zone' => ['template' => 'zone', 'id' => 'zones', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_zones' ] + ); + public function __construct($pageCall/*, $pageParam */) { $this->time = microtime(true); @@ -518,18 +548,15 @@ class GenericPage $$n = $v; if (!$this->isSaneInclude('template/bricks/', $file)) - echo User::isInGroup(U_GROUP_EMPLOYEE) ? "\n\nError: nonexistant template requested: template/bricks/".$file.".tpl.php\n\n" : null; + trigger_error("Nonexistant template requested: template/bricks/".$file.".tpl.php"); else include('template/bricks/'.$file.'.tpl.php'); } - public function lvBrick($file, array $localVars = []) // load listview + public function lvBrick($file) // load listview addIns { - foreach ($localVars as $n => $v) - $$n = $v; - if (!$this->isSaneInclude('template/listviews/', $file)) - echo User::isInGroup(U_GROUP_EMPLOYEE) ? "\n\nError: nonexistant template requested: template/listviews/".$file.".tpl.php\n\n" : null; + trigger_error('Nonexistant Listview addin requested: template/listviews/'.$file.'.tpl.php'); else include('template/listviews/'.$file.'.tpl.php'); } @@ -539,7 +566,7 @@ class GenericPage if (!$this->isSaneInclude('template/localized/', $file.'_'.$loc)) { if ($loc == LOCALE_EN || !$this->isSaneInclude('template/localized/', $file.'_'.LOCALE_EN)) - echo User::isInGroup(U_GROUP_EMPLOYEE) ? "\n\nError: nonexistant template requested: template/localized/".$file.'_'.$loc.".tpl.php\n\n" : null; + trigger_error("Nonexistant template requested: template/localized/".$file.'_'.$loc.".tpl.php"); else include('template/localized/'.$file.'_'.LOCALE_EN.'.tpl.php'); } diff --git a/pages/item.php b/pages/item.php index 1466dd4d..f3ca4d33 100644 --- a/pages/item.php +++ b/pages/item.php @@ -438,15 +438,12 @@ class ItemPage extends genericPage $this->extendGlobalIDs(TYPE_SPELL, $perfItem[$sId]['requiredSpecialization']); } - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $lvData, - 'params' => [ - 'name' => '$LANG.tab_createdby', - 'id' => 'created-by', // should by exclusive with created-by from spell_loot - 'extraCols' => '$[Listview.extraCols.percent, Listview.extraCols.condition]' - ] - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($lvData), + 'name' => '$LANG.tab_createdby', + 'id' => 'created-by', // should by exclusive with created-by from spell_loot + 'extraCols' => ['$Listview.extraCols.percent', '$Listview.extraCols.condition'] + )]; } } @@ -457,34 +454,24 @@ class ItemPage extends genericPage { $this->extendGlobalData($lootTabs->jsGlobals); - foreach ($lootTabs->iterate() as $idx => $tab) + foreach ($lootTabs->iterate() as $idx => list($file, $tabData)) { - if (!$tab[1]) + if (!$tabData['data']) continue; if ($idx == 16) - $createdBy = array_column($tab[1], 'id'); + $createdBy = array_column($tabData['data'], 'id'); - $this->lvTabs[] = array( - 'file' => $tab[0], - 'data' => $tab[1], - 'params' => [ - 'name' => $tab[2], - 'id' => $tab[3], - 'extraCols' => $tab[4] ? '$['.implode(', ', array_unique($tab[4])).']' : null, - 'hiddenCols' => $tab[5] ? '$ '.Util::toJSON( array_unique($tab[5])) : null, - 'visibleCols' => $tab[6] ? '$'. Util::toJSON( array_unique($tab[6])) : null - ] - ); + $this->lvTabs[] = [$file, $tabData]; } } // tabs: this item contains.. $sourceFor = array( - [LOOT_ITEM, $this->subject->id, '$LANG.tab_contains', 'contains', ['Listview.extraCols.percent'], [] , []], - [LOOT_PROSPECTING, $this->subject->id, '$LANG.tab_prospecting', 'prospecting', ['Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []], - [LOOT_MILLING, $this->subject->id, '$LANG.tab_milling', 'milling', ['Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []], - [LOOT_DISENCHANT, $this->subject->getField('disenchantId'), '$LANG.tab_disenchanting', 'disenchanting', ['Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []] + [LOOT_ITEM, $this->subject->id, '$LANG.tab_contains', 'contains', ['$Listview.extraCols.percent'], [] , []], + [LOOT_PROSPECTING, $this->subject->id, '$LANG.tab_prospecting', 'prospecting', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []], + [LOOT_MILLING, $this->subject->id, '$LANG.tab_milling', 'milling', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []], + [LOOT_DISENCHANT, $this->subject->getField('disenchantId'), '$LANG.tab_disenchanting', 'disenchanting', ['$Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []] ); $reqQuest = []; @@ -508,17 +495,22 @@ class ItemPage extends genericPage $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]]; } - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $lootTab->getResult(), - 'params' => [ - 'name' => $sf[2], - 'id' => $sf[3], - 'extraCols' => $sf[4] ? "$[".implode(', ', array_unique($sf[4]))."]" : null, - 'hiddenCols' => $sf[5] ? "$".Util::toJSON($sf[5]) : null, - 'visibleCols' => $sf[6] ? '$'.Util::toJSON($sf[6]) : null - ] + $tabData = array( + 'data' => array_values($lootTab->getResult()), + 'name' => $sf[2], + 'id' => $sf[3], ); + + if ($sf[4]) + $tabData['extraCols'] = array_unique($sf[4]); + + if ($sf[5]) + $tabData['hiddenCols'] = array_unique($sf[5]); + + if ($sf[6]) + $tabData['visibleCols'] = array_unique($sf[6]); + + $this->lvTabs[] = ['item', $tabData]; } } @@ -558,15 +550,12 @@ class ItemPage extends genericPage if (!$contains->hasSetFields(['slot'])) $hCols[] = 'slot'; - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $contains->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_cancontain', - 'id' => 'can-contain', - 'hiddenCols' => '$'.Util::toJSON($hCols) - ] - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($contains->getListviewData()), + 'name' => '$LANG.tab_cancontain', + 'id' => 'can-contain', + 'hiddenCols' => $hCols + )]; } } @@ -578,15 +567,12 @@ class ItemPage extends genericPage { $this->extendGlobalData($contains->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $contains->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_canbeplacedin', - 'id' => 'can-be-placed-in', - 'hiddenCols' => "$['side']" - ] - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($contains->getListviewData()), + 'name' => '$LANG.tab_canbeplacedin', + 'id' => 'can-be-placed-in', + 'hiddenCols' => ['side'] + )]; } } @@ -599,22 +585,19 @@ class ItemPage extends genericPage $criteriaOf = new AchievementList($conditions); if (!$criteriaOf->error) { - $this->extendGlobalData($criteriaOf->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); + $this->extendGlobalData($criteriaOf->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); - $hCols = []; - if (!$criteriaOf->hasSetFields(['reward_loc0'])) - $hCols = ['rewards']; + $tabData = array( + 'data' => array_values($criteriaOf->getListviewData()), + 'name' => '$LANG.tab_criteriaof', + 'id' => 'criteria-of', + 'visibleCols' => ['category'] + ); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $criteriaOf->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_criteriaof', - 'id' => 'criteria-of', - 'visibleCols' => "$['category']", - 'hiddenCols' => '$'.Util::toJSON($hCols) - ] - ); + if (!$criteriaOf->hasSetFields(['reward_loc0'])) + $tabData['hiddenCols'] = ['rewards']; + + $this->lvTabs[] = ['achievement', $tabData]; } // tab: reagent for @@ -629,15 +612,12 @@ class ItemPage extends genericPage { $this->extendGlobalData($reagent->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $reagent->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_reagentfor', - 'id' => 'reagent-for', - 'visibleCols' => "$['reagents']" - ] - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($reagent->getListviewData()), + 'name' => '$LANG.tab_reagentfor', + 'id' => 'reagent-for', + 'visibleCols' => ['reagents'] + )]; } // tab: unlocks (object or item) @@ -654,14 +634,11 @@ class ItemPage extends genericPage $lockedObj = new GameObjectList(array(['lockId', $lockIds])); if (!$lockedObj->error) { - $this->lvTabs[] = array( - 'file' => 'object', - 'data' => $lockedObj->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_unlocks', - 'id' => 'unlocks-object' - ] - ); + $this->lvTabs[] = ['object', array( + 'data' => array_values($lockedObj->getListviewData()), + 'name' => '$LANG.tab_unlocks', + 'id' => 'unlocks-object' + )]; } // items (generally unused. It's the spell on the item, that unlocks stuff) @@ -670,14 +647,11 @@ class ItemPage extends genericPage { $this->extendGlobalData($lockedItm->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $lockedItm->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_unlocks', - 'id' => 'unlocks-item' - ] - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($lockedItm->getListviewData()), + 'name' => '$LANG.tab_unlocks', + 'id' => 'unlocks-item' + )]; } } @@ -705,14 +679,11 @@ class ItemPage extends genericPage { $this->extendGlobalData($saItems->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $saItems->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_seealso', - 'id' => 'see-also' - ] - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($saItems->getListviewData()), + 'name' => '$LANG.tab_seealso', + 'id' => 'see-also' + )]; } // tab: starts (quest) @@ -723,14 +694,11 @@ class ItemPage extends genericPage { $this->extendGlobalData($starts->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $starts->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_starts', - 'id' => 'starts-quest' - ] - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($starts->getListviewData()), + 'name' => '$LANG.tab_starts', + 'id' => 'starts-quest' + )]; } } @@ -745,14 +713,11 @@ class ItemPage extends genericPage { $this->extendGlobalData($objective->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $objective->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_objectiveof', - 'id' => 'objective-of-quest' - ] - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($objective->getListviewData()), + 'name' => '$LANG.tab_objectiveof', + 'id' => 'objective-of-quest' + )]; } // tab: provided for (quest) @@ -766,14 +731,11 @@ class ItemPage extends genericPage { $this->extendGlobalData($provided->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $provided->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_providedfor', - 'id' => 'provided-for-quest' - ] - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($provided->getListviewData()), + 'name' => '$LANG.tab_providedfor', + 'id' => 'provided-for-quest' + )]; } // tab: same model as @@ -785,15 +747,12 @@ class ItemPage extends genericPage { $this->extendGlobalData($sameModel->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'genericmodel', - 'data' => $sameModel->getListviewData(ITEMINFO_MODEL), - 'params' => [ - 'name' => '$LANG.tab_samemodelas', - 'id' => 'same-model-as', - 'genericlinktype' => 'item' - ] - ); + $this->lvTabs[] = ['genericmodel', array( + 'data' => array_values($sameModel->getListviewData(ITEMINFO_MODEL)), + 'name' => '$LANG.tab_samemodelas', + 'id' => 'same-model-as', + 'genericlinktype' => 'item' + )]; } } @@ -807,7 +766,7 @@ class ItemPage extends genericPage $sbData = $soldBy->getListviewData(); $this->extendGlobalData($soldBy->getJSGlobals(GLOBALINFO_SELF)); - $extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost']; + $extraCols = ['$Listview.extraCols.stock', "\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost']; $holidays = []; foreach ($sbData as $k => &$row) @@ -837,7 +796,7 @@ class ItemPage extends genericPage if ($e = $vendors[$k]['event']) { if (count($extraCols) == 3) - $extraCols[] = 'Listview.extraCols.condition'; + $extraCols[] = '$Listview.extraCols.condition'; $this->extendGlobalIds(TYPE_WORLDEVENT, $e); $row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $e]]; @@ -860,16 +819,13 @@ class ItemPage extends genericPage } - $this->lvTabs[] = array( - 'file' => 'creature', - 'data' => $sbData, - 'params' => [ - 'name' => '$LANG.tab_soldby', - 'id' => 'sold-by-npc', - 'extraCols' => '$['.implode(', ', $extraCols).']', - 'hiddenCols' => "$['level', 'type']" - ] - ); + $this->lvTabs[] = ['creature', array( + 'data' => array_values($sbData), + 'name' => '$LANG.tab_soldby', + 'id' => 'sold-by-npc', + 'extraCols' => $extraCols, + 'hiddenCols' => ['level', 'type'] + )]; } } @@ -898,22 +854,21 @@ class ItemPage extends genericPage $boughtBy = new ItemList(array(['id', $boughtBy])); if (!$boughtBy->error) { - if ($boughtBy->getMatches() <= CFG_SQL_LIMIT_DEFAULT) - $n = null; - $iCur = new CurrencyList(array(['itemId', $this->typeId])); $filter = $iCur->error ? [TYPE_ITEM => $this->typeId] : [TYPE_CURRENCY => $iCur->id]; - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, $filter), - 'params' => [ - 'name' => '$LANG.tab_currencyfor', - 'id' => 'currency-for', - 'extraCols' => "$[Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack'), Listview.extraCols.cost]", - 'note' => $n ? sprintf(Util::$filterResultString, $n) : null - ] + $tabData = array( + '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'], ); + + if ($boughtBy->getMatches() > CFG_SQL_LIMIT_DEFAULT && $n) + $tabData['note'] = sprintf(Util::$filterResultString, $n); + + $this->lvTabs[] = ['item', $tabData]; + $this->extendGlobalData($boughtBy->getJSGlobals(GLOBALINFO_ANY)); } } @@ -951,15 +906,12 @@ class ItemPage extends genericPage if ($taughtSpells->hasSetFields(['reagent1'])) $visCols[] = 'reagents'; - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $taughtSpells->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_teaches', - 'id' => 'teaches', - 'visibleCols' => '$'.Util::toJSON($visCols) - ] - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($taughtSpells->getListviewData()), + 'name' => '$LANG.tab_teaches', + 'id' => 'teaches', + 'visibleCols' => $visCols + )]; } } @@ -982,14 +934,11 @@ class ItemPage extends genericPage $cdItems = new ItemList($conditions); if (!$cdItems->error) { - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $cdItems->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_sharedcooldown', - 'id' => 'shared-cooldown' - ] - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($cdItems->getListviewData()), + 'name' => '$LANG.tab_sharedcooldown', + 'id' => 'shared-cooldown' + )]; $this->extendGlobalData($cdItems->getJSGlobals(GLOBALINFO_SELF)); } diff --git a/pages/items.php b/pages/items.php index 00340df4..de6c3b5f 100644 --- a/pages/items.php +++ b/pages/items.php @@ -306,10 +306,9 @@ class ItemsPage extends GenericPage continue; $this->extendGlobalData($items->getJSGlobals()); - $tab = array( - 'file' => 'item', - 'data' => $items->getListviewData($infoMask), - 'params' => $this->sharedLV + $tabData = array_merge( + ['data' => $items->getListviewData($infoMask)], + $this->sharedLV ); $upg = []; @@ -322,17 +321,17 @@ class ItemsPage extends GenericPage })); foreach ($upg as $uId) - $tab['data'][$uId] = $upgItemData[$uId]; + $tabData['data'][$uId] = $upgItemData[$uId]; if ($upg) - $tab['params']['_upgradeIds'] = '$'.Util::toJSON($upg); + $tabData['_upgradeIds'] = $upg; } else if ($grouping) { $upg = array_keys($this->filter['upg']); - $tab['params']['_upgradeIds'] = '$'.Util::toJSON($upg); + $tabData['_upgradeIds'] = $upg; foreach ($upgItemData as $uId => $data) // using numeric keys => cant use array_merge - $tab['data'][$uId] = $data; + $tabData['data'][$uId] = $data; } } @@ -341,28 +340,28 @@ class ItemsPage extends GenericPage switch ($grouping) { case 1: - $tab['params']['id'] = 'slot-'.$group; + $tabData['id'] = 'slot-'.$group; break; case 2: - $tab['params']['id'] = $group > 0 ? 'level-'.$group : 'other'; + $tabData['id'] = $group > 0 ? 'level-'.$group : 'other'; break; case 3: - $tab['params']['id'] = $group ? 'source-'.$group : 'unknown'; + $tabData['id'] = $group ? 'source-'.$group : 'unknown'; break; } - $tab['params']['name'] = $nameSource[$group]; - $tab['params']['tabs'] = '$tabsGroups'; + $tabData['name'] = $nameSource[$group]; + $tabData['tabs'] = '$tabsGroups'; } if (!empty($this->filter['fi']['setWeights'])) if ($items->hasSetFields(['armor'])) - $tab['params']['visibleCols'][] = 'armor'; + $tabData['visibleCols'][] = 'armor'; // create note if search limit was exceeded; overwriting 'note' is intentional if ($items->getMatches() > $maxResults && count($groups) > 1) { - $tab['params']['_truncated'] = 1; + $tabData['_truncated'] = 1; $cls = isset($this->category[0]) ? '='.$this->category[0] : ''; $override = ['gb' => '']; @@ -373,7 +372,7 @@ class ItemsPage extends GenericPage { case 1: $override['sl'] = $group; - $tab['params']['note'] = '$$WH.sprintf(LANG.lvnote_viewmoreslot, \''.$cls.'\', \''.$this->filterObj->urlize($override).'\')'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_viewmoreslot, \''.$cls.'\', \''.$this->filterObj->urlize($override).'\')'; break; case 2: if ($group > 0) @@ -384,35 +383,31 @@ class ItemsPage extends GenericPage else $override['maxle'] = abs($group) - 1; - $tab['params']['note'] = '$$WH.sprintf(LANG.lvnote_viewmorelevel, \''.$cls.'\', \''.$this->filterObj->urlize($override).'\')'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_viewmorelevel, \''.$cls.'\', \''.$this->filterObj->urlize($override).'\')'; break; case 3: if ($_ = [null, 3, 4, 5, 6, 7, 9, 10, 11][$group]) - $tab['params']['note'] = '$$WH.sprintf(LANG.lvnote_viewmoresource, \''.$cls.'\', \''.$this->filterObj->urlize($override, ['cr' => 128, 'crs' => $_, 'crv' => 0]).'\')'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_viewmoresource, \''.$cls.'\', \''.$this->filterObj->urlize($override, ['cr' => 128, 'crs' => $_, 'crv' => 0]).'\')'; break; } } else if ($items->getMatches() > $maxResults) { - $tab['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsfound', $items->getMatches(), CFG_SQL_LIMIT_DEFAULT); - $tab['params']['_truncated'] = 1; + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsfound', $items->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['_truncated'] = 1; } - if (!empty($tab['params']['hiddenCols'])) - $tab['params']['hiddenCols'] = '$'.Util::toJSON($tab['params']['hiddenCols']); - - if (!empty($tab['params']['visibleCols'])) - $tab['params']['visibleCols'] = '$'.Util::toJSON($tab['params']['visibleCols']); - - foreach ($tab['params'] as $k => $p) - if (!$p) - unset($tab['params'][$k]); + foreach ($tabData as $k => $p) + if (!$p && $k != 'data') + unset($tabData[$k]); if ($grouping) - $tab['params']['hideCount'] = '$1'; + $tabData['hideCount'] = 1; - $this->lvTabs[] = $tab; + $tabData['data'] = array_values($tabData['data']); + + $this->lvTabs[] = ['item', $tabData]; } // reformat for use in template @@ -423,7 +418,7 @@ class ItemsPage extends GenericPage if (empty($this->lvTabs)) { $this->forceTabs = false; - $this->lvTabs[] = ['file' => 'item', 'data' => [], 'params' => []]; + $this->lvTabs[] = ['item', ['data' => []]]; } // sort for dropdown-menus @@ -502,7 +497,7 @@ class ItemsPage extends GenericPage $this->sharedLV['onBeforeCreate'] = '$fi_initWeightedListview'; $this->sharedLV['onAfterCreate'] = '$fi_addUpgradeIndicator'; - $this->sharedLV['sort'] = "$['-score', 'name']"; + $this->sharedLV['sort'] = ['-score', 'name']; array_push($this->sharedLV['hiddenCols'], 'type', 'source'); diff --git a/pages/itemset.php b/pages/itemset.php index ea046c61..403bf707 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -139,12 +139,11 @@ class ItemsetPage extends GenericPage $compare[] = $itemId; - $pieces[] = array( - 'id' => $itemId, - 'name' => $iList->getField('name', true), - 'quality' => $iList->getField('quality'), - 'icon' => $iList->getField('iconString'), - 'json' => $data[$itemId] + $pieces[$itemId] = array( + 'name_'.User::$localeString => $iList->getField('name', true), + 'quality' => $iList->getField('quality'), + 'icon' => $iList->getField('iconString'), + 'jsonequip' => $data[$itemId] ); } @@ -168,11 +167,12 @@ class ItemsetPage extends GenericPage BUTTON_VIEW3D => ['type' => TYPE_ITEMSET, 'typeId' => $this->typeId, 'equipList' => $eqList], BUTTON_COMPARE => ['eqList' => implode(':', $compare), 'qty' => $_cnt] ); - $this->compare = array( - 'level' => $this->subject->getField('reqLevel'), - 'items' => array_map(function ($v) { - return [[$v]]; - }, $compare) + $this->summary = array( + 'id' => 'itemset', + 'template' => 'itemset', + 'parent' => 'summary-generic', + 'groups' => array_map(function ($v) { return [[$v]]; }, $compare), + 'level' => $this->subject->getField('reqLevel'), ); /**************/ @@ -213,19 +213,16 @@ class ItemsetPage extends GenericPage $relSets = new ItemsetList($rel); if (!$relSets->error) { - $lv = array( - 'file' => 'itemset', - 'data' => $relSets->getListviewData(), - 'params' => array( - 'id' => 'see-also', - 'name' => '$LANG.tab_seealso' - ) + $tabData = array( + 'data' => array_values($relSets->getListviewData()), + 'id' => 'see-also', + 'name' => '$LANG.tab_seealso' ); if (!$relSets->hasDiffFields(['classMask'])) - $lv['params']['hiddenCols'] = "$['classes']"; + $tabData['hiddenCols'] = ['classes']; - $this->lvTabs[] = $lv; + $this->lvTabs[] = ['itemset', $tabData]; $this->extendGlobalData($relSets->getJSGlobals()); } diff --git a/pages/itemsets.php b/pages/itemsets.php index d0e87428..e67e6c07 100644 --- a/pages/itemsets.php +++ b/pages/itemsets.php @@ -47,26 +47,22 @@ class ItemsetsPage extends GenericPage $this->addJS('?data=weight-presets&locale='.User::$localeId.'&t='.$_SESSION['dataKey']); - $lv = array( - 'file' => 'itemset', - 'data' => $itemsets->getListviewData(), // listview content - 'params' => [] - ); + $tabData = ['data' => array_values($itemsets->getListviewData())]; if (!empty($this->filter['fi']['extraCols'])) - $lv['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; + $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; // create note if search limit was exceeded if ($itemsets->getMatches() > CFG_SQL_LIMIT_DEFAULT) { - $lv['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsetsfound', $itemsets->getMatches(), CFG_SQL_LIMIT_DEFAULT); - $lv['params']['_truncated'] = 1; + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsetsfound', $itemsets->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['_truncated'] = 1; } if ($this->filterObj->error) - $lv['params']['_errors'] = '$1'; + $tabData['_errors'] = 1; - $this->lvTabs[] = $lv; + $this->lvTabs[] = ['itemset', $tabData]; // sort for dropdown-menus Lang::sort('itemset', 'notes', SORT_NATURAL); diff --git a/pages/npc.php b/pages/npc.php index 48283a4f..db7b8e99 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -403,24 +403,18 @@ class NpcPage extends GenericPage } if ($normal) - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $normal, - 'params' => array( - 'name' => '$LANG.tab_abilities', - 'id' => 'abilities' - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($normal), + 'name' => '$LANG.tab_abilities', + 'id' => 'abilities' + )]; if ($controled) - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $controled, - 'params' => array( - 'name' => '$LANG.tab_controlledabilities', - 'id' => 'controlled-abilities' - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($controled), + 'name' => '$LANG.tab_controlledabilities', + 'id' => 'controlled-abilities' + )]; } } @@ -437,14 +431,11 @@ class NpcPage extends GenericPage { $this->extendGlobalData($summoned->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $summoned->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_summonedby', - 'id' => 'summoned-by' - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($summoned->getListviewData()), + 'name' => '$LANG.tab_summonedby', + 'id' => 'summoned-by' + )]; } // tab: teaches @@ -496,16 +487,17 @@ class NpcPage extends GenericPage $data[$sId]['trainingcost'] = $_; } - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $data, - 'params' => array( - 'name' => '$LANG.tab_teaches', - 'id' => 'teaches', - 'visibleCols' => "$['trainingcost']", - 'extraCols' => $extra ? '$['.implode(', ', $extra).']' : null - ) + $tabData = array( + 'data' => array_values($data), + 'name' => '$LANG.tab_teaches', + 'id' => 'teaches', + 'visibleCols' => ['trainingcost'] ); + + if ($extra) + $tabData['extraCols'] = $extra; + + $this->lvTabs[] = ['spell', $tabData]; } } else @@ -518,9 +510,9 @@ class NpcPage extends GenericPage $soldItems = new ItemList(array(['id', $sells])); if (!$soldItems->error) { - $extraCols = ["Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost']; + $extraCols = ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost']; if ($soldItems->hasSetFields(['condition'])) - $extraCols[] = 'Listview.extraCols.condition'; + $extraCols[] = '$Listview.extraCols.condition'; $lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [TYPE_NPC => [$this->typeId]]); @@ -529,8 +521,7 @@ class NpcPage extends GenericPage { $this->extendGlobalData($sc[1]); - if (!array_search('Listview.extraCols.condition', $extraCols)) - $extraCols[] = 'Listview.extraCols.condition'; + $extraCols[] = 'Listview.extraCols.condition'; foreach ($lvData as $id => &$row) foreach ($sc[0] as $srcType => $cndData) @@ -538,15 +529,12 @@ class NpcPage extends GenericPage $row['condition'][0][$id.':'.$this->typeId] = $cndData[$id.':'.$this->typeId]; } - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $lvData, - 'params' => array( - 'name' => '$LANG.tab_sells', - 'id' => 'currency-for', - 'extraCols' => '$['.implode(', ', $extraCols).']' - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($lvData), + 'name' => '$LANG.tab_sells', + 'id' => 'currency-for', + 'extraCols' => array_unique($extraCols) + )]; $this->extendGlobalData($soldItems->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } @@ -610,7 +598,7 @@ class NpcPage extends GenericPage if ($creatureLoot->getByContainer($sf[0], $sf[1])) { $extraCols = $creatureLoot->extraCols; - $extraCols[] = 'Listview.extraCols.percent'; + $extraCols[] = '$Listview.extraCols.percent'; $this->extendGlobalData($creatureLoot->jsGlobals); @@ -619,27 +607,26 @@ class NpcPage extends GenericPage if (!$lv['quest']) continue; - $extraCols[] = 'Listview.extraCols.condition'; + $extraCols[] = '$Listview.extraCols.condition'; $reqQuest[$lv['id']] = 0; $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]]; } - $lootTab = array( - 'file' => 'item', - 'data' => $creatureLoot->getResult(), - 'params' => array( - 'name' => $sf[2], - 'id' => $sf[3], - 'extraCols' => "$[".implode(', ', array_unique($extraCols))."]", - 'hiddenCols' => $sf[4] ? "$".Util::toJSON($sf[4]) : null, - 'sort' => "$['-percent', 'name']", - ) + $tabData = array( + 'data' => array_values($creatureLoot->getResult()), + 'name' => $sf[2], + 'id' => $sf[3], + 'extraCols' => array_unique($extraCols), + 'sort' => ['-percent', 'name'], ); if (!empty($sf['note'])) - $lootTab['params']['note'] = $sf['note']; + $lootTab['note'] = $sf['note']; - $this->lvTabs[] = $lootTab; + if ($sf[4]) + $lootTab['hiddenCols'] = $sf[4]; + + $this->lvTabs[] = ['item', $tabData]; } } @@ -686,28 +673,18 @@ class NpcPage extends GenericPage } if ($_[0]) - { - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $_[0], - 'params' => array( - 'name' => '$LANG.tab_starts', - 'id' => 'starts' - ) - ); - } + $this->lvTabs[] = ['quest', array( + 'data' => array_values($_[0]), + 'name' => '$LANG.tab_starts', + 'id' => 'starts' + )]; if ($_[1]) - { - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $_[1], - 'params' => array( - 'name' => '$LANG.tab_ends', - 'id' => 'ends' - ) - ); - } + $this->lvTabs[] = ['quest', array( + 'data' => array_values($_[1]), + 'name' => '$LANG.tab_ends', + 'id' => 'ends' + )]; } // tab: objective of quest @@ -724,14 +701,11 @@ class NpcPage extends GenericPage { $this->extendGlobalData($objectiveOf->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $objectiveOf->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_objectiveof', - 'id' => 'objective-of' - ) - ); + $this->lvTabs[] = ['quest', array( + 'data' => aray_values($objectiveOf->getListviewData()), + 'name' => '$LANG.tab_objectiveof', + 'id' => 'objective-of' + )]; } // tab: criteria of [ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE have no data set to check for] @@ -745,14 +719,11 @@ class NpcPage extends GenericPage { $this->extendGlobalData($crtOf->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $crtOf->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_criteriaof', - 'id' => 'criteria-of' - ) - ); + $this->lvTabs[] = ['achievement', array( + 'data' => array_values($crtOf->getListviewData()), + 'name' => '$LANG.tab_criteriaof', + 'id' => 'criteria-of' + )]; } // tab: passengers @@ -763,25 +734,22 @@ class NpcPage extends GenericPage { $data = $passengers->getListviewData(); - $xCols = null; if (User::isInGroup(U_GROUP_STAFF)) - { foreach ($data as $id => &$d) $d['seat'] = str_replace(',', ', ', $_[$id]); - $xCols = "$[Listview.funcBox.createSimpleCol('seat', '".Lang::npc('seat')."', '10%', 'seat')]"; - } - $this->extendGlobalData($passengers->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'creature', - 'data' => $data, - 'params' => array( - 'extraCols' => $xCols, - 'name' => Lang::npc('accessory'), - 'id' => 'accessory' - ) + + $tabData = array( + 'data' => array_values($data), + 'name' => Lang::npc('accessory'), + 'id' => 'accessory' ); + + if (User::isInGroup(U_GROUP_STAFF)) + $tabData['extraCols'] = ["\$Listview.funcBox.createSimpleCol('seat', '".Lang::npc('seat')."', '10%', 'seat')"]; + + $this->lvTabs[] = ['creature', $tabData]; } } } diff --git a/pages/npcs.php b/pages/npcs.php index 488c4ec5..8e341346 100644 --- a/pages/npcs.php +++ b/pages/npcs.php @@ -59,31 +59,29 @@ class NpcsPage extends GenericPage $repCols = $this->filterObj->getForm('reputationCols'); - $lv = array( - 'file' => 'creature', - 'data' => $npcs->getListviewData($repCols ? NPCINFO_REP : 0x0), - 'params' => [] + $tabData = array( + 'data' => array_values($npcs->getListviewData($repCols ? NPCINFO_REP : 0x0)), ); if ($repCols) - $lv['params']['extraCols'] = '$fi_getReputationCols('.Util::toJSON($repCols).')'; + $tabData['extraCols'] = '$fi_getReputationCols('.Util::toJSON($repCols).')'; else if (!empty($this->filter['fi']['extraCols'])) - $lv['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; + $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; if ($this->category) - $lv['params']['hiddenCols'] = "$['type']"; + $tabData['hiddenCols'] = ['type']; // create note if search limit was exceeded if ($npcs->getMatches() > CFG_SQL_LIMIT_DEFAULT) { - $lv['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_npcsfound', $npcs->getMatches(), CFG_SQL_LIMIT_DEFAULT); - $lv['params']['_truncated'] = 1; + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_npcsfound', $npcs->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['_truncated'] = 1; } if ($this->filterObj->error) - $lv['params']['_errors'] = '$1'; + $tabData['_errors'] = 1; - $this->lvTabs[] = $lv; + $this->lvTabs[] = ['creature', $tabData]; // sort for dropdown-menus Lang::sort('game', 'fa'); diff --git a/pages/object.php b/pages/object.php index e93e42eb..4b65b319 100644 --- a/pages/object.php +++ b/pages/object.php @@ -271,14 +271,11 @@ class ObjectPage extends GenericPage { $this->extendGlobalData($summons->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $summons->getListviewData(), - 'params' => array( - 'id' => 'summoned-by', - 'name' => '$LANG.tab_summonedby' - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($summons->getListviewData()), + 'id' => 'summoned-by', + 'name' => '$LANG.tab_summonedby' + )]; } // tab: related spells @@ -293,16 +290,13 @@ class ObjectPage extends GenericPage foreach ($data as $relId => $d) $data[$relId]['trigger'] = array_search($relId, $_); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $data, - 'params' => array( - 'id' => 'spells', - 'name' => '$LANG.tab_spells', - 'hiddenCols' => "$['skill']", - 'extraCols' => "$[Listview.funcBox.createSimpleCol('trigger', 'Condition', '10%', 'trigger')]" - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($data), + 'id' => 'spells', + 'name' => '$LANG.tab_spells', + 'hiddenCols' => ['skill'], + 'extraCols' => ["\$Listview.funcBox.createSimpleCol('trigger', 'Condition', '10%', 'trigger')"] + )]; } } @@ -312,14 +306,11 @@ class ObjectPage extends GenericPage { $this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $acvs->getListviewData(), - 'params' => array( - 'id' => 'criteria-of', - 'name' => '$LANG.tab_criteriaof' - ) - ); + $this->lvTabs[] = ['achievement', array( + 'data' => array_values($acvs->getListviewData()), + 'id' => 'criteria-of', + 'name' => '$LANG.tab_criteriaof' + )]; } // tab: starts quest @@ -341,28 +332,18 @@ class ObjectPage extends GenericPage } if ($_[0]) - { - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $_[0], - 'params' => array( - 'name' => '$LANG.tab_starts', - 'id' => 'starts' - ) - ); - } + $this->lvTabs[] = ['quest', array( + 'data' => array_values($_[0]), + 'name' => '$LANG.tab_starts', + 'id' => 'starts' + )]; if ($_[1]) - { - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $_[1], - 'params' => array( - 'name' => '$LANG.tab_ends', - 'id' => 'ends' - ) - ); - } + $this->lvTabs[] = ['quest', array( + 'data' => array_values($_[1]), + 'name' => '$LANG.tab_ends', + 'id' => 'ends' + )]; } // tab: related quests @@ -373,14 +354,11 @@ class ObjectPage extends GenericPage { $this->extendGlobalData($relQuest->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $relQuest->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_quests', - 'id' => 'quests' - ) - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($relQuest->getListviewData()), + 'name' => '$LANG.tab_quests', + 'id' => 'quests' + )]; } } @@ -412,17 +390,17 @@ class ObjectPage extends GenericPage $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]]; } - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $goLoot->getResult(), - 'params' => array( - 'name' => '$LANG.tab_contains', - 'id' => 'contains', - 'extraCols' => "$[".implode(', ', array_unique($extraCols))."]", - 'hiddenCols' => $hiddenCols ? '$'.Util::toJSON(array_values($hiddenCols)) : null, - 'sort' => "$['-percent', 'name']" - ) + $tabData = array( + 'data' => array_values($goLoot->getResult()), + 'id' => 'contains', + 'name' => '$LANG.tab_contains', + 'sort' => ['-percent', 'name'] ); + + if ($hiddenCols) + $tabData['hiddenCols'] = $hiddenCols; + + $this->lvTabs[] = ['item', $tabData]; } } @@ -456,14 +434,11 @@ class ObjectPage extends GenericPage { $this->extendGlobalData($sameModel->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'object', - 'data' => $sameModel->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_samemodelas', - 'id' => 'same-model-as' - ) - ); + $this->lvTabs[] = ['object', array( + 'data' => array_values($sameModel->getListviewData()), + 'name' => '$LANG.tab_samemodelas', + 'id' => 'same-model-as' + )]; } } diff --git a/pages/objects.php b/pages/objects.php index 10d9a7bc..3087bfe4 100644 --- a/pages/objects.php +++ b/pages/objects.php @@ -47,31 +47,26 @@ class ObjectsPage extends GenericPage if ($_ = $this->filterObj->getConditions()) $conditions[] = $_; - $params = $data = []; + $tabData = ['data' => []]; $objects = new GameObjectList($conditions, ['extraOpts' => $this->filterObj->extraOpts]); if (!$objects->error) { - $data = $objects->getListviewData(); + $tabData['data'] = array_values($objects->getListviewData()); if ($objects->hasSetFields(['reqSkill'])) - $params['visibleCols'] = "$['skill']"; - + $tabData['visibleCols'] = ['skill']; // create note if search limit was exceeded if ($objects->getMatches() > CFG_SQL_LIMIT_DEFAULT) { - $params['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_objectsfound', $objects->getMatches(), CFG_SQL_LIMIT_DEFAULT); - $params['_truncated'] = 1; + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_objectsfound', $objects->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['_truncated'] = 1; } if ($this->filterObj->error) - $params['_errors'] = '$1'; + $tabData['_errors'] = 1; } - $this->lvTabs[] = array( - 'file' => 'object', - 'data' => $data, - 'params' => $params - ); + $this->lvTabs[] = ['object', $tabData]; } protected function generateTitle() diff --git a/pages/pet.php b/pages/pet.php index 574d9dce..9828f90d 100644 --- a/pages/pet.php +++ b/pages/pet.php @@ -88,23 +88,17 @@ class PetPage extends GenericPage ); $tng = new CreatureList($condition); - $this->lvTabs[] = array( - 'file' => 'creature', - 'data' => $tng->getListviewData(NPCINFO_TAMEABLE), - 'params' => array( - 'name' => '$LANG.tab_tameable', - 'hiddenCols' => "$['type']", - 'visibleCols' => "$['skin']", - 'note' => sprintf(Util::$filterResultString, '?npcs=1&filter=fa=38'), - 'id' => 'tameable' - ) - ); - - $this->lvTabs[] = array( - 'file' => 'model', - 'data' => $tng->getListviewData(NPCINFO_MODEL), - 'params' => [] - ); + $this->lvTabs[] = ['creature', array( + 'data' => array_values($tng->getListviewData(NPCINFO_TAMEABLE)), + 'name' => '$LANG.tab_tameable', + 'hiddenCols' => ['type'], + 'visibleCols' => ['skin'], + 'note' => sprintf(Util::$filterResultString, '?npcs=1&filter=fa=38'), + 'id' => 'tameable' + )]; + $this->lvTabs[] = ['model', array( + 'data' => array_values($tng->getListviewData(NPCINFO_MODEL)) + )]; // tab: diet $list = []; @@ -116,16 +110,13 @@ class PetPage extends GenericPage $food = new ItemList(array(['i.subClass', [5, 8]], ['i.FoodType', $list], CFG_SQL_LIMIT_NONE)); $this->extendGlobalData($food->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $food->getListviewData(), - 'params' => array( - 'name' => '$LANG.diet', - 'hiddenCols' => "$['source', 'slot', 'side']", - 'sort' => "$['level']", - 'id' => 'diet' - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($food->getListviewData()), + 'name' => '$LANG.diet', + 'hiddenCols' => ['source', 'slot', 'side'], + 'sort' => ['level'], + 'id' => 'diet' + )]; // tab: spells $mask = 0x0; @@ -153,15 +144,12 @@ class PetPage extends GenericPage $spells = new SpellList($conditions); $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $spells->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_abilities', - 'visibleCols' => "$['schools', 'level']", - 'id' => 'abilities' - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($spells->getListviewData()), + 'name' => '$LANG.tab_abilities', + 'visibleCols' => ['schools', 'level'], + 'id' => 'abilities' + )]; // tab: talents $conditions = array( @@ -183,17 +171,14 @@ class PetPage extends GenericPage $talents = new SpellList($conditions); $this->extendGlobalData($talents->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $talents->getListviewData(), - 'params' => array( - 'visibleCols' => "$['tier', 'level']", - 'name' => '$LANG.tab_talents', - 'id' => 'talents', - 'sort' => "$['tier', 'name']", - '_petTalents' => 1 - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($talents->getListviewData()), + 'visibleCols' => ['tier', 'level'], + 'name' => '$LANG.tab_talents', + 'id' => 'talents', + 'sort' => ['tier', 'name'], + '_petTalents' => 1 + )]; } } diff --git a/pages/pets.php b/pages/pets.php index f63c3001..cbd48a32 100644 --- a/pages/pets.php +++ b/pages/pets.php @@ -41,15 +41,16 @@ class PetsPage extends GenericPage { $this->extendGlobalData($pets->getJSGlobals(GLOBALINFO_RELATED)); - $params = ['visibleCols' => "$['abilities']"]; - if (!$pets->hasDiffFields(['type'])) - $params['hiddenCols'] = "$['type']"; - - $this->lvTabs[] = array( - 'file' => 'pet', - 'data' => $pets->getListviewData(), - 'params' => $params + $data = array( + 'data' => array_values($pets->getListviewData()), + 'visibleCols' => ['abilities'], + 'computeDataFunc' => '$_' ); + + if (!$pets->hasDiffFields(['type'])) + $data['hiddenCols'] = ['type']; + + $this->lvTabs[] = ['pet', $data, 'petFoodCol']; }; } diff --git a/pages/profiles.php b/pages/profiles.php index 37fc9bdd..c58787cf 100644 --- a/pages/profiles.php +++ b/pages/profiles.php @@ -93,20 +93,17 @@ class ProfilesPage extends GenericPage // dont send ID for real chars unless they have some kind of custom avatar // on second thought .. ids are required for resync, but the function that generates the icon is faulty - $this->lvTabs[] = array( - 'file' => 'profile', - 'data' => [$exampleRow], - 'params' => [ - 'id' => 'characters', - 'name' => '$LANG.tab_characters', - 'hideCount' => 1, - '_truncated' => 1, - 'roster' => 3, - 'visibleCols' => "$['race','classs','level','talents','achievementpoints']", - 'note' => '$$WH.sprintf(LANG.lvnote_charactersfound, \'20,592,390\', 200) + LANG.dash + LANG.lvnote_tryfiltering.replace(\'\', \'\')', - 'onBeforeCreate' => '$pr_initRosterListview' // $_GET['roster'] = 1|2|3|4 .. 2,3,4 arenateam-size (4 => 5-man), 1 guild .. it puts a resync button on the lv... - ] - ); + $this->lvTabs[] = ['profile', array( + 'data' => [$exampleRow], + 'id' => 'characters', + 'name' => '$LANG.tab_characters', + 'hideCount' => 1, + '_truncated' => 1, + 'roster' => 3, + 'visibleCols' => ['race','classs','level','talents','achievementpoints'], + 'note' => '$$WH.sprintf(LANG.lvnote_charactersfound, \'20,592,390\', 200) + LANG.dash + LANG.lvnote_tryfiltering.replace(\'\', \'\')', + 'onBeforeCreate' => '$pr_initRosterListview' // $_GET['roster'] = 1|2|3|4 .. 2,3,4 arenateam-size (4 => 5-man), 1 guild .. it puts a resync button on the lv... + )]; diff --git a/pages/quest.php b/pages/quest.php index 844bd00a..d6828c7b 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -591,14 +591,11 @@ class QuestPage extends GenericPage if (!$seeAlso->error) { $this->extendGlobalData($seeAlso->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $seeAlso->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_seealso', - 'id' => 'see-also' - ) - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($seeAlso->getListviewData()), + 'name' => '$LANG.tab_seealso', + 'id' => 'see-also' + )]; } // tab: criteria of @@ -606,14 +603,11 @@ class QuestPage extends GenericPage if (!$criteriaOf->error) { $this->extendGlobalData($criteriaOf->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $criteriaOf->getListviewData(), - 'params' => array( - 'name' => '$LANG.tab_criteriaof', - 'id' => 'criteria-of' - ) - ); + $this->lvTabs[] = ['achievement', array( + 'data' => array_values($criteriaOf->getListviewData()), + 'name' => '$LANG.tab_criteriaof', + 'id' => 'criteria-of' + )]; } // tab: conditions @@ -655,14 +649,11 @@ class QuestPage extends GenericPage "Markup.printHtml(markup, 'tab-conditions', { allow: Markup.CLASS_STAFF })" . ""; - $this->lvTabs[] = array( - 'file' => null, + $this->lvTabs[] = [null, array( 'data' => $tab, - 'params' => array( - 'id' => 'conditions', - 'name' => '$LANG.requires' - ) - ); + 'id' => 'conditions', + 'name' => '$LANG.requires' + )]; } } @@ -891,29 +882,26 @@ class QuestPage extends GenericPage if (!($se['method'] & 0x2) || $se['type'] != TYPE_NPC) continue; - if ($_ = CreatureList::getName($se['typeId'])) + if ($ti = CreatureList::getName($se['typeId'])) { - $mail['sender'] = sprintf(Lang::quest('mailBy'), $se['typeId'], $_); + $mail['sender'] = sprintf(Lang::quest('mailBy'), $se['typeId'], $ti); break; } } - $extraCols = ['Listview.extraCols.percent']; + $extraCols = ['$Listview.extraCols.percent']; $mailLoot = new Loot(); if ($mailLoot->getByContainer(LOOT_MAIL, $_)) { $this->extendGlobalData($mailLoot->jsGlobals); - $attachmentTab = array( - 'file' => 'item', - 'data' => $mailLoot->getResult(), - 'params' => array( - 'name' => '[Mail Attachments]', - 'id' => 'mail-attachments', - 'extraCols' => "$[".implode(', ', array_merge($extraCols, $mailLoot->extraCols))."]", - 'hiddenCols' => "$['side', 'slot', 'reqlevel']" - ) - ); + $attachmentTab = ['item', array( + 'data' => array_values($mailLoot->getResult()), + 'name' => Lang::quest('attachment'), + 'id' => 'mail-attachments', + 'extraCols' => array_merge($extraCols, $mailLoot->extraCols), + 'hiddenCols' => ['side', 'slot', 'reqlevel'] + )]; } } diff --git a/pages/quests.php b/pages/quests.php index 6827df79..e4b5a9b4 100644 --- a/pages/quests.php +++ b/pages/quests.php @@ -54,30 +54,26 @@ class QuestsPage extends GenericPage $this->filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL; $this->filter['fi'] = $this->filterObj->getForm(); - $lv = array( - 'file' => 'quest', - 'data' => $quests->getListviewData(), - 'params' => [] - ); + $tabData = ['data' => array_values($quests->getListviewData())]; if ($_ = $this->filterObj->getForm('reputationCols')) - $lv['params']['extraCols'] = '$fi_getReputationCols('.Util::toJSON($_).')'; + $tabData['extraCols'] = '$fi_getReputationCols('.json_encode($_, JSON_NUMERIC_CHECK).')'; else if (!empty($this->filter['fi']['extraCols'])) - $lv['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; + $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; // create note if search limit was exceeded if ($quests->getMatches() > CFG_SQL_LIMIT_DEFAULT) { - $lv['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_questsfound', $quests->getMatches(), CFG_SQL_LIMIT_DEFAULT); - $lv['params']['_truncated'] = 1; + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_questsfound', $quests->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['_truncated'] = 1; } else if (isset($this->category[1]) && $this->category[1] > 0) - $lv['params']['note'] = '$$WH.sprintf(LANG.lvnote_questgivers, '.$this->category[1].', g_zones['.$this->category[1].'], '.$this->category[1].')'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_questgivers, '.$this->category[1].', g_zones['.$this->category[1].'], '.$this->category[1].')'; if ($this->filterObj->error) - $lv['params']['_errors'] = '$1'; + $tabData['_errors'] = 1; - $this->lvTabs[] = $lv; + $this->lvTabs[] = ['quest', $tabData]; } protected function generateTitle() diff --git a/pages/race.php b/pages/race.php index 6d20fae5..2dd74980 100644 --- a/pages/race.php +++ b/pages/race.php @@ -109,11 +109,7 @@ class RacePage extends GenericPage if (!$classes->error) { $this->extendGlobalData($classes->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'class', - 'data' => $classes->getListviewData(), - 'params' => [] - ); + $this->lvTabs[] = ['class', ['data' => array_values($classes->getListviewData())]]; } // Tongues @@ -126,15 +122,12 @@ class RacePage extends GenericPage if (!$tongues->error) { $this->extendGlobalData($tongues->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $tongues->getListviewData(), - 'params' => array( - 'id' => 'languages', - 'name' => '$LANG.tab_languages', - 'hiddenCols' => "$['reagents']" - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($tongues->getListviewData()), + 'id' => 'languages', + 'name' => '$LANG.tab_languages', + 'hiddenCols' => ['reagents'] + )]; } // Racials @@ -147,15 +140,12 @@ class RacePage extends GenericPage if (!$racials->error) { $this->extendGlobalData($racials->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $racials->getListviewData(), - 'params' => array( - 'id' => 'racial-traits', - 'name' => '$LANG.tab_racialtraits', - 'hiddenCols' => "$['reagents']" - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($racials->getListviewData()), + 'id' => 'racial-traits', + 'name' => '$LANG.tab_racialtraits', + 'hiddenCols' => ['reagents'] + )]; } // Quests @@ -169,11 +159,7 @@ class RacePage extends GenericPage if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $quests->getListviewData(), - 'params' => [] - ); + $this->lvTabs[] = ['quest', ['data' => array_values($quests->getListviewData())]]; } // Mounts @@ -190,15 +176,12 @@ class RacePage extends GenericPage if (!$mounts->error) { $this->extendGlobalData($mounts->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $mounts->getListviewData(), - 'params' => array( - 'id' => 'mounts', - 'name' => '$LANG.tab_mounts', - 'hiddenCols' => "$['slot', 'type']" - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($mounts->getListviewData()), + 'id' => 'mounts', + 'name' => '$LANG.tab_mounts', + 'hiddenCols' => ['slot', 'type'] + )]; } } } diff --git a/pages/races.php b/pages/races.php index 922e0d17..e1c28255 100644 --- a/pages/races.php +++ b/pages/races.php @@ -32,13 +32,7 @@ class RacesPage extends GenericPage $races = new CharRaceList($conditions); if (!$races->error) - { - $this->lvTabs[] = array( - 'file' => 'race', - 'data' => $races->getListviewData(), - 'params' => [] - ); - } + $this->lvTabs[] = ['race', ['data' => array_values($races->getListviewData())]]; } protected function generateTitle() diff --git a/pages/search.php b/pages/search.php index bce6387e..2fc4e47a 100644 --- a/pages/search.php +++ b/pages/search.php @@ -36,7 +36,7 @@ class SearchPage extends GenericPage protected $tabId = 0; protected $mode = CACHE_TYPE_SEARCH; protected $js = ['swfobject.js']; - protected $lvTabs = []; + protected $lvTabs = []; // [file, data, extraInclude, osInfo] // osInfo:[type, appendix, nMatches, param1, param2] protected $search = ''; // output protected $invalid = []; @@ -153,7 +153,7 @@ class SearchPage extends GenericPage if (!empty($this->lvTabs[3])) // has world events { // update WorldEvents to date() - foreach ($this->lvTabs[3]['data'] as &$d) + foreach ($this->lvTabs[3][1]['data'] as &$d) { $updated = WorldEventList::updateDates($d['_date']); unset($d['_date']); @@ -166,14 +166,14 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) { $foundTotal = 0; - foreach ($this->lvTabs as $_) - $foundTotal += count($_['data']); + foreach ($this->lvTabs as list($file, $tabData, $_, $osInfo)) + $foundTotal += count($tabData['data']); if ($foundTotal == 1) // only one match -> redirect to find { - $_ = array_pop($this->lvTabs); - $type = Util::$typeStrings[$_['type']]; - $typeId = key($_['data']); + $tab = array_pop($this->lvTabs); + $type = Util::$typeStrings[$tab[3][0]]; + $typeId = array_pop($tab[1]['data'])['id']; header('Location: ?'.$type.'='.$typeId, true, 302); exit(); @@ -254,20 +254,20 @@ class SearchPage extends GenericPage if (!$asError) { // items - if (!empty($this->lvTabs[6]['data'])) + if (!empty($this->lvTabs[6][1]['data'])) { $items = []; - foreach ($this->lvTabs[6]['data'] as $k => $v) + foreach ($this->lvTabs[6][1]['data'] as $k => $v) $items[] = Util::toJSON($v); $outItems = "\t".implode(",\n\t", $items)."\n"; } - // sets - if (!empty($this->lvTabs[5]['data'])) + // item sets + if (!empty($this->lvTabs[5][1]['data'])) { $sets = []; - foreach ($this->lvTabs[5]['data'] as $k => $v) + foreach ($this->lvTabs[5][1]['data'] as $k => $v) { unset($v['quality']); if (!$v['heroic']) @@ -293,33 +293,34 @@ class SearchPage extends GenericPage [], [], [], [], [], [], [] ); - foreach ($this->lvTabs as $_) - $foundTotal += $_['matches']; + foreach ($this->lvTabs as list($_, $_, $_, $osInfo)) + $foundTotal += $osInfo[2]; if (!$foundTotal || $asError) return '["'.Util::jsEscape($this->search).'", []]'; - foreach ($this->lvTabs as $idx => $set) + foreach ($this->lvTabs as list($_, $tabData, $_, $osInfo)) { - $max = max(1, intVal($limit * $set['matches'] / $foundTotal)); + $max = max(1, intVal($limit * $osInfo[2] / $foundTotal)); $limit -= $max; for ($i = 0; $i < $max; $i++) { - $data = array_shift($set['data']); + $data = array_shift($tabData['data']); if (!$data) break; $hasQ = is_numeric($data['name'][0]) || $data['name'][0] == '@'; - $result[1][] = ($hasQ ? mb_substr($data['name'], 1) : $data['name']).$set['appendix']; - $result[3][] = HOST_URL.'/?'.Util::$typeStrings[$set['type']].'='.$data['id']; - $extra = [$set['type'], $data['id']]; + $result[1][] = ($hasQ ? mb_substr($data['name'], 1) : $data['name']).$osInfo[1]; + $result[3][] = HOST_URL.'/?'.Util::$typeStrings[$osInfo[0]].'='.$data['id']; - if (isset($data['param1'])) - $extra[] = $data['param1']; + $extra = [$osInfo[0], $data['id']]; // type, typeId - if (isset($data['param2'])) - $extra[] = $data['param2']; + if (isset($osInfo[3][$data['id']])) + $extra[] = $osInfo[3][$data['id']]; // param1 + + if (isset($osInfo[4][$data['id']])) + $extra[] = $osInfo[4][$data['id']]; // param2 $result[7][] = $extra; } @@ -382,100 +383,84 @@ class SearchPage extends GenericPage private function _searchCharClass($cndBase) // 0 Classes: $searchMask & 0x00000001 { - $result = []; $cnd = array_merge($cndBase, [$this->createLookup()]); $classes = new CharClassList($cnd); if ($data = $classes->getListviewData()) { - if ($this->searchMask & SEARCH_TYPE_OPEN) - foreach ($classes->iterate() as $__) - $data[$classes->id]['param1'] = 'class_'.strToLower($classes->getField('fileString')); + $result['data'] = array_values($data); + $osInfo = [TYPE_CLASS, ' (Class)', $classes->getMatches(), []]; - $result = array( - 'type' => TYPE_CLASS, - 'appendix' => ' (Class)', - 'matches' => $classes->getMatches(), - 'file' => CharClassList::$brickFile, - 'data' => $data, - 'params' => [] - ); + if ($this->searchMask & SEARCH_TYPE_OPEN) + foreach ($classes->iterate() as $id => $__) + $osInfo[3][$id] = 'class_'.strToLower($classes->getField('fileString')); if ($classes->getMatches() > $this->maxResults) { - // $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $classes->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + // $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $classes->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['class', $result, null, $osInfo]; } - return $result; + return false; } private function _searchCharRace($cndBase) // 1 Races: $searchMask & 0x00000002 { - $result = []; - $cnd = array_merge($cndBase, [$this->createLookup()]); - $races = new CharRaceList($cnd); + $cnd = array_merge($cndBase, [$this->createLookup()]); + $races = new CharRaceList($cnd); if ($data = $races->getListviewData()) { - if ($this->searchMask & SEARCH_TYPE_OPEN) - foreach ($races->iterate() as $__) - $data[$races->id]['param1'] = '"race_'.strToLower($races->getField('fileString')).'_male"'; + $result['data'] = array_values($data); + $osInfo = [TYPE_RACE, ' (Race)', $races->getMatches(), []]; - $result = array( - 'type' => TYPE_RACE, - 'appendix' => ' (Race)', - 'matches' => $races->getMatches(), - 'file' => CharRaceList::$brickFile, - 'data' => $data, - 'params' => [] - ); + if ($this->searchMask & SEARCH_TYPE_OPEN) + foreach ($races->iterate() as $id => $__) + $osInfo[3][$id] = 'race_'.strToLower($races->getField('fileString')).'_male'; if ($races->getMatches() > $this->maxResults) { - // $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $races->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + // $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $races->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['race', $result, null, $osInfo]; } - return $result; + return false; } private function _searchTitle($cndBase) // 2 Titles: $searchMask & 0x00000004 { - $result = []; $cnd = array_merge($cndBase, [$this->createLookup(['male_loc'.User::$localeId, 'female_loc'.User::$localeId])]); $titles = new TitleList($cnd); if ($data = $titles->getListviewData()) { + $result['data'] = array_values($data); + $osInfo = [TYPE_TITLE, ' (Title)', $titles->getMatches(), []]; + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($titles->iterate() as $id => $__) - $data[$id]['param1'] = $titles->getField('side'); - - $result = array( - 'type' => TYPE_TITLE, - 'appendix' => ' (Title)', - 'matches' => $titles->getMatches(), - 'file' => TitleList::$brickFile, - 'data' => $data, - 'params' => [] - ); + $osInfo[3][$id] = $titles->getField('side'); if ($titles->getMatches() > $this->maxResults) { - // $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $titles->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + // $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $titles->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['title', $result, null, $osInfo]; } - return $result; + return false; } private function _searchWorldEvent($cndBase) // 3 World Events: $searchMask & 0x00000008 { - $result = []; $cnd = array_merge($cndBase, array( array( 'OR', @@ -490,102 +475,87 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($wEvents->getJSGlobals()); - // as allways: dates are updated in postCache-step + $result['data'] = array_values($data); + $osInfo = [TYPE_WORLDEVENT, ' (World Event)', $wEvents->getMatches()]; - $result = array( - 'type' => TYPE_WORLDEVENT, - 'appendix' => ' (World Event)', - 'matches' => $wEvents->getMatches(), - 'file' => WorldEventList::$brickFile, - 'data' => $data, - 'params' => [] - ); + // as allways: dates are updated in postCache-step if ($wEvents->getMatches() > $this->maxResults) { - // $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $wEvents->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + // $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $wEvents->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['event', $result, null, $osInfo]; } - return $result; + return false; } private function _searchCurrency($cndBase) // 4 Currencies $searchMask & 0x0000010 { - $result = []; - $cnd = array_merge($cndBase, [$this->createLookup()]); - $money = new CurrencyList($cnd); + $cnd = array_merge($cndBase, [$this->createLookup()]); + $money = new CurrencyList($cnd); if ($data = $money->getListviewData()) { - if ($this->searchMask & SEARCH_TYPE_OPEN) - foreach ($money->iterate() as $__) - $data[$money->id]['param1'] = strToLower($money->getField('iconString')); + $result['data'] = array_values($data); + $osInfo = [TYPE_CURRENCY, ' (Currency)', $money->getMatches()]; - $result = array( - 'type' => TYPE_CURRENCY, - 'appendix' => ' (Currency)', - 'matches' => $money->getMatches(), - 'file' => CurrencyList::$brickFile, - 'data' => $data, - 'params' => [] - ); + if ($this->searchMask & SEARCH_TYPE_OPEN) + foreach ($money->iterate() as $id => $__) + $osInfo[3][$id] = strToLower($money->getField('iconString')); if ($money->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_currenciesfound', $money->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_currenciesfound', $money->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['currency', $result, null, $osInfo]; } - return $result; + return false; } private function _searchItemset($cndBase, &$shared) // 5 Itemsets $searchMask & 0x0000020 { - $result = []; - $cnd = array_merge($cndBase, [is_int($this->query) ? ['id', $this->query] : $this->createLookup()]); - $sets = new ItemsetList($cnd); + $cnd = array_merge($cndBase, [is_int($this->query) ? ['id', $this->query] : $this->createLookup()]); + $sets = new ItemsetList($cnd); if ($data = $sets->getListviewData()) { if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($sets->getJSGlobals(GLOBALINFO_SELF)); - if ($this->searchMask & SEARCH_TYPE_OPEN) - foreach ($sets->iterate() as $__) - $data[$sets->id]['param1'] = $sets->getField('quality'); + $result['data'] = array_values($data); + $osInfo = [TYPE_ITEMSET, ' (Item Set)', $sets->getMatches()]; - $result = array( - 'type' => TYPE_ITEMSET, - 'appendix' => ' (Item Set)', - 'matches' => $sets->getMatches(), - 'file' => ItemsetList::$brickFile, - 'data' => $data, - 'params' => [], - ); + if ($this->searchMask & SEARCH_TYPE_OPEN) + foreach ($sets->iterate() as $id => $__) + $osInfo[3][$id] = $sets->getField('quality'); $shared['pcsToSet'] = $sets->pieceToSet; if ($sets->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_itemsetsfound', $sets->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_itemsetsfound', $sets->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?itemsets&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?itemsets&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?itemsets&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?itemsets&filter=na='.urlencode($this->search).'\')'; + + return ['itemset', $result, null, $osInfo]; } - return $result; + return false; } private function _searchItem($cndBase, &$shared) // 6 Items $searchMask & 0x0000040 { - $result = []; $miscData = []; $cndAdd = empty($this->query) ? [] : (is_int($this->query) ? ['id', $this->query] : $this->createLookup()); @@ -622,48 +592,43 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($items->getJSGlobals()); - if ($this->searchMask & SEARCH_TYPE_OPEN) - { - foreach ($items->iterate() as $__) - { - $data[$items->id]['param1'] = $items->getField('iconString'); - $data[$items->id]['param2'] = $items->getField('quality'); - } - } - foreach ($items->iterate() as $itemId => $__) if (!empty($data[$itemId]['subitems'])) foreach ($data[$itemId]['subitems'] as &$si) $si['enchantment'] = implode(', ', $si['enchantment']); - $result = array( - 'type' => TYPE_ITEM, - 'appendix' => ' (Item)', - 'matches' => $items->getMatches(), - 'file' => ItemList::$brickFile, - 'data' => $data, - 'params' => [] - ); + $osInfo = [TYPE_ITEM, ' (Item)', $items->getMatches(), [], []]; + $result['data'] = array_values($data); + + if ($this->searchMask & SEARCH_TYPE_OPEN) + { + foreach ($items->iterate() as $id => $__) + { + $osInfo[3][$id] = $items->getField('iconString'); + $osInfo[4][$id] = $items->getField('quality'); + } + } if ($items->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_itemsfound', $items->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_itemsfound', $items->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?items&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?items&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?items&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?items&filter=na='.urlencode($this->search).'\')'; + + return ['item', $result, null, $osInfo]; } - return $result; + return false; } private function _searchAbility($cndBase) // 7 Abilities (Player + Pet) $searchMask & 0x0000080 { - $result = []; - $cnd = array_merge($cndBase, array( // hmm, inclued classMounts..? + $cnd = array_merge($cndBase, array( // hmm, inclued classMounts..? ['s.typeCat', [7, -2, -3]], [['s.cuFlags', (SPELL_CU_TRIGGERED | SPELL_CU_TALENT), '&'], 0], [['s.attributes0', 0x80, '&'], 0], @@ -680,47 +645,43 @@ class SearchPage extends GenericPage if ($abilities->hasSetFields(['reagent1'])) $vis[] = 'reagents'; + $osInfo = [TYPE_SPELL, ' (Ability)', $abilities->getMatches(), [], []]; + $result = array( + 'data' => array_values($data), + 'id' => 'abilities', + 'name' => '$LANG.tab_abilities', + 'visibleCols' => $vis + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) { - foreach ($abilities->iterate() as $__) + foreach ($abilities->iterate() as $id => $__) { - $data[$abilities->id]['param1'] = strToLower($abilities->getField('iconString')); - $data[$abilities->id]['param2'] = $abilities->ranks[$abilities->id]; + $osInfo[3][$id] = strToLower($abilities->getField('iconString')); + $osInfo[4][$id] = $abilities->ranks[$id]; } } - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Ability)', - 'matches' => $abilities->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'abilities', - 'name' => '$LANG.tab_abilities', - 'visibleCols' => '$'.Util::toJSON($vis) - ] - ); - if ($abilities->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_abilitiesfound', $abilities->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_abilitiesfound', $abilities->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=7&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=7&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=7&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=7&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchTalent($cndBase) // 8 Talents (Player + Pet) $searchMask & 0x0000100 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( ['s.typeCat', [-7, -2]], $this->createLookup() )); @@ -735,46 +696,42 @@ class SearchPage extends GenericPage if ($talents->hasSetFields(['reagent1'])) $vis[] = 'reagents'; + $osInfo = [TYPE_SPELL, ' (Talent)', $talents->getMatches(), [], []]; + $result = array( + 'data' => array_values($data), + 'id' => 'talents', + 'name' => '$LANG.tab_talents', + 'visibleCols' => $vis + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) { foreach ($talents->iterate() as $__) { - $data[$talents->id]['param1'] = strToLower($talents->getField('iconString')); - $data[$talents->id]['param2'] = $talents->ranks[$talents->id]; + $osInfo[3][$id] = strToLower($talents->getField('iconString')); + $osInfo[4][$id] = $talents->ranks[$talents->id]; } } - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Talent)', - 'matches' => $talents->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'talents', - 'name' => '$LANG.tab_talents', - 'visibleCols' => '$'.Util::toJSON($vis) - ] - ); - if ($talents->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_talentsfound', $talents->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_talentsfound', $talents->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-2&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-2&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-2&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-2&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchGlyph($cndBase) // 9 Glyphs $searchMask & 0x0000200 { - $result = []; $cnd = array_merge($cndBase, array( ['s.typeCat', -13], $this->createLookup() @@ -786,42 +743,38 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($glyphs->getJSGlobals(GLOBALINFO_SELF)); + $osInfo = [TYPE_SPELL, ' (Glyph)', $glyphs->getMatches(), []]; + $result = array( + 'data' => array_values($data), + 'id' => 'glyphs', + 'name' => '$LANG.tab_glyphs', + 'visibleCols' => ['singleclass', 'glyphtype'] + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($glyphs->iterate() as $__) - $data[$glyphs->id]['param1'] = strToLower($glyphs->getField('iconString')); - - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Glyph)', - 'matches' => $glyphs->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'glyphs', - 'name' => '$LANG.tab_glyphs', - 'visibleCols' => "$['singleclass', 'glyphtype']" - ] - ); + $osInfo[3][$id] = strToLower($glyphs->getField('iconString')); if ($glyphs->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_glyphsfound', $glyphs->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_glyphsfound', $glyphs->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-13&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-13&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-13&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-13&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchProficiency($cndBase) // 10 Proficiencies $searchMask & 0x0000400 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( ['s.typeCat', -11], $this->createLookup() )); @@ -832,42 +785,38 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($prof->getJSGlobals(GLOBALINFO_SELF)); + $osInfo = [TYPE_SPELL, ' (Proficiency)', $prof->getMatches(), []]; + $result = array( + 'data' => array_values($data), + 'id' => 'proficiencies', + 'name' => '$LANG.tab_proficiencies', + 'visibleCols' => ['classes'] + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($prof->iterate() as $__) - $data[$prof->id]['param1'] = strToLower($prof->getField('iconString')); - - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Proficiency)', - 'matches' => $prof->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'proficiencies', - 'name' => '$LANG.tab_proficiencies', - 'visibleCols' => "$['classes']" - ] - ); + $osInfo[3][$id] = strToLower($prof->getField('iconString')); if ($prof->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $prof->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $prof->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-11&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-11&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-11&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-11&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchProfession($cndBase) // 11 Professions (Primary + Secondary) $searchMask & 0x0000800 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( ['s.typeCat', [9, 11]], $this->createLookup() )); @@ -878,42 +827,38 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($prof->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); + $osInfo = [TYPE_SPELL, ' (Profession)', $prof->getMatches()]; + $result = array( + 'data' => array_values($data), + 'id' => 'professions', + 'name' => '$LANG.tab_professions', + 'visibleCols' => ['source', 'reagents'] + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($prof->iterate() as $__) - $data[$prof->id]['param1'] = strToLower($prof->getField('iconString')); - - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Profession)', - 'matches' => $prof->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'professions', - 'name' => '$LANG.tab_professions', - 'visibleCols' => "$['source', 'reagents']" - ] - ); + $osInfo[3][$id] = strToLower($prof->getField('iconString')); if ($prof->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_professionfound', $prof->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_professionfound', $prof->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=11&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=11&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=11&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=11&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchCompanion($cndBase) // 12 Companions $searchMask & 0x0001000 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( ['s.typeCat', -6], $this->createLookup() )); @@ -924,41 +869,37 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($vPets->getJSGlobals()); + $osInfo = [TYPE_SPELL, ' (Companion)', $vPets->getMatches(), []]; + $result = array( + 'data' => array_values($data), + 'id' => 'companions', + 'name' => '$LANG.tab_companions', + 'visibleCols' => ['reagents'] + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($vPets->iterate() as $__) - $data[$vPets->id]['param1'] = strToLower($vPets->getField('iconString')); - - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Companion)', - 'matches' => $vPets->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'companions', - 'name' => '$LANG.tab_companions', - 'visibleCols' => "$['reagents']" - ] - ); + $osInfo[3][$id] = strToLower($vPets->getField('iconString')); if ($vPets->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_companionsfound', $vPets->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_companionsfound', $vPets->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-6&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-6&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-6&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-6&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchMount($cndBase) // 13 Mounts $searchMask & 0x0002000 { - $result = []; $cnd = array_merge($cndBase, array( ['s.typeCat', -5], $this->createLookup() @@ -970,41 +911,37 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($mounts->getJSGlobals(GLOBALINFO_SELF)); + $osInfo = [TYPE_SPELL, ' (Mount)', $mounts->getMatches(), []]; + $result = array( + 'data' => array_values($data), + 'id' => 'mounts', + 'name' => '$LANG.tab_mounts', + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($mounts->iterate() as $__) - $data[$mounts->id]['param1'] = strToLower($mounts->getField('iconString')); - - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Mount)', - 'matches' => $mounts->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'mounts', - 'name' => '$LANG.tab_mounts', - ] - ); + $osInfo[3][$id] = strToLower($mounts->getField('iconString')); if ($mounts->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_mountsfound', $mounts->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_mountsfound', $mounts->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-5&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-5&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-5&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-5&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchCreature($cndBase) // 14 NPCs $searchMask & 0x0004000 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( [['flagsExtra', 0x80], 0], // exclude trigger creatures // [['cuFlags', MASK, '&'], 0], // todo (med): exclude difficulty entries $this->createLookup() @@ -1013,36 +950,32 @@ class SearchPage extends GenericPage if ($data = $npcs->getListviewData()) { + $osInfo = [TYPE_NPC, ' (NPC)', $npcs->getMatches()]; $result = array( - 'type' => TYPE_NPC, - 'appendix' => ' (NPC)', - 'matches' => $npcs->getMatches(), - 'file' => CreatureList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'npcs', - 'name' => '$LANG.tab_npcs', - ] + 'data' => array_values($data), + 'id' => 'npcs', + 'name' => '$LANG.tab_npcs', ); if ($npcs->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_npcsfound', $npcs->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_npcsfound', $npcs->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?npcs&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?npcs&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?npcs&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?npcs&filter=na='.urlencode($this->search).'\')'; + + return ['creature', $result, null, $osInfo]; } - return $result; + return false; } private function _searchQuest($cndBase) // 15 Quests $searchMask & 0x0008000 { - $result = []; $cnd = array_merge($cndBase, array( // [['cuFlags', MASK, '&'], 0], // todo (med): identify disabled quests $this->createLookup() @@ -1051,37 +984,32 @@ class SearchPage extends GenericPage if ($data = $quests->getListviewData()) { + $osInfo = [TYPE_QUEST, ' (Quest)', $quests->getMatches()]; + $result['data'] = array_values($data); + if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($quests->getJSGlobals()); - $result = array( - 'type' => TYPE_QUEST, - 'appendix' => ' (Quest)', - 'matches' => $quests->getMatches(), - 'file' => QuestList::$brickFile, - 'data' => $data, - 'params' => [] - ); - if ($quests->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_questsfound', $quests->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_questsfound', $quests->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?quests&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?quests&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?quests&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?quests&filter=na='.urlencode($this->search).'\')'; + + return ['quest', $result, null, $osInfo]; } - return $result; + return false; } private function _searchAchievement($cndBase) // 16 Achievements $searchMask & 0x0010000 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( [['flags', ACHIEVEMENT_FLAG_COUNTER, '&'], 0], // not a statistic $this->createLookup() )); @@ -1092,40 +1020,36 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($acvs->getJSGlobals()); + $osInfo = [TYPE_ACHIEVEMENT, ' (Achievement)', $acvs->getMatches(), []]; + $result = array( + 'data' => array_values($data), + 'visibleCols' => ['category'] + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($acvs->iterate() as $__) - $data[$acvs->id]['param1'] = strToLower($acvs->getField('iconString')); - - $result = array( - 'type' => TYPE_ACHIEVEMENT, - 'appendix' => ' (Achievement)', - 'matches' => $acvs->getMatches(), - 'file' => AchievementList::$brickFile, - 'data' => $data, - 'params' => [ - 'visibleCols' => "$['category']" - ] - ); + $osInfo[3][$id] = strToLower($acvs->getField('iconString')); if ($acvs->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_achievementsfound', $acvs->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_achievementsfound', $acvs->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?achieveemnts&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?achieveemnts&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?achievements&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?achievements&filter=na='.urlencode($this->search).'\')'; + + return ['achievement', $result, null, $osInfo]; } - return $result; + return false; } private function _searchStatistic($cndBase) // 17 Statistics $searchMask & 0x0020000 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( ['flags', ACHIEVEMENT_FLAG_COUNTER, '&'], // is a statistic $this->createLookup() )); @@ -1136,37 +1060,34 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($stats->getJSGlobals(GLOBALINFO_SELF)); + $osInfo = [TYPE_ACHIEVEMENT, ' (Statistic)', $stats->getMatches()]; $result = array( - 'type' => TYPE_ACHIEVEMENT, - 'matches' => $stats->getMatches(), - 'file' => AchievementList::$brickFile, - 'data' => $data, - 'params' => [ - 'visibleCols' => "$['category']", - 'hiddenCols' => "$['side', 'points', 'rewards']", - 'name' => '$LANG.tab_statistics', - 'id' => 'statistics' - ] + 'data' => array_values($data), + 'visibleCols' => ['category'], + 'hiddenCols' => ['side', 'points', 'rewards'], + 'name' => '$LANG.tab_statistics', + 'id' => 'statistics' ); if ($stats->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_statisticsfound', $stats->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_statisticsfound', $stats->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?achievements=1&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?achievements=1&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?achievements=1&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?achievements=1&filter=na='.urlencode($this->search).'\')'; + + return ['achievement', $result, null, $osInfo]; } - return $result; + return false; } private function _searchZone($cndBase) // 18 Zones $searchMask & 0x0040000 { - $result = []; $cnd = array_merge($cndBase, [$this->createLookup()]); $zones = new ZoneList($cnd); @@ -1175,28 +1096,23 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($zones->getJSGlobals()); - $result = array( - 'type' => TYPE_ZONE, - 'appendix' => ' (Zone)', - 'matches' => $zones->getMatches(), - 'file' => ZoneList::$brickFile, - 'data' => $data, - 'params' => [] - ); + $osInfo = [TYPE_ZONE, ' (Zone)', $zones->getMatches()]; + $result['data'] = array_values($data); if ($zones->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_zonesfound', $zones->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_zonesfound', $zones->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['zone', $result, null, $osInfo]; } - return $result; + return false; } private function _searchObject($cndBase) // 19 Objects $searchMask & 0x0080000 { - $result = []; $cnd = array_merge($cndBase, [$this->createLookup()]); $objects = new GameObjectList($cnd); @@ -1205,123 +1121,106 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($objects->getJSGlobals()); - $result = array( - 'type' => TYPE_OBJECT, - 'appendix' => ' (Object)', - 'matches' => $objects->getMatches(), - 'file' => GameObjectList::$brickFile, - 'data' => $data, - 'params' => [] - ); + $osInfo = [TYPE_OBJECT, ' (Object)', $objects->getMatches()]; + $result['data'] = array_values($data); if ($objects->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_objectsfound', $objects->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_objectsfound', $objects->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?objects&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?objects&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?objects&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?objects&filter=na='.urlencode($this->search).'\')'; + + return ['object', $result, null, $osInfo]; } - return $result; + return false; } private function _searchFaction($cndBase) // 20 Factions $searchMask & 0x0100000 { - $result = []; $cnd = array_merge($cndBase, [$this->createLookup()]); $factions = new FactionList($cnd); if ($data = $factions->getListviewData()) { - $result = array( - 'type' => TYPE_FACTION, - 'appendix' => ' (Faction)', - 'matches' => $factions->getMatches(), - 'file' => FactionList::$brickFile, - 'data' => $data, - 'params' => [] - ); + $osInfo = [TYPE_FACTION, ' (Faction)', $factions->getMatches()]; + $result['data'] = array_values($data); if ($factions->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_factionsfound', $factions->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_factionsfound', $factions->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['faction', $result, null, $osInfo]; } - return $result; + return false; } private function _searchSkill($cndBase) // 21 Skills $searchMask & 0x0200000 { - $result = []; $cnd = array_merge($cndBase, [$this->createLookup()]); $skills = new SkillList($cnd); if ($data = $skills->getListviewData()) { + $osInfo = [TYPE_SKILL, ' (Skill)', $skills->getMatches(), []]; + $result['data'] = array_values($data); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($skills->iterate() as $id => $__) - $data[$id]['param1'] = $skills->getField('iconString'); - - $result = array( - 'type' => TYPE_SKILL, - 'appendix' => ' (Skill)', - 'matches' => $skills->getMatches(), - 'file' => SkillList::$brickFile, - 'data' => $data, - 'params' => [] - ); + $osInf[3][$id] = $skills->getField('iconString'); if ($skills->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_skillsfound', $skills->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_skillsfound', $skills->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['skill', $result, null, $osInfo]; } - return $result; + return false; } private function _searchPet($cndBase) // 22 Pets $searchMask & 0x0400000 { - $result = []; $cnd = array_merge($cndBase, [$this->createLookup()]); $pets = new PetList($cnd); if ($data = $pets->getListviewData()) { + $osInfo = [TYPE_PET, ' (Pet)', $pets->getMatches(), []]; + $result = array( + 'data' => array_values($data), + 'computeDataFunc' => '$_' + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($pets->iterate() as $__) - $data[$pets->id]['param1'] = $pets->getField('iconString'); - - $result = array( - 'type' => TYPE_PET, - 'appendix' => ' (Pet)', - 'matches' => $pets->getMatches(), - 'file' => PetList::$brickFile, - 'data' => $data, - 'params' => [] - ); + $osInfo[3][$id] = $pets->getField('iconString'); if ($pets->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_petsfound', $pets->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_petsfound', $pets->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['pet', $result, 'petFoodCol', $osInfo]; } - return $result; + return false; } private function _searchCreatureAbility($cndBase) // 23 NPCAbilities $searchMask & 0x0800000 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( ['s.typeCat', -8], $this->createLookup() )); @@ -1332,43 +1231,39 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($npcAbilities->getJSGlobals(GLOBALINFO_SELF)); + $osInfo = [TYPE_SPELL, ' (Spell)', $npcAbilities->getMatches(), []]; + $result = array( + 'data' => array_values($data), + 'id' => 'npc-abilities', + 'name' => '$LANG.tab_npcabilities', + 'visibleCols' => ['level'], + 'hiddenCols' => ['skill'] + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($npcAbilities->iterate() as $__) - $data[$npcAbilities->id]['param1'] = strToLower($npcAbilities->getField('iconString')); - - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Spell)', - 'matches' => $npcAbilities->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'id' => 'npc-abilities', - 'name' => '$LANG.tab_npcabilities', - 'visibleCols' => "$['level']", - 'hiddenCols' => "$['skill']" - ] - ); + $osInfo[3][$id] = strToLower($npcAbilities->getField('iconString')); if ($npcAbilities->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $npcAbilities->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $npcAbilities->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-8&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=-8&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-8&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=-8&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchSpell($cndBase) // 24 Spells (Misc + GM + triggered abilities) $searchMask & 0x1000000 { - $result = []; - $cnd = array_merge($cndBase, array( + $cnd = array_merge($cndBase, array( [ 'OR', ['s.typeCat', [0, -9]], @@ -1383,62 +1278,56 @@ class SearchPage extends GenericPage if ($this->searchMask & SEARCH_TYPE_REGULAR) $this->extendGlobalData($misc->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); + $osInfo = [TYPE_SPELL, ' (Spell)', $misc->getMatches(), []]; + $result = array( + 'data' => array_values($data), + 'name' => '$LANG.tab_uncategorizedspells', + 'visibleCols' => ['level'], + 'hiddenCols' => ['skill'] + ); + if ($this->searchMask & SEARCH_TYPE_OPEN) foreach ($misc->iterate() as $__) - $data[$misc->id]['param1'] = strToLower($misc->getField('iconString')); - - $result = array( - 'type' => TYPE_SPELL, - 'appendix' => ' (Spell)', - 'matches' => $misc->getMatches(), - 'file' => SpellList::$brickFile, - 'data' => $data, - 'params' => [ - 'name' => '$LANG.tab_uncategorizedspells', - 'visibleCols' => "$['level']", - 'hiddenCols' => "$['skill']", - ] - ); + $osInfo[3][$id] = strToLower($misc->getField('iconString')); if ($misc->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $misc->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $misc->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } - if (isset($result['params']['note'])) - $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=0&filter=na='.urlencode($this->search).'\')'; + if (isset($result['note'])) + $result['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=0&filter=na='.urlencode($this->search).'\')'; else - $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=0&filter=na='.urlencode($this->search).'\')'; + $result['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=0&filter=na='.urlencode($this->search).'\')'; + + return ['spell', $result, null, $osInfo]; } - return $result; + return false; } private function _searchEmote($cndBase) // 25 Emotes $searchMask & 0x2000000 { - $result = []; - $cnd = array_merge($cndBase, [$this->createLookup(['cmd', 'self_loc'.User::$localeId, 'target_loc'.User::$localeId, 'noTarget_loc'.User::$localeId])]); - $emote = new EmoteList($cnd); + $cnd = array_merge($cndBase, [$this->createLookup(['cmd', 'self_loc'.User::$localeId, 'target_loc'.User::$localeId, 'noTarget_loc'.User::$localeId])]); + $emote = new EmoteList($cnd); if ($data = $emote->getListviewData()) { + $osInfo = [TYPE_EMOTE, ' (Emote)', $emote->getMatches()]; $result = array( - 'type' => TYPE_EMOTE, - 'appendix' => ' (Emote)', - 'matches' => $emote->getMatches(), - 'file' => EmoteList::$brickFile, - 'data' => $data, - 'params' => [] + 'data' => array_values($data), + 'name' => Util::ucFirst(Lang::game('emotes')) ); + + return ['emote', $result, 'emote', $osInfo]; } - return $result; + return false; } private function _searchEnchantment($cndBase) // 26 Enchantments $searchMask & 0x4000000 { - $result = []; $cnd = array_merge($cndBase, [$this->createLookup(['name_loc'.User::$localeId])]); $enchantment = new EnchantmentList($cnd); @@ -1446,29 +1335,28 @@ class SearchPage extends GenericPage { $this->extendGlobalData($enchantment->getJSGlobals()); + $osInfo = [TYPE_ENCHANTMENT, ' (Enchantment)', $enchantment->getMatches()]; $result = array( - 'type' => TYPE_ENCHANTMENT, - 'appendix' => ' (Enchantment)', - 'matches' => $enchantment->getMatches(), - 'file' => EnchantmentList::$brickFile, - 'data' => $data, - 'params' => [] + 'data' => array_values($data), + 'name' => Util::ucFirst(Lang::game('enchantments')) ); if (array_filter(array_column($result['data'], 'spells'))) - $result['params']['visibleCols'] = '$[\'trigger\']'; + $result['visibleCols'] = ['trigger']; if (!$enchantment->hasSetFields(['skillLine'])) - $result['params']['hiddenCols'] = '$[\'skill\']'; + $result['hiddenCols'] = ['skill']; if ($enchantment->getMatches() > $this->maxResults) { - $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_enchantmentsfound', $enchantment->getMatches(), $this->maxResults); - $result['params']['_truncated'] = 1; + $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_enchantmentsfound', $enchantment->getMatches(), $this->maxResults); + $result['_truncated'] = 1; } + + return ['enchantment', $result, 'enchantment', $osInfo]; } - return $result; + return false; } // private function _searchCharacter($cndBase) { } // 27 Characters $searchMask & 0x8000000 diff --git a/pages/skill.php b/pages/skill.php index 17570054..60e4014c 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -76,16 +76,13 @@ class SkillPage extends GenericPage { $this->extendGlobalData($recipes->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $recipes->getListviewData(), - 'params' => array( - 'id' => 'recipes', - 'name' => '$LANG.tab_recipes', - 'visibleCols' => "$['reagents', 'source']", - 'note' => sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.$this->typeId.'&filter=cr=20;crs=1;crv=0') - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($recipes->getListviewData()), + 'id' => 'recipes', + 'name' => '$LANG.tab_recipes', + 'visibleCols' => ['reagents', 'source'], + 'note' => sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.$this->typeId.'&filter=cr=20;crs=1;crv=0') + )]; } // tab: recipe Items [items] (Books) @@ -101,18 +98,16 @@ class SkillPage extends GenericPage { $this->extendGlobalData($recipeItems->getJSGlobals(GLOBALINFO_SELF)); - if ($_ = array_search($this->typeId, $filterRecipe)) - $_ = sprintf(Util::$filterResultString, "?items=9.".$_); - - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $recipeItems->getListviewData(), - 'params' => array( - 'id' => 'recipe-items', - 'name' => '$LANG.tab_recipeitems', - 'note' => $_ - ) + $tabData = array( + 'data' => array_values($recipeItems->getListviewData()), + 'id' => 'recipe-items', + 'name' => '$LANG.tab_recipeitems', ); + + if ($_ = array_search($this->typeId, $filterRecipe)) + $tabData['note'] = sprintf(Util::$filterResultString, "?items=9.".$_); + + $this->lvTabs[] = ['item', $tabData]; } // tab: crafted items [items] @@ -130,18 +125,16 @@ class SkillPage extends GenericPage { $this->extendGlobalData($created->getJSGlobals(GLOBALINFO_SELF)); - if ($_ = array_search($this->typeId, $filterItem)) - $_ = sprintf(Util::$filterResultString, "?items&filter=cr=86;crs=".$_.";crv=0"); - - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $created->getListviewData(), - 'params' => array( - 'id' => 'crafted-items', - 'name' => '$LANG.tab_crafteditems', - 'note' => $_ - ) + $tabData = array( + 'data' => array_values($created->getListviewData()), + 'id' => 'crafted-items', + 'name' => '$LANG.tab_crafteditems', ); + + if ($_ = array_search($this->typeId, $filterItem)) + $tabData['note'] = sprintf(Util::$filterResultString, "?items&filter=cr=86;crs=".$_.";crv=0"); + + $this->lvTabs[] = ['item', $tabData]; } } @@ -157,18 +150,16 @@ class SkillPage extends GenericPage { $this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF)); - if ($_ = array_search($this->typeId, $filterItem)) - $_ = sprintf(Util::$filterResultString, "?items&filter=cr=99:168;crs=".$_.":2;crv=0:0"); - - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $reqBy->getListviewData(), - 'params' => array( - 'id' => 'required-by', - 'name' => '$LANG.tab_requiredby', - 'note' => $_ - ) + $tabData = array( + 'data' => array_values($reqBy->getListviewData()), + 'id' => 'required-by', + 'name' => '$LANG.tab_requiredby', ); + + if ($_ = array_search($this->typeId, $filterItem)) + $tabData['note'] = sprintf(Util::$filterResultString, "?items&filter=99:168;crs=".$_.":2;crv=0:0"); + + $this->lvTabs[] = ['item', $tabData]; } // tab: required by [itemset] @@ -182,14 +173,11 @@ class SkillPage extends GenericPage { $this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = array( - 'file' => 'itemset', - 'data' => $reqBy->getListviewData(), - 'params' => array( - 'id' => 'required-by-set', - 'name' => '$LANG.tab_requiredby' - ) - ); + $this->lvTabs[] = ['itemset', array( + 'data' => array_values($reqBy->getListviewData()), + 'id' => 'required-by-set', + 'name' => '$LANG.tab_requiredby' + )]; } } @@ -221,28 +209,27 @@ class SkillPage extends GenericPage $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF)); - $lv = array( - 'file' => 'spell', - 'data' => $spells->getListviewData(), - 'params' => ['visibleCols' => "$['source']"] + $tabData = array( + 'data' => array_values($spells->getListviewData()), + 'visibleCols' => ['source'] ); switch ($this->cat) { case -4: - $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=-4'); + $tabData['note'] = sprintf(Util::$filterResultString, '?spells=-4'); break; case 7: if ($this->typeId != 769) // Internal - $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.(log($reqClass, 2) + 1).'.'.$this->typeId); // doesn't matter what spell; reqClass should be identical for all Class Spells + $tabData['note'] = sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.(log($reqClass, 2) + 1).'.'.$this->typeId); // doesn't matter what spell; reqClass should be identical for all Class Spells break; case 9: case 11: - $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.$this->typeId); + $tabData['note'] = sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.$this->typeId); break; } - $this->lvTabs[] = $lv; + $this->lvTabs[] = ['spell', $tabData]; } // tab: trainers [npcs] @@ -284,14 +271,11 @@ class SkillPage extends GenericPage { $this->extendGlobalData($trainer->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'creature', - 'data' => $trainer->getListviewData(), - 'params' => array( - 'id' => 'trainer', - 'name' => '$LANG.tab_trainers', - ) - ); + $this->lvTabs[] = ['creature', array( + 'data' => array_values($trainer->getListviewData()), + 'id' => 'trainer', + 'name' => '$LANG.tab_trainers', + )]; } } } @@ -321,11 +305,7 @@ class SkillPage extends GenericPage if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $quests->getListviewData(), - 'params' => [] - ); + $this->lvTabs[] = ['quest', ['data' => array_values($quests->getListviewData())]]; } } } @@ -340,13 +320,7 @@ class SkillPage extends GenericPage { $classes = new CharClassList(array(['id', $class])); if (!$classes->error) - { - $this->lvTabs[] = array( - 'file' => 'class', - 'data' => $classes->getListviewData(), - 'params' => [] - ); - } + $this->lvTabs[] = ['class', ['data' => array_values($classes->getListviewData())]]; } // tab: related races (apply races from [spells]) @@ -359,13 +333,7 @@ class SkillPage extends GenericPage { $races = new CharRaceList(array(['id', $race])); if (!$races->error) - { - $this->lvTabs[] = array( - 'file' => 'race', - 'data' => $races->getListviewData(), - 'params' => [] - ); - } + $this->lvTabs[] = ['race', ['data' => array_values($races->getListviewData())]]; } } } diff --git a/pages/skills.php b/pages/skills.php index dbb0c6ac..377f2471 100644 --- a/pages/skills.php +++ b/pages/skills.php @@ -38,11 +38,7 @@ class SkillsPage extends GenericPage $skills = new SkillList($conditions); - $this->lvTabs[] = array( - 'file' => 'skill', - 'data' => $skills->getListviewData(), // listview content - 'params' => [] - ); + $this->lvTabs[] = ['skill', ['data' => array_values($skills->getListviewData())]]; } protected function generateTitle() diff --git a/pages/spell.php b/pages/spell.php index c638ba6c..081ce7ab 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -321,20 +321,18 @@ class SpellPage extends GenericPage $abilities = new SpellList(array(['id', $formSpells])); if (!$abilities->error) { - if (!$abilities->hasSetFields(['skillLines'])) - $abH = "$['skill']"; - - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $abilities->getListviewData(), - 'params' => array( - 'id' => 'controlledabilities', - 'name' => '$LANG.tab_controlledabilities', - 'visibleCols' => "$['level']", - 'hiddenCols' => isset($abH) ? $abH : null - ) + $tabData = array( + 'data' => array_values($abilities->getListviewData()), + 'id' => 'controlledabilities', + 'name' => '$LANG.tab_controlledabilities', + 'visibleCols' => ['level'], ); + if (!$abilities->hasSetFields(['skillLines'])) + $tabData['hiddenCols'] = ['skill']; + + $this->lvTabs[] = ['spell', $tabData]; + $this->extendGlobalData($abilities->getJSGlobals(GLOBALINFO_SELF)); } } @@ -370,20 +368,18 @@ class SpellPage extends GenericPage $modSpells = new SpellList($conditions); if (!$modSpells->error) { - if (!$modSpells->hasSetFields(['skillLines'])) - $msH = "$['skill']"; - - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $modSpells->getListviewData(), - 'params' => array( - 'id' => 'modifies', - 'name' => '$LANG.tab_modifies', - 'visibleCols' => "$['level']", - 'hiddenCols' => isset($msH) ? $msH : null - ) + $tabData = array( + 'data' => array_values($modSpells->getListviewData()), + 'id' => 'modifies', + 'name' => '$LANG.tab_modifies', + 'visibleCols' => ['level'], ); + if (!$modSpells->hasSetFields(['skillLines'])) + $tabData['hiddenCols'] = ['skill']; + + $this->lvTabs[] = ['spell', $tabData]; + $this->extendGlobalData($modSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } @@ -421,20 +417,18 @@ class SpellPage extends GenericPage $modsSpell = new SpellList($conditions); if (!$modsSpell->error) { - if (!$modsSpell->hasSetFields(['skillLines'])) - $mbH = "$['skill']"; - - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $modsSpell->getListviewData(), - 'params' => array( - 'id' => 'modified-by', - 'name' => '$LANG.tab_modifiedby', - 'visibleCols' => "$['level']", - 'hiddenCols' => isset($mbH) ? $mbH : null - ) + $tabData = array( + 'data' => array_values($modsSpell->getListviewData()), + 'id' => 'modified-by', + 'name' => '$LANG.tab_modifiedby', + 'visibleCols' => ['level'], ); + if (!$modsSpell->hasSetFields(['skillLines'])) + $tabData['hiddenCols'] = ['skill']; + + $this->lvTabs[] = ['spell', $tabData]; + $this->extendGlobalData($modsSpell->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } @@ -455,7 +449,7 @@ class SpellPage extends GenericPage $data = $saSpells->getListviewData(); if ($this->difficulties) // needs a way to distinguish between dungeon and raid :x; creature using this -> map -> areaType? { - $saE = '$[Listview.extraCols.mode]'; + $saE = ['$Listview.extraCols.mode']; foreach ($data as $id => &$d) { @@ -485,21 +479,21 @@ class SpellPage extends GenericPage } } - if (!$saSpells->hasSetFields(['skillLines'])) - $saH = "$['skill']"; - - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $data, - 'params' => array( - 'id' => 'see-also', - 'name' => '$LANG.tab_seealso', - 'visibleCols' => "$['level']", - 'extraCols' => isset($saE) ? $saE : null, - 'hiddenCols' => isset($saH) ? $saH : null - ) + $tabData = array( + 'data' => array_values($data), + 'id' => 'see-also', + 'name' => '$LANG.tab_seealso', + 'visibleCols' => ['level'], ); + if (!$saSpells->hasSetFields(['skillLines'])) + $tabData['hiddenCols'] = ['skill']; + + if (isset($saE)) + $tabData['extraCols'] = $saE; + + $this->lvTabs[] = ['spell', $tabData]; + $this->extendGlobalData($saSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } @@ -513,14 +507,11 @@ class SpellPage extends GenericPage $ubSets = new ItemsetList($conditions); if (!$ubSets->error) { - $this->lvTabs[] = array( - 'file' => 'itemset', - 'data' => $ubSets->getListviewData(), - 'params' => array( - 'id' => 'used-by-itemset', - 'name' => '$LANG.tab_usedby' - ) - ); + $this->lvTabs[] = ['itemset', array( + 'data' => array_values($ubSets->getListviewData()), + 'id' => 'used-by-itemset', + 'name' => '$LANG.tab_usedby' + )]; $this->extendGlobalData($ubSets->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } @@ -538,14 +529,11 @@ class SpellPage extends GenericPage $ubItems = new ItemList($conditions); if (!$ubItems->error) { - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $ubItems->getListviewData(), - 'params' => array( - 'id' => 'used-by-item', - 'name' => '$LANG.tab_usedby' - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($ubItems->getListviewData()), + 'id' => 'used-by-item', + 'name' => '$LANG.tab_usedby' + )]; $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF)); } @@ -560,14 +548,11 @@ class SpellPage extends GenericPage $ubObjects = new GameObjectList($conditions); if (!$ubObjects->error) { - $this->lvTabs[] = array( - 'file' => 'object', - 'data' => $ubObjects->getListviewData(), - 'params' => array( - 'id' => 'used-by-object', - 'name' => '$LANG.tab_usedby' - ) - ); + $this->lvTabs[] = ['object', array( + 'data' => array_values($ubObjects->getListviewData()), + 'id' => 'used-by-object', + 'name' => '$LANG.tab_usedby' + )]; $this->extendGlobalData($ubObjects->getJSGlobals()); } @@ -582,14 +567,11 @@ class SpellPage extends GenericPage $coAchievemnts = new AchievementList($conditions); if (!$coAchievemnts->error) { - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $coAchievemnts->getListviewData(), - 'params' => array( - 'id' => 'criteria-of', - 'name' => '$LANG.tab_criteriaof' - ) - ); + $this->lvTabs[] = ['achievement', array( + 'data' => array_values($coAchievemnts->getListviewData()), + 'id' => 'criteria-of', + 'name' => '$LANG.tab_criteriaof' + )]; $this->extendGlobalData($coAchievemnts->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } @@ -605,7 +587,7 @@ class SpellPage extends GenericPage $lv = $spellLoot->getResult(); $extraCols = $spellLoot->extraCols; - $extraCols[] = 'Listview.extraCols.percent'; + $extraCols[] = '$Listview.extraCols.percent'; if ($extraItem && $this->subject->canCreateItem()) { @@ -619,7 +601,7 @@ class SpellPage extends GenericPage $lv[$bar]['percent'] = $extraItem['additionalCreateChance']; $lv[$bar]['condition'][0][$this->typeId][] = [[CND_SPELL, $extraItem['requiredSpecialization']]]; $this->extendGlobalIds(TYPE_SPELL, $extraItem['requiredSpecialization']); - $extraCols[] = 'Listview.extraCols.condition'; + $extraCols[] = '$Listview.extraCols.condition'; if ($max = $extraItem['additionalMaxNum']) { $lv[$bar]['mincount'] = 1; @@ -631,16 +613,13 @@ class SpellPage extends GenericPage } } - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $lv, - 'params' => array( - 'name' => '$LANG.tab_contains', - 'id' => 'contains', - 'hiddenCols' => "$['side', 'slot', 'source', 'reqlevel']", - 'extraCols' => '$['.implode(', ', $extraCols).']' - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($lv), + 'name' => '$LANG.tab_contains', + 'id' => 'contains', + 'hiddenCols' => ['side', 'slot', 'source', 'reqlevel'], + 'extraCols' => $extraCols + )]; } // tab: exclusive with @@ -689,19 +668,20 @@ class SpellPage extends GenericPage $data[$k]['stackRule'] = $groups[$k]; if (!$stacks->hasSetFields(['skillLines'])) - $sH = "$['skill']"; + $sH = ['skill']; - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $data, - 'params' => array( - 'id' => 'spell-group-stack', - 'name' => 'Stack Group', // todo (med): localize - 'visibleCols' => "$['stackRules']", - 'hiddenCols' => isset($sH) ? $sH : null - ) + $tabData = array( + 'data' => array_values($data), + 'id' => 'spell-group-stack', + 'name' => Lang::spell('stackGroup'), + 'visibleCols' => ['stackRules'] ); + if (isset($sH)) + $tabData['hiddenCols'] = $sH; + + $this->lvTabs[] = ['spell', $tabData]; + $this->extendGlobalData($stacks->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } @@ -743,16 +723,13 @@ class SpellPage extends GenericPage } } - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $data, - 'params' => array( - 'id' => 'spell-link', - 'name' => 'Linked with', // todo (med): localize - 'hiddenCols' => "$['skill', 'name']", - 'visibleCols' => "$['linkedTrigger', 'linkedEffect']" - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($data), + 'id' => 'spell-link', + 'name' => Lang::spell('linkedWith'), + 'hiddenCols' => ['skill', 'name'], + 'visibleCols' => ['linkedTrigger', 'linkedEffect'] + )]; $this->extendGlobalData($linked->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } @@ -769,14 +746,11 @@ class SpellPage extends GenericPage $trigger = new SpellList($conditions); if (!$trigger->error) { - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $trigger->getListviewData(), - 'params' => array( - 'id' => 'triggered-by', - 'name' => '$LANG.tab_triggeredby' - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($trigger->getListviewData()), + 'id' => 'triggered-by', + 'name' => '$LANG.tab_triggeredby' + )]; $this->extendGlobalData($trigger->getJSGlobals(GLOBALINFO_SELF)); } @@ -794,14 +768,11 @@ class SpellPage extends GenericPage $ubCreature = new CreatureList($conditions); if (!$ubCreature->error) { - $this->lvTabs[] = array( - 'file' => 'creature', - 'data' => $ubCreature->getListviewData(), - 'params' => array( - 'id' => 'used-by-npc', - 'name' => '$LANG.tab_usedby' - ) - ); + $this->lvTabs[] = ['creature', array( + 'data' => array_values($ubCreature->getListviewData()), + 'id' => 'used-by-npc', + 'name' => '$LANG.tab_usedby' + )]; $this->extendGlobalData($ubCreature->getJSGlobals(GLOBALINFO_SELF)); } @@ -944,14 +915,15 @@ class SpellPage extends GenericPage $_ = array_merge($_, $parents[$_['parentArea']]); } - $this->lvTabs[] = array( - 'file' => 'zone', - 'data' => $lv, - 'params' => array( - 'extraCols' => $extra ? '$[Listview.extraCols.condition]' : null, - 'hiddenCols' => $extra ? "$['instancetype']" : null - ) - ); + $tabData = ['data' => array_values($lv)]; + + if ($extra) + { + $tabData['extraCols'] = ['$Listview.extraCols.condition']; + $tabData['hiddenCols'] = ['instancetype']; + } + + $this->lvTabs[] = ['zone', $tabData]; } } @@ -963,9 +935,6 @@ class SpellPage extends GenericPage { $this->extendGlobalData($teaches->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $vis = ['level', 'schools']; - $hid = []; - if (!$teaches->hasSetFields(['skillLines'])) - $hid[] = 'skill'; foreach ($teaches->iterate() as $__) { @@ -976,16 +945,17 @@ class SpellPage extends GenericPage break; } - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $teaches->getListviewData(), - 'params' => array( - 'id' => 'teaches-spell', - 'name' => '$LANG.tab_teaches', - 'visibleCols' => '$'.Util::toJSON($vis), - 'hiddenCols' => $hid ? '$'.Util::toJSON($hid) : null - ) + $tabData = array( + 'data' => array_values($teaches->getListviewData()), + 'id' => 'teaches-spell', + 'name' => '$LANG.tab_teaches', + 'visibleCols' => $vis, ); + + if (!$teaches->hasSetFields(['skillLines'])) + $tabData['hiddenCols'] = ['skill']; + + $this->lvTabs[] = ['spell', $tabData]; } } @@ -1036,14 +1006,11 @@ class SpellPage extends GenericPage if (!$tbTrainer->error) { $this->extendGlobalData($tbTrainer->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'creature', - 'data' => $tbTrainer->getListviewData(), - 'params' => array( - 'id' => 'taught-by-npc', - 'name' => '$LANG.tab_taughtby', - ) - ); + $this->lvTabs[] = ['creature', array( + 'data' => array_values($tbTrainer->getListviewData()), + 'id' => 'taught-by-npc', + 'name' => '$LANG.tab_taughtby', + )]; } } } @@ -1061,14 +1028,11 @@ class SpellPage extends GenericPage if (!$tbSpell->error) { $tbsData = $tbSpell->getListviewData(); - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $tbsData, - 'params' => array( - 'id' => 'taught-by-spell', - 'name' => '$LANG.tab_taughtby' - ) - ); + $this->lvTabs[] = ['spell', array( + 'data' => array_values($tbsData), + 'id' => 'taught-by-spell', + 'name' => '$LANG.tab_taughtby' + )]; $this->extendGlobalData($tbSpell->getJSGlobals(GLOBALINFO_SELF)); } @@ -1087,14 +1051,11 @@ class SpellPage extends GenericPage $tbQuest = new QuestList($conditions); if (!$tbQuest->error) { - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $tbQuest->getListviewData(), - 'params' => array( - 'id' => 'reward-from-quest', - 'name' => '$LANG.tab_rewardfrom' - ) - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($tbQuest->getListviewData()), + 'id' => 'reward-from-quest', + 'name' => '$LANG.tab_rewardfrom' + )]; $this->extendGlobalData($tbQuest->getJSGlobals()); } @@ -1112,14 +1073,11 @@ class SpellPage extends GenericPage $tbItem = new ItemList($conditions); if (!$tbItem->error) { - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $tbItem->getListviewData(), - 'params' => array( - 'id' => 'taught-by-item', - 'name' => '$LANG.tab_taughtby' - ) - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($tbItem->getListviewData()), + 'id' => 'taught-by-item', + 'name' => '$LANG.tab_taughtby' + )]; $this->extendGlobalData($tbItem->getJSGlobals(GLOBALINFO_SELF)); } @@ -1134,11 +1092,10 @@ class SpellPage extends GenericPage $enchList = new EnchantmentList($conditions); if (!$enchList->error) { - $this->lvTabs[] = array( - 'file' => 'enchantment', - 'data' => $enchList->getListviewData(), - 'params' => [] - ); + $this->lvTabs[] = ['enchantment', array( + 'data' => array_values($enchList->getListviewData()), + 'name' => Util::ucFirst(Lang::game('enchantments')) + ), 'enchantment']; $this->extendGlobalData($enchList->getJSGlobals()); } @@ -1159,14 +1116,11 @@ class SpellPage extends GenericPage "Markup.printHtml(markup, 'tab-conditions', { allow: Markup.CLASS_STAFF })" . ""; - $this->lvTabs[] = array( - 'file' => null, + $this->lvTabs[] = [null, array( 'data' => $tab, - 'params' => array( - 'id' => 'conditions', - 'name' => '$LANG.requires' - ) - ); + 'id' => 'conditions', + 'name' => '$LANG.requires' + )]; } } diff --git a/pages/spells.php b/pages/spells.php index bf7370d3..7c6452be 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -100,11 +100,7 @@ class SpellsPage extends GenericPage $conditions = []; $visibleCols = []; $hiddenCols = []; - $tab = array( - 'file' => 'spell', - 'data' => [], - 'params' => [] - ); + $tabData = ['data' => []]; // the next lengthy ~250 lines determine $conditions and lvParams if ($this->category) @@ -200,10 +196,10 @@ class SpellsPage extends GenericPage break; } - $tab['params']['note'] = '$$WH.sprintf(LANG.lvnote_pettalents, "'.$url.'")'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_pettalents, "'.$url.'")'; } - $tab['params']['_petTalents'] = 1; // not conviced, this is correct, but .. it works + $tabData['_petTalents'] = 1; // not conviced, this is correct, but .. it works break; case -11: // Proficiencies ... the subIds are actually SkillLineCategories @@ -299,8 +295,8 @@ class SpellsPage extends GenericPage if (is_array($note)) $note = $note[0]; - $tab['params']['note'] = sprintf(Lang::spell('relItems', 'base'), $txt, $note); - $tab['params']['sort'] = "$['skill', 'name']"; + $tabData['note'] = sprintf(Lang::spell('relItems', 'base'), $txt, $note); + $tabData['sort'] = ['skill', 'name']; } } @@ -339,8 +335,8 @@ class SpellsPage extends GenericPage if (is_array($note)) $note = $note[0]; - $tab['params']['note'] = sprintf(Lang::spell('relItems', 'base'), $txt, $note); - $tab['params']['sort'] = "$['skill', 'name']"; + $tabData['note'] = sprintf(Lang::spell('relItems', 'base'), $txt, $note); + $tabData['sort'] = ['skill', 'name']; } } @@ -367,7 +363,7 @@ class SpellsPage extends GenericPage $spells = new SpellList($conditions); $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); - $tab['data'] = $spells->getListviewData(); + $tabData['data'] = array_values($spells->getListviewData()); // recreate form selection $this->filter = array_merge($this->filterObj->getForm('form'), $this->filter); @@ -375,17 +371,17 @@ class SpellsPage extends GenericPage $this->filter['fi'] = $this->filterObj->getForm(); if (!empty($this->filter['fi']['extraCols'])) - $tab['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; + $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; // create note if search limit was exceeded; overwriting 'note' is intentional if ($spells->getMatches() > CFG_SQL_LIMIT_DEFAULT) { - $tab['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_spellsfound', $spells->getMatches(), CFG_SQL_LIMIT_DEFAULT); - $tab['params']['_truncated'] = 1; + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_spellsfound', $spells->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['_truncated'] = 1; } if ($this->filterObj->error) - $tab['params']['_errors'] = '$1'; + $tabData['_errors'] = 1; // add source to cols if explicitly searching for it if ($_ = $this->filterObj->getForm('setCriteria', true)) @@ -404,12 +400,12 @@ class SpellsPage extends GenericPage if ($visibleCols) - $tab['params']['visibleCols'] = '$'.Util::toJSON($visibleCols); + $tabData['visibleCols'] = $visibleCols; if ($hiddenCols) - $tab['params']['hiddenCols'] = '$'.Util::toJSON($hiddenCols); + $tabData['hiddenCols'] = $hiddenCols; - $this->lvTabs[] = $tab; + $this->lvTabs[] = ['spell', $tabData]; // sort for dropdown-menus Lang::sort('game', 'ra'); diff --git a/pages/title.php b/pages/title.php index d9f49bd3..47dde429 100644 --- a/pages/title.php +++ b/pages/title.php @@ -104,16 +104,13 @@ class TitlePage extends GenericPage { $this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_REWARDS)); - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $quests->getListviewData(), - 'params' => array( - 'id' => 'reward-from-quest', - 'name' => '$LANG.tab_rewardfrom', - 'hiddenCols' => "$['experience', 'money']", - 'visibleCols' => "$['category']" - ) - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($quests->getListviewData()), + 'id' => 'reward-from-quest', + 'name' => '$LANG.tab_rewardfrom', + 'hiddenCols' => ['experience', 'money'], + 'visibleCols' => ['category'] + )]; } // tab: achievement source @@ -124,16 +121,13 @@ class TitlePage extends GenericPage { $this->extendGlobalData($acvs->getJSGlobals()); - $this->lvTabs[] = array( - 'file' => 'achievement', - 'data' => $acvs->getListviewData(), - 'params' => array( - 'id' => 'reward-from-achievement', - 'name' => '$LANG.tab_rewardfrom', - 'visibleCols' => "$['category']", - 'sort' => "$['reqlevel', 'name']" - ) - ); + $this->lvTabs[] = ['achievement', array( + 'data' => array_values($acvs->getListviewData()), + 'id' => 'reward-from-achievement', + 'name' => '$LANG.tab_rewardfrom', + 'visibleCols' => ['category'], + 'sort' => ['reqlevel', 'name'] + )]; } } diff --git a/pages/titles.php b/pages/titles.php index 64c2abb3..ed41c6ea 100644 --- a/pages/titles.php +++ b/pages/titles.php @@ -36,22 +36,20 @@ class TitlesPage extends GenericPage if ($this->category) $conditions[] = ['category', $this->category[0]]; - $titles = new TitleList($conditions); + $tabData = ['data' => []]; + $titles = new TitleList($conditions); if (!$titles->error) { - $params = []; + $tabData['data'] = array_values($titles->getListviewData()); + if ($titles->hasDiffFields(['category'])) - $params['visibleCols'] = "$['category']"; + $tabData['visibleCols'] = ['category']; if (!$titles->hasAnySource()) - $params['hiddenCols'] = "$['source']"; - - $this->lvTabs[] = array( - 'file' => 'title', - 'data' => $titles->getListviewData(), - 'params' => $params - ); + $tabData['hiddenCols'] = ['source']; } + + $this->lvTabs[] = ['title', $tabData]; } protected function generateTitle() diff --git a/pages/user.php b/pages/user.php index 19117ced..cb5b69c5 100644 --- a/pages/user.php +++ b/pages/user.php @@ -138,95 +138,79 @@ class UserPage extends GenericPage foreach ($repData as &$r) $r['when'] = date(Util::$dateFormatInternal, $r['when']); - $this->lvTabs[] = array( - 'file' => 'reputationhistory', - 'data' => $repData, - 'params' => [] - ); + $this->lvTabs[] = ['reputationhistory', ['data' => $repData]]; } // Comments if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => false], $nFound)) { - $lvData = array( - 'file' => 'commentpreview', - 'data' => $_, - 'params' => array( - 'hiddenCols' => "$['author']", - 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', - '_totalCount' => $nFound - ) + $tabData = array( + 'data' => $_, + 'hiddenCols' => ['author'], + 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', + '_totalCount' => $nFound ); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { - $lvData['params']['name'] = '$LANG.tab_latestcomments'; - $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_usercomments, '.$nFound.')'; + $tabData['name'] = '$LANG.tab_latestcomments'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_usercomments, '.$nFound.')'; } - $this->lvTabs[] = $lvData; + $this->lvTabs[] = ['commentpreview', $tabData]; } // Comment Replies if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => true], $nFound)) { - $lvData = array( - 'file' => 'replypreview', - 'data' => $_, - 'params' => array( - 'hiddenCols' => "$['author']", - 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', - '_totalCount' => $nFound - ) + $tabData = array( + 'data' => $_, + 'hiddenCols' => ['author'], + 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', + '_totalCount' => $nFound ); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { - $lvData['params']['name'] = '$LANG.tab_latestreplies'; - $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_userreplies, '.$nFound.')'; + $tabData['name'] = '$LANG.tab_latestreplies'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_userreplies, '.$nFound.')'; } - $this->lvTabs[] = $lvData; + $this->lvTabs[] = ['replypreview', $tabData]; } // Screenshots if ($_ = CommunityContent::getScreenshots(-$this->user['id'], 0, $nFound)) { - $lvData = array( - 'file' => 'screenshot', - 'data' => $_, - 'params' => array( - '_totalCount' => $nFound - ) + $tabData = array( + 'data' => $_, + '_totalCount' => $nFound ); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { - $lvData['params']['name'] = '$LANG.tab_latestscreenshots'; - $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_userscreenshots, '.$nFound.')'; + $tabData['name'] = '$LANG.tab_latestscreenshots'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_userscreenshots, '.$nFound.')'; } - $this->lvTabs[] = $lvData; + $this->lvTabs[] = ['screenshot', $tabData]; } // Videos if ($_ = CommunityContent::getVideos(-$this->user['id'], 0, $nFound)) { - $lvData = array( - 'file' => 'video', - 'data' => $_, - 'params' => array( - '_totalCount' => $nFound - ) + $tabData = array( + 'data' => $_, + '_totalCount' => $nFound ); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { - $lvData['params']['name'] = '$LANG.tab_latestvideos'; - $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_uservideos, '.$nFound.')'; + $tabData['name'] = '$LANG.tab_latestvideos'; + $tabData['note'] = '$$WH.sprintf(LANG.lvnote_uservideos, '.$nFound.')'; } - $this->lvTabs[] = $lvData; + $this->lvTabs[] = ['video', $tabData]; } // forum -> latest topics [unused] @@ -235,6 +219,34 @@ class UserPage extends GenericPage // Characters [todo] $this->user['characterData'] = []; + /* + us_addCharactersTab([ + { + id:763, + "name":"Lilywhite", + "achievementpoints":"0", + "guild":"whatever", + "guildrank":"0", + "realm":"draenor", + "realmname":"Draenor", + "battlegroup":"cyclone", + "battlegroupname":"Cyclone", + "region":"us", + "level":"10", + "race":"7", + "gender":"0", + "classs":"1", + "faction":"0", + "gearscore":"0", + "talenttree1":"0", + "talenttree2":"0", + "talenttree3":"0", + "talentspec":0, + "published":1, + "pinned":0 + } + ]); + */ // Profiles [todo] $this->user['profileData'] = []; diff --git a/pages/utility.php b/pages/utility.php index 8106762c..ee45285d 100644 --- a/pages/utility.php +++ b/pages/utility.php @@ -91,13 +91,8 @@ class UtilityPage extends GenericPage } } else - { - $this->lvTabs[] = array( - 'file' => 'commentpreview', - 'data' => $data, - 'params' => [] - ); - } + $this->lvTabs[] = ['commentpreview', ['data' => $data]]; + break; case 'latest-screenshots': // rss $data = CommunityContent::getScreenshots(); @@ -124,13 +119,8 @@ class UtilityPage extends GenericPage } } else - { - $this->lvTabs[] = array( - 'file' => 'screenshot', - 'data' => $data, - 'params' => [] - ); - } + $this->lvTabs[] = ['screenshot', ['data' => $data]]; + break; case 'latest-videos': // rss $data = CommunityContent::getVideos(); @@ -157,13 +147,8 @@ class UtilityPage extends GenericPage } } else - { - $this->lvTabs[] = array( - 'file' => 'video', - 'data' => $data, - 'params' => [] - ); - } + $this->lvTabs[] = ['video', ['data' => $data]]; + break; case 'latest-articles': // rss $this->lvTabs = []; @@ -172,11 +157,7 @@ class UtilityPage extends GenericPage $extraText = ''; break; case 'unrated-comments': - $this->lvTabs[] = array( - 'file' => 'commentpreview', - 'data' => [], - 'params' => [] - ); + $this->lvTabs[] = ['commentpreview', ['data' => []]]; break; case 'missing-screenshots': // limit to 200 entries each (it generates faster, consumes less memory and should be enough options) @@ -193,11 +174,7 @@ class UtilityPage extends GenericPage if (!$typeObj->error) { $this->extendGlobalData($typeObj->getJSGlobals(GLOBALINFO_ANY)); - $this->lvTabs[] = array( - 'file' => $typeObj::$brickFile, - 'data' => $typeObj->getListviewData(), - 'params' => [] - ); + $this->lvTabs[] = [$typeObj::$brickFile, ['data' => array_values($typeObj->getListviewData())]]; } } break; @@ -205,9 +182,9 @@ class UtilityPage extends GenericPage if ($this->category && !in_array($this->category[0], [1, 7, 30])) header('Location: ?most-comments=1'.($this->rss ? '&rss' : null), true, 302); - $params = array( - 'extraCols' => '$[Listview.funcBox.createSimpleCol(\'ncomments\', \'tab_comments\', \'10%\', \'ncomments\')]', - 'sort' => '$[\'-ncomments\']' + $tabBase = array( + 'extraCols' => ["\$Listview.funcBox.createSimpleCol('ncomments', 'tab_comments', '10%', 'ncomments')"], + 'sort' => ['-ncomments'] ); foreach (Util::$typeClasses as $type => $classStr) @@ -250,11 +227,7 @@ class UtilityPage extends GenericPage $d['ncomments'] = $comments[$typeId]; $this->extendGlobalData($typeClass->getJSGlobals(GLOBALINFO_ANY)); - $this->lvTabs[] = array( - 'file' => $typeClass::$brickFile, - 'data' => $data, - 'params' => $params - ); + $this->lvTabs[] = [$typeClass::$brickFile, array_merge($tabBase, ['data' => array_values($data)])]; } } } @@ -263,14 +236,9 @@ class UtilityPage extends GenericPage } // found nothing => set empty content + // tpl: commentpreview - anything, doesn't matter what if (!$this->lvTabs && !$this->rss) - { - $this->lvTabs[] = array( - 'file' => 'commentpreview', // anything, doesn't matter what - 'data' => [], - 'params' => [] - ); - } + $this->lvTabs[] = ['commentpreview', ['data' => []]]; } protected function generateRSS() diff --git a/pages/zone.php b/pages/zone.php index 2577db92..806aadba 100644 --- a/pages/zone.php +++ b/pages/zone.php @@ -460,45 +460,42 @@ class ZonePage extends GenericPage // tab: NPCs if ($cSpawns && !$creatureSpawns->error) { - $lvData = array( - 'file' => 'creature', - 'data' => $creatureSpawns->getListviewData(), - 'params' => ['note' => sprintf(Util::$filterResultString, '?npcs&filter=cr=6;crs='.$this->typeId.';crv=0')] + $tabData = array( + 'data' => array_values($creatureSpawns->getListviewData()), + 'note' => sprintf(Util::$filterResultString, '?npcs&filter=cr=6;crs='.$this->typeId.';crv=0') ); if ($creatureSpawns->getMatches() > CFG_SQL_LIMIT_DEFAULT) - $lvData['params']['_truncated'] = 1; + $tabData['_truncated'] = 1; $this->extendGlobalData($creatureSpawns->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = $lvData; + $this->lvTabs[] = ['creature', $tabData]; } // tab: Objects if ($oSpawns && !$objectSpawns->error) { - $lvData = array( - 'file' => 'object', - 'data' => $objectSpawns->getListviewData(), - 'params' => ['note' => sprintf(Util::$filterResultString, '?objects&filter=cr=1;crs='.$this->typeId.';crv=0')] + $tabData = array( + 'data' => array_values($objectSpawns->getListviewData()), + 'note' => sprintf(Util::$filterResultString, '?objects&filter=cr=1;crs='.$this->typeId.';crv=0') ); if ($objectSpawns->getMatches() > CFG_SQL_LIMIT_DEFAULT) - $lvData['params']['_truncated'] = 1; + $tabData['_truncated'] = 1; $this->extendGlobalData($objectSpawns->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = $lvData; + $this->lvTabs[] = ['object', $tabData]; } // tab: Quests [data collected by SOM-routine] if ($questsLV) { - $this->lvTabs[] = array( - 'file' => 'quest', - 'data' => $questsLV, - 'params' => ['note' => '$$WH.sprintf(LANG.lvnote_zonequests, '.$this->subject->getField('mapId').', '.$this->typeId.', \''.Util::jsEscape($this->subject->getField('name', true)).'\', '.$this->typeId.')'] - ); + $this->lvTabs[] = ['quest', array( + 'data' => array_values($questsLV), + 'note' => '$$WH.sprintf(LANG.lvnote_zonequests, '.$this->subject->getField('mapId').', '.$this->typeId.', \''.Util::jsEscape($this->subject->getField('name', true)).'\', '.$this->typeId.')' + )]; } // tab: item-quest starter @@ -517,14 +514,11 @@ class ZonePage extends GenericPage $qsiList = new ItemList(array(['id', array_keys($questStartItem)])); if (!$qsiList->error) { - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $qsiList->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_startsquest', - 'id' => 'starts-quest' - ] - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($qsiList->getListviewData()), + 'name' => '$LANG.tab_startsquest', + 'id' => 'starts-quest' + )]; $this->extendGlobalData($qsiList->getJSGlobals(GLOBALINFO_SELF)); } @@ -536,15 +530,12 @@ class ZonePage extends GenericPage $rewards = new ItemList(array(['id', array_unique($rewardsLV)])); if (!$rewards->error) { - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $rewards->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_questrewards', - 'id' => 'quest-rewards', - 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=126;crs='.$this->typeId.';crv=0') - ] - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($rewards->getListviewData()), + 'name' => '$LANG.tab_questrewards', + 'id' => 'quest-rewards', + 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=126;crs='.$this->typeId.';crv=0') + )]; $this->extendGlobalData($rewards->getJSGlobals(GLOBALINFO_SELF)); } @@ -557,30 +548,27 @@ class ZonePage extends GenericPage if ($fish->getByContainer(LOOT_FISHING, $this->typeId)) { $this->extendGlobalData($fish->jsGlobals); - $xCols = array_merge(['Listview.extraCols.percent'], $fish->extraCols); + $xCols = array_merge(['$Listview.extraCols.percent'], $fish->extraCols); foreach ($fish->iterate() as $lv) { if (!$lv['quest']) continue; - $xCols = array_merge($xCols, ['Listview.extraCols.condition']); + $xCols = array_merge($xCols, ['$Listview.extraCols.condition']); $reqQuest[$lv['id']] = 0; $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]]; } - $this->lvTabs[] = array( - 'file' => 'item', - 'data' => $fish->getResult(), - 'params' => [ - 'name' => '$LANG.tab_fishing', - 'id' => 'fishing', - 'extraCols' => $xCols ? "$[".implode(', ', array_unique($xCols))."]" : null, - 'hiddenCols' => "$['side']" - ] - ); + $this->lvTabs[] = ['item', array( + 'data' => array_values($fish->getResult()), + 'name' => '$LANG.tab_fishing', + 'id' => 'fishing', + 'extraCols' => array_unique($xCols), + 'hiddenCols' => ['side'] + )]; } // tab: spells @@ -672,14 +660,15 @@ class ZonePage extends GenericPage } } - $this->lvTabs[] = array( - 'file' => 'spell', - 'data' => $lvSpells, - 'params' => array( - 'extraCols' => $extra ? '$[Listview.extraCols.condition]' : null, - 'hiddenCols' => "$['skill']" - ) + $tabData = array( + 'data' => array_values($lvSpells), + 'hiddenCols' => ['skill'] ); + + if ($extra) + $tabData['extraCols'] = ['$Listview.extraCols.condition']; + + $this->lvTabs[] = ['spell', $tabData]; } } @@ -687,15 +676,12 @@ class ZonePage extends GenericPage $subZones = new ZoneList(array(['parentArea', $this->typeId])); if (!$subZones->error) { - $this->lvTabs[] = array( - 'file' => 'zone', - 'data' => $subZones->getListviewData(), - 'params' => [ - 'name' => '$LANG.tab_zones', - 'id' => 'subzones', - 'hiddenCols' => "$['territory', 'instancetype']" - ] - ); + $this->lvTabs[] = ['zone', array( + 'data' => array_values($subZones->getListviewData()), + 'name' => '$LANG.tab_zones', + 'id' => 'subzones', + 'hiddenCols' => ['territory', 'instancetype'] + )]; $this->extendGlobalData($subZones->getJSGlobals(GLOBALINFO_SELF)); } diff --git a/pages/zones.php b/pages/zones.php index af16e7ef..9f69e354 100644 --- a/pages/zones.php +++ b/pages/zones.php @@ -32,7 +32,6 @@ class ZonesPage extends GenericPage $conditions = [CFG_SQL_LIMIT_NONE]; $visibleCols = []; $hiddenCols = []; - $params = []; $mapFile = 0; $spawnMap = -1; @@ -75,18 +74,16 @@ class ZonesPage extends GenericPage if (!$zones->hasSetFields(['type'])) $hiddenCols[] = 'instancetype'; + $tabData = ['data' => array_values($zones->getListviewData())]; + if ($visibleCols) - $params['visibleCols'] = "$['".implode("', '", $visibleCols)."']"; + $tabData['visibleCols'] = $visibleCols; if ($hiddenCols) - $params['hiddenCols'] = "$['".implode("', '", $hiddenCols)."']"; + $tabData['hiddenCols'] = $hiddenCols; $this->map = null; - $this->lvTabs[] = array( - 'file' => 'zone', - 'data' => $zones->getListviewData(), - 'params' => $params - ); + $this->lvTabs[] = ['zone', $tabData]; // create flight map if ($mapFile) diff --git a/template/bricks/announcement.tpl.php b/template/bricks/announcement.tpl.php index a508bc35..05c35421 100644 --- a/template/bricks/announcement.tpl.php +++ b/template/bricks/announcement.tpl.php @@ -1,12 +1,9 @@ announcements as $id => $data): - $data = json_encode($data, JSON_NUMERIC_CHECK); - // json_encode does not recognize variables - $data = preg_replace('/"\$((.+?)([^\\\\]))"/i', '$1', $data); ?> -
+
pageText)): ?>
-

+

user) ? 'tabsRelated' : 'myTabs'; $isTabbed = !empty($this->forceTabs) || $relTabs || count($this->lvTabs) > 1; +// lvTab: [file, data, extraInclude] + if ($isTabbed): ?>
@@ -10,17 +12,17 @@ if ($isTabbed):
lvTabs as $lv): - if ($lv['file']): + if ($lv[0]): continue; endif; - echo ''; + echo ''; endforeach; ?>
diff --git a/template/pages/home.tpl.php b/template/pages/home.tpl.php index eba7f5c9..ac92ab52 100644 --- a/template/pages/home.tpl.php +++ b/template/pages/home.tpl.php @@ -58,7 +58,7 @@ endif; echo $this->writeGlobalVars(); if ($this->news): - echo " Markup.printHtml(".json_encode($this->news['text']).", 'news-generic', { allow: Markup.CLASS_ADMIN });\n"; + echo " Markup.printHtml(".Util::toJSON($this->news['text']).", 'news-generic', { allow: Markup.CLASS_ADMIN });\n"; endif; ?> //]]> diff --git a/template/pages/itemset.tpl.php b/template/pages/itemset.tpl.php index 7ed3cc64..51224dde 100644 --- a/template/pages/itemset.tpl.php +++ b/template/pages/itemset.tpl.php @@ -28,24 +28,26 @@ echo $this->description; ?> pieces as $i => $p): - echo ' \n"; +$idx = 0; +foreach ($this->pieces as $iId => $piece): + echo ' \n"; endforeach; ?>
'.$p['name']."
'.$piece['name_'.User::$localeString]."
@@ -54,12 +56,12 @@ endforeach; if ($this->unavailable): ?>
- + -

bonusExt; ?>

+

bonusExt; ?>

- + -

+

-

+

brick('infobox'); ?>
-

name; ?>

+

name; ?>

- +
- +
-
-
+ +
localizedBrick('ssReminder', User::$localeId); ?> - +