From 49800da2c85b3d17177d238a128a0528ad365bc9 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Thu, 11 Jul 2013 21:29:05 +0200 Subject: [PATCH] Moved most code related to jsGlobals to template. (Except for Globals, that belong to the object already created, it makes zero sense to look them up again from the template.) I'm not overly happy with passing the templateObject to each typeObject, but it works .. for now. Effectively this should reduce db-lookups as each type should be looked up only twice at max (once for relevant data on the page and maybe again to get related jsGlobals for the template) also removed BaseType::addRewardsToJscript() get it with BaseType::addGlobalsToJscript() and the appropriate addMask * added ListviewHelper::getSetFields() wich is more appropriate in some cases (like reagents for spells should be shown even if they are all the same) * load bricks as needed, removed the if-blocks (maybe add the filename to every TypeClass..?) --- includes/class.achievement.php | 50 +++---- includes/class.charclass.php | 15 +- includes/class.charrace.php | 13 +- includes/class.creature.php | 25 ++-- includes/class.currency.php | 20 +-- includes/class.faction.php | 5 +- includes/class.gameobject.php | 5 +- includes/class.item.php | 31 ++-- includes/class.itemset.php | 21 +-- includes/class.pet.php | 19 ++- includes/class.quest.php | 82 ++++------- includes/class.skill.php | 5 +- includes/class.spell.php | 53 +++---- includes/class.title.php | 20 +-- includes/class.worldevent.php | 48 +----- includes/class.zone.php | 14 +- includes/defines.php | 7 +- includes/utilities.php | 195 ++++++++++++++++++------- pages/achievement.php | 21 +-- pages/achievements.php | 4 +- pages/classes.php | 1 - pages/compare.php | 1 - pages/currencies.php | 3 +- pages/events.php | 3 +- pages/item.php | 3 - pages/itemset.php | 5 +- pages/itemsets.php | 3 +- pages/maps.php | 1 - pages/npc.php | 3 - pages/pet.php | 9 +- pages/pets.php | 3 +- pages/quest.php | 3 - pages/races.php | 1 - pages/spell.php | 34 ++--- pages/spells.php | 5 +- pages/talent.php | 1 - pages/title.php | 10 +- pages/titles.php | 1 - pages/zones.php | 1 - search.php | 101 +++++++++---- template/bricks/listviews/creature.tpl | 2 +- template/header.tpl | 14 +- template/search.tpl | 29 +--- 43 files changed, 445 insertions(+), 445 deletions(-) diff --git a/includes/class.achievement.php b/includes/class.achievement.php index f049dfeb..1ceff7f0 100644 --- a/includes/class.achievement.php +++ b/includes/class.achievement.php @@ -7,11 +7,13 @@ class AchievementList extends BaseType { use listviewHelper; - public $criteria = []; - public $tooltip = []; + public static $type = TYPE_ACHIEVEMENT; - protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_achievement WHERE [filter] [cond] GROUP BY Id ORDER BY `orderInGroup` ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM ?_achievement WHERE [filter] [cond]'; + public $criteria = []; + public $tooltip = []; + + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_achievement WHERE [filter] [cond] GROUP BY Id ORDER BY `orderInGroup` ASC'; + protected $matchQuery = 'SELECT COUNT(1) FROM ?_achievement WHERE [filter] [cond]'; public function __construct($conditions, $applyFilter = false) { @@ -42,38 +44,24 @@ class AchievementList extends BaseType $this->reset(); // restore 'iterator' } - public function addRewardsToJScript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = GLOBALINFO_ANY) { - $items = []; - $titles = []; - while ($this->iterate()) { - foreach ($this->curTpl['rewards'][TYPE_ITEM] as $_) - $items[] = $_; + if ($addMask & GLOBALINFO_SELF) + $template->extendGlobalData(self::$type, [$this->id => array( + 'icon' => $this->curTpl['iconString'], + 'name' => Util::localizedString($this->curTpl, 'name') + )]); - foreach ($this->curTpl['rewards'][TYPE_TITLE] as $_) - $titles[] = $_; - } + if ($addMask & GLOBALINFO_REWARDS) + { + foreach ($this->curTpl['rewards'][TYPE_ITEM] as $_) + $template->extendGlobalIds(TYPE_ITEM, $_); - if ($items) - (new ItemList(array(['i.entry', $items])))->addGlobalsToJscript($refs); - - if ($titles) - (new TitleList(array(['id', $titles])))->addGlobalsToJscript($refs); - } - - public function addGlobalsToJscript(&$refs) - { - if (!isset($refs['gAchievements'])) - $refs['gAchievements'] = []; - - while ($this->iterate()) - { - $refs['gAchievements'][$this->id] = array( - 'icon' => $this->curTpl['iconString'], - 'name' => Util::localizedString($this->curTpl, 'name') - ); + foreach ($this->curTpl['rewards'][TYPE_TITLE] as $_) + $template->extendGlobalIds(TYPE_TITLE, $_); + } } } diff --git a/includes/class.charclass.php b/includes/class.charclass.php index 388bbd97..d23a2e78 100644 --- a/includes/class.charclass.php +++ b/includes/class.charclass.php @@ -5,8 +5,10 @@ if (!defined('AOWOW_REVISION')) class CharClassList extends BaseType { - protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_classes WHERE [cond] ORDER BY Id ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM ?_classes WHERE [cond]'; + public static $type = TYPE_CLASS; + + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_classes WHERE [cond] ORDER BY Id ASC'; + protected $matchQuery = 'SELECT COUNT(1) FROM ?_classes WHERE [cond]'; public function getListviewData() { @@ -24,7 +26,7 @@ class CharClassList extends BaseType 'power' => $this->curTpl['powerType'], ); - if ($this->curTpl['expansion'] == 2) // todo: grr, move to db + if ($this->curTpl['expansion'] == 2) // todo (low): grr, move to db $data[$this->id]['hero'] = 1; if ($this->curTpl['expansion']) @@ -34,13 +36,10 @@ class CharClassList extends BaseType return $data; } - public function addGlobalsToJscript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = 0) { - if (!isset($refs['gClasses'])) - $refs['gClasses'] = []; - while ($this->iterate()) - $refs['gClasses'][$this->id] = ['name' => $this->getField('name', true)]; + $template->extendGlobalData(self::$type, [$this->id => ['name' => $this->getField('name', true)]]); } public function addRewardsToJScript(&$ref) { } diff --git a/includes/class.charrace.php b/includes/class.charrace.php index 7a33215e..4e05b658 100644 --- a/includes/class.charrace.php +++ b/includes/class.charrace.php @@ -5,8 +5,10 @@ if (!defined('AOWOW_REVISION')) class CharRaceList extends BaseType { - protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_races WHERE [cond] ORDER BY Id ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM ?_races WHERE [cond]'; + public static $type = TYPE_RACE; + + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_races WHERE [cond] ORDER BY Id ASC'; + protected $matchQuery = 'SELECT COUNT(1) FROM ?_races WHERE [cond]'; public function getListviewData() { @@ -31,13 +33,10 @@ class CharRaceList extends BaseType return $data; } - public function addGlobalsToJscript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = 0) { - if (!isset($refs['gRaces'])) - $refs['gRaces'] = []; - while ($this->iterate()) - $refs['gRaces'][$this->id] = ['name' => $this->getField('name', true)]; + $template->extendGlobalData(self::$type, [$this->id => ['name' => $this->getField('name', true)]]); } public function addRewardsToJScript(&$ref) { } diff --git a/includes/class.creature.php b/includes/class.creature.php index b2c80383..60785f36 100644 --- a/includes/class.creature.php +++ b/includes/class.creature.php @@ -8,10 +8,12 @@ class CreatureList extends BaseType { use spawnHelper; - public $tooltips = []; + public static $type = TYPE_NPC; - protected $setupQuery = 'SELECT ct.*, ct.id AS ARRAY_KEY, ft.A, ft.H, ft.factionId FROM ?_creature ct LEFT JOIN ?_factiontemplate ft ON ft.id = ct.faction_A WHERE [filter] [cond]'; - protected $matchQuery = 'SELECT COUNT(*) FROM ?_creature ct WHERE [filter] [cond]'; + public $tooltips = []; + + protected $setupQuery = 'SELECT ct.*, ct.id AS ARRAY_KEY, ft.A, ft.H, ft.factionId FROM ?_creature ct LEFT JOIN ?_factiontemplate ft ON ft.id = ct.faction_A WHERE [filter] [cond]'; + protected $matchQuery = 'SELECT COUNT(*) FROM ?_creature ct WHERE [filter] [cond]'; public static function getName($id) { @@ -151,16 +153,12 @@ class CreatureList extends BaseType 'location' => json_encode($this->getSpawns(SPAWNINFO_ZONES), JSON_NUMERIC_CHECK), 'name' => $this->getField('name', true), 'tag' => $this->getField('subname', true), - 'type' => $this->curTpl['type'] + 'type' => $this->curTpl['type'], + 'react' => '['.$this->curTpl['A'].', '.$this->curTpl['H'].']' ); - if ($addInfoMask & NPCINFO_TAMEABLE) - { - // only first skin of first model ... we're omitting potentially 11 skins here .. but the lv accepts only one .. w/e + if ($addInfoMask & NPCINFO_TAMEABLE) // only first skin of first model ... we're omitting potentially 11 skins here .. but the lv accepts only one .. w/e $data[$this->id]['skin'] = $this->curTpl['textureString']; - - $data[$this->id]['react'] = '['.$this->curTpl['A'].', '.$this->curTpl['H'].']'; - } } } @@ -168,13 +166,10 @@ class CreatureList extends BaseType return $data; } - public function addGlobalsToJScript(&$refs) + public function addGlobalsToJScript(&$template, $addMask = 0) { - if (!isset($refs['gCreatures'])) - $refs['gCreatures'] = []; - while ($this->iterate()) - $refs['gCreatures'][$this->id] = ['name' => $this->getField('name', true)]; + $template->extendGlobalData(TYPE_NPC, [$this->id => ['name' => $this->getField('name', true)]]); } public function addRewardsToJScript(&$refs) { } diff --git a/includes/class.currency.php b/includes/class.currency.php index aa9b5ab0..9e2f7d55 100644 --- a/includes/class.currency.php +++ b/includes/class.currency.php @@ -5,8 +5,10 @@ if (!defined('AOWOW_REVISION')) class CurrencyList extends BaseType { - protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_currencies WHERE [cond] ORDER BY Id ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM ?_currencies WHERE [cond]'; + public static $type = TYPE_CURRENCY; + + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_currencies WHERE [cond] ORDER BY Id ASC'; + protected $matchQuery = 'SELECT COUNT(1) FROM ?_currencies WHERE [cond]'; public function getListviewData() { @@ -25,25 +27,17 @@ class CurrencyList extends BaseType return $data; } - public function addGlobalsToJscript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = 0) { - if (!isset($refs['gCurrencies'])) - $refs['gCurrencies'] = []; - - $data = []; - while ($this->iterate()) { - $refs['gCurrencies'][$this->id] = array( + $template->extendGlobalData(self::$type, [$this->id => array( 'name' => $this->getField('name', true), 'icon' => $this->curTpl['iconString'] - ); + )]); } - - return $data; } - public function addRewardsToJScript(&$ref) { } public function renderTooltip() { } } diff --git a/includes/class.faction.php b/includes/class.faction.php index a64d0de2..920e660a 100644 --- a/includes/class.faction.php +++ b/includes/class.faction.php @@ -6,6 +6,8 @@ if (!defined('AOWOW_REVISION')) class FactionList extends BaseType { + public static $type = TYPE_FACTION; + public static function getName($id) { $n = DB::Aowow()->SelectRow(' @@ -35,8 +37,7 @@ class FactionList extends BaseType } public function getListviewData() { } - public function addGlobalsToJScript(&$refs) { } - public function addRewardsToJScript(&$refs) { } + public function addGlobalsToJScript(&$template, $addMask = 0) { } public function renderTooltip() { } } diff --git a/includes/class.gameobject.php b/includes/class.gameobject.php index 05e50b12..cd1e2148 100644 --- a/includes/class.gameobject.php +++ b/includes/class.gameobject.php @@ -6,6 +6,8 @@ if (!defined('AOWOW_REVISION')) class GameObjectList extends BaseType { + public static $type = TYPE_OBJECT; + public static function getName($id) { $n = DB::Aowow()->SelectRow(' @@ -29,8 +31,7 @@ class GameObjectList extends BaseType } public function getListviewData() { } - public function addGlobalsToJScript(&$refs) { } - public function addRewardsToJScript(&$refs) { } + public function addGlobalsToJScript(&$template, $addMask = 0) { } public function renderTooltip() { } } diff --git a/includes/class.item.php b/includes/class.item.php index f285545f..7f9f210f 100644 --- a/includes/class.item.php +++ b/includes/class.item.php @@ -5,17 +5,19 @@ if (!defined('AOWOW_REVISION')) class ItemList extends BaseType { - public $tooltip = ''; - public $json = []; - public $itemMods = []; + public static $type = TYPE_ITEM; - public $rndEnchIds = []; - public $subItems = []; + public $tooltip = ''; + public $json = []; + public $itemMods = []; - private $ssd = []; + public $rndEnchIds = []; + public $subItems = []; - protected $setupQuery = 'SELECT *, i.entry AS ARRAY_KEY FROM item_template i LEFT JOIN ?_item_template_addon iX ON i.entry = iX.id LEFT JOIN locales_item l ON i.entry = l.entry WHERE [filter] [cond] ORDER BY i.Quality DESC'; - protected $matchQuery = 'SELECT COUNT(1) FROM item_template i LEFT JOIN ?_item_template_addon iX ON i.entry = iX.id LEFT JOIN locales_item l ON i.entry = l.entry WHERE [filter] [cond]'; + private $ssd = []; + + protected $setupQuery = 'SELECT *, i.entry AS ARRAY_KEY FROM item_template i LEFT JOIN ?_item_template_addon iX ON i.entry = iX.id LEFT JOIN locales_item l ON i.entry = l.entry WHERE [filter] [cond] ORDER BY i.Quality DESC'; + protected $matchQuery = 'SELECT COUNT(1) FROM item_template i LEFT JOIN ?_item_template_addon iX ON i.entry = iX.id LEFT JOIN locales_item l ON i.entry = l.entry WHERE [filter] [cond]'; public function __construct($conditions, $pieceToSet = null) { @@ -148,7 +150,7 @@ class ItemList extends BaseType {"source":[5],"sourcemore":[{"n":"Commander Oxheart","t":1,"ti":64606,"z":5842}], cost:[] format unk 0:copper, 1:[items]? 2, 3, 4, 5 - stack [unk, unk] + stack [min, max] // when looting avail unk rel unk glyph major | minor (as id) @@ -159,18 +161,15 @@ class ItemList extends BaseType return $data; } - public function addGlobalsToJscript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = 0) { - if (!isset($refs['gItems'])) - $refs['gItems'] = []; - while ($this->iterate()) { - $refs['gItems'][$this->id] = array( + $template->extendGlobalData(self::$type, [$this->id => array( 'name' => $this->getField('name', true), 'quality' => $this->curTpl['Quality'], - 'icon' => $this->curTpl['icon'], - ); + 'icon' => $this->curTpl['icon'] + )]); } } diff --git a/includes/class.itemset.php b/includes/class.itemset.php index 693b241e..694a9580 100644 --- a/includes/class.itemset.php +++ b/includes/class.itemset.php @@ -7,11 +7,13 @@ class ItemsetList extends BaseType { use ListviewHelper; - private $classes = []; // used to build g_classes - public $pieceToSet = []; // used to build g_items and search + public static $type = TYPE_ITEMSET; - protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_itemset WHERE [filter] [cond] ORDER BY maxlevel DESC'; - protected $matchQuery = 'SELECT COUNT(1) FROM ?_itemset WHERE [filter] [cond]'; + public $pieceToSet = []; // used to build g_items and search + private $classes = []; // used to build g_classes + + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_itemset WHERE [filter] [cond] ORDER BY maxlevel DESC'; + protected $matchQuery = 'SELECT COUNT(1) FROM ?_itemset WHERE [filter] [cond]'; public function __construct($data, $applyFilter = false) { @@ -71,16 +73,15 @@ class ItemsetList extends BaseType return $data; } - public function addGlobalsToJscript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = GLOBALINFO_ANY) { - if ($this->classes) - (new CharClassList(array(['id', $this->classes])))->addGlobalsToJscript($refs); + if ($this->classes && ($addMask & GLOBALINFO_RELATED)) + $template->extendGlobalIds(TYPE_CLASS, $this->classes); - if ($this->pieceToSet) - (new ItemList(array(['i.entry', array_keys($this->pieceToSet)], 0)))->addGlobalsToJscript($refs); + if ($this->pieceToSet && ($addMask & GLOBALINFO_SELF)) + $template->extendGlobalIds(TYPE_ITEM, array_keys($this->pieceToSet)); } - public function addRewardsToJScript(&$ref) { } public function renderTooltip() { } } diff --git a/includes/class.pet.php b/includes/class.pet.php index 71639f7b..674ab698 100644 --- a/includes/class.pet.php +++ b/includes/class.pet.php @@ -7,6 +7,8 @@ class PetList extends BaseType { use ListviewHelper; + public static $type = TYPE_PET; + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_pet WHERE [cond] ORDER BY Id ASC'; protected $matchQuery = 'SELECT COUNT(1) FROM ?_pet WHERE [cond]'; @@ -44,19 +46,20 @@ class PetList extends BaseType return $data; } - public function addGlobalsToJscript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = GLOBALINFO_ANY) { - $gathered = []; while ($this->iterate()) - for ($i = 1; $i <= 4; $i++) - if ($this->curTpl['spellId'.$i] > 0) - $gathered[] = (int)$this->curTpl['spellId'.$i]; + { + if ($addMask & GLOBALINFO_RELATED) + for ($i = 1; $i <= 4; $i++) + if ($this->curTpl['spellId'.$i] > 0) + $template->extendGlobalIds(TYPE_SPELL, $this->curTpl['spellId'.$i]); - if ($gathered) - (new SpellList(array(['s.id', $gathered])))->addGlobalsToJscript($refs); + if ($addMask & GLOBALINFO_SELF) + $template->extendGlobalData(self::$type, [$this->id => ['icon' => $this->curTpl['iconString']]]); + } } - public function addRewardsToJScript(&$ref) { } public function renderTooltip() { } } diff --git a/includes/class.quest.php b/includes/class.quest.php index fe20f9c8..284b722d 100644 --- a/includes/class.quest.php +++ b/includes/class.quest.php @@ -5,11 +5,13 @@ if (!defined('AOWOW_REVISION')) class QuestList extends BaseType { - public $cat1 = 0; - public $cat2 = 0; + public static $type = TYPE_QUEST; - protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM quest_template qt LEFT JOIN locales_quest lq ON qt.Id = lq.entry WHERE [filter] [cond] ORDER BY Id ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM quest_template WHERE [filter] [cond]'; + public $cat1 = 0; + public $cat2 = 0; + + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM quest_template qt LEFT JOIN locales_quest lq ON qt.Id = lq.entry WHERE [filter] [cond] ORDER BY Id ASC'; + protected $matchQuery = 'SELECT COUNT(1) FROM quest_template WHERE [filter] [cond]'; // parent::__construct does the job @@ -128,45 +130,6 @@ class QuestList extends BaseType return $data; } - public function addRewardsToJscript(&$refs) - { - $items = []; - $spells = []; - $titles = []; - - while ($this->iterate()) - { - // items - for ($i = 1; $i < 5; $i++) - if ($this->curTpl['RewardItemId'.$i] > 0) - $items[] = $this->curTpl['RewardItemId'.$i]; - - for ($i = 1; $i < 7; $i++) - if ($this->curTpl['RewardChoiceItemId'.$i] > 0) - $items[] = $this->curTpl['RewardChoiceItemId'.$i]; - - // spells - if ($this->curTpl['RewardSpell'] > 0) - $spells[] = $this->curTpl['RewardSpell']; - - if ($this->curTpl['RewardSpellCast'] > 0) - $spells[] = $this->curTpl['RewardSpellCast']; - - // titles - if ($this->curTpl['RewardTitleId'] > 0) - $titles[] = $this->curTpl['RewardTitleId']; - } - - if ($items) - (new ItemList(array(['i.entry', $items])))->addGlobalsToJscript($refs); - - if ($spells) - (new SpellList(array(['s.id', $spells])))->addGlobalsToJscript($refs); - - if ($titles) - (new TitleList(array(['id', $titles])))->addGlobalsToJscript($refs); - } - private function parseText($type = 'Objectives') { $replace = array( @@ -263,16 +226,35 @@ class QuestList extends BaseType return $x; } - public function addGlobalsToJScript(&$refs) + public function addGlobalsToJScript(&$template, $addMask = GLOBALINFO_ANY) { - if (!isset($refs['gQuests'])) - $refs['gQuests'] = []; - while ($this->iterate()) { - $refs['gQuests'][$this->id] = array( - 'name' => $this->getField('Title', true) - ); + if ($addMask & GLOBALINFO_REWARDS) + { + // items + for ($i = 1; $i < 5; $i++) + if ($this->curTpl['RewardItemId'.$i] > 0) + $template->extendGlobalIds(TYPE_ITEM, $this->curTpl['RewardItemId'.$i]); + + for ($i = 1; $i < 7; $i++) + if ($this->curTpl['RewardChoiceItemId'.$i] > 0) + $template->extendGlobalIds(TYPE_ITEM, $this->curTpl['RewardChoiceItemId'.$i]); + + // spells + if ($this->curTpl['RewardSpell'] > 0) + $template->extendGlobalIds(TYPE_SPELL, $this->curTpl['RewardSpell']); + + if ($this->curTpl['RewardSpellCast'] > 0) + $template->extendGlobalIds(TYPE_SPELL, $this->curTpl['RewardSpellCast']); + + // titles + if ($this->curTpl['RewardTitleId'] > 0) + $template->extendGlobalIds(TYPE_TITLE, $this->curTpl['RewardTitleId']); + } + + if ($addMask & GLOBALINFO_SELF) + $template->extendGlobalData(self::$type, [$this->id => ['name' => $this->getField('Title', true)]]); } } } diff --git a/includes/class.skill.php b/includes/class.skill.php index a22d3bda..330b079a 100644 --- a/includes/class.skill.php +++ b/includes/class.skill.php @@ -6,6 +6,8 @@ if (!defined('AOWOW_REVISION')) class SkillList extends BaseType { + public static $type = TYPE_SKILL; + public static function getName($id) { $n = DB::Aowow()->SelectRow(' @@ -25,8 +27,7 @@ class SkillList extends BaseType } public function getListviewData() { } - public function addGlobalsToJScript(&$refs) { } - public function addRewardsToJScript(&$refs) { } + public function addGlobalsToJScript(&$template, $addMask = 0) { } public function renderTooltip() { } } diff --git a/includes/class.spell.php b/includes/class.spell.php index 87f65019..c5664049 100644 --- a/includes/class.spell.php +++ b/includes/class.spell.php @@ -13,6 +13,7 @@ class SpellList extends BaseType public $relItems = null; public $sources = []; + public static $type = TYPE_SPELL; public static $skillLines = array( 6 => [43, 44, 45, 46, 54, 55, 95, 118, 136, 160, 162, 172, 173, 176, 226, 228, 229, 473], // Weapons 8 => [293, 413, 414, 415, 433], // Armor @@ -1625,49 +1626,41 @@ class SpellList extends BaseType return $result; } - public function addGlobalsToJScript(&$refs) + public function addGlobalsToJScript(&$template, $addMask = GLOBALINFO_ANY) { - if ($this->relItems) + if ($this->relItems && ($addMask & GLOBALINFO_RELATED)) { $this->relItems->reset(); - $this->relItems->addGlobalsToJscript($refs); + $this->relItems->addGlobalsToJscript($template); } - $classes = []; - $races = []; - - if (!isset($refs['gSpells'])) - $refs['gSpells'] = []; - while ($this->iterate()) { - if ($mask = $this->curTpl['reqClassMask']) - for ($i = 0; $i < 11; $i++) - if ($mask & (1 << $i)) - $classes[] = $i + 1; + if ($addMask & GLOBALINFO_RELATED) + { + if ($mask = $this->curTpl['reqClassMask']) + for ($i = 0; $i < 11; $i++) + if ($mask & (1 << $i)) + $template->extendGlobalIds(TYPE_CLASS, $i + 1); - if ($mask = $this->curTpl['reqRaceMask']) - for ($i = 0; $i < 11; $i++) - if ($mask & (1 << $i)) - $races[] = $i + 1; + if ($mask = $this->curTpl['reqRaceMask']) + for ($i = 0; $i < 11; $i++) + if ($mask & (1 << $i)) + $template->extendGlobalIds(TYPE_RACE, $i + 1); + } - $iconString = $this->curTpl['iconStringAlt'] ? 'iconStringAlt' : 'iconString'; + if ($addMask & GLOBALINFO_SELF) + { + $iconString = $this->curTpl['iconStringAlt'] ? 'iconStringAlt' : 'iconString'; - $refs['gSpells'][$this->id] = array( - 'icon' => $this->curTpl[$iconString], - 'name' => $this->getField('name', true), - ); + $template->extendGlobalData(self::$type, [$this->id => array( + 'icon' => $this->curTpl[$iconString], + 'name' => $this->getField('name', true), + )]); + } } - - if ($classes) - (new CharClassList(array(['id', $classes])))->addGlobalsToJScript($refs); - - if ($races) - (new CharRaceList(array(['id', $races])))->addGlobalsToJScript($refs); } - public function addRewardsToJScript(&$refs) { } - } ?> diff --git a/includes/class.title.php b/includes/class.title.php index b3be735e..6e43f11b 100644 --- a/includes/class.title.php +++ b/includes/class.title.php @@ -7,10 +7,12 @@ class TitleList extends BaseType { use listviewHelper; - public $sources = []; + public static $type = TYPE_TITLE; - protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_titles WHERE [cond] ORDER BY Id ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM ?_titles WHERE [cond]'; + public $sources = []; + + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_titles WHERE [cond] ORDER BY Id ASC'; + protected $matchQuery = 'SELECT COUNT(1) FROM ?_titles WHERE [cond]'; public function __construct($data) { @@ -59,18 +61,19 @@ class TitleList extends BaseType return $data; } - public function addGlobalsToJscript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = 0) { - if (!isset($refs['gTitles'])) - $refs['gTitles'] = []; + $data = []; while ($this->iterate()) { - $refs['gTitles'][$this->id]['name'] = Util::jsEscape($this->getField('male', true)); + $data[$this->id]['name'] = Util::jsEscape($this->getField('male', true)); if ($_ = $this->getField('female', true)) - $refs['gTitles'][$this->id]['namefemale'] = $_; + $data[$this->id]['namefemale'] = $_; } + + $template->extendGlobalData(self::$type, $data); } private function createSource() @@ -143,7 +146,6 @@ class TitleList extends BaseType return str_replace('%s', '<'.Lang::$main['name'].'>', $this->getField($field, true)); } - public function addRewardsToJScript(&$ref) { } public function renderTooltip() { } private function faction2Side(&$faction) // thats weird.. and hopefully unique to titles diff --git a/includes/class.worldevent.php b/includes/class.worldevent.php index 40e20cd3..9022e349 100644 --- a/includes/class.worldevent.php +++ b/includes/class.worldevent.php @@ -5,36 +5,10 @@ if (!defined('AOWOW_REVISION')) class WorldEventList extends BaseType { - private static $holidayIcons = [ - 141 => 'calendar_winterveilstart', - 327 => 'calendar_lunarfestivalstart', - 335 => 'calendar_loveintheairstart', - 423 => 'calendar_loveintheairstart', - 181 => 'calendar_noblegardenstart', - 201 => 'calendar_childrensweekstart', - 341 => 'calendar_midsummerstart', - 62 => 'inv_misc_missilelarge_red', - 321 => 'calendar_harvestfestivalstart', - 398 => 'calendar_piratesdaystart', - 372 => 'calendar_brewfeststart', - 324 => 'calendar_hallowsendstart', - 409 => 'calendar_dayofthedeadstart', - 404 => 'calendar_harvestfestivalstart', - 283 => 'inv_jewelry_necklace_21', - 284 => 'inv_misc_rune_07', - 400 => 'achievement_bg_winsoa', - 420 => 'achievement_bg_winwsg', - 285 => 'inv_jewelry_amulet_07', - 353 => 'spell_nature_eyeofthestorm', - 301 => 'calendar_fishingextravaganzastart', - 424 => 'calendar_fishingextravaganzastart', - 374 => 'calendar_darkmoonfaireelwynnstart', - 375 => 'calendar_darkmoonfairemulgorestart', - 376 => 'calendar_darkmoonfaireterokkarstart' - ]; + public static $type = TYPE_WORLDEVENT; - protected $setupQuery = 'SELECT *, -e.id AS ARRAY_KEY, -e.id as id FROM ?_events e LEFT JOIN ?_holidays h ON e.holidayId = h.id WHERE [cond] ORDER BY -e.id ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM ?_events e LEFT JOIN ?_holidays h ON e.holidayId = h.id WHERE [cond]'; + protected $setupQuery = 'SELECT *, -e.id AS ARRAY_KEY, -e.id as id FROM ?_events e LEFT JOIN ?_holidays h ON e.holidayId = h.id WHERE [cond] ORDER BY -e.id ASC'; + protected $matchQuery = 'SELECT COUNT(1) FROM ?_events e LEFT JOIN ?_holidays h ON e.holidayId = h.id WHERE [cond]'; public function __construct($data) { @@ -158,27 +132,17 @@ class WorldEventList extends BaseType return $data; } - public function setup() + public function addGlobalsToJScript(&$template, $addMask = 0) { - foreach (self::$holidayIcons as $id => $s) - DB::Aowow()->Query('UPDATE ?_holidays SET iconString = ?s WHERE id = ?', $s, $id); - } - - public function addGlobalsToJScript(&$refs) - { - if (!isset($refs['gHolidays'])) - $refs['gHolidays'] = []; - while ($this->iterate()) { - $refs['gHolidays'][$this->id] = array( + $template->extendGlobalData(self::$type, [$this->id => array( 'name' => $this->getField('name', true), 'icon' => $this->curTpl['iconString'] - ); + )]); } } - public function addRewardsToJScript(&$ref) { } public function renderTooltip() { } } diff --git a/includes/class.zone.php b/includes/class.zone.php index 362bf84a..ebbbd355 100644 --- a/includes/class.zone.php +++ b/includes/class.zone.php @@ -11,8 +11,10 @@ if (!defined('AOWOW_REVISION')) class ZoneList extends BaseType { - protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_zones z WHERE [cond] ORDER BY Id ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM ?_zones WHERE [cond]'; + public static $type = TYPE_ZONE; + + protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_zones z WHERE [cond] ORDER BY Id ASC'; + protected $matchQuery = 'SELECT COUNT(1) FROM ?_zones WHERE [cond]'; // public function __construct($data) // { @@ -148,16 +150,12 @@ visibleCols: ['heroiclevel', 'players'] return $data; } - public function addGlobalsToJscript(&$refs) + public function addGlobalsToJscript(&$template, $addMask = 0) { - if (!isset($refs['gZones'])) - $refs['gZones'] = []; - while ($this->iterate()) - $refs['gZones'][$this->id]['name'] = Util::jsEscape($this->getField('name', true)); + $template->extendGlobalData(self::$type, [$this->id => ['name' => Util::jsEscape($this->getField('name', true))]]); } - public function addRewardsToJScript(&$ref) { } public function renderTooltip() { } } diff --git a/includes/defines.php b/includes/defines.php index 69e595e5..f378f5a4 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -87,7 +87,12 @@ define('LOCALE_DE', 3); define('LOCALE_ES', 6); define('LOCALE_RU', 8); -// conditional information in listviews +// conditional information in template +define('GLOBALINFO_SELF', 0x1); // id, name, icon +define('GLOBALINFO_RELATED', 0x2); // spells used by pet, classes/races required by spell, ect +define('GLOBALINFO_REWARDS', 0x4); // items rewarded by achievement/quest, ect +define('GLOBALINFO_ANY', 0xF); + define('ITEMINFO_JSON', 0x1); define('ITEMINFO_SUBITEMS', 0x2); define('ITEMINFO_VENDOR', 0x4); diff --git a/includes/utilities.php b/includes/utilities.php index 3e1d559e..9816ecb1 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -249,11 +249,7 @@ abstract class BaseType abstract public function getListviewData(); // should return data to extend global js variables for a certain type (e.g. g_items) - abstract public function addGlobalsToJScript(&$ref); - - // should return data to extend global js variables for the rewards provided by this type (e.g. g_titles) - // rewards will not always be required and only by Achievement and Quest .. but yeah.. maybe it should be merged with addGlobalsToJScript - abstract public function addRewardsToJScript(&$ref); + abstract public function addGlobalsToJScript(&$smarty, $addMask = GLOBALINFO_ANY); // NPC, GO, Item, Quest, Spell, Achievement, Profile would require this abstract public function renderTooltip(); @@ -261,6 +257,33 @@ abstract class BaseType trait listviewHelper { + public function hasSetFields($fields) + { + if (!is_array($fields)) + return 0x0; + + $result = 0x0; + + $this->reset(); + + while ($this->iterate()) + { + foreach ($fields as $k => $str) + { + if ($this->getField($str)) + { + $result |= 1 << $k; + unset($fields[$k]); + } + } + + if (empty($fields)) // all set .. return early + return $result; + } + + return $result; + } + public function hasDiffFields($fields) { if (!is_array($fields)) @@ -603,33 +626,35 @@ class Lang class SmartyAoWoW extends Smarty { - private $config = []; + private $config = []; + private $jsGlobals = []; public function __construct($config) { $cwd = str_replace("\\", "/", getcwd()); $this->Smarty(); - $this->config = $config; - $this->template_dir = $cwd.'/template/'; - $this->compile_dir = $cwd.'/cache/template/'; - $this->config_dir = $cwd.'/configs/'; - $this->cache_dir = $cwd.'/cache/'; - $this->debugging = $config['debug']; - $this->left_delimiter = '{'; - $this->right_delimiter = '}'; - $this->caching = false; // Total Cache, this site does not work $this->assign('appName', $config['page']['name']); $this->assign('AOWOW_REVISION', AOWOW_REVISION); - $this->_tpl_vars['page'] = array( - 'reqJS' => [], // <[string]> path to required JSFile - 'reqCSS' => [], // <[string,string]> path to required CSSFile, IE condition - 'title' => null, // [string] page title - 'tab' => null, // [int] # of tab to highlight in the menu - 'type' => null, // [int] numCode for spell, npc, object, ect - 'typeId' => null, // [int] entry to display - 'path' => '[]' // [string] (js:array) path to preselect in the menu + $this->config = $config; + $this->template_dir = $cwd.'/template/'; + $this->compile_dir = $cwd.'/cache/template/'; + $this->config_dir = $cwd.'/configs/'; + $this->cache_dir = $cwd.'/cache/'; + $this->debugging = $config['debug']; + $this->left_delimiter = '{'; + $this->right_delimiter = '}'; + $this->caching = false; // Total Cache, this site does not work + $this->_tpl_vars['page'] = array( + 'reqJS' => [], // <[string]> path to required JSFile + 'reqCSS' => [], // <[string,string]> path to required CSSFile, IE condition + 'title' => null, // [string] page title + 'tab' => null, // [int] # of tab to highlight in the menu + 'type' => null, // [int] numCode for spell, npc, object, ect + 'typeId' => null, // [int] entry to display + 'path' => '[]' // [string] (js:array) path to preselect in the menu ); + $this->_tpl_vars['jsGlobals'] = []; } // using Smarty::assign would overwrite every pair and result in undefined indizes @@ -658,33 +683,10 @@ class SmartyAoWoW extends Smarty foreach ($globals as $glob) { - if (!isset($_[$glob['type']])) - $_[$glob['type']] = []; + if (!isset($this->jsGlobals[$glob['type']])) + $this->jsGlobals[$glob['type']] = []; - $_[$glob['type']][] = $glob['typeId']; - } - - foreach ($_ as $type => $ids) - { - switch ($type) - { - case TYPE_NPC: (new CreatureList(array(['ct.entry', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_OBJECT: (new GameobjectList(array(['gt.entry', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_ITEM: (new ItemList(array(['it.entry', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_ITEMSET: (new ItemsetList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_QUEST: (new QuestList(array(['qt.entry', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_SPELL: (new SpellList(array(['s.id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_ZONE: (new ZoneList(array(['z.id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_FACTION: (new FactionList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_PET: (new PetList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_ACHIEVEMENT: (new AchievementList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_TITLE: (new TitleList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_WORLDEVENT: (new WorldEventList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_CLASS: (new CharClassList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_RACE: (new CharRaceList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_SKILL: (new SkillList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - case TYPE_CURRENCY: (new CurrencyList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break; - } + $this->jsGlobals[$glob['type']][] = $glob['typeId']; } } } @@ -704,9 +706,103 @@ class SmartyAoWoW extends Smarty $this->_tpl_vars['announcements'] = $ann; } + $this->applyGlobals(); + + $this->_tpl_vars['mysql'] = DB::Aowow()->getStatistics(); + parent::display($tpl); } + public function extendGlobalIds($type, $data) + { + if (!$type || !$data) + return false; + + if (!isset($this->jsGlobals[$type])) + $this->jsGlobals[$type] = []; + + if (is_array($data)) + foreach ($data as $id) + $this->jsGlobals[$type][] = (int)$id; + else if (is_numeric($data)) + $this->jsGlobals[$type][] = (int)$data; + else + return false; + + return true; + } + + public function extendGlobalData($type, $data) + { + $this->initJSGlobal($type); + $_ = &$this->_tpl_vars['jsGlobals'][$type][1]; // shorthand + + foreach ($data as $id => $set) + if (!isset($_[$id])) + $_[$id] = $set; + } + + private function initJSGlobal($type) + { + $jsg = &$this->_tpl_vars['jsGlobals']; // shortcut + + if (isset($jsg[$type])) + return; + + switch ($type) + { // [brickFile, [data]] + case TYPE_NPC: $jsg[TYPE_NPC] = ['creatures', []]; break; + case TYPE_OBJECT: $jsg[TYPE_OBJECT] = ['objects', []]; break; + case TYPE_ITEM: $jsg[TYPE_ITEM] = ['items', []]; break; + case TYPE_QUEST: $jsg[TYPE_QUEST] = ['quests', []]; break; + case TYPE_SPELL: $jsg[TYPE_SPELL] = ['spells', []]; break; + case TYPE_ZONE: $jsg[TYPE_ZONE] = ['zones', []]; break; + case TYPE_FACTION: $jsg[TYPE_FACTION] = ['factions', []]; break; + case TYPE_PET: $jsg[TYPE_PET] = ['pets', []]; break; + case TYPE_ACHIEVEMENT: $jsg[TYPE_ACHIEVEMENT] = ['achievements', []]; break; + case TYPE_TITLE: $jsg[TYPE_TITLE] = ['titles', []]; break; + case TYPE_WORLDEVENT: $jsg[TYPE_WORLDEVENT] = ['holidays', []]; break; + case TYPE_CLASS: $jsg[TYPE_CLASS] = ['classes', []]; break; + case TYPE_RACE: $jsg[TYPE_RACE] = ['races', []]; break; + case TYPE_SKILL: $jsg[TYPE_SKILL] = ['skills', []]; break; + case TYPE_CURRENCY: $jsg[TYPE_CURRENCY] = ['curencies', []]; break; + } + } + + private function applyGlobals() + { + foreach ($this->jsGlobals as $type => $ids) + { + if (!$ids) + continue; + + $this->initJSGlobal($type); + + foreach ($ids as $k => $id) // filter already generated data, maybe we can save a lookup or two + if (isset($this->_tpl_vars['jsGlobals'][$type][$id])) + unset($ids[$k]); + + switch ($type) + { + case TYPE_NPC: (new CreatureList(array(['ct.entry', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_OBJECT: (new GameobjectList(array(['gt.entry', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_ITEM: (new ItemList(array(['i.entry', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_QUEST: (new QuestList(array(['qt.entry', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_SPELL: (new SpellList(array(['s.id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_ZONE: (new ZoneList(array(['z.id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_FACTION: (new FactionList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_PET: (new PetList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_ACHIEVEMENT: (new AchievementList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_TITLE: (new TitleList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_WORLDEVENT: (new WorldEventList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_CLASS: (new CharClassList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_RACE: (new CharRaceList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_SKILL: (new SkillList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + case TYPE_CURRENCY: (new CurrencyList(array(['id', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break; + } + } + } + public function notFound($subject) { $this->updatePageVars(array( @@ -716,6 +812,7 @@ class SmartyAoWoW extends Smarty )); $this->assign('lang', Lang::$main); + $this->assign('mysql', DB::Aowow()->getStatistics()); $this->display('404.tpl'); exit(); diff --git a/pages/achievement.php b/pages/achievement.php index d6689723..44c509d6 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -75,7 +75,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) array_unshift($pageData['title'], $acv->getField('name', true)); - $acv->addRewardsToJscript($pageData); + $acv->addGlobalsToJscript($smarty, GLOBALINFO_REWARDS); $pageData['page'] = $acv->getDetailedData()[$id]; $acv->reset(); @@ -110,8 +110,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) 'tabs' => '$tabsRelated' ); - $saList->addRewardsToJscript($pageData); - $saList->addGlobalsToJscript($pageData); + $saList->addGlobalsToJscript($smarty); // listview: "criteria of" $refs = DB::Aowow()->SelectCol('SELECT refAchievement FROM ?_achievementcriteria WHERE Type = ?d AND value1 = ?d', @@ -129,8 +128,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) 'tabs' => '$tabsRelated' ); - $coList->addRewardsToJscript($pageData); - $coList->addGlobalsToJscript($pageData); + $coList->addGlobalsToJscript($smarty); } // create rewards @@ -259,8 +257,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) 'type' => 'g_achievements', 'id' => $obj, ); - if ($crtAcv = new AchievementList(array(['id', $obj]))) - $crtAcv->addGlobalsToJscript($pageData); + $smarty->extendGlobalIds(TYPE_ACHIEVEMENT, $obj); break; // link to quest case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST: @@ -276,13 +273,12 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL: case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL: case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2: - $crtSpl = new SpellList(array(['s.id', $obj])); - $text = !empty($crtName) ? $crtName : $crtSpl->getField('name', true); + $text = !empty($crtName) ? $crtName : SpellList::getName($obj); $tmp['link'] = array( 'href' => '?spell='.$obj, 'text' => $text ); - $crtSpl->addGlobalsToJscript($pageData); + $smarty->extendGlobalIds(TYPE_SPELL, $obj); $tmp['icon'] = $iconId; $pageData['page']['icons'][] = array( 'itr' => $iconId++, @@ -303,7 +299,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) 'quality' => $crtItm->getField('Quality'), 'count' => $qty, ); - $crtItm->addGlobalsToJscript($pageData); + $crtItm->addGlobalsToJscript($smarty); $tmp['icon'] = $iconId; $pageData['page']['icons'][] = array( 'itr' => $iconId++, @@ -405,9 +401,6 @@ $smarty->assign('community', CommunityContent::getAll(TYPE_ACHIEVEMENT, $id)); $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$achievement)); $smarty->assign('lvData', $pageData); -// Mysql query execution statistics -$smarty->assign('mysql', DB::Aowow()->getStatistics()); - // load the page $smarty->display('achievement.tpl'); diff --git a/pages/achievements.php b/pages/achievements.php index 4bc6e4b6..928ab4e2 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -82,8 +82,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) ); // fill g_items, g_titles, g_achievements - $acvList->addGlobalsToJscript($pageData); - $acvList->addRewardsToJScript($pageData); + $acvList->addGlobalsToJscript($smarty); // if we are have different cats display field if ($acvList->hasDiffFields(['category'])) @@ -118,7 +117,6 @@ asort(Lang::$game['si']); $smarty->updatePageVars($page); $smarty->assign('filter', $filter); $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$achievement)); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('lvData', $pageData); $smarty->display('achievements.tpl'); diff --git a/pages/classes.php b/pages/classes.php index 19df622b..05751e26 100644 --- a/pages/classes.php +++ b/pages/classes.php @@ -28,7 +28,6 @@ $page = array( $smarty->updatePageVars($page); $smarty->assign('lang', Lang::$main); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('lvData', $pageData); $smarty->display('generic-no-filter.tpl'); diff --git a/pages/compare.php b/pages/compare.php index ee669427..c5eb8a80 100644 --- a/pages/compare.php +++ b/pages/compare.php @@ -70,7 +70,6 @@ $smarty->updatePageVars(array( )); $smarty->assign('lvData', $pageData); $smarty->assign('lang', array_merge(Lang::$main, Lang::$compare)); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('compare.tpl'); ?> diff --git a/pages/currencies.php b/pages/currencies.php index ece2673d..9f7fb5b1 100644 --- a/pages/currencies.php +++ b/pages/currencies.php @@ -29,7 +29,7 @@ if (!$smarty->loadCache($cacheKey, $pageData)) 'params' => [] ); - $money->addGlobalsToJscript($pageData); + $money->addGlobalsToJscript($smarty); $smarty->saveCache($cacheKey, $pageData); } @@ -43,7 +43,6 @@ $page = array( $smarty->updatePageVars($page); $smarty->assign('lang', Lang::$main); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('lvData', $pageData); $smarty->display('generic-no-filter.tpl'); diff --git a/pages/events.php b/pages/events.php index f440969f..20965971 100644 --- a/pages/events.php +++ b/pages/events.php @@ -57,7 +57,7 @@ if (!$smarty->loadCache($cacheKey, $pageData)) ) ); - $events->addGlobalsToJScript($pageData); + $events->addGlobalsToJScript($smarty); $smarty->saveCache($cacheKey, $pageData); } @@ -86,7 +86,6 @@ $page = array( $smarty->updatePageVars($page); $smarty->assign('lang', Lang::$main); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('lvData', $pageData); $smarty->display('generic-no-filter.tpl'); diff --git a/pages/item.php b/pages/item.php index 90f3cfea..36b458dd 100644 --- a/pages/item.php +++ b/pages/item.php @@ -824,9 +824,6 @@ $smarty->assign('community', CommunityContent::getAll(TYPE_ITEM, $id)); $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$item, ['colon' => Lang::$colon])); $smarty->assign('lvData', $pageData); -// Mysql query execution statistics -$smarty->assign('mysql', $DB->getStatistics()); - // load the page $smarty->display('item.tpl'); diff --git a/pages/itemset.php b/pages/itemset.php index 56a61098..94838b1f 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -181,7 +181,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - $iSet->addGlobalsToJscript($pageData); + $iSet->addGlobalsToJscript($smarty, GLOBALINFO_RELATED); // related sets (priority: 1: similar tag + class; 2: has event; 3: no tag + similar type, 4: similar type + profession) $rel = []; @@ -230,7 +230,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if (!$mask) $pageData['related']['params']['hiddenCols'] = "$['classes']"; - $relSets->addGlobalsToJscript($pageData); + $relSets->addGlobalsToJscript($smarty); } } @@ -253,7 +253,6 @@ $smarty->updatePageVars(array( $smarty->assign('community', CommunityContent::getAll(TYPE_ITEMSET, $id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main, Lang::$itemset)); $smarty->assign('lvData', $pageData); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('itemset.tpl'); ?> diff --git a/pages/itemsets.php b/pages/itemsets.php index 5601aec3..3f9a254a 100644 --- a/pages/itemsets.php +++ b/pages/itemsets.php @@ -20,7 +20,7 @@ if (!$smarty->loadCache($cacheKey, $pageData)) 'params' => [] ); - $itemsets->addGlobalsToJscript($pageData); + $itemsets->addGlobalsToJscript($smarty); // recreate form selection $filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL; @@ -62,7 +62,6 @@ asort(Lang::$game['cl']); $smarty->updatePageVars($page); $smarty->assign('filter', $filter); $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$itemset, Lang::$item)); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('lvData', $pageData); $smarty->display('itemsets.tpl'); diff --git a/pages/maps.php b/pages/maps.php index 23eb7e1d..dc65bc28 100644 --- a/pages/maps.php +++ b/pages/maps.php @@ -22,7 +22,6 @@ $page = array( $smarty->updatePageVars($page); $smarty->assign('lang', array_merge(Lang::$main, Lang::$maps)); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('maps.tpl'); ?> diff --git a/pages/npc.php b/pages/npc.php index 473b6069..a9c8c6f3 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -482,9 +482,6 @@ $smarty->assign('community', CommunityContent::getAll(TYPE_NPC, $id)); / $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$npc, ['colon' => Lang::$colon])); $smarty->assign('lvData', $pageData); -// Mysql query execution statistics -$smarty->assign('mysql', $DB->getStatistics()); - // load the page $smarty->display('npc.tpl'); diff --git a/pages/pet.php b/pages/pet.php index 06aa344e..1f9a188c 100644 --- a/pages/pet.php +++ b/pages/pet.php @@ -18,7 +18,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($pet->error) $smarty->notFound(Lang::$game['pet']); - $pet->addGlobalsToJscript($pageData); + // $pet->addGlobalsToJscript($smarty); $pet->reset(); $infobox = []; @@ -83,7 +83,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $list[] = $i; $food = new ItemList(array(['i.subClass', [5, 8]], ['i.FoodType', $list])); - $food->addGlobalsToJscript($pageData); + $food->addGlobalsToJscript($smarty); $pageData['diet'] = array( 'data' => $food->getListviewData(), @@ -126,7 +126,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $spells = new SpellList($conditions); - $spells->addGlobalsToJscript($pageData); + $spells->addGlobalsToJscript($smarty, GLOBALINFO_SELF); $pageData['abilities'] = array( 'data' => $spells->getListviewData(), @@ -148,7 +148,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) } $talents = new SpellList($conditions); - $talents->addGlobalsToJscript($pageData); + $talents->addGlobalsToJscript($smarty, GLOBALINFO_SELF); $pageData['talents'] = array( 'data' => $talents->getListviewData(), @@ -180,7 +180,6 @@ $smarty->updatePageVars(array( $smarty->assign('community', CommunityContent::getAll(TYPE_PET, $id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main, Lang::$game)); $smarty->assign('lvData', $pageData); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('pet.tpl'); ?> diff --git a/pages/pets.php b/pages/pets.php index 34f386d8..5f9a5587 100644 --- a/pages/pets.php +++ b/pages/pets.php @@ -34,7 +34,7 @@ if (!$smarty->loadCache($cacheKey, $pageData)) $pageData['params']['hiddenCols'] = "$['type']"; $pets->reset(); - $pets->addGlobalsToJscript($pageData); + $pets->addGlobalsToJscript($smarty, GLOBALINFO_RELATED); $smarty->saveCache($cacheKey, $pageData); } @@ -49,7 +49,6 @@ $page = array( $smarty->updatePageVars($page); $smarty->assign('lang', Lang::$main); $smarty->assign('lvData', $pageData); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('generic-no-filter.tpl'); ?> diff --git a/pages/quest.php b/pages/quest.php index 89ee60c8..c8fcac71 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -613,9 +613,6 @@ $smarty->assign('community', CommunityContent::getAll(TYPE_QUEST, $id)); $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$quest, ['colon' => Lang::$colon])); $smarty->assign('lvData', $pageData); -// Mysql query execution statistics -$smarty->assign('mysql', $DB->getStatistics()); - // load the page $smarty->display('quest.tpl'); diff --git a/pages/races.php b/pages/races.php index 0da32a21..f6e34b3e 100644 --- a/pages/races.php +++ b/pages/races.php @@ -28,7 +28,6 @@ $page = array( $smarty->updatePageVars($page); $smarty->assign('lang', Lang::$main); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('lvData', $pageData); $smarty->display('generic-no-filter.tpl'); diff --git a/pages/spell.php b/pages/spell.php index 334021c3..a9b1619d 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -187,7 +187,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $pageData['title'] = [$spell->getField('name', true), Util::ucFirst(Lang::$game['spell'])]; // js-globals - $spell->addGlobalsToJScript($pageData); + $spell->addGlobalsToJScript($smarty, GLOBALINFO_RELATED); // prepare Tools foreach ($pageData['page']['tools'] as $k => $tool) @@ -273,7 +273,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) 'count' => 0 ); - $trig->addGlobalsToJScript($pageData); + $trig->addGlobalsToJScript($smarty); } // Effect Name @@ -604,8 +604,8 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ] ); - $modSpells->addGlobalsToJScript($pageData); - if(!$modSpells->hasDiffFields(['skillLines'])) + $modSpells->addGlobalsToJScript($smarty); + if(!$modSpells->hasSetFields(['skillLines'])) $pageData['modifies']['params']['hiddenCols'] = "$['skill']"; } } @@ -653,8 +653,8 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ] ); - $modsSpell->addGlobalsToJScript($pageData); - if(!$modsSpell->hasDiffFields(['skillLines'])) + $modsSpell->addGlobalsToJScript($smarty); + if(!$modsSpell->hasSetFields(['skillLines'])) $pageData['modifiedBy']['params']['hiddenCols'] = "$['skill']"; } } @@ -682,8 +682,8 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ] ); - $saSpells->addGlobalsToJScript($pageData); - if(!$saSpells->hasDiffFields(['skillLines'])) + $saSpells->addGlobalsToJScript($smarty); + if(!$saSpells->hasSetFields(['skillLines'])) $pageData['seeAlso']['params']['hiddenCols'] = "$['skill']"; } @@ -706,7 +706,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ] ); - $ubSets->addGlobalsToJScript($pageData); + $ubSets->addGlobalsToJScript($smarty); } @@ -732,11 +732,11 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ] ); - $ubItems->addGlobalsToJScript($pageData); + $ubItems->addGlobalsToJScript($smarty); } // criteria of - $_ = [ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL]; + $_ = [ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL]; if ($crs = DB::Aowow()->selectCol('SELECT refAchievement FROM ?_achievementCriteria WHERE type IN (?a) AND value1 = ?d', $_, $spell->id)) { $coAchievemnts = new AchievementList(array(['id', $crs])); @@ -751,7 +751,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ] ); - $coAchievemnts->addGlobalsToJScript($pageData); + $coAchievemnts->addGlobalsToJScript($smarty); } } @@ -771,7 +771,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) { // todo (high): generic loot-processing function $slItems = new ItemList(array(['i.entry', $ids])); - $slItems->addGlobalsToJscript($pageData); + $slItems->addGlobalsToJscript($smarty); $lv += $slItems->getListviewData(); $equal = true; @@ -803,11 +803,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) { if (($bar = $spell->getField('effect'.$i.'CreateItemId')) && isset($foo[$bar])) { - $reqSpec = new SpellList(array(['s.id', (int)$extraItem['requiredSpecialization']])); $lv[$bar] = $foo[$bar]; $lv[$bar]['percent'] = $extraItem['additionalCreateChance']; - $lv[$bar]['condition'] = json_encode(['type' => TYPE_SPELL, 'typeId' => $reqSpec->id, 'status' => 2], JSON_NUMERIC_CHECK); - $reqSpec->addGlobalsToJscript($pageData); + $lv[$bar]['condition'] = json_encode(['type' => TYPE_SPELL, 'typeId' => $extraItem['requiredSpecialization'], 'status' => 2], JSON_NUMERIC_CHECK); + $smarty->extendGlobalIds(TYPE_SPELL, $extraItem['requiredSpecialization']); $extraCols[] = 'Listview.extraCols.condition'; if ($max = $extraItem['additionalMaxNum']) @@ -939,9 +938,6 @@ $smarty->assign('community', CommunityContent::getAll(TYPE_SPELL, $id)); $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$spell, ['colon' => Lang::$colon])); $smarty->assign('lvData', $pageData); -// Mysql query execution statistics -$smarty->assign('mysql', DB::Aowow()->getStatistics()); - // load the page $smarty->display('spell.tpl'); diff --git a/pages/spells.php b/pages/spells.php index b94017a8..3cc16252 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -381,7 +381,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $pageData['data'] = $spells->getListviewData(); - $spells->addGlobalsToJscript($pageData); + $spells->addGlobalsToJscript($smarty, GLOBALINFO_SELF); // create note if search limit was exceeded; overwriting 'note' is intentional if ($spells->getMatches() > $AoWoWconf['sqlLimit']) @@ -393,7 +393,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) if ($spells->filterGetError()) $pageData['params']['_errors'] = '$1'; - $mask = $spells->hasDiffFields(['reagent1', 'skillLines', 'trainingCost']); + $mask = $spells->hasSetFields(['reagent1', 'skillLines', 'trainingCost']); if ($mask & 0x1) $visibleCols[] = 'reagents'; @@ -444,7 +444,6 @@ Lang::$game['race'] = Util::ucFirst(Lang::$game['race']); $smarty->updatePageVars($page); $smarty->assign('filter', $filter); $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$achievement)); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('lvData', $pageData); $smarty->display('spells.tpl'); diff --git a/pages/talent.php b/pages/talent.php index 5ad78fd6..cdee2c15 100644 --- a/pages/talent.php +++ b/pages/talent.php @@ -35,7 +35,6 @@ if ($petCalc) $smarty->updatePageVars($page); $smarty->assign('tcType', $petCalc ? 'pc' : 'tc'); $smarty->assign('lang', array_merge(Lang::$main, Lang::$talent)); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('talent.tpl'); ?> diff --git a/pages/title.php b/pages/title.php index 3477cc06..1704687b 100644 --- a/pages/title.php +++ b/pages/title.php @@ -16,11 +16,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($title->error) $smarty->notFound(Lang::$game['title']); - $title->addGlobalsToJscript($pageData); - $title->reset(); - $infobox = []; - if ($title->getField('side') == SIDE_ALLIANCE) $infobox[] = Lang::$main['side'].Lang::$colon.'[span class=alliance-icon]'.Lang::$game['si'][SIDE_ALLIANCE].'[/span]'; else if ($title->getField('side') == SIDE_HORDE) @@ -51,7 +47,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) { case 4: $quests = new QuestList(array(['id', $entries])); - $quests->addRewardsToJscript($pageData); + $quests->addGlobalsToJscript($smarty, GLOBALINFO_REWARDS); $pageData['page']['questReward'] = $quests->getListviewData(); $pageData['page']['questParams'] = array( @@ -64,8 +60,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) break; case 12: $acvs = new AchievementList(array(['id', $entries])); - $acvs->addGlobalsToJscript($pageData); - $acvs->addRewardsToJscript($pageData); + $acvs->addGlobalsToJscript($smarty); $pageData['page']['acvReward'] = $acvs->getListviewData(); $pageData['page']['acvParams'] = array( @@ -100,7 +95,6 @@ $smarty->updatePageVars(array( $smarty->assign('community', CommunityContent::getAll(TYPE_TITLE, $id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main)); $smarty->assign('lvData', $pageData); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('title.tpl'); ?> diff --git a/pages/titles.php b/pages/titles.php index b6c18902..b90c846a 100644 --- a/pages/titles.php +++ b/pages/titles.php @@ -47,7 +47,6 @@ $page = array( $smarty->updatePageVars($page); $smarty->assign('lang', Lang::$main); $smarty->assign('lvData', $pageData); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('generic-no-filter.tpl'); ?> diff --git a/pages/zones.php b/pages/zones.php index c68ff87f..22dd3570 100644 --- a/pages/zones.php +++ b/pages/zones.php @@ -138,7 +138,6 @@ $page = array( $smarty->updatePageVars($page); $smarty->assign('lang', Lang::$main); -$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('lvData', $pageData); $smarty->display('generic-no-filter.tpl'); diff --git a/search.php b/search.php index b6d72b58..6a1bb269 100644 --- a/search.php +++ b/search.php @@ -87,7 +87,6 @@ if (strlen($query) < 3 || !($searchMask & SEARCH_MASK_ALL)) // insufficient queries throw an error $smarty->assign('lang', array_merge(Lang::$main, Lang::$search)); $smarty->assign('found', []); - $smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('search', $query); $smarty->display('search.tpl'); @@ -124,6 +123,7 @@ if ($searchMask & 0x1) 'type' => TYPE_CLASS, 'appendix' => ' (Class)', 'matches' => $classes->getMatches(), + 'file' => 'class', 'data' => $data, 'params' => ['tabs' => '$myTabs'] ); @@ -156,6 +156,7 @@ if ($searchMask & 0x2) 'type' => TYPE_RACE, 'appendix' => ' (Race)', 'matches' => $races->getMatches(), + 'file' => 'race', 'data' => $data, 'params' => ['tabs' => '$myTabs'] ); @@ -200,6 +201,7 @@ if ($searchMask & 0x4) 'type' => TYPE_TITLE, 'appendix' => ' (Title)', 'matches' => $titles->getMatches(), + 'file' => 'title', 'data' => $data, 'params' => ['tabs' => '$myTabs'] ); @@ -230,7 +232,7 @@ if ($searchMask & 0x8) if ($data = $wEvents->getListviewData()) { - $wEvents->addGlobalsToJscript($jsGlobals); + $wEvents->addGlobalsToJscript($smarty); foreach ($data as &$d) { @@ -243,6 +245,7 @@ if ($searchMask & 0x8) 'type' => TYPE_WORLDEVENT, 'appendix' => ' (World Event)', 'matches' => $wEvents->getMatches(), + 'file' => 'event', 'data' => $data, 'params' => ['tabs' => '$myTabs'] ); @@ -269,6 +272,7 @@ if ($searchMask & 0x10) 'type' => TYPE_CURRENCY, 'appendix' => ' (Currency)', 'matches' => $money->getMatches(), + 'file' => 'currency', 'data' => $data, 'params' => ['tabs' => '$myTabs'] ); @@ -294,7 +298,7 @@ if ($searchMask & 0x20) if ($data = $sets->getListviewData()) { - $sets->addGlobalsToJscript($jsGlobals); + $sets->addGlobalsToJscript($smarty, GLOBALINFO_SELF); while ($sets->iterate()) $data[$sets->id]['param1'] = $sets->getField('quality'); @@ -303,6 +307,7 @@ if ($searchMask & 0x20) 'type' => TYPE_ITEMSET, 'appendix' => ' (Item Set)', 'matches' => $sets->getMatches(), + 'file' => 'itemset', 'data' => $data, 'params' => ['tabs' => '$myTabs'], 'pcsToSet' => $sets->pieceToSet @@ -330,7 +335,7 @@ if ($searchMask & 0x40) if ($data = $items->getListviewData($searchMask & SEARCH_TYPE_JSON ? (ITEMINFO_SUBITEMS | ITEMINFO_JSON) : 0)) { - $items->addGlobalsToJscript($jsGlobals); + $items->addGlobalsToJscript($smarty); while ($items->iterate()) { @@ -345,8 +350,9 @@ if ($searchMask & 0x40) 'type' => TYPE_ITEM, 'appendix' => ' (Item)', 'matches' => $items->getMatches(), - 'params' => ['tabs' => '$myTabs'], + 'file' => 'item', 'data' => $data, + 'params' => ['tabs' => '$myTabs'] ); if ($items->getMatches() > $maxResults) @@ -372,11 +378,10 @@ if ($searchMask & 0x80) if ($data = $abilities->getListviewData()) { - $abilities->addGlobalsToJscript($jsGlobals); + $abilities->addGlobalsToJscript($smarty); $vis = ['level', 'singleclass', 'schools']; - - if ($abilities->hasDiffFields(['reagent1'])) + if ($abilities->hasSetFields(['reagent1'])) $vis[] = 'reagents'; while ($abilities->iterate()) @@ -389,6 +394,7 @@ if ($searchMask & 0x80) 'type' => TYPE_SPELL, 'appendix' => ' (Ability)', 'matches' => $abilities->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'id' => 'abilities', @@ -419,7 +425,11 @@ if ($searchMask & 0x100) if ($data = $talents->getListviewData()) { - $talents->addGlobalsToJscript($jsGlobals); + $talents->addGlobalsToJscript($smarty); + + $vis = ['level', 'singleclass', 'schools']; + if ($abilities->hasSetFields(['reagent1'])) + $vis[] = 'reagents'; while ($talents->iterate()) { @@ -431,12 +441,13 @@ if ($searchMask & 0x100) 'type' => TYPE_SPELL, 'appendix' => ' (Talent)', 'matches' => $talents->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'id' => 'talents', 'tabs' => '$myTabs', 'name' => '$LANG.tab_talents', - 'visibleCols' => "$['level', 'singleclass', 'schools']" + 'visibleCols' => '$'.json_encode($vis) ] ); @@ -461,7 +472,7 @@ if ($searchMask & 0x200) if ($data = $glyphs->getListviewData()) { - $glyphs->addGlobalsToJscript($jsGlobals); + $glyphs->addGlobalsToJscript($smarty, GLOBALINFO_SELF); while ($glyphs->iterate()) $data[$glyphs->id]['param1'] = '"'.strToLower($glyphs->getField('iconString')).'"'; @@ -470,6 +481,7 @@ if ($searchMask & 0x200) 'type' => TYPE_SPELL, 'appendix' => ' (Glyph)', 'matches' => $glyphs->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'id' => 'glyphs', @@ -500,7 +512,7 @@ if ($searchMask & 0x400) if ($data = $prof->getListviewData()) { - $prof->addGlobalsToJscript($jsGlobals); + $prof->addGlobalsToJscript($smarty, GLOBALINFO_SELF); while ($prof->iterate()) $data[$prof->id]['param1'] = '"'.strToLower($prof->getField('iconString')).'"'; @@ -509,6 +521,7 @@ if ($searchMask & 0x400) 'type' => TYPE_SPELL, 'appendix' => ' (Proficiency)', 'matches' => $prof->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'id' => 'proficiencies', @@ -539,7 +552,7 @@ if ($searchMask & 0x800) if ($data = $prof->getListviewData()) { - $prof->addGlobalsToJscript($jsGlobals); + $prof->addGlobalsToJscript($smarty); while ($prof->iterate()) $data[$prof->id]['param1'] = '"'.strToLower($prof->getField('iconString')).'"'; @@ -548,6 +561,7 @@ if ($searchMask & 0x800) 'type' => TYPE_SPELL, 'appendix' => ' (Profession)', 'matches' => $prof->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'id' => 'professions', @@ -579,7 +593,7 @@ if ($searchMask & 0x1000) if ($data = $vPets->getListviewData()) { - $vPets->addGlobalsToJscript($jsGlobals); + $vPets->addGlobalsToJscript($smarty); while ($vPets->iterate()) $data[$vPets->id]['param1'] = '"'.strToLower($vPets->getField('iconString')).'"'; @@ -588,6 +602,7 @@ if ($searchMask & 0x1000) 'type' => TYPE_SPELL, 'appendix' => ' (Companion)', 'matches' => $vPets->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'id' => 'companions', @@ -618,7 +633,7 @@ if ($searchMask & 0x2000) if ($data = $mounts->getListviewData()) { - $mounts->addGlobalsToJscript($jsGlobals); + $mounts->addGlobalsToJscript($smarty, GLOBALINFO_SELF); while ($mounts->iterate()) $data[$mounts->id]['param1'] = '"'.strToLower($mounts->getField('iconString')).'"'; @@ -627,6 +642,7 @@ if ($searchMask & 0x2000) 'type' => TYPE_SPELL, 'appendix' => ' (Mount)', 'matches' => $mounts->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'id' => 'mounts', @@ -644,7 +660,42 @@ if ($searchMask & 0x2000) } // 15 NPCs -// if ($searchMask & 0x4000) +if ($searchMask & 0x4000) +{ + $conditions = array( + [ + 'OR', + ['name_loc'.User::$localeId, $query], + ['subname_loc'.User::$localeId, $query] + ], + // [['cuFlags', MASKE, '&'], 0], // todo (med): exclude trigger creatures and difficulty entries + $maxResults + ); + + $npcs = new CreatureList($conditions); + + if ($data = $npcs->getListviewData()) + { + $found['npc'] = array( + 'type' => TYPE_NPC, + 'appendix' => ' (NPC)', + 'matches' => $npcs->getMatches(), + 'file' => 'creature', + 'data' => $data, + 'params' => [ + 'id' => 'npcs', + 'tabs' => '$myTabs', + 'name' => '$LANG.tab_npcs', + ] + ); + + if ($npcs->getMatches() > $maxResults) + { + $found['npc']['params']['note'] = '$'.sprintf(Util::$narrowResultString, 'LANG.lvnote_npcsfound', $npcs->getMatches(), $maxResults); + $found['npc']['params']['_truncated'] = 1; + } + } +} // 16 Quests // if ($searchMask & 0x8000) @@ -662,8 +713,7 @@ if ($searchMask & 0x10000) if ($data = $acvs->getListviewData()) { - $acvs->addGlobalsToJScript($jsGlobals); - $acvs->addRewardsToJScript($jsGlobals); + $acvs->addGlobalsToJScript($smarty); while ($acvs->iterate()) $data[$acvs->id]['param1'] = '"'.strToLower($acvs->getField('iconString')).'"'; @@ -672,6 +722,7 @@ if ($searchMask & 0x10000) 'type' => TYPE_ACHIEVEMENT, 'appendix' => ' (Achievement)', 'matches' => $acvs->getMatches(), + 'file' => 'achievement', 'data' => $data, 'params' => [ 'tabs' => '$myTabs', @@ -700,12 +751,12 @@ if ($searchMask & 0x20000) if ($data = $stats->getListviewData()) { - $stats->addGlobalsToJScript($jsGlobals); - $stats->addRewardsToJScript($jsGlobals); + $stats->addGlobalsToJScript($smarty, GLOBALINFO_SELF); $found['statistic'] = array( 'type' => TYPE_ACHIEVEMENT, 'matches' => $stats->getMatches(), + 'file' => 'achievement', 'data' => $data, 'params' => [ 'tabs' => '$myTabs', @@ -743,8 +794,6 @@ if ($searchMask & 0x400000) if ($data = $pets->getListviewData()) { - $pets->addGlobalsToJScript($jsGlobals); - while ($pets->iterate()) $data[$pets->id]['param1'] = '"'.$pets->getField('iconString').'"'; @@ -752,6 +801,7 @@ if ($searchMask & 0x400000) 'type' => TYPE_PET, 'appendix' => ' (Pet)', 'matches' => $pets->getMatches(), + 'file' => 'pet', 'data' => $data, 'params' => [ 'tabs' => '$myTabs', @@ -779,7 +829,7 @@ if ($searchMask & 0x800000) if ($data = $npcAbilities->getListviewData()) { - $npcAbilities->addGlobalsToJscript($jsGlobals); + $npcAbilities->addGlobalsToJscript($smarty, GLOBALINFO_SELF); while ($npcAbilities->iterate()) $data[$npcAbilities->id]['param1'] = '"'.strToLower($npcAbilities->getField('iconString')).'"'; @@ -788,6 +838,7 @@ if ($searchMask & 0x800000) 'type' => TYPE_SPELL, 'appendix' => ' (Spell)', 'matches' => $npcAbilities->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'id' => 'npc-abilities', @@ -819,7 +870,7 @@ if ($searchMask & 0x1000000) if ($data = $misc->getListviewData()) { - $misc->addGlobalsToJscript($jsGlobals); + $misc->addGlobalsToJscript($smarty, GLOBALINFO_SELF); while ($misc->iterate()) $data[$misc->id]['param1'] = '"'.strToLower($misc->getField('iconString')).'"'; @@ -828,6 +879,7 @@ if ($searchMask & 0x1000000) 'type' => TYPE_SPELL, 'appendix' => ' (Spell)', 'matches' => $misc->getMatches(), + 'file' => 'spell', 'data' => $data, 'params' => [ 'tabs' => '$myTabs', @@ -979,7 +1031,6 @@ else /* if ($searchMask & SEARCH_TYPE_REGULAR) */ $smarty->assign('found', $found); $smarty->assign('lvData', $jsGlobals); $smarty->assign('search', $search); - $smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->display('search.tpl'); } diff --git a/template/bricks/listviews/creature.tpl b/template/bricks/listviews/creature.tpl index f620a7db..ecbaa36a 100644 --- a/template/bricks/listviews/creature.tpl +++ b/template/bricks/listviews/creature.tpl @@ -27,7 +27,7 @@ {/if} react:{$curr.react}, location:{$curr.location}, - {if $curr.skin} + {if isset($curr.skin)} skin: '{$curr.skin}', {/if} {if isset($curr.percent)} diff --git a/template/header.tpl b/template/header.tpl index 9cd4c9e7..1dc6a3a1 100644 --- a/template/header.tpl +++ b/template/header.tpl @@ -31,15 +31,7 @@ {strip}{/strip} diff --git a/template/search.tpl b/template/search.tpl index 64d7f578..51203a99 100644 --- a/template/search.tpl +++ b/template/search.tpl @@ -17,32 +17,9 @@
{else}