implemented grouping by itemlevel and slot for items

group by source won't require much additional work besides adding source to
items in the first place

search for multiple itemUpgrades are also yet to come
This commit is contained in:
Sarjuuk
2014-03-20 17:08:59 +01:00
parent 1ced59c113
commit f236d7ae93
10 changed files with 268 additions and 140 deletions

View File

@@ -49,7 +49,7 @@ foreach ($AoWoWconf['characters'] as $realm => $charDBInfo)
// load config to constants // load config to constants
$sets = DB::Aowow()->select('SELECT `key` AS ARRAY_KEY, intValue as i, strValue as s FROM ?_config'); $sets = DB::Aowow()->select('SELECT `key` AS ARRAY_KEY, intValue as i, strValue as s FROM ?_config');
foreach ($sets as $k => $v) foreach ($sets as $k => $v)
define('CFG_'.strtoupper($k), $v['i'] ? intVal($v['i']) : $v['s']); define('CFG_'.strtoupper($k), $v['s'] ? $v['s'] : intVal($v['i']));
define('STATIC_URL', substr('http://'.$_SERVER['SERVER_NAME'].strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']), 0, -1).'/static'); // points js to images & scripts (change here if you want to use a separate subdomain) define('STATIC_URL', substr('http://'.$_SERVER['SERVER_NAME'].strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']), 0, -1).'/static'); // points js to images & scripts (change here if you want to use a separate subdomain)
define('HOST_URL', substr('http://'.$_SERVER['SERVER_NAME'].strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']), 0, -1)); // points js to executable files define('HOST_URL', substr('http://'.$_SERVER['SERVER_NAME'].strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']), 0, -1)); // points js to executable files

View File

@@ -349,7 +349,6 @@ abstract class BaseType
// additional (str) // additional (str)
case 'g': // group by case 'g': // group by
case 'h': // having case 'h': // having
case 'o': // order by
if (!empty($this->queryOpts[$tbl][$module])) if (!empty($this->queryOpts[$tbl][$module]))
$this->queryOpts[$tbl][$module] .= $value; $this->queryOpts[$tbl][$module] .= $value;
else else
@@ -364,9 +363,10 @@ abstract class BaseType
$this->queryOpts[$tbl][$module] = $value; $this->queryOpts[$tbl][$module] = $value;
break; break;
// replacement // replacement (str)
case 'l': // limit case 'l': // limit
case 's': // select case 's': // select
case 'o': // order by
$this->queryOpts[$tbl][$module] = $value; $this->queryOpts[$tbl][$module] = $value;
break; break;
} }
@@ -543,7 +543,7 @@ abstract class Filter
private $cndSet = []; private $cndSet = [];
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
'setCriteria' => [], // dynamic criteria list - index checked 'setCriteria' => [], // dynamic criteria list - index checked
'setWeights' => [], // dynamic weights list - index checked 'setWeights' => [], // dynamic weights list - index checked
@@ -581,20 +581,8 @@ abstract class Filter
} }
} }
// create get-data
$tmp = [];
foreach (array_merge($this->fiData['c'], $this->fiData['v']) as $k => $v)
{
if ($v === '')
continue;
else if (is_array($v))
$tmp[$k] = $k."=".implode(':', $v);
else
$tmp[$k] = $k."=".$v;
}
// do get request // do get request
header('Location: '.HOST_URL.'?'.$_SERVER['QUERY_STRING'].'='.implode(';', $tmp)); header('Location: '.HOST_URL.'?'.$_SERVER['QUERY_STRING'].'='.$this->urlize());
} }
// sanitize input and build sql // sanitize input and build sql
else if (!empty($_GET['filter'])) else if (!empty($_GET['filter']))
@@ -674,6 +662,23 @@ abstract class Filter
} }
} }
public function urlize(array $override = [], array $addCr = [])
{
$_ = [];
foreach (array_merge($this->fiData['c'], $this->fiData['v'], $override) as $k => $v)
{
if (isset($addCr[$k]))
$v = $v ? array_merge((array)$v, (array)$addCr[$k]) : $addCr[$k];
if (is_array($v) && !empty($v))
$_[$k] = $k.'='.implode(':', $v);
else if ($v === '')
$_[$k] = $k.'='.$v;
}
return implode(';', $_);
}
// todo: kill data, that is unexpected or points to wrong indizes // todo: kill data, that is unexpected or points to wrong indizes
private function evaluateFilter() private function evaluateFilter()
{ {

View File

@@ -180,6 +180,10 @@ $lang = array(
'modes' => ['Normal / Normal 10', 'Heroisch / Normal 25', 'Heroisch 10', 'Heroisch 25'], 'modes' => ['Normal / Normal 10', 'Heroisch / Normal 25', 'Heroisch 10', 'Heroisch 25'],
'expansions' => array("Classic", "The Burning Crusade", "Wrath of the Lich King"), 'expansions' => array("Classic", "The Burning Crusade", "Wrath of the Lich King"),
'stats' => array("Stärke", "Beweglichkeit", "Ausdauer", "Intelligenz", "Willenskraft"), 'stats' => array("Stärke", "Beweglichkeit", "Ausdauer", "Intelligenz", "Willenskraft"),
'sources' => array(
null, "Hergestellt", "Drop", "PvP", "Quest", "Händler", "Lehrer", "Entdeckung",
"Einlösung", "Talent", "Startausrüstung", "Ereignis", "Erfolg"
),
'languages' => array( 'languages' => array(
1 => "Orcisch", 2 => "Darnassisch", 3 => "Taurisch", 6 => "Zwergisch", 7 => "Gemeinsprache", 8 => "Dämonisch", 9 => "Titanisch", 10 => "Thalassisch", 1 => "Orcisch", 2 => "Darnassisch", 3 => "Taurisch", 6 => "Zwergisch", 7 => "Gemeinsprache", 8 => "Dämonisch", 9 => "Titanisch", 10 => "Thalassisch",
11 => "Drachisch", 12 => "Kalimagisch", 13 => "Gnomisch", 14 => "Trollisch", 33 => "Gossensprache", 35 => "Draeneiisch", 36 => "Zombie", 37 => "Gnomenbinär", 38 => "Goblinbinär" 11 => "Drachisch", 12 => "Kalimagisch", 13 => "Gnomisch", 14 => "Trollisch", 33 => "Gossensprache", 35 => "Draeneiisch", 36 => "Zombie", 37 => "Gnomenbinär", 38 => "Goblinbinär"
@@ -614,6 +618,7 @@ $lang = array(
'usableBy' => "Benutzbar von", 'usableBy' => "Benutzbar von",
'buyout' => "Sofortkaufpreis", 'buyout' => "Sofortkaufpreis",
'each' => "Stück", 'each' => "Stück",
'tabOther' => "Anderes",
'gems' => "Edelsteine", 'gems' => "Edelsteine",
'socketBonus' => "Sockelbonus", 'socketBonus' => "Sockelbonus",
'socket' => array ( 'socket' => array (

View File

@@ -167,8 +167,12 @@ $lang = array(
'modes' => ['Normal / Normal 10', 'Heroic / Normal 25', 'Heroic 10', 'Heroic 25'], 'modes' => ['Normal / Normal 10', 'Heroic / Normal 25', 'Heroic 10', 'Heroic 25'],
'expansions' => array("Classic", "The Burning Crusade", "Wrath of the Lich King"), 'expansions' => array("Classic", "The Burning Crusade", "Wrath of the Lich King"),
'stats' => array("Strength", "Agility", "Stamina", "Intellect", "Spirit"), 'stats' => array("Strength", "Agility", "Stamina", "Intellect", "Spirit"),
'sources' => array(
null, "Crafted", "Drop", "PvP", "Quest", "Vendor", "Trainer", "Discovery",
"Redemption", "Talent", "Starter", "Event", "Achievement"
),
'languages' => array( 'languages' => array(
1 => "Orcish", 2 => "Darnassian", 3 => "Taurahe", 6 => "Dwarvish", 7 => "Common", 8 => "Demonic", 9 => "Titan", 10 => "Thalassian", 1 => "Orcish", 2 => "Darnassian", 3 => "Taurahe", 6 => "Dwarvish", 7 => "Common", 8 => "Demonic", 9 => "Titan", 10 => "Thalassian",
11 => "Draconic", 12 => "Kalimag", 13 => "Gnomish", 14 => "Troll", 33 => "Gutterspeak", 35 => "Draenei", 36 => "Zombie", 37 => "Gnomish Binary", 38 => "Goblin Binary" 11 => "Draconic", 12 => "Kalimag", 13 => "Gnomish", 14 => "Troll", 33 => "Gutterspeak", 35 => "Draenei", 36 => "Zombie", 37 => "Gnomish Binary", 38 => "Goblin Binary"
), ),
'gl' => array(null, "Major", "Minor"), 'gl' => array(null, "Major", "Minor"),
@@ -199,8 +203,8 @@ $lang = array(
"Critter", "Mechanical", "Not specified", "Totem", "Non-combat Pet", "Gas Cloud" "Critter", "Mechanical", "Not specified", "Totem", "Non-combat Pet", "Gas Cloud"
), ),
'fa' => array( 'fa' => array(
1 => "Wolf", 2 => "Cat", 3 => "Spider", 4 => "Bear", 5 => "Boar", 6 => "Crocolisk", 7 => "Carrion Bird", 8 => "Crab", 1 => "Wolf", 2 => "Cat", 3 => "Spider", 4 => "Bear", 5 => "Boar", 6 => "Crocolisk", 7 => "Carrion Bird", 8 => "Crab",
9 => "Gorilla", 11 => "Raptor", 12 => "Tallstrider", 20 => "Scorpid", 21 => "Turtle", 24 => "Bat", 25 => "Hyena", 26 => "Bird of Prey", 9 => "Gorilla", 11 => "Raptor", 12 => "Tallstrider", 20 => "Scorpid", 21 => "Turtle", 24 => "Bat", 25 => "Hyena", 26 => "Bird of Prey",
27 => "Wind Serpent", 30 => "Dragonhawk", 31 => "Ravager", 32 => "Warp Stalker", 33 => "Sporebat", 34 => "Nether Ray", 35 => "Serpent", 37 => "Moth", 27 => "Wind Serpent", 30 => "Dragonhawk", 31 => "Ravager", 32 => "Warp Stalker", 33 => "Sporebat", 34 => "Nether Ray", 35 => "Serpent", 37 => "Moth",
38 => "Chimaera", 39 => "Devilsaur", 41 => "Silithid", 42 => "Worm", 43 => "Rhino", 44 => "Wasp", 45 => "Core Hound", 46 => "Spirit Beast" 38 => "Chimaera", 39 => "Devilsaur", 41 => "Silithid", 42 => "Worm", 43 => "Rhino", 44 => "Wasp", 45 => "Core Hound", 46 => "Spirit Beast"
), ),
@@ -604,6 +608,7 @@ $lang = array(
'usableBy' => "Usable by", 'usableBy' => "Usable by",
'buyout' => "Buyout price", 'buyout' => "Buyout price",
'each' => "each", 'each' => "each",
'tabOther' => "Other",
'gems' => "Gems", 'gems' => "Gems",
'socketBonus' => "Socket Bonus", 'socketBonus' => "Socket Bonus",
'socket' => array( 'socket' => array(

View File

@@ -172,6 +172,10 @@ $lang = array(
'modes' => ['Normal / Normal 10', 'Heroico / Normal 25', 'Heróico 10', 'Heróico 25'], 'modes' => ['Normal / Normal 10', 'Heroico / Normal 25', 'Heróico 10', 'Heróico 25'],
'expansions' => array("World of Warcraft", "The Burning Crusade", "Wrath of the Lich King"), 'expansions' => array("World of Warcraft", "The Burning Crusade", "Wrath of the Lich King"),
'stats' => array("Fuerza", "Agilidad", "Aguante", "Intelecto", "Espíritu"), 'stats' => array("Fuerza", "Agilidad", "Aguante", "Intelecto", "Espíritu"),
'sources' => array(
null, "Creado", "Encontrado", "JcJ", "Misión", "Vendedor", "Entrenador", "Descubierto",
"Redención", "Talento", "Habilidad Inicial", "Evento", "Logro"
),
'languages' => array( 'languages' => array(
1 => "Orco", 2 => "Darnassiano", 3 => "Taurahe", 6 => "Enánico", 7 => "Lengua común", 8 => "Demoníaco", 9 => "Titánico", 10 => "Thalassiano", 1 => "Orco", 2 => "Darnassiano", 3 => "Taurahe", 6 => "Enánico", 7 => "Lengua común", 8 => "Demoníaco", 9 => "Titánico", 10 => "Thalassiano",
11 => "Dracónico", 12 => "Kalimag", 13 => "Gnomótico", 14 => "Trol", 33 => "Viscerálico", 35 => "Draenei", 36 => "Zombie", 37 => "Binario gnomo", 38 => "Binario goblin" 11 => "Dracónico", 12 => "Kalimag", 13 => "Gnomótico", 14 => "Trol", 33 => "Viscerálico", 35 => "Draenei", 36 => "Zombie", 37 => "Binario gnomo", 38 => "Binario goblin"
@@ -572,6 +576,7 @@ $lang = array(
'usableBy' => "Usable por", 'usableBy' => "Usable por",
'buyout' => "Precio de venta en subasta", 'buyout' => "Precio de venta en subasta",
'each' => "cada uno", 'each' => "cada uno",
'tabOther' => "Otros",
'gems' => "Gemas", 'gems' => "Gemas",
'socketBonus' => "Bono de ranura", 'socketBonus' => "Bono de ranura",
'socket' => array( 'socket' => array(

View File

@@ -172,6 +172,10 @@ $lang = array(
'modes' => ['Standard / Normal 10', 'Héroïque / Normal 25', '10 héroïque', '25 héroïque'], 'modes' => ['Standard / Normal 10', 'Héroïque / Normal 25', '10 héroïque', '25 héroïque'],
'expansions' => array("Classique", "The Burning Crusade", "Wrath of the Lich King"), 'expansions' => array("Classique", "The Burning Crusade", "Wrath of the Lich King"),
'stats' => array("Force", "Agilité", "Endurance", "Intelligence", "Esprit"), 'stats' => array("Force", "Agilité", "Endurance", "Intelligence", "Esprit"),
'sources' => array(
null, "Fabriqué", "Butin", "JcJ", "Quête", "Vendeur", "Maître", "Découverte",
"Échange d'un code", "Talent", "Débutant", "Événement", "Haut fait"
),
'languages' => array( 'languages' => array(
1 => "Orc", 2 => "Darnassien", 3 => "Taurahe", 6 => "Nain", 7 => "Commun", 8 => "Démoniaque", 9 => "Titan", 10 => "Thalassien", 1 => "Orc", 2 => "Darnassien", 3 => "Taurahe", 6 => "Nain", 7 => "Commun", 8 => "Démoniaque", 9 => "Titan", 10 => "Thalassien",
11 => "Draconique", 12 => "Kalimag", 13 => "Gnome", 14 => "Troll", 33 => "Bas-parler", 35 => "Draeneï", 36 => "Zombie", 37 => "Binaire gnome", 38 => "Binaire gobelin" 11 => "Draconique", 12 => "Kalimag", 13 => "Gnome", 14 => "Troll", 33 => "Bas-parler", 35 => "Draeneï", 36 => "Zombie", 37 => "Binaire gnome", 38 => "Binaire gobelin"
@@ -572,6 +576,7 @@ $lang = array(
'usableBy' => "Utilisable par", 'usableBy' => "Utilisable par",
'buyout' => "Vente immédiate", 'buyout' => "Vente immédiate",
'each' => "chacun", 'each' => "chacun",
'tabOther' => "Autre",
'gems' => "Gemmes", 'gems' => "Gemmes",
'socketBonus' => "Bonus de châsse", 'socketBonus' => "Bonus de châsse",
'socket' => array( 'socket' => array(

View File

@@ -172,6 +172,10 @@ $lang = array(
'modes' => ['Обычный / 10-норм.', 'Героический / 25-норм.', '10-героич', '25-героич'], 'modes' => ['Обычный / 10-норм.', 'Героический / 25-норм.', '10-героич', '25-героич'],
'expansions' => array("World of Warcraft", "The Burning Crusade", "Wrath of the Lich King"), 'expansions' => array("World of Warcraft", "The Burning Crusade", "Wrath of the Lich King"),
'stats' => array("к силе", "к ловкости", "к выносливости", "к интеллекту", "к духу"), 'stats' => array("к силе", "к ловкости", "к выносливости", "к интеллекту", "к духу"),
'sources' => array(
null, "Ремесло", "Добыча", "PvP", "Задание", "Продавец", "Тренер", "Открытие",
"Рекламная акция", "Талант", "Начальное заклинание", "Мероприятие", "Достижение"
),
'languages' => array( 'languages' => array(
1 => "орочий", 2 => "дарнасский", 3 => "таурахэ", 6 => "дворфийский", 7 => "всеобщий", 8 => "язык демонов", 9 => "язык титанов", 10 => "талассийский", 1 => "орочий", 2 => "дарнасский", 3 => "таурахэ", 6 => "дворфийский", 7 => "всеобщий", 8 => "язык демонов", 9 => "язык титанов", 10 => "талассийский",
11 => "драконий", 12 => "калимаг", 13 => "гномский", 14 => "язык троллей", 33 => "наречие нежити", 35 => "дренейский", 36 => "наречие зомби", 37 => "машинный гномский", 38 => "машинный гоблинский" 11 => "драконий", 12 => "калимаг", 13 => "гномский", 14 => "язык троллей", 33 => "наречие нежити", 35 => "дренейский", 36 => "наречие зомби", 37 => "машинный гномский", 38 => "машинный гоблинский"
@@ -572,6 +576,7 @@ $lang = array(
'usableBy' => "Используется (кем)", 'usableBy' => "Используется (кем)",
'buyout' => "Цена выкупа", 'buyout' => "Цена выкупа",
'each' => "каждый", 'each' => "каждый",
'tabOther' => "Другое",
'gems' => "Самоцветы", 'gems' => "Самоцветы",
'socketBonus' => "При соответствии цвета", 'socketBonus' => "При соответствии цвета",
'socket' => array( 'socket' => array(

View File

@@ -158,39 +158,8 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
if (isset($filter['slot'][INVTYPE_SHIELD])) // "Off Hand" => "Shield" if (isset($filter['slot'][INVTYPE_SHIELD])) // "Off Hand" => "Shield"
$filter['slot'][INVTYPE_SHIELD] = Lang::$item['armorSubClass'][6]; $filter['slot'][INVTYPE_SHIELD] = Lang::$item['armorSubClass'][6];
/*
set conditions
*/
/*
* todo (low): this is a long term issue.
* Filter is used as a subSystem to each TypeList
* but here we would need to preemptive check for $filter['gb']
* .. bummer .. this is to be removed when the issue is _really_ solved
*
* ALSO upgradeItems .. Profiler can send them as lists, so multiple lv-tabs would occur
*
*/
$itemFilter = new ItemListFilter(); $itemFilter = new ItemListFilter();
if (preg_match('/gb\=(1|2|3)/i', $_SERVER['QUERY_STRING'], $match))
$filter['gb'] = $match[1];
if (isset($cats[0]))
$conditions[] = ['i.class', $cats[0]];
if (isset($cats[1]))
$conditions[] = ['i.subClass', $cats[1]];
if (isset($cats[2]))
$conditions[] = ['i.subSubClass', $cats[2]];
if ($_ = $itemFilter->getConditions())
$conditions[] = $_;
$items = new ItemList($conditions, ['extraOpts' => $itemFilter->extraOpts]);
$items->addGlobalsToJscript($smarty);
// recreate form selection // recreate form selection
$filter = array_merge($itemFilter->getForm('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;
@@ -206,6 +175,7 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
if (array_intersect([63, 64], $xCols)) // 63:buyPrice; 64:sellPrice if (array_intersect([63, 64], $xCols)) // 63:buyPrice; 64:sellPrice
$infoMask |= ITEMINFO_VENDOR; $infoMask |= ITEMINFO_VENDOR;
// menuId 0: Item g_initPath() // menuId 0: Item g_initPath()
// tabId 0: Database g_initHeader() // tabId 0: Database g_initHeader()
$pageData = array( $pageData = array(
@@ -220,89 +190,46 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter))
'?data=weight-presets' '?data=weight-presets'
) )
), ),
'lv' => array( 'lv' => array(
'data' => $items->getListviewData($infoMask), 'tabs' => [],
'params' => [] 'isGrouped' => false
) )
); );
if ($itemFilter->error)
$pageData['lv']['params']['_errors'] = '$1';
if (!empty($filter['upg'])) /*
{ set conditions
// upgrade-item got deleted by filter */
if (empty($pageData['lv']['data'][$filter['upg']]))
{
if ($w = $itemFilter->getForm('setWeights', true))
{
$upgItem = new ItemList(array(['id', $filter['upg']]), false, ['wt' => $w[0], 'wtv' => $w[1]]);
// still it may not be found if you apply really weired filters (e.g. search for a melee item with caster-weights) .. not my fault :[ if (isset($cats[0]))
if (!$upgItem->error) $conditions[] = ['i.class', $cats[0]];
{ if (isset($cats[1]))
$upgItem->addGlobalsToJScript($smarty); $conditions[] = ['i.subClass', $cats[1]];
$pageData['lv']['data'][$filter['upg']] = $upgItem->getListviewData($infoMask)[$filter['upg']]; if (isset($cats[2]))
} $conditions[] = ['i.subSubClass', $cats[2]];
}
}
if (!empty($filter['gb'])) if ($_ = $itemFilter->getConditions())
$pageData['lv']['params']['customFilter'] = '$fi_filterUpgradeListview'; $conditions[] = $_;
$pageData['lv']['params']['_upgradeIds'] = "$[".$filter['upg']."]";
}
/*
by level: max 10 itemlevel steps (Level X) +1x Other|Autre|Anderes|Otros|Другое levels
by slot: all slots available
by source: .. well .. no
template: 'item', /*
id: 'one-hand', shared parameter between all possible lv-tabs
name: 'One-Hand', */
tabs: tabsGroups,
parent: 'lkljbjkb574',
hideCount: 1,
note: $WH.sprintf(LANG.lvnote_viewmoreslot, '=2', 'sl=13;ub=10;cr=161;crs=1;crv=0;gm=3;rf=1;wt=23:123:24:103:96:170;wtv=100:85:75:60:50:40;upg=104585'),
customFilter: fi_filterUpgradeListview,
_upgradeIds: [104585],
extraCols: fi_getExtraCols(fi_extraCols, 3, 1, 0),
sort: ['-score', 'name'],
computeDataFunc: fi_scoreSockets,
onBeforeCreate: fi_initWeightedListview,
onAfterCreate: fi_addUpgradeIndicator,
hiddenCols: ['type', 'source'],
data: []
template: 'item', $sharedLvParams = [];
id: 'two-hand', $upgItemData = [];
name: 'Two-Hand',
tabs: tabsGroups,
parent: 'lkljbjkb574',
hideCount: 1,
note: $WH.sprintf(LANG.lvnote_viewmoreslot, '=2', 'sl=17;ub=10;cr=161;crs=1;crv=0;gm=3;rf=1;wt=23:123:24:103:96:170;wtv=100:85:75:60:50:40;upg=104585'),
customFilter: fi_filterUpgradeListview,
_upgradeIds: [104585],
extraCols: fi_getExtraCols(fi_extraCols, 3, 1, 0),
sort: ['-score', 'name'],
computeDataFunc: fi_scoreSockets,
onBeforeCreate: fi_initWeightedListview,
onAfterCreate: fi_addUpgradeIndicator,
hiddenCols: ['type', 'source'],
data: []
*/
if (!empty($filter['fi']['extraCols'])) if (!empty($filter['fi']['extraCols']))
{ {
$gem = empty($filter['gm']) ? 0 : $filter['gm']; $gem = empty($filter['gm']) ? 0 : $filter['gm'];
$cost = array_intersect([63], $xCols) ? 1 : 0; $cost = array_intersect([63], $xCols) ? 1 : 0;
$pageData['lv']['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, '.$gem.', '.$cost.')'; $sharedLvParams['extraCols'] = '$fi_getExtraCols(fi_extraCols, '.$gem.', '.$cost.')';
} }
if (!empty($filter['fi']['setWeights'])) if (!empty($filter['fi']['setWeights']))
{ {
if (!empty($filter['gm'])) if (!empty($filter['gm']))
{ {
$pageData['lv']['params']['computeDataFunc'] = '$fi_scoreSockets'; $sharedLvParams['computeDataFunc'] = '$fi_scoreSockets';
$w = $itemFilter->getForm('setWeights', true); $w = $itemFilter->getForm('setWeights', true);
$q = intVal($filter['gm']); $q = intVal($filter['gm']);
@@ -337,28 +264,201 @@ 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'; $sharedLvParams['onBeforeCreate'] = '$fi_initWeightedListview';
$pageData['lv']['params']['onAfterCreate'] = '$fi_addUpgradeIndicator'; $sharedLvParams['onAfterCreate'] = '$fi_addUpgradeIndicator';
$pageData['lv']['params']['sort'] = "$['-score', 'name']"; $sharedLvParams['sort'] = "$['-score', 'name']";
if ($items->hasSetFields(['armor']))
$visibleCols[] = 'armor';
array_push($hiddenCols, 'type', 'source'); array_push($hiddenCols, 'type', 'source');
} }
// create note if search limit was exceeded; overwriting 'note' is intentional if ($itemFilter->error)
if ($items->getMatches() > CFG_SQL_LIMIT_DEFAULT && empty($filter['upg'])) $sharedLvParams['_errors'] = '$1';
if (!empty($filter['upg']))
{ {
$pageData['lv']['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsfound', $items->getMatches(), CFG_SQL_LIMIT_DEFAULT); // v poke it to use item_stats
$pageData['lv']['params']['_truncated'] = 1; $upgItem = new ItemList(array(['id', $filter['upg']], ['is.id', null, '!']), ['extraOpts' => $itemFilter->extraOpts]);
if (!$upgItem->error)
{
$upgItem->addGlobalsToJScript($smarty);
$upgItemData = $upgItem->getListviewData($infoMask)[$filter['upg']];
}
// if (!empty($filter['gb']))
$sharedLvParams['customFilter'] = '$fi_filterUpgradeListview';
$sharedLvParams['_upgradeIds'] = "$[".$filter['upg']."]";
} }
if ($hiddenCols) /*
$pageData['lv']['params']['hiddenCols'] = '$'.json_encode($hiddenCols); * todo (low): this is a long term issue.
* upgradeItems .. Profiler can send them as lists, so multiple lv-tabs would occur
*
*/
if ($visibleCols) /*
$pageData['lv']['params']['visibleCols'] = '$'.json_encode($visibleCols); group by
*/
$availableSlots = array(
ITEM_CLASS_ARMOR => [INVTYPE_HEAD, INVTYPE_NECK, INVTYPE_SHOULDERS, INVTYPE_CHEST, INVTYPE_WAIST, INVTYPE_LEGS, INVTYPE_FEET, INVTYPE_WRISTS, INVTYPE_HANDS, INVTYPE_FINGER, INVTYPE_TRINKET, INVTYPE_SHIELD, INVTYPE_CLOAK],
ITEM_CLASS_WEAPON => [INVTYPE_WEAPON, INVTYPE_RANGED, INVTYPE_2HWEAPON, INVTYPE_WEAPONMAINHAND, INVTYPE_WEAPONOFFHAND, INVTYPE_THROWN, INVTYPE_HOLDABLE]
);
$sourcesGlobalToItem = [1 => 3, 2 => 4, 3 => 5, 4 => 6, 5 => 7, 6 => 8];
$groups = [];
$nameSource = [];
$field = '';
switch (@$filter['gb'])
{
// slot: (try to limit the lookups by class grouping and intersecting with preselected slots)
// if intersect yields an empty array no lookups will occur
case 1:
if (isset($cats[0]) && $cats[0] == ITEM_CLASS_ARMOR)
$groups = isset($filter['sl']) ? array_intersect($availableSlots[ITEM_CLASS_ARMOR], (array)$filter['sl']) : $availableSlots[ITEM_CLASS_ARMOR];
else if (isset($cats[0]) && $cats[0] == ITEM_CLASS_WEAPON)
$groups = isset($filter['sl']) ? array_intersect($availableSlots[ITEM_CLASS_WEAPON], (array)$filter['sl']) : $availableSlots[ITEM_CLASS_WEAPON];
else
{
$groups = array_merge($availableSlots[ITEM_CLASS_ARMOR], $availableSlots[ITEM_CLASS_WEAPON]);
if (isset($filter['sl']))
$groups = array_intersect($groups, (array)$filter['sl']);
}
if ($groups)
{
$nameSource = Lang::$item['inventoryType'];
$pageData['lv']['isGrouped'] = true;
$field = 'slot';
}
break;
// itemlevel: first, try to find 10 level steps within range (if given) as tabs
case 2:
$levelRef = new ItemList(array_merge($conditions, [10]), ['extraOpts' => ['i' => ['g' => 'itemlevel', 'o' => 'itemlevel DESC']]]);
foreach ($levelRef->iterate() as $_)
{
$l = $levelRef->getField('itemLevel');
$groups[] = $l;
$nameSource[$l] = Lang::$game['level'].' '.$l;
}
if ($groups)
{
$l = -end($groups);
$groups[] = $l; // push last value as negativ to signal misc group after this level
$nameSource[$l] = Lang::$item['tabOther'];
$pageData['lv']['isGrouped'] = true;
$field = 'itemlevel';
}
break;
// todo(med): source
// .. well .. no, not at the moment .. the databse doesn't event have a field for that
case 3:
$groups = array_filter(array_keys(Lang::$game['sources']));
if ($groups)
{
$nameSource = Lang::$game['sources'];
$pageData['lv']['isGrouped'] = true;
$field = 'source';
}
break;
// none
default:
$groups[0] = null;
}
foreach ($groups as $group)
{
$finalCnd = $field ? array_merge($conditions, [[$field, abs($group), $group > 0 ? null : '<'], 25]) : $conditions;
$items = new ItemList($finalCnd, ['extraOpts' => $itemFilter->extraOpts]);
$items->addGlobalsToJscript($smarty);
if ($items->error)
continue;
$data = $items->getListviewData($infoMask);
if ($upgItemData)
$data[$filter['upg']] = $upgItemData;
$tab = array(
'data' => $data,
'params' => $sharedLvParams
);
if ($field)
{
$tab['params']['id'] = $group > 0 ? $field.'-'.$group : 'other';
$tab['params']['name'] = $nameSource[$group];
$tab['params']['tabs'] = '$tabsGroups';
}
if (!empty($filter['fi']['setWeights']))
{
if ($items->hasSetFields(['armor']))
$visibleCols[] = 'armor';
}
// create note if search limit was exceeded; overwriting 'note' is intentional
if ($items->getMatches() > CFG_SQL_LIMIT_DEFAULT && empty($filter['upg']) && !$field)
{
$tab['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsfound', $items->getMatches(), CFG_SQL_LIMIT_DEFAULT);
$tab['params']['_truncated'] = 1;
}
else if ($field && $items->getMatches() > 25)
{
$tab['params']['_truncated'] = 1;
$addCr = [];
if ($field == 'slot')
{
$note = 'lvnote_viewmoreslot';
$override = ['sl' => $group, 'gb' => ''];
}
else if ($field == 'itemlevel')
{
$note = 'lvnote_viewmorelevel';
$override = ['minle' => $group, 'maxle' => $group, 'gb' => ''];
}
else if ($field == 'source')
{
if ($_ = @$sourcesGlobalToItem[$group])
{
$note = 'lvnote_viewmoresource';
$addCr = ['cr' => 128, 'crs' => $_, 'crv' => 0];
}
$override = ['gb' => ''];
}
$cls = isset($cats[0]) ? '='.$cats[0] : '';
$filterUrl = $itemFilter->urlize($override, $addCr);
if ($note)
$tab['params']['note'] = '$$WH.sprintf(LANG.'.$note.', \''.$cls.'\', \''.$filterUrl.'\')';
}
if ($hiddenCols)
$tab['params']['hiddenCols'] = '$'.json_encode($hiddenCols);
if ($visibleCols)
$tab['params']['visibleCols'] = '$'.json_encode($visibleCols);
if ($field)
$tab['params']['hideCount'] = '$1';
$pageData['lv']['tabs'][] = $tab;
}
// whoops, we have no data? create emergency content
if (!$pageData['lv']['tabs'])
{
$pageData['lv']['isGrouped'] = false;
$pageData['lv']['tabs'][] = ['data' => [], 'params' => []];
}
$smarty->saveCache($cacheKey, $pageData, $filter); $smarty->saveCache($cacheKey, $pageData, $filter);
} }

View File

@@ -636,7 +636,7 @@ function Profiler() {
_divAuras.id = 'aura-container'; _divAuras.id = 'aura-container';
_divAuras.style.cssFloat = 'left'; _divAuras.style.cssFloat = 'left';
_divAuras.style.marginLeft = '390px'; _divAuras.style.marginLeft = '390px';
_divAuras.style.width = '350px'; _divAuras.style.width = '325px';
_divAuras.style.display = 'none'; _divAuras.style.display = 'none';
_ = $WH.ce('h3'); _ = $WH.ce('h3');

View File

@@ -171,23 +171,21 @@
{/foreach} {/foreach}
//]]></script> //]]></script>
{if isset($lvData.data[0].params)} {if $lvData.isGrouped}
<div id="tabs-generic"></div> <div id="tabs-generic"></div>
{/if} {/if}
<div id="lv-generic" class="listview"></div> <div id="lv-generic" class="listview"></div>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
{if !empty($gemScores)}var fi_gemScores = {$gemScores};{/if} {if !empty($gemScores)}var fi_gemScores = {$gemScores};{/if}
{if isset($lvData.data[0].params)} {if $lvData.isGrouped}
var tabsRelated = new Tabs({ldelim}parent: $WH.ge('tabs-generic'){rdelim}); var tabsGroups = new Tabs({ldelim}parent: $WH.ge('tabs-generic'){rdelim});
{foreach from=$tabs item="tab"} {/if}
{if !empty($tab.data)} {foreach from=$lvData.tabs item="tab"}
{include file="listviews/item.tpl" data=$tab.data params=$tab.params} {include file="listviews/item.tpl" data=$tab.data params=$tab.params}
{/if}
{/foreach} {/foreach}
tabsRelated.flush(); {if $lvData.isGrouped}
{else} tabsGroups.flush();
{include file='listviews/item.tpl' data=$lvData.data params=$lvData.params}
{/if} {/if}
//]]></script> //]]></script>