From 1ced59c1131e2361eff5bb18f40193ea873272f7 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 19 Mar 2014 22:06:04 +0100 Subject: [PATCH] - decoupled filter from type-classes, this is required for items.php to be groupable - force profile.lastupdated to new Date; trial and aerror on raid-progress; remove 'profile=summary' from generated pages (is generated by jscript) - fixed some misc errors --- includes/kernel.php | 2 + includes/types/achievement.class.php | 4 +- includes/types/basetype.class.php | 122 +++++++++++++++------------ includes/types/gameobject.class.php | 4 +- includes/types/item.class.php | 107 +++++++++++------------ includes/types/itemset.class.php | 4 +- includes/types/quest.class.php | 33 +++++++- includes/types/spell.class.php | 4 +- pages/achievements.php | 16 ++-- pages/items.php | 34 +++++--- pages/itemsets.php | 10 ++- pages/miscTools.php | 2 +- pages/npcs.php | 12 ++- pages/objects.php | 11 ++- pages/profile.php | 32 +++---- pages/spells.php | 12 ++- search.php | 13 ++- static/css/Profiler.css | 1 + static/css/global.css | 4 +- static/js/Profiler.js | 2 +- template/items.tpl | 2 +- template/spell.tpl | 2 +- 22 files changed, 257 insertions(+), 176 deletions(-) diff --git a/includes/kernel.php b/includes/kernel.php index bad68dd0..5385865e 100644 --- a/includes/kernel.php +++ b/includes/kernel.php @@ -17,6 +17,8 @@ require 'includes/database.class.php'; // autoload List-Classes and Associated Filters spl_autoload_register(function ($class) { + $class = str_replace('Filter', '', $class); + if (strpos($class, 'List') && !class_exists($class)) { if (!class_exists('BaseType')) diff --git a/includes/types/achievement.class.php b/includes/types/achievement.class.php index 068f2ee7..67344484 100644 --- a/includes/types/achievement.class.php +++ b/includes/types/achievement.class.php @@ -24,9 +24,9 @@ class AchievementList extends BaseType todo: evaluate TC custom-data-tables: a*_criteria_data should be merged on installation, a*_reward linked with mail_loot_template and achievement */ - public function __construct($conditions = [], $applyFilter = false) + public function __construct($conditions = []) { - parent::__construct($conditions, $applyFilter); + parent::__construct($conditions); // post processing foreach ($this->iterate() as &$_curTpl) diff --git a/includes/types/basetype.class.php b/includes/types/basetype.class.php index 17c020c7..1af2f1f3 100644 --- a/includes/types/basetype.class.php +++ b/includes/types/basetype.class.php @@ -11,7 +11,6 @@ abstract class BaseType protected $templates = []; protected $curTpl = []; // lets iterate! - protected $filter = null; protected $matches = null; // total matches unaffected by sqlLimit in config protected $queryBase = ''; @@ -50,7 +49,7 @@ abstract class BaseType * results in * WHERE ((`id` = 45) OR (`name` NOT LIKE "%test%") OR ((`flags` & 255) AND (`flags2` & 15)) OR ((`mask` & 3) = 0)) OR (`joinedTbl`.`field` IS NULL) LIMIT 5 */ - public function __construct($conditions = [], $applyFilter = false) + public function __construct($conditions = []) { $where = []; $linking = ' AND '; @@ -60,23 +59,12 @@ abstract class BaseType if (!$this->queryBase || $conditions === null) return; - // may be called without filtering - if ($applyFilter && class_exists($className.'Filter')) - { - $fiName = $className.'Filter'; - $this->filter = new $fiName($this); - } - $prefixes = []; if (preg_match('/FROM \??[\w\_]+( AS)?\s?`?(\w+)`?$/i', $this->queryBase, $match)) $prefixes['base'] = $match[2]; else $prefixes['base'] = ''; - // add conditions from filter - // to consider - conditions from filters are already escaped and contain sql-wildcards reescaping those sucks - $conditions[] = $this->filter ? $this->filter->getConditions() : null; - $resolveCondition = function ($c, $supLink) use (&$resolveCondition, &$prefixes) { $subLink = ''; @@ -344,47 +332,46 @@ abstract class BaseType return $this->matches; } - public function filterGetForm($key = null, $raw = false) + protected function extendQueryOpts($extra) // needs to be called from __construct { - $form = []; - - if (!$this->filter) - return $form; - - foreach ($this->filter->getForm() as $name => $data) + foreach ($extra as $tbl => $sets) { - if (!$data || ($key && $name != $key)) + if (!isset($this->queryOpts[$tbl])) // allow adding only to known tables continue; - switch ($name) + foreach ($sets as $module => $value) { - case 'setCriteria': - $form[$name] = $raw ? $data : 'fi_setCriteria('.$data['cr'].', '.$data['crs'].', '.$data['crv'].');'; - break; - case 'extraCols': - $form[$name] = $raw ? $data : 'fi_extraCols = '.json_encode(array_unique($data), JSON_NUMERIC_CHECK).';'; - break; - case 'setWeights': - $form[$name] = $raw ? $data : 'fi_setWeights('.json_encode($data, JSON_NUMERIC_CHECK).', 0, 1, 1);'; - break; - case 'form': - if ($key == $name) // only if explicitely specifies - $form[$name] = $data; - break; - default: - break; + if (!$value) + continue; + + switch ($module) + { + // additional (str) + case 'g': // group by + case 'h': // having + case 'o': // order by + if (!empty($this->queryOpts[$tbl][$module])) + $this->queryOpts[$tbl][$module] .= $value; + else + $this->queryOpts[$tbl][$module] = $value; + + break; + // additional (arr) + case 'j': // join + if (is_array($this->queryOpts[$tbl][$module])) + $this->queryOpts[$tbl][$module][0][] = $value; + else + $this->queryOpts[$tbl][$module] = $value; + + break; + // replacement + case 'l': // limit + case 's': // select + $this->queryOpts[$tbl][$module] = $value; + break; + } } } - - return $key ? (empty($form[$key]) ? [] : $form[$key]) : $form; - } - - public function filterGetError() - { - if ($this->filter) - return $this->filter->error; - else - return false; } // should return data required to display a listview of any kind @@ -555,7 +542,6 @@ abstract class Filter private $cndSet = []; - protected $parent = null; // itemFilter requires this protected $fiData = ['c' => [], 'v' =>[]]; protected $formData = array( // data to fill form fields 'form' => [], // base form - unsanitized @@ -565,10 +551,8 @@ abstract class Filter ); // parse the provided request into a usable format; recall self with GET-params if nessecary - public function __construct($parent) + public function __construct() { - $this->parent = $parent; - // prefer POST over GET, translate to url if (!empty($_POST)) { @@ -610,7 +594,7 @@ abstract class Filter } // do get request - header('Location: '.STATIC_URL.'?'.$_SERVER['QUERY_STRING'].'='.implode(';', $tmp)); + header('Location: '.HOST_URL.'?'.$_SERVER['QUERY_STRING'].'='.implode(';', $tmp)); } // sanitize input and build sql else if (!empty($_GET['filter'])) @@ -704,9 +688,39 @@ abstract class Filter array_unshift($this->cndSet, empty($this->fiData['v']['ma']) ? 'AND' : 'OR'); } - public function getForm() + public function getForm($key = null, $raw = false) { - return $this->formData; + $form = []; + + if (!$this->formData) + return $form; + + foreach ($this->formData as $name => $data) + { + if (!$data || ($key && $name != $key)) + continue; + + switch ($name) + { + case 'setCriteria': + $form[$name] = $raw ? $data : 'fi_setCriteria('.$data['cr'].', '.$data['crs'].', '.$data['crv'].');'; + break; + case 'extraCols': + $form[$name] = $raw ? $data : 'fi_extraCols = '.json_encode(array_unique($data), JSON_NUMERIC_CHECK).';'; + break; + case 'setWeights': + $form[$name] = $raw ? $data : 'fi_setWeights('.json_encode($data, JSON_NUMERIC_CHECK).', 0, 1, 1);'; + break; + case 'form': + if ($key == $name) // only if explicitely specified + $form[$name] = $data; + break; + default: + break; + } + } + + return $key ? (empty($form[$key]) ? [] : $form[$key]) : $form; } public function getConditions() diff --git a/includes/types/gameobject.class.php b/includes/types/gameobject.class.php index 1784a270..b394b5da 100644 --- a/includes/types/gameobject.class.php +++ b/includes/types/gameobject.class.php @@ -19,9 +19,9 @@ class GameObjectList extends BaseType 'ir' => ['j' => ['gameobject_involvedrelation ir ON ir.id = o.id', true]] // ends at GO ); - public function __construct($conditions = [], $applyFilter = false) + public function __construct($conditions = []) { - parent::__construct($conditions, $applyFilter); + parent::__construct($conditions); if ($this->error) return; diff --git a/includes/types/item.class.php b/includes/types/item.class.php index dc7aefd4..ca9dad75 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -28,13 +28,13 @@ class ItemList extends BaseType 'i' => ['o' => 'i.quality DESC, i.itemLevel DESC'] ); - public function __construct($conditions = [], $applyFilter = false, $miscData = null) + public function __construct($conditions = [], $miscData = null) { // search by statweight - if ($miscData && isset($miscData['wt']) && isset($miscData['wtv'])) - $conditions[] = $this->createConditionsForWeights($miscData); + if ($miscData && !empty($miscData['extraOpts'])) + $this->extendQueryOpts($miscData['extraOpts']); - parent::__construct($conditions, $applyFilter); + parent::__construct($conditions); foreach ($this->iterate() as &$_curTpl) { @@ -283,7 +283,8 @@ class ItemList extends BaseType $currency[] = [-$k, $qty]; } - $data[$this->id]['stock'] = $cost['stock']; + $data[$this->id]['stock'] = $cost['stock']; // display as column in lv + $data[$this->id]['avail'] = $cost['stock']; // display as number on icon $data[$this->id]['cost'] = [$this->getField('buyPrice')]; if ($e = $cost['event']) @@ -354,8 +355,6 @@ class ItemList extends BaseType /* even more complicated crap "source":[5],"sourcemore":[{"n":"Commander Oxheart","t":1,"ti":64606,"z":5842}], - avail unk - rel unk modelviewer {type:X, displayid:Y, slot:z} .. not sure, when to set */ @@ -1128,47 +1127,6 @@ class ItemList extends BaseType unset($this->json[$this->id][$k]); } - public function createConditionsForWeights(&$data) - { - if (count($data['wt']) != count($data['wtv'])) - return null; - - $select = $cnd = []; - $wtSum = 0; - - foreach ($data['wt'] as $k => $v) - { - @$str = Util::$itemFilter[$v]; - $qty = intVal($data['wtv'][$k]); - - if ($str && $qty) - { - if ($str == 'rgdspeed') // dont need no duplicate column - $str = 'speed'; - - if ($str == 'mledps') // todo (med): unify rngdps and mledps to dps - $str = 'dps'; - - $select[] = '(`is`.`'.$str.'` * '.$qty.')'; - $cnd[] = ['is.'.$str, 0, '>']; - $wtSum += $qty; - } - else // well look at that.. erronous indizes or zero-weights - { - unset($data['wt'][$k]); - unset($data['wtv'][$k]); - } - } - - if (count($cnd) > 1) - array_unshift($cnd, 'OR'); - else if (count($cnd) == 1) - $cnd = $cnd[0]; - - $this->queryOpts['is']['s'] = $select ? ', ('.implode(' + ', $select).') / '.$wtSum.' AS score' : null; - return $cnd; - } - private function canTeachSpell() { // 483: learn recipe; 55884: learn mount/pet @@ -1438,8 +1396,8 @@ class ItemList extends BaseType class ItemListFilter extends Filter { - // usable-by - limit weapon/armor selection per CharClass - itemClass => available itemsubclasses - private $ubFilter = []; + private $ubFilter = []; // usable-by - limit weapon/armor selection per CharClass - itemClass => available itemsubclasses + public $extraOpts = null; // score for statWeights protected $enums = array( 99 => array( // profession | recycled for 86, 87 null, 171, 164, 185, 333, 202, 129, 755, 165, 186, 197, true, false, 356, 182, 773 @@ -1569,7 +1527,7 @@ class ItemListFilter extends Filter 177 => [FILTER_CR_STAFFFLAG, 'flagsExtra' ], // flags2 ); - public function __construct($parent) + public function __construct() { $classes = new CharClassList(); foreach ($classes->iterate() as $cId => $_tpl) @@ -1586,7 +1544,50 @@ class ItemListFilter extends Filter $this->ubFilter[$cId][ITEM_CLASS_ARMOR][] = $i; } - parent::__construct($parent); + parent::__construct(); + } + + public function createConditionsForWeights(&$data) + { + if (count($data['wt']) != count($data['wtv'])) + return null; + + $select = $cnd = []; + $wtSum = 0; + + foreach ($data['wt'] as $k => $v) + { + @$str = Util::$itemFilter[$v]; + $qty = intVal($data['wtv'][$k]); + + if ($str && $qty) + { + if ($str == 'rgdspeed') // dont need no duplicate column + $str = 'speed'; + + if ($str == 'mledps') // todo (med): unify rngdps and mledps to dps + $str = 'dps'; + + $select[] = '(`is`.`'.$str.'` * '.$qty.')'; + $cnd[] = ['is.'.$str, 0, '>']; + $wtSum += $qty; + } + else // well look at that.. erronous indizes or zero-weights + { + unset($data['wt'][$k]); + unset($data['wtv'][$k]); + } + } + + if (count($cnd) > 1) + array_unshift($cnd, 'OR'); + else if (count($cnd) == 1) + $cnd = $cnd[0]; + + if ($select) + $this->extraOpts['is']['s'] = ', ('.implode(' + ', $select).') / '.$wtSum.' AS score'; + + return $cnd; } protected function createSQLForCriterium(&$cr) @@ -1873,7 +1874,7 @@ class ItemListFilter extends Filter $_v['wt'] = (array)$_v['wt']; $_v['wtv'] = (array)$_v['wtv']; - $parts[] = $this->parent->createConditionsForWeights($_v); + $parts[] = $this->createConditionsForWeights($_v); foreach ($_v['wt'] as $_) $this->formData['extraCols'][] = $_; diff --git a/includes/types/itemset.class.php b/includes/types/itemset.class.php index ad8b5b55..07fa7a36 100644 --- a/includes/types/itemset.class.php +++ b/includes/types/itemset.class.php @@ -17,9 +17,9 @@ class ItemsetList extends BaseType protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_itemset `set`'; protected $queryOpts = ['set' => ['o' => 'maxlevel DESC']]; - public function __construct($conditions = [], $applyFilter = false) + public function __construct($conditions = []) { - parent::__construct($conditions, $applyFilter); + parent::__construct($conditions); // post processing foreach ($this->iterate() as &$_curTpl) diff --git a/includes/types/quest.class.php b/includes/types/quest.class.php index 094da394..37b5b2d7 100644 --- a/includes/types/quest.class.php +++ b/includes/types/quest.class.php @@ -24,9 +24,9 @@ class QuestList extends BaseType 'itemStart' => ['j' => ['?_items itemStart ON itemStart.startQuest = qt.id', true], 'g' => 'qt.id'] // started by item .. grouping required, as the same quest may have multiple starter ); - public function __construct($conditions = [], $applyFilter = false) + public function __construct($conditions = []) { - parent::__construct($conditions, $applyFilter); + parent::__construct($conditions); // post processing foreach ($this->iterate() as $id => &$_curTpl) @@ -48,7 +48,7 @@ class QuestList extends BaseType for ($i = 0; $i < 9; $i++) unset($_curTpl['Field'.$i]); - // todo (med): extend for reward case + // store requirements $data = []; for ($i = 1; $i < 7; $i++) { @@ -66,9 +66,34 @@ class QuestList extends BaseType if ($_ = $_curTpl['RequiredSourceItemId'.$i]) $data[TYPE_ITEM][] = $_; } - if ($data) $this->requires[$id] = $data; + + // store rewards + $data = []; + + if ($_ = $_curTpl['RewardTitleId']) + $data[TYPE_TITLE][] = $_; + + for ($i = 1; $i < 7; $i++) + { + if ($_ = $_curTpl['RewardChoiceItemId'.$i]) + $data[TYPE_ITEM][] = $_; + + if ($i > 5) + continue; + + if ($_ = $_curTpl['RewardFactionId'.$i]) + $data[TYPE_FACTION][] = $_; + + if ($i > 4) + continue; + + if ($_ = $_curTpl['RewardItemId'.$i]) + $data[TYPE_ITEM][] = $_; + } + if ($data) + $this->rewards[$id] = $data; } } diff --git a/includes/types/spell.class.php b/includes/types/spell.class.php index 9bfca507..7c92ddeb 100644 --- a/includes/types/spell.class.php +++ b/includes/types/spell.class.php @@ -53,9 +53,9 @@ class SpellList extends BaseType protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_spell s'; - public function __construct($conditions = [], $applyFilter = false) + public function __construct($conditions = []) { - parent::__construct($conditions, $applyFilter); + parent::__construct($conditions); if ($this->error) return; diff --git a/pages/achievements.php b/pages/achievements.php index 135c92a7..4ce7564f 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -39,9 +39,15 @@ if (!Util::isValidPage($validCats, $cats)) if (!$smarty->loadCache($cacheKey, $pageData, $filter)) { + $acvFilter = new AchievementListFilter(); + // include child categories if current category is empty $condition = !empty($cats) ? [['category', (int)end($cats)]] : []; - $acvList = new AchievementList($condition, true); + + if ($_ = $acvFilter->getConditions()) + $condition[] = $_; + + $acvList = new AchievementList($condition); if (!$acvList->getMatches()) { $curCats = $catList = [!empty($cats) ? (int)end($cats) : 0]; @@ -50,13 +56,13 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $curCats = DB::Aowow()->SelectCol('SELECT Id FROM ?_achievementCategory WHERE parentCategory IN (?a)', $curCats); $catList = array_merge($catList, $curCats); } - $acvList = new AchievementList($catList ? [['category', $catList]] : [], true); + $acvList = new AchievementList($catList ? [['category', $catList]] : []); } // recreate form selection - $filter = array_merge($acvList->filterGetForm('form'), $filter); + $filter = array_merge($acvFilter->getForm('form'), $filter); $filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL; - $filter['fi'] = $acvList->filterGetForm(); + $filter['fi'] = $acvFilter->getForm(); // create page title and path if ($cats) @@ -104,7 +110,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $pageData['lv']['params']['_truncated'] = 1; } - if ($acvList->filterGetError()) + if ($acvFilter->error) $pageData['lv']['params']['_errors'] = '$1'; $smarty->saveCache($cacheKey, $pageData, $filter); diff --git a/pages/items.php b/pages/items.php index 23dca8d3..652db61c 100644 --- a/pages/items.php +++ b/pages/items.php @@ -172,6 +172,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) * ALSO upgradeItems .. Profiler can send them as lists, so multiple lv-tabs would occur * */ + $itemFilter = new ItemListFilter(); if (preg_match('/gb\=(1|2|3)/i', $_SERVER['QUERY_STRING'], $match)) $filter['gb'] = $match[1]; @@ -183,16 +184,19 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) if (isset($cats[2])) $conditions[] = ['i.subSubClass', $cats[2]]; - $items = new ItemList($conditions, true); + if ($_ = $itemFilter->getConditions()) + $conditions[] = $_; + + $items = new ItemList($conditions, ['extraOpts' => $itemFilter->extraOpts]); $items->addGlobalsToJscript($smarty); // recreate form selection - $filter = array_merge($items->filterGetForm('form'), $filter); + $filter = array_merge($itemFilter->getForm('form'), $filter); $filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL; - $filter['fi'] = $items->filterGetForm(); + $filter['fi'] = $itemFilter->getForm(); - $xCols = $items->filterGetForm('extraCols', true); + $xCols = $itemFilter->getForm('extraCols', true); // if slot-dropdown is available && Armor && $path points to Armor-Class if (count($path) == 4 && $cats[0] == 4 && isset($filter['sl']) && !is_array($filter['sl'])) @@ -222,7 +226,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) ) ); - if ($items->filterGetError()) + if ($itemFilter->error) $pageData['lv']['params']['_errors'] = '$1'; if (!empty($filter['upg'])) @@ -230,7 +234,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) // upgrade-item got deleted by filter if (empty($pageData['lv']['data'][$filter['upg']])) { - if ($w = $items->filterGetForm('setWeights', true)) + if ($w = $itemFilter->getForm('setWeights', true)) { $upgItem = new ItemList(array(['id', $filter['upg']]), false, ['wt' => $w[0], 'wtv' => $w[1]]); @@ -300,14 +304,18 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) { $pageData['lv']['params']['computeDataFunc'] = '$fi_scoreSockets'; - $w = $items->filterGetForm('setWeights', true); + $w = $itemFilter->getForm('setWeights', true); $q = intVal($filter['gm']); $mask = 14; $cnd = [10, ['class', ITEM_CLASS_GEM], ['gemColorMask', &$mask, '&'], ['quality', &$q]]; if (!isset($filter['jc'])) $cnd[] = ['itemLimitCategory', 0]; // Jeweler's Gems - $anyColor = new ItemList($cnd, false, ['wt' => $w[0], 'wtv' => $w[1]]); + $wData = ['wt' => $w[0], 'wtv' => $w[1]]; + If ($_ = $itemFilter->createConditionsForWeights($wData)) + $cnd[] = $_; + + $anyColor = new ItemList($cnd, ['extraOpts' => $itemFilter->extraOpts]); if (!$anyColor->error) { $anyColor->addGlobalsToJScript($smarty); @@ -317,8 +325,8 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) for ($i = 0; $i < 4; $i++) { $mask = 1 << $i; - $q = !$i ? 3 : intVal($filter['gm']); // meta gems are always included.. - $byColor = new ItemList($cnd, false, ['wt' => $w[0], 'wtv' => $w[1]]); + $q = !$i ? 3 : intVal($filter['gm']); // meta gems are always included.. ($q is backReferenced) + $byColor = new ItemList($cnd, ['extraOpts' => $itemFilter->extraOpts]); if (!$byColor->error) { $byColor->addGlobalsToJScript($smarty); @@ -329,9 +337,9 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $pageData['page']['gemScores'] = json_encode($pageData['page']['gemScores'], JSON_NUMERIC_CHECK); } - $pageData['lv']['params']['onBeforeCreate'] = '$fi_initWeightedListview'; - $pageData['lv']['params']['onAfterCreate'] = '$fi_addUpgradeIndicator'; - $pageData['lv']['params']['sort'] = "$['-score', 'name']"; + $pageData['lv']['params']['onBeforeCreate'] = '$fi_initWeightedListview'; + $pageData['lv']['params']['onAfterCreate'] = '$fi_addUpgradeIndicator'; + $pageData['lv']['params']['sort'] = "$['-score', 'name']"; if ($items->hasSetFields(['armor'])) $visibleCols[] = 'armor'; diff --git a/pages/itemsets.php b/pages/itemsets.php index 0dbddcf3..b02e9bda 100644 --- a/pages/itemsets.php +++ b/pages/itemsets.php @@ -11,13 +11,15 @@ $cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_ITEMSET, -1, $filterHash, User: if (!$smarty->loadCache($cacheKey, $pageData, $filter)) { - $itemsets = new ItemsetList([], true); // class selection is via filter, nothing applies here + $itemsetFilter = new ItemsetListFilter(); + + $itemsets = new ItemsetList([$itemsetFilter->getConditions()]); $itemsets->addGlobalsToJscript($smarty); // recreate form selection - $filter = array_merge($itemsets->filterGetForm('form'), $filter); + $filter = array_merge($itemsetFilter->getForm('form'), $filter); $filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL; - $filter['fi'] = $itemsets->filterGetForm(); + $filter['fi'] = $itemsetFilter->getForm(); if (isset($filter['cl'])) $path[] = $filter['cl']; @@ -53,7 +55,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $lv['params']['_truncated'] = 1; } - if ($itemsets->filterGetError()) + if ($itemsetFilter->error) $lv['params']['_errors'] = '$1'; $pageData['lv'] = $lv; diff --git a/pages/miscTools.php b/pages/miscTools.php index ef357ff4..ee250a1d 100644 --- a/pages/miscTools.php +++ b/pages/miscTools.php @@ -127,7 +127,7 @@ if (strstr($pageCall, 'latest') || $pageCall == 'most-comments') $xml = "\n". "\n\t\n". "\t\t".CFG_NAME_SHORT.' - '.Lang::$main['utilities'][$menu] . ($_title ? Lang::$colon . $_title : null)."\n". - "\t\t".STATIC_URL.'?'.$pageCall . ($pageParam ? '='.$pageParam : null)."\n". + "\t\t".HOST_URL.'?'.$pageCall . ($pageParam ? '='.$pageParam : null)."\n". "\t\t".CFG_NAME."\n". "\t\t".implode('-', str_split(User::$localeString, 2))."\n". "\t\t".CFG_TTL_RSS."\n". diff --git a/pages/npcs.php b/pages/npcs.php index 06c85f08..9f64a330 100644 --- a/pages/npcs.php +++ b/pages/npcs.php @@ -25,12 +25,16 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) array_unshift($title, Lang::$npc['cat'][$cats[0]]); } - $npcs = new CreatureList($conditions, true); // beast subtypes are selected via filter + $npcFilter = new CreatureListFilter(); + if ($_ = $npcFilter->getConditions()) + $conditions[] = $_; + + $npcs = new CreatureList($conditions); // beast subtypes are selected via filter // recreate form selection - $filter = array_merge($npcs->filterGetForm('form'), $filter); + $filter = array_merge($npcFilter->getForm('form'), $filter); $filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL; - $filter['fi'] = $npcs->filterGetForm(); + $filter['fi'] = $npcFilter->getForm(); if (isset($filter['fa'])) $path[] = $filter['fa']; @@ -66,7 +70,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $lv['params']['_truncated'] = 1; } - if ($npcs->filterGetError()) + if ($npcFilter->error) $lv['params']['_errors'] = '$1'; $pageData['lv'] = $lv; diff --git a/pages/objects.php b/pages/objects.php index 86fd9804..6962f01e 100644 --- a/pages/objects.php +++ b/pages/objects.php @@ -24,6 +24,11 @@ if ($cat) if (!$smarty->loadCache($cacheKey, $pageData, $filter)) { + + $objectFilter = new GameObjectListFilter(); + if ($_ = $objectFilter->getConditions()) + $conditions[] = $_; + $objects = new GameObjectList($conditions, true); // menuId 5: Object g_initPath() @@ -40,9 +45,9 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) ); // recreate form selection - $filter = array_merge($objects->filterGetForm('form'), $filter); + $filter = array_merge($objectFilter->getForm('form'), $filter); $filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL; - $filter['fi'] = $objects->filterGetForm(); + $filter['fi'] = $objectFilter->getForm(); $params = []; if ($objects->hasSetFields(['reqSkill'])) @@ -61,7 +66,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $lv['params']['_truncated'] = 1; } - if ($objects->filterGetError()) + if ($objectFilter->error) $lv['params']['_errors'] = '$1'; $pageData['lv'] = $lv; diff --git a/pages/profile.php b/pages/profile.php index f32e61cf..f6702da8 100644 --- a/pages/profile.php +++ b/pages/profile.php @@ -194,15 +194,6 @@ function handlePurge() // removes certain s return 'NYI'; } -function handleSummary() // can probably be removed -{ - /* params - null - return - null [jScript sets content] - */ -} - function handleLoad() { /* params @@ -249,7 +240,7 @@ function handleLoad() 'bookmarks' => [2], // UNK pinned or claimed profileIds..? 'arenateams' => [2 => 'Dead in the water', 3 => 'Hier kommt die Maus', 5 => 'High Five'], - // 'lastupdated' => 1394407364000, // UNK at some points it should be a date, at others an integer + 'lastupdated' => 1395185741600, // timestamp in ms 'talents' => array( 'builds' => array( ['talents' => '55322331200212', 'glyphs' => '45623:45625'], @@ -264,8 +255,6 @@ function handleLoad() 'reputation' => [], 'achievements' => [], 'achievementpoints' => 9001, // max you have - 'statistics' => [574 => 5, 575 => 20], // UNK all statistics [id => cnt] - 'activity' => [574 => 2], // UNK recent achievements? [id => cnt] 'titles' => [111 => 1, 144 => 1], 'quests' => [], 'spells' => [], @@ -306,9 +295,22 @@ function handleLoad() 1563 => 1226439600, 705 => 1226439600, 16 => 1226439600, - 546 => 1226439600 + 546 => 1226439600, + 23980 => 1216439600, + 575 => 1216439600 ); + $character['statistics'] = array( // UNK all statistics? [id => killCount] + 1377 => 1, + 23980 => 5, + 575 => 20 + ); + + $character['activity'] = array( // UNK recent achievements? [id => killCount] + 1377 => 1, + 23980 => 1, + 575 => 1 + ); foreach ($inventory as &$iv) while (count($iv) < 8) @@ -540,8 +542,8 @@ switch ($pageParam) die(handleDelete()); case 'purge': die(handlePurge()); - case 'summary': - die(handleSummary()); + case 'summary': // page is generated by jScript + die(); case 'avatar': die(handleAvatar()); case 'load': diff --git a/pages/spells.php b/pages/spells.php index 0befef73..4b0b9e64 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -383,15 +383,19 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) } } - $spells = new SpellList($conditions, true); + $spellFilter = new SpellListFilter(); + if ($_ = $spellFilter->getConditions()) + $conditions[] = $_; + + $spells = new SpellList($conditions); $spells->addGlobalsToJscript($smarty, GLOBALINFO_SELF | GLOBALINFO_RELATED); $lv['data'] = $spells->getListviewData(); // recreate form selection - $filter = array_merge($spells->filterGetForm('form'), $filter); + $filter = array_merge($spellFilter->getForm('form'), $filter); $filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL; - $filter['fi'] = $spells->filterGetForm(); + $filter['fi'] = $spellFilter->getForm(); if (isset($filter['gl']) && !is_array($filter['gl'])) { @@ -411,7 +415,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $lv['params']['_truncated'] = 1; } - if ($spells->filterGetError()) + if ($spellFilter->error) $lv['params']['_errors'] = '$1'; $mask = $spells->hasSetFields(['reagent1', 'skillLines', 'trainingCost']); diff --git a/search.php b/search.php index c52142c2..b3f37116 100644 --- a/search.php +++ b/search.php @@ -337,13 +337,20 @@ if (!$smarty->loadCache($cacheKey, $found)) if ($_slots) $iCnd[] = ['slot', $_slots]; - $cnd = array_merge($cndBase, [$iCnd]); - $miscData = ['wt' => $_wt, 'wtv' => $_wtv]; + $cnd = array_merge($cndBase, [$iCnd]); + $wData = ['wt' => $_wt, 'wtv' => $_wtv]; + + $itemFilter = new ItemListFilter(); + if ($_ = $itemFilter->createConditionsForWeights($wData)) + { + $miscData['extraOpts'] = $itemFilter->extraOpts; + $cnd = array_merge($cnd, [$_]); + } } else $cnd = array_merge($cndBase, [$cndAdd]); - $items = new ItemList($cnd, false, $miscData); + $items = new ItemList($cnd, $miscData); if ($data = $items->getListviewData($searchMask & SEARCH_TYPE_JSON ? (ITEMINFO_SUBITEMS | ITEMINFO_JSON) : 0)) { diff --git a/static/css/Profiler.css b/static/css/Profiler.css index 72d16532..8ed56425 100644 --- a/static/css/Profiler.css +++ b/static/css/Profiler.css @@ -219,6 +219,7 @@ a.profiler-header-editlink { text-align: center; border: 1px solid #101010; background: url(../images/icons/ajax.gif) no-repeat 8px #141414; + position: relative; -webkit-border-radius: 6px; -moz-border-radius: 6px; diff --git a/static/css/global.css b/static/css/global.css index e315814d..67e6b9f6 100644 --- a/static/css/global.css +++ b/static/css/global.css @@ -1479,7 +1479,7 @@ Variations: .icon-delete { - padding-left: 19px; + padding-left: 19px !important; background: url(../images/icons/delete.gif) no-repeat left center; } @@ -1595,7 +1595,7 @@ Variations: .icon-save { - padding-left: 21px; + padding-left: 21px !important; background: url(../images/icons/save.gif) no-repeat left center; } diff --git a/static/js/Profiler.js b/static/js/Profiler.js index 77841365..46f58bb9 100644 --- a/static/js/Profiler.js +++ b/static/js/Profiler.js @@ -1317,7 +1317,7 @@ function Profiler() { sp = $WH.ce('span'); $WH.ae(div, $WH.ct((_isArmoryProfile() ? LANG.pr_qf_resynced : LANG.pr_qf_updated))); - g_formatDate(sp, elapsed, _profile.lastupdated); + g_formatDate(sp, elapsed, new Date(_profile.lastupdated)); if (elapsed > (60 * 60 * 24)) { // 1 Day sp.style.color = 'red'; diff --git a/template/items.tpl b/template/items.tpl index 19c323bb..adf442a9 100644 --- a/template/items.tpl +++ b/template/items.tpl @@ -126,7 +126,7 @@ -   +   diff --git a/template/spell.tpl b/template/spell.tpl index 01e459f6..8c949d5d 100644 --- a/template/spell.tpl +++ b/template/spell.tpl @@ -23,7 +23,7 @@ {include file='bricks/redButtons.tpl'} - {$name} +

{$name}

{include file='bricks/tooltip.tpl'}