Files
aowow/includes/types/areatrigger.class.php
Sarjuuk 16eabb90b6 Core/Cleanup
* move DBType Filter base to its own file under components
 * modernize class and its children
2025-08-05 21:12:23 +02:00

96 lines
2.9 KiB
PHP

<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class AreaTriggerList extends BaseType
{
use spawnHelper;
public static $type = Type::AREATRIGGER;
public static $brickFile = 'areatrigger';
public static $dataTable = '?_areatrigger';
public static $contribute = CONTRIBUTE_CO;
protected $queryBase = 'SELECT a.*, a.id AS ARRAY_KEY FROM ?_areatrigger a';
protected $queryOpts = array(
'a' => [['s']], // guid < 0 are teleporter targets, so exclude them here
's' => ['j' => ['?_spawns s ON s.`type` = 503 AND s.`typeId` = a.`id` AND s.`guid` > 0', true], 's' => ', GROUP_CONCAT(s.`areaId`) AS "areaId"', 'g' => 'a.`id`']
);
public function __construct(array $conditions = [], array $miscData = [])
{
parent::__construct($conditions, $miscData);
foreach ($this->iterate() as $id => &$_curTpl)
if (!$_curTpl['name'])
$_curTpl['name'] = 'Unnamed Areatrigger #' . $id;
}
public function getListviewData() : array
{
$data = [];
foreach ($this->iterate() as $__)
{
$data[$this->id] = array(
'id' => $this->curTpl['id'],
'type' => $this->curTpl['type'],
'name' => $this->curTpl['name'],
);
if ($_ = $this->curTpl['areaId'])
$data[$this->id]['location'] = explode(',', $_);
}
return $data;
}
public function getJSGlobals($addMask = GLOBALINFO_ANY)
{
return [];
}
public function renderTooltip() { }
}
class AreaTriggerListFilter extends Filter
{
protected string $type = 'areatrigger';
protected array $genericFilter = array(
2 => [parent::CR_NUMERIC, 'id', NUM_CAST_INT] // id
);
// fieldId => [checkType, checkValue[, fieldIsArray]]
protected array $inputFields = array(
'cr' => [parent::V_LIST, [2], true ], // criteria ids
'crs' => [parent::V_RANGE, [1, 6], true ], // criteria operators
'crv' => [parent::V_REGEX, parent::PATTERN_INT, true ], // criteria values - all criteria are numeric here
'na' => [parent::V_REGEX, parent::PATTERN_NAME, false], // name - only printable chars, no delimiter
'ma' => [parent::V_EQUAL, 1, false], // match any / all filter
'ty' => [parent::V_RANGE, [0, 5], true ] // types
);
protected function createSQLForValues() : array
{
$parts = [];
$_v = &$this->values;
// name [str]
if ($_v['na'])
if ($_ = $this->tokenizeString(['name']))
$parts[] = $_;
// type [list]
if ($_v['ty'])
$parts[] = ['type', $_v['ty']];
return $parts;
}
}
?>