- 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
This commit is contained in:
Sarjuuk
2014-03-19 22:06:04 +01:00
parent d89d2c8c91
commit 1ced59c113
22 changed files with 257 additions and 176 deletions

View File

@@ -17,6 +17,8 @@ require 'includes/database.class.php';
// autoload List-Classes and Associated Filters // autoload List-Classes and Associated Filters
spl_autoload_register(function ($class) { spl_autoload_register(function ($class) {
$class = str_replace('Filter', '', $class);
if (strpos($class, 'List') && !class_exists($class)) if (strpos($class, 'List') && !class_exists($class))
{ {
if (!class_exists('BaseType')) if (!class_exists('BaseType'))

View File

@@ -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 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 // post processing
foreach ($this->iterate() as &$_curTpl) foreach ($this->iterate() as &$_curTpl)

View File

@@ -11,7 +11,6 @@ abstract class BaseType
protected $templates = []; protected $templates = [];
protected $curTpl = []; // lets iterate! protected $curTpl = []; // lets iterate!
protected $filter = null;
protected $matches = null; // total matches unaffected by sqlLimit in config protected $matches = null; // total matches unaffected by sqlLimit in config
protected $queryBase = ''; protected $queryBase = '';
@@ -50,7 +49,7 @@ abstract class BaseType
* results in * 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 * 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 = []; $where = [];
$linking = ' AND '; $linking = ' AND ';
@@ -60,23 +59,12 @@ abstract class BaseType
if (!$this->queryBase || $conditions === null) if (!$this->queryBase || $conditions === null)
return; return;
// may be called without filtering
if ($applyFilter && class_exists($className.'Filter'))
{
$fiName = $className.'Filter';
$this->filter = new $fiName($this);
}
$prefixes = []; $prefixes = [];
if (preg_match('/FROM \??[\w\_]+( AS)?\s?`?(\w+)`?$/i', $this->queryBase, $match)) if (preg_match('/FROM \??[\w\_]+( AS)?\s?`?(\w+)`?$/i', $this->queryBase, $match))
$prefixes['base'] = $match[2]; $prefixes['base'] = $match[2];
else else
$prefixes['base'] = ''; $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) $resolveCondition = function ($c, $supLink) use (&$resolveCondition, &$prefixes)
{ {
$subLink = ''; $subLink = '';
@@ -344,47 +332,46 @@ abstract class BaseType
return $this->matches; return $this->matches;
} }
public function filterGetForm($key = null, $raw = false) protected function extendQueryOpts($extra) // needs to be called from __construct
{ {
$form = []; foreach ($extra as $tbl => $sets)
if (!$this->filter)
return $form;
foreach ($this->filter->getForm() as $name => $data)
{ {
if (!$data || ($key && $name != $key)) if (!isset($this->queryOpts[$tbl])) // allow adding only to known tables
continue; continue;
switch ($name) foreach ($sets as $module => $value)
{ {
case 'setCriteria': if (!$value)
$form[$name] = $raw ? $data : 'fi_setCriteria('.$data['cr'].', '.$data['crs'].', '.$data['crv'].');'; continue;
break;
case 'extraCols': switch ($module)
$form[$name] = $raw ? $data : 'fi_extraCols = '.json_encode(array_unique($data), JSON_NUMERIC_CHECK).';'; {
break; // additional (str)
case 'setWeights': case 'g': // group by
$form[$name] = $raw ? $data : 'fi_setWeights('.json_encode($data, JSON_NUMERIC_CHECK).', 0, 1, 1);'; case 'h': // having
break; case 'o': // order by
case 'form': if (!empty($this->queryOpts[$tbl][$module]))
if ($key == $name) // only if explicitely specifies $this->queryOpts[$tbl][$module] .= $value;
$form[$name] = $data; else
break; $this->queryOpts[$tbl][$module] = $value;
default:
break; 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 // should return data required to display a listview of any kind
@@ -555,7 +542,6 @@ abstract class Filter
private $cndSet = []; private $cndSet = [];
protected $parent = null; // itemFilter requires this
protected $fiData = ['c' => [], 'v' =>[]]; protected $fiData = ['c' => [], 'v' =>[]];
protected $formData = array( // data to fill form fields protected $formData = array( // data to fill form fields
'form' => [], // base form - unsanitized '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 // 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 // prefer POST over GET, translate to url
if (!empty($_POST)) if (!empty($_POST))
{ {
@@ -610,7 +594,7 @@ abstract class Filter
} }
// do get request // 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 // sanitize input and build sql
else if (!empty($_GET['filter'])) else if (!empty($_GET['filter']))
@@ -704,9 +688,39 @@ abstract class Filter
array_unshift($this->cndSet, empty($this->fiData['v']['ma']) ? 'AND' : 'OR'); 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() public function getConditions()

View File

@@ -19,9 +19,9 @@ class GameObjectList extends BaseType
'ir' => ['j' => ['gameobject_involvedrelation ir ON ir.id = o.id', true]] // ends at GO '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) if ($this->error)
return; return;

View File

@@ -28,13 +28,13 @@ class ItemList extends BaseType
'i' => ['o' => 'i.quality DESC, i.itemLevel DESC'] '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 // search by statweight
if ($miscData && isset($miscData['wt']) && isset($miscData['wtv'])) if ($miscData && !empty($miscData['extraOpts']))
$conditions[] = $this->createConditionsForWeights($miscData); $this->extendQueryOpts($miscData['extraOpts']);
parent::__construct($conditions, $applyFilter); parent::__construct($conditions);
foreach ($this->iterate() as &$_curTpl) foreach ($this->iterate() as &$_curTpl)
{ {
@@ -283,7 +283,8 @@ class ItemList extends BaseType
$currency[] = [-$k, $qty]; $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')]; $data[$this->id]['cost'] = [$this->getField('buyPrice')];
if ($e = $cost['event']) if ($e = $cost['event'])
@@ -354,8 +355,6 @@ class ItemList extends BaseType
/* even more complicated crap /* even more complicated crap
"source":[5],"sourcemore":[{"n":"Commander Oxheart","t":1,"ti":64606,"z":5842}], "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 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]); 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() private function canTeachSpell()
{ {
// 483: learn recipe; 55884: learn mount/pet // 483: learn recipe; 55884: learn mount/pet
@@ -1438,8 +1396,8 @@ class ItemList extends BaseType
class ItemListFilter extends Filter class ItemListFilter extends Filter
{ {
// usable-by - limit weapon/armor selection per CharClass - itemClass => available itemsubclasses private $ubFilter = []; // usable-by - limit weapon/armor selection per CharClass - itemClass => available itemsubclasses
private $ubFilter = []; public $extraOpts = null; // score for statWeights
protected $enums = array( protected $enums = array(
99 => array( // profession | recycled for 86, 87 99 => array( // profession | recycled for 86, 87
null, 171, 164, 185, 333, 202, 129, 755, 165, 186, 197, true, false, 356, 182, 773 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 177 => [FILTER_CR_STAFFFLAG, 'flagsExtra' ], // flags2
); );
public function __construct($parent) public function __construct()
{ {
$classes = new CharClassList(); $classes = new CharClassList();
foreach ($classes->iterate() as $cId => $_tpl) foreach ($classes->iterate() as $cId => $_tpl)
@@ -1586,7 +1544,50 @@ class ItemListFilter extends Filter
$this->ubFilter[$cId][ITEM_CLASS_ARMOR][] = $i; $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) protected function createSQLForCriterium(&$cr)
@@ -1873,7 +1874,7 @@ class ItemListFilter extends Filter
$_v['wt'] = (array)$_v['wt']; $_v['wt'] = (array)$_v['wt'];
$_v['wtv'] = (array)$_v['wtv']; $_v['wtv'] = (array)$_v['wtv'];
$parts[] = $this->parent->createConditionsForWeights($_v); $parts[] = $this->createConditionsForWeights($_v);
foreach ($_v['wt'] as $_) foreach ($_v['wt'] as $_)
$this->formData['extraCols'][] = $_; $this->formData['extraCols'][] = $_;

View File

@@ -17,9 +17,9 @@ class ItemsetList extends BaseType
protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_itemset `set`'; protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_itemset `set`';
protected $queryOpts = ['set' => ['o' => 'maxlevel DESC']]; 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 // post processing
foreach ($this->iterate() as &$_curTpl) foreach ($this->iterate() as &$_curTpl)

View File

@@ -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 '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 // post processing
foreach ($this->iterate() as $id => &$_curTpl) foreach ($this->iterate() as $id => &$_curTpl)
@@ -48,7 +48,7 @@ class QuestList extends BaseType
for ($i = 0; $i < 9; $i++) for ($i = 0; $i < 9; $i++)
unset($_curTpl['Field'.$i]); unset($_curTpl['Field'.$i]);
// todo (med): extend for reward case // store requirements
$data = []; $data = [];
for ($i = 1; $i < 7; $i++) for ($i = 1; $i < 7; $i++)
{ {
@@ -66,9 +66,34 @@ class QuestList extends BaseType
if ($_ = $_curTpl['RequiredSourceItemId'.$i]) if ($_ = $_curTpl['RequiredSourceItemId'.$i])
$data[TYPE_ITEM][] = $_; $data[TYPE_ITEM][] = $_;
} }
if ($data) if ($data)
$this->requires[$id] = $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;
} }
} }

View File

@@ -53,9 +53,9 @@ class SpellList extends BaseType
protected $queryBase = 'SELECT *, id AS ARRAY_KEY FROM ?_spell s'; 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) if ($this->error)
return; return;

View File

@@ -39,9 +39,15 @@ if (!Util::isValidPage($validCats, $cats))
if (!$smarty->loadCache($cacheKey, $pageData, $filter)) if (!$smarty->loadCache($cacheKey, $pageData, $filter))
{ {
$acvFilter = new AchievementListFilter();
// include child categories if current category is empty // include child categories if current category is empty
$condition = !empty($cats) ? [['category', (int)end($cats)]] : []; $condition = !empty($cats) ? [['category', (int)end($cats)]] : [];
$acvList = new AchievementList($condition, true);
if ($_ = $acvFilter->getConditions())
$condition[] = $_;
$acvList = new AchievementList($condition);
if (!$acvList->getMatches()) if (!$acvList->getMatches())
{ {
$curCats = $catList = [!empty($cats) ? (int)end($cats) : 0]; $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); $curCats = DB::Aowow()->SelectCol('SELECT Id FROM ?_achievementCategory WHERE parentCategory IN (?a)', $curCats);
$catList = array_merge($catList, $curCats); $catList = array_merge($catList, $curCats);
} }
$acvList = new AchievementList($catList ? [['category', $catList]] : [], true); $acvList = new AchievementList($catList ? [['category', $catList]] : []);
} }
// recreate form selection // 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['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$filter['fi'] = $acvList->filterGetForm(); $filter['fi'] = $acvFilter->getForm();
// create page title and path // create page title and path
if ($cats) if ($cats)
@@ -104,7 +110,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
$pageData['lv']['params']['_truncated'] = 1; $pageData['lv']['params']['_truncated'] = 1;
} }
if ($acvList->filterGetError()) if ($acvFilter->error)
$pageData['lv']['params']['_errors'] = '$1'; $pageData['lv']['params']['_errors'] = '$1';
$smarty->saveCache($cacheKey, $pageData, $filter); $smarty->saveCache($cacheKey, $pageData, $filter);

View File

@@ -172,6 +172,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
* ALSO upgradeItems .. Profiler can send them as lists, so multiple lv-tabs would occur * 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)) if (preg_match('/gb\=(1|2|3)/i', $_SERVER['QUERY_STRING'], $match))
$filter['gb'] = $match[1]; $filter['gb'] = $match[1];
@@ -183,16 +184,19 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
if (isset($cats[2])) if (isset($cats[2]))
$conditions[] = ['i.subSubClass', $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); $items->addGlobalsToJscript($smarty);
// recreate form selection // 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['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 slot-dropdown is available && Armor && $path points to Armor-Class
if (count($path) == 4 && $cats[0] == 4 && isset($filter['sl']) && !is_array($filter['sl'])) 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'; $pageData['lv']['params']['_errors'] = '$1';
if (!empty($filter['upg'])) if (!empty($filter['upg']))
@@ -230,7 +234,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
// upgrade-item got deleted by filter // upgrade-item got deleted by filter
if (empty($pageData['lv']['data'][$filter['upg']])) 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]]); $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'; $pageData['lv']['params']['computeDataFunc'] = '$fi_scoreSockets';
$w = $items->filterGetForm('setWeights', true); $w = $itemFilter->getForm('setWeights', true);
$q = intVal($filter['gm']); $q = intVal($filter['gm']);
$mask = 14; $mask = 14;
$cnd = [10, ['class', ITEM_CLASS_GEM], ['gemColorMask', &$mask, '&'], ['quality', &$q]]; $cnd = [10, ['class', ITEM_CLASS_GEM], ['gemColorMask', &$mask, '&'], ['quality', &$q]];
if (!isset($filter['jc'])) if (!isset($filter['jc']))
$cnd[] = ['itemLimitCategory', 0]; // Jeweler's Gems $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) if (!$anyColor->error)
{ {
$anyColor->addGlobalsToJScript($smarty); $anyColor->addGlobalsToJScript($smarty);
@@ -317,8 +325,8 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
for ($i = 0; $i < 4; $i++) for ($i = 0; $i < 4; $i++)
{ {
$mask = 1 << $i; $mask = 1 << $i;
$q = !$i ? 3 : intVal($filter['gm']); // meta gems are always included.. $q = !$i ? 3 : intVal($filter['gm']); // meta gems are always included.. ($q is backReferenced)
$byColor = new ItemList($cnd, false, ['wt' => $w[0], 'wtv' => $w[1]]); $byColor = new ItemList($cnd, ['extraOpts' => $itemFilter->extraOpts]);
if (!$byColor->error) if (!$byColor->error)
{ {
$byColor->addGlobalsToJScript($smarty); $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['page']['gemScores'] = json_encode($pageData['page']['gemScores'], JSON_NUMERIC_CHECK);
} }
$pageData['lv']['params']['onBeforeCreate'] = '$fi_initWeightedListview'; $pageData['lv']['params']['onBeforeCreate'] = '$fi_initWeightedListview';
$pageData['lv']['params']['onAfterCreate'] = '$fi_addUpgradeIndicator'; $pageData['lv']['params']['onAfterCreate'] = '$fi_addUpgradeIndicator';
$pageData['lv']['params']['sort'] = "$['-score', 'name']"; $pageData['lv']['params']['sort'] = "$['-score', 'name']";
if ($items->hasSetFields(['armor'])) if ($items->hasSetFields(['armor']))
$visibleCols[] = 'armor'; $visibleCols[] = 'armor';

View File

@@ -11,13 +11,15 @@ $cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_ITEMSET, -1, $filterHash, User:
if (!$smarty->loadCache($cacheKey, $pageData, $filter)) 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); $itemsets->addGlobalsToJscript($smarty);
// recreate form selection // 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['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$filter['fi'] = $itemsets->filterGetForm(); $filter['fi'] = $itemsetFilter->getForm();
if (isset($filter['cl'])) if (isset($filter['cl']))
$path[] = $filter['cl']; $path[] = $filter['cl'];
@@ -53,7 +55,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
$lv['params']['_truncated'] = 1; $lv['params']['_truncated'] = 1;
} }
if ($itemsets->filterGetError()) if ($itemsetFilter->error)
$lv['params']['_errors'] = '$1'; $lv['params']['_errors'] = '$1';
$pageData['lv'] = $lv; $pageData['lv'] = $lv;

View File

@@ -127,7 +127,7 @@ if (strstr($pageCall, 'latest') || $pageCall == 'most-comments')
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n". $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".
"<rss version=\"2.0\">\n\t<channel>\n". "<rss version=\"2.0\">\n\t<channel>\n".
"\t\t<title>".CFG_NAME_SHORT.' - '.Lang::$main['utilities'][$menu] . ($_title ? Lang::$colon . $_title : null)."</title>\n". "\t\t<title>".CFG_NAME_SHORT.' - '.Lang::$main['utilities'][$menu] . ($_title ? Lang::$colon . $_title : null)."</title>\n".
"\t\t<link>".STATIC_URL.'?'.$pageCall . ($pageParam ? '='.$pageParam : null)."</link>\n". "\t\t<link>".HOST_URL.'?'.$pageCall . ($pageParam ? '='.$pageParam : null)."</link>\n".
"\t\t<description>".CFG_NAME."</description>\n". "\t\t<description>".CFG_NAME."</description>\n".
"\t\t<language>".implode('-', str_split(User::$localeString, 2))."</language>\n". "\t\t<language>".implode('-', str_split(User::$localeString, 2))."</language>\n".
"\t\t<ttl>".CFG_TTL_RSS."</ttl>\n". "\t\t<ttl>".CFG_TTL_RSS."</ttl>\n".

View File

@@ -25,12 +25,16 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
array_unshift($title, Lang::$npc['cat'][$cats[0]]); 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 // 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['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$filter['fi'] = $npcs->filterGetForm(); $filter['fi'] = $npcFilter->getForm();
if (isset($filter['fa'])) if (isset($filter['fa']))
$path[] = $filter['fa']; $path[] = $filter['fa'];
@@ -66,7 +70,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
$lv['params']['_truncated'] = 1; $lv['params']['_truncated'] = 1;
} }
if ($npcs->filterGetError()) if ($npcFilter->error)
$lv['params']['_errors'] = '$1'; $lv['params']['_errors'] = '$1';
$pageData['lv'] = $lv; $pageData['lv'] = $lv;

View File

@@ -24,6 +24,11 @@ if ($cat)
if (!$smarty->loadCache($cacheKey, $pageData, $filter)) if (!$smarty->loadCache($cacheKey, $pageData, $filter))
{ {
$objectFilter = new GameObjectListFilter();
if ($_ = $objectFilter->getConditions())
$conditions[] = $_;
$objects = new GameObjectList($conditions, true); $objects = new GameObjectList($conditions, true);
// menuId 5: Object g_initPath() // menuId 5: Object g_initPath()
@@ -40,9 +45,9 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
); );
// recreate form selection // 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['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$filter['fi'] = $objects->filterGetForm(); $filter['fi'] = $objectFilter->getForm();
$params = []; $params = [];
if ($objects->hasSetFields(['reqSkill'])) if ($objects->hasSetFields(['reqSkill']))
@@ -61,7 +66,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
$lv['params']['_truncated'] = 1; $lv['params']['_truncated'] = 1;
} }
if ($objects->filterGetError()) if ($objectFilter->error)
$lv['params']['_errors'] = '$1'; $lv['params']['_errors'] = '$1';
$pageData['lv'] = $lv; $pageData['lv'] = $lv;

View File

@@ -194,15 +194,6 @@ function handlePurge() // removes certain s
return 'NYI'; return 'NYI';
} }
function handleSummary() // can probably be removed
{
/* params
null
return
null [jScript sets content]
*/
}
function handleLoad() function handleLoad()
{ {
/* params /* params
@@ -249,7 +240,7 @@ function handleLoad()
'bookmarks' => [2], // UNK pinned or claimed profileIds..? 'bookmarks' => [2], // UNK pinned or claimed profileIds..?
'arenateams' => [2 => 'Dead in the water', 3 => 'Hier kommt die Maus', 5 => 'High Five'], '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( 'talents' => array(
'builds' => array( 'builds' => array(
['talents' => '55322331200212', 'glyphs' => '45623:45625'], ['talents' => '55322331200212', 'glyphs' => '45623:45625'],
@@ -264,8 +255,6 @@ function handleLoad()
'reputation' => [], 'reputation' => [],
'achievements' => [], 'achievements' => [],
'achievementpoints' => 9001, // max you have '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], 'titles' => [111 => 1, 144 => 1],
'quests' => [], 'quests' => [],
'spells' => [], 'spells' => [],
@@ -306,9 +295,22 @@ function handleLoad()
1563 => 1226439600, 1563 => 1226439600,
705 => 1226439600, 705 => 1226439600,
16 => 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) foreach ($inventory as &$iv)
while (count($iv) < 8) while (count($iv) < 8)
@@ -540,8 +542,8 @@ switch ($pageParam)
die(handleDelete()); die(handleDelete());
case 'purge': case 'purge':
die(handlePurge()); die(handlePurge());
case 'summary': case 'summary': // page is generated by jScript
die(handleSummary()); die();
case 'avatar': case 'avatar':
die(handleAvatar()); die(handleAvatar());
case 'load': case 'load':

View File

@@ -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); $spells->addGlobalsToJscript($smarty, GLOBALINFO_SELF | GLOBALINFO_RELATED);
$lv['data'] = $spells->getListviewData(); $lv['data'] = $spells->getListviewData();
// recreate form selection // 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['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$filter['fi'] = $spells->filterGetForm(); $filter['fi'] = $spellFilter->getForm();
if (isset($filter['gl']) && !is_array($filter['gl'])) if (isset($filter['gl']) && !is_array($filter['gl']))
{ {
@@ -411,7 +415,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
$lv['params']['_truncated'] = 1; $lv['params']['_truncated'] = 1;
} }
if ($spells->filterGetError()) if ($spellFilter->error)
$lv['params']['_errors'] = '$1'; $lv['params']['_errors'] = '$1';
$mask = $spells->hasSetFields(['reagent1', 'skillLines', 'trainingCost']); $mask = $spells->hasSetFields(['reagent1', 'skillLines', 'trainingCost']);

View File

@@ -337,13 +337,20 @@ if (!$smarty->loadCache($cacheKey, $found))
if ($_slots) if ($_slots)
$iCnd[] = ['slot', $_slots]; $iCnd[] = ['slot', $_slots];
$cnd = array_merge($cndBase, [$iCnd]); $cnd = array_merge($cndBase, [$iCnd]);
$miscData = ['wt' => $_wt, 'wtv' => $_wtv]; $wData = ['wt' => $_wt, 'wtv' => $_wtv];
$itemFilter = new ItemListFilter();
if ($_ = $itemFilter->createConditionsForWeights($wData))
{
$miscData['extraOpts'] = $itemFilter->extraOpts;
$cnd = array_merge($cnd, [$_]);
}
} }
else else
$cnd = array_merge($cndBase, [$cndAdd]); $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)) if ($data = $items->getListviewData($searchMask & SEARCH_TYPE_JSON ? (ITEMINFO_SUBITEMS | ITEMINFO_JSON) : 0))
{ {

View File

@@ -219,6 +219,7 @@ a.profiler-header-editlink {
text-align: center; text-align: center;
border: 1px solid #101010; border: 1px solid #101010;
background: url(../images/icons/ajax.gif) no-repeat 8px #141414; background: url(../images/icons/ajax.gif) no-repeat 8px #141414;
position: relative;
-webkit-border-radius: 6px; -webkit-border-radius: 6px;
-moz-border-radius: 6px; -moz-border-radius: 6px;

View File

@@ -1479,7 +1479,7 @@ Variations:
.icon-delete .icon-delete
{ {
padding-left: 19px; padding-left: 19px !important;
background: url(../images/icons/delete.gif) no-repeat left center; background: url(../images/icons/delete.gif) no-repeat left center;
} }
@@ -1595,7 +1595,7 @@ Variations:
.icon-save .icon-save
{ {
padding-left: 21px; padding-left: 21px !important;
background: url(../images/icons/save.gif) no-repeat left center; background: url(../images/icons/save.gif) no-repeat left center;
} }

View File

@@ -1317,7 +1317,7 @@ function Profiler() {
sp = $WH.ce('span'); sp = $WH.ce('span');
$WH.ae(div, $WH.ct((_isArmoryProfile() ? LANG.pr_qf_resynced : LANG.pr_qf_updated))); $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 if (elapsed > (60 * 60 * 24)) { // 1 Day
sp.style.color = 'red'; sp.style.color = 'red';

View File

@@ -126,7 +126,7 @@
<option value="3" {if isset($filter.gm) && $filter.gm == 3}selected{/if}>{$lang.quality[3]}</option> <option value="3" {if isset($filter.gm) && $filter.gm == 3}selected{/if}>{$lang.quality[3]}</option>
<option value="4" {if isset($filter.gm) && $filter.gm == 4}selected{/if}>{$lang.quality[4]}</option> <option value="4" {if isset($filter.gm) && $filter.gm == 4}selected{/if}>{$lang.quality[4]}</option>
</select> </select>
&nbsp; <input type="checkbox" name="jc" value="1" id="jc" /><label for="jc">{$lang.jcGemsOnly|sprintf:' class="tip" onmouseover="$WH.Tooltip.showAtCursor(event, LANG.tooltip_jconlygems, 0, 0, \'q\')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"'}</label> &nbsp; <input type="checkbox" name="jc" value="1" id="jc" {if isset($filter.jc) && $filter.jc == 1}checked="checked"{/if}/><label for="jc">{$lang.jcGemsOnly|sprintf:' class="tip" onmouseover="$WH.Tooltip.showAtCursor(event, LANG.tooltip_jconlygems, 0, 0, \'q\')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"'}</label>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -23,7 +23,7 @@
{include file='bricks/redButtons.tpl'} {include file='bricks/redButtons.tpl'}
<h1{if isset($expansion)} class="h1-icon">{$name}</h1> <h1 class="h1-icon">{$name}</h1>
{include file='bricks/tooltip.tpl'} {include file='bricks/tooltip.tpl'}