mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Profiler/Filter
* implemented flag options when searching for strings
This commit is contained in:
@@ -76,6 +76,8 @@ class AjaxFilter extends AjaxHandler
|
|||||||
{
|
{
|
||||||
$url = '?'.$this->page;
|
$url = '?'.$this->page;
|
||||||
|
|
||||||
|
$this->filter->mergeCat($this->cat);
|
||||||
|
|
||||||
if ($this->cat)
|
if ($this->cat)
|
||||||
$url .= '='.implode('.', $this->cat);
|
$url .= '='.implode('.', $this->cat);
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ abstract class BaseType
|
|||||||
if ($x = $resolveCondition($foo, $supLink))
|
if ($x = $resolveCondition($foo, $supLink))
|
||||||
$sql[] = $x;
|
$sql[] = $x;
|
||||||
|
|
||||||
return '('.implode($subLink, $sql).')';
|
return $sql ? '('.implode($subLink, $sql).')' : null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -798,6 +798,12 @@ abstract class Filter
|
|||||||
return ['formData'];
|
return ['formData'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function mergeCat(&$cats)
|
||||||
|
{
|
||||||
|
foreach ($this->parentCats as $idx => $cat)
|
||||||
|
$cats[$idx] = $cat;
|
||||||
|
}
|
||||||
|
|
||||||
private function &criteriaIterator()
|
private function &criteriaIterator()
|
||||||
{
|
{
|
||||||
if (!$this->fiData['c'])
|
if (!$this->fiData['c'])
|
||||||
@@ -908,13 +914,13 @@ abstract class Filter
|
|||||||
{
|
{
|
||||||
$buff = [];
|
$buff = [];
|
||||||
foreach ((array)$val as $v)
|
foreach ((array)$val as $v)
|
||||||
if ($v !== '' && $this->checkInput($type, $valid, $v))
|
if ($v !== '' && $this->checkInput($type, $valid, $v) && $v !== '')
|
||||||
$buff[] = $v;
|
$buff[] = $v;
|
||||||
|
|
||||||
if ($buff)
|
if ($buff)
|
||||||
$this->fiData[$k][$inp] = $buff;
|
$this->fiData[$k][$inp] = $buff;
|
||||||
}
|
}
|
||||||
else if ($this->checkInput($type, $valid, $val))
|
else if ($val !== '' && $this->checkInput($type, $valid, $val) && $val !== '')
|
||||||
$this->fiData[$k][$inp] = $val;
|
$this->fiData[$k][$inp] = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -954,7 +960,7 @@ abstract class Filter
|
|||||||
{
|
{
|
||||||
$buff = [];
|
$buff = [];
|
||||||
foreach (explode(':', $val) as $v)
|
foreach (explode(':', $val) as $v)
|
||||||
if ($v !== '' && $this->checkInput($type, $valid, $v))
|
if ($v !== '' && $this->checkInput($type, $valid, $v) && $v !== '')
|
||||||
$buff[] = $v;
|
$buff[] = $v;
|
||||||
|
|
||||||
if ($buff)
|
if ($buff)
|
||||||
@@ -965,7 +971,7 @@ abstract class Filter
|
|||||||
$this->fiData[$k][$inp] = array_map(function ($x) { return strtr($x, Filter::$wCards); }, $buff);
|
$this->fiData[$k][$inp] = array_map(function ($x) { return strtr($x, Filter::$wCards); }, $buff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($this->checkInput($type, $valid, $val))
|
else if ($val !== '' && $this->checkInput($type, $valid, $val) && $val !== '')
|
||||||
{
|
{
|
||||||
if ($k == 'v')
|
if ($k == 'v')
|
||||||
$this->formData['form'][$inp] = $val;
|
$this->formData['form'][$inp] = $val;
|
||||||
@@ -997,10 +1003,10 @@ abstract class Filter
|
|||||||
$_crs = &$this->fiData['c']['crs'];
|
$_crs = &$this->fiData['c']['crs'];
|
||||||
$_crv = &$this->fiData['c']['crv'];
|
$_crv = &$this->fiData['c']['crv'];
|
||||||
|
|
||||||
if (count($_cr) != count($_crv) || count($_cr) != count($_crs))
|
if (count($_cr) != count($_crv) || count($_cr) != count($_crs) || count($_cr) > 5 || count($_crs) > 5 /*|| count($_crv) > 5*/)
|
||||||
{
|
{
|
||||||
// use min provided criterion as basis
|
// use min provided criterion as basis; 5 criteria at most
|
||||||
$min = min(count($_cr), count($_crv), count($_crs));
|
$min = max(5, min(count($_cr), count($_crv), count($_crs)));
|
||||||
if (count($_cr) > $min)
|
if (count($_cr) > $min)
|
||||||
array_splice($_cr, $min);
|
array_splice($_cr, $min);
|
||||||
|
|
||||||
@@ -1155,7 +1161,7 @@ abstract class Filter
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function modularizeString(array $fields, $string = '', $exact = false)
|
protected function modularizeString(array $fields, $string = '', $exact = false, $shortStr = false)
|
||||||
{
|
{
|
||||||
if (!$string && !empty($this->fiData['v']['na']))
|
if (!$string && !empty($this->fiData['v']['na']))
|
||||||
$string = $this->fiData['v']['na'];
|
$string = $this->fiData['v']['na'];
|
||||||
@@ -1168,9 +1174,9 @@ abstract class Filter
|
|||||||
$parts = array_filter(explode(' ', $string));
|
$parts = array_filter(explode(' ', $string));
|
||||||
foreach ($parts as $p)
|
foreach ($parts as $p)
|
||||||
{
|
{
|
||||||
if ($p[0] == '-' && mb_strlen($p) > 3)
|
if ($p[0] == '-' && (mb_strlen($p) > 3 || $shortStr))
|
||||||
$sub[] = [$f, sprintf($exPH, mb_substr($p, 1)), '!'];
|
$sub[] = [$f, sprintf($exPH, mb_substr($p, 1)), '!'];
|
||||||
else if ($p[0] != '-' && mb_strlen($p) > 2)
|
else if ($p[0] != '-' && (mb_strlen($p) > 2 || $shortStr))
|
||||||
$sub[] = [$f, sprintf($exPH, $p)];
|
$sub[] = [$f, sprintf($exPH, $p)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1258,12 +1264,12 @@ abstract class Filter
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function genericString($field, $value, $localized)
|
private function genericString($field, $value, $strFlags)
|
||||||
{
|
{
|
||||||
if ($localized)
|
if ($strFlags & STR_LOCALIZED)
|
||||||
$field .= '_loc'.User::$localeId;
|
$field .= '_loc'.User::$localeId;
|
||||||
|
|
||||||
return $this->modularizeString([$field], (string)$value);
|
return $this->modularizeString([$field], (string)$value, $strFlags & STR_MATCH_EXACT, $strFlags & STR_ALLOW_SHORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function genericNumeric($field, &$value, $op, $castInt)
|
private function genericNumeric($field, &$value, $op, $castInt)
|
||||||
@@ -1296,6 +1302,9 @@ abstract class Filter
|
|||||||
$gen = $this->genericFilter[$cr[0]];
|
$gen = $this->genericFilter[$cr[0]];
|
||||||
$result = null;
|
$result = null;
|
||||||
|
|
||||||
|
if(!isset($gen[2]))
|
||||||
|
$gen[2] = 0;
|
||||||
|
|
||||||
switch ($gen[0])
|
switch ($gen[0])
|
||||||
{
|
{
|
||||||
case FILTER_CR_NUMERIC:
|
case FILTER_CR_NUMERIC:
|
||||||
@@ -1312,7 +1321,7 @@ abstract class Filter
|
|||||||
$result = $this->genericBoolean($gen[1], $cr[1], !empty($gen[2]));
|
$result = $this->genericBoolean($gen[1], $cr[1], !empty($gen[2]));
|
||||||
break;
|
break;
|
||||||
case FILTER_CR_STRING:
|
case FILTER_CR_STRING:
|
||||||
$result = $this->genericString($gen[1], $cr[2], !empty($gen[2]));
|
$result = $this->genericString($gen[1], $cr[2], $gen[2]);
|
||||||
break;
|
break;
|
||||||
case FILTER_CR_ENUM:
|
case FILTER_CR_ENUM:
|
||||||
if (isset($this->enums[$cr[0]][$cr[1]]))
|
if (isset($this->enums[$cr[0]][$cr[1]]))
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ define('CC_FLAG_APPROVED', 0x8);
|
|||||||
define('SOUND_TYPE_OGG', 1);
|
define('SOUND_TYPE_OGG', 1);
|
||||||
define('SOUND_TYPE_MP3', 2);
|
define('SOUND_TYPE_MP3', 2);
|
||||||
|
|
||||||
|
define('CONTRIBUTE_NONE', 0x0);
|
||||||
define('CONTRIBUTE_CO', 0x1);
|
define('CONTRIBUTE_CO', 0x1);
|
||||||
define('CONTRIBUTE_SS', 0x2);
|
define('CONTRIBUTE_SS', 0x2);
|
||||||
define('CONTRIBUTE_VI', 0x4);
|
define('CONTRIBUTE_VI', 0x4);
|
||||||
@@ -229,6 +230,10 @@ define('NUM_CAST_FLOAT', 2);
|
|||||||
define('NUM_REQ_INT', 3);
|
define('NUM_REQ_INT', 3);
|
||||||
define('NUM_REQ_FLOAT', 4);
|
define('NUM_REQ_FLOAT', 4);
|
||||||
|
|
||||||
|
define('STR_LOCALIZED', 0x1);
|
||||||
|
define('STR_MATCH_EXACT', 0x2);
|
||||||
|
define('STR_ALLOW_SHORT', 0x4);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Game
|
* Game
|
||||||
*/
|
*/
|
||||||
@@ -389,6 +394,7 @@ define('SPELL_SCHOOL_NATURE', 3);
|
|||||||
define('SPELL_SCHOOL_FROST', 4);
|
define('SPELL_SCHOOL_FROST', 4);
|
||||||
define('SPELL_SCHOOL_SHADOW', 5);
|
define('SPELL_SCHOOL_SHADOW', 5);
|
||||||
define('SPELL_SCHOOL_ARCANE', 6);
|
define('SPELL_SCHOOL_ARCANE', 6);
|
||||||
|
define('SPELL_MAGIC_SCHOOLS', 0x7E);
|
||||||
define('SPELL_ALL_SCHOOLS', 0x7F);
|
define('SPELL_ALL_SCHOOLS', 0x7F);
|
||||||
|
|
||||||
// CharacterSlot
|
// CharacterSlot
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ class AchievementListFilter extends Filter
|
|||||||
|
|
||||||
protected $genericFilter = array( // misc (bool): _NUMERIC => useFloat; _STRING => localized; _FLAG => match Value; _BOOLEAN => stringSet
|
protected $genericFilter = array( // misc (bool): _NUMERIC => useFloat; _STRING => localized; _FLAG => match Value; _BOOLEAN => stringSet
|
||||||
2 => [FILTER_CR_BOOLEAN, 'reward_loc0', true ], // givesreward
|
2 => [FILTER_CR_BOOLEAN, 'reward_loc0', true ], // givesreward
|
||||||
3 => [FILTER_CR_STRING, 'reward', true ], // rewardtext
|
3 => [FILTER_CR_STRING, 'reward', STR_LOCALIZED ], // rewardtext
|
||||||
4 => [FILTER_CR_NYI_PH, null, 1, ], // location [enum]
|
4 => [FILTER_CR_NYI_PH, null, 1, ], // location [enum]
|
||||||
5 => [FILTER_CR_CALLBACK, 'cbSeries', ACHIEVEMENT_CU_FIRST_SERIES, null], // first in series [yn]
|
5 => [FILTER_CR_CALLBACK, 'cbSeries', ACHIEVEMENT_CU_FIRST_SERIES, null], // first in series [yn]
|
||||||
6 => [FILTER_CR_CALLBACK, 'cbSeries', ACHIEVEMENT_CU_LAST_SERIES, null], // last in series [yn]
|
6 => [FILTER_CR_CALLBACK, 'cbSeries', ACHIEVEMENT_CU_LAST_SERIES, null], // last in series [yn]
|
||||||
|
|||||||
@@ -1811,7 +1811,7 @@ class ItemListFilter extends Filter
|
|||||||
101 => [FILTER_CR_NUMERIC, 'is.rgdhastertng', NUM_CAST_INT, true ], // rgdhastertng
|
101 => [FILTER_CR_NUMERIC, 'is.rgdhastertng', NUM_CAST_INT, true ], // rgdhastertng
|
||||||
102 => [FILTER_CR_NUMERIC, 'is.splhastertng', NUM_CAST_INT, true ], // splhastertng
|
102 => [FILTER_CR_NUMERIC, 'is.splhastertng', NUM_CAST_INT, true ], // splhastertng
|
||||||
103 => [FILTER_CR_NUMERIC, 'is.hastertng', NUM_CAST_INT, true ], // hastertng
|
103 => [FILTER_CR_NUMERIC, 'is.hastertng', NUM_CAST_INT, true ], // hastertng
|
||||||
104 => [FILTER_CR_STRING, 'description', true ], // flavortext
|
104 => [FILTER_CR_STRING, 'description', STR_LOCALIZED ], // flavortext
|
||||||
105 => [FILTER_CR_NYI_PH, null, 1, ], // dropsinnormal [heroicdungeon-any]
|
105 => [FILTER_CR_NYI_PH, null, 1, ], // dropsinnormal [heroicdungeon-any]
|
||||||
106 => [FILTER_CR_NYI_PH, null, 1, ], // dropsinheroic [heroicdungeon-any]
|
106 => [FILTER_CR_NYI_PH, null, 1, ], // dropsinheroic [heroicdungeon-any]
|
||||||
107 => [FILTER_CR_NYI_PH, null, 1, ], // effecttext [str] not yet parsed ['effectsParsed_loc'.User::$localeId, $cr[2]]
|
107 => [FILTER_CR_NYI_PH, null, 1, ], // effecttext [str] not yet parsed ['effectsParsed_loc'.User::$localeId, $cr[2]]
|
||||||
@@ -2215,7 +2215,7 @@ class ItemListFilter extends Filter
|
|||||||
protected function cbArmorBonus($cr)
|
protected function cbArmorBonus($cr)
|
||||||
{
|
{
|
||||||
if (!Util::checkNumeric($cr[2], NUM_CAST_FLOAT) || !$this->int2Op($cr[1]))
|
if (!Util::checkNumeric($cr[2], NUM_CAST_FLOAT) || !$this->int2Op($cr[1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$this->formData['extraCols'][] = $cr[0];
|
$this->formData['extraCols'][] = $cr[0];
|
||||||
return ['AND', ['armordamagemodifier', $cr[2], $cr[1]], ['class', ITEM_CLASS_ARMOR]];
|
return ['AND', ['armordamagemodifier', $cr[2], $cr[1]], ['class', ITEM_CLASS_ARMOR]];
|
||||||
@@ -2529,7 +2529,7 @@ class ItemListFilter extends Filter
|
|||||||
return in_array($v, $sl);
|
return in_array($v, $sl);
|
||||||
|
|
||||||
// consumables - any; perm / temp item enhancements
|
// consumables - any; perm / temp item enhancements
|
||||||
else if ($c[0] == 0 && (!isset($c[1]) || in_array($c[1], [3, -6])))
|
else if ($c[0] == 0 && (!isset($c[1]) || in_array($c[1], [-3, 6])))
|
||||||
return in_array($v, $sl);
|
return in_array($v, $sl);
|
||||||
|
|
||||||
// weapons - always
|
// weapons - always
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ class ItemsetListFilter extends Filter
|
|||||||
protected $genericFilter = array( // misc (bool): _NUMERIC => useFloat; _STRING => localized; _FLAG => match Value; _BOOLEAN => stringSet
|
protected $genericFilter = array( // misc (bool): _NUMERIC => useFloat; _STRING => localized; _FLAG => match Value; _BOOLEAN => stringSet
|
||||||
2 => [FILTER_CR_NUMERIC, 'id', NUM_CAST_INT, true], // id
|
2 => [FILTER_CR_NUMERIC, 'id', NUM_CAST_INT, true], // id
|
||||||
3 => [FILTER_CR_NUMERIC, 'npieces', NUM_CAST_INT ], // pieces
|
3 => [FILTER_CR_NUMERIC, 'npieces', NUM_CAST_INT ], // pieces
|
||||||
4 => [FILTER_CR_STRING, 'bonusText', true ], // bonustext
|
4 => [FILTER_CR_STRING, 'bonusText', STR_LOCALIZED ], // bonustext
|
||||||
5 => [FILTER_CR_BOOLEAN, 'heroic', ], // heroic
|
5 => [FILTER_CR_BOOLEAN, 'heroic', ], // heroic
|
||||||
6 => [FILTER_CR_ENUM, 'e.holidayId', ], // relatedevent
|
6 => [FILTER_CR_ENUM, 'e.holidayId', ], // relatedevent
|
||||||
8 => [FILTER_CR_FLAG, 'cuFlags', CUSTOM_HAS_COMMENT ], // hascomments
|
8 => [FILTER_CR_FLAG, 'cuFlags', CUSTOM_HAS_COMMENT ], // hascomments
|
||||||
|
|||||||
Reference in New Issue
Block a user