mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
* move checks to __construct so they can be run on $_POST data and don't create malformed filter urls * if we received malformed $_GET params, build new params and reload * do not store error state in cache * cleanup
103 lines
3.1 KiB
PHP
103 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Aowow;
|
|
|
|
if (!defined('AOWOW_REVISION'))
|
|
die('illegal access');
|
|
|
|
|
|
class AreatriggersBaseResponse extends TemplateResponse implements ICache
|
|
{
|
|
use TrListPage, TrCache;
|
|
|
|
protected int $type = Type::AREATRIGGER;
|
|
protected int $cacheType = CACHE_TYPE_LIST_PAGE;
|
|
protected int $requiredUserGroup = U_GROUP_STAFF;
|
|
|
|
protected string $template = 'areatriggers';
|
|
protected string $pageName = 'areatriggers';
|
|
protected ?int $activeTab = parent::TAB_DATABASE;
|
|
protected array $breadcrumb = [0, 102];
|
|
|
|
protected array $scripts = [[SC_JS_FILE, 'js/filters.js']];
|
|
protected array $expectedGET = ['filter' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => Filter::PATTERN_PARAM]]];
|
|
protected array $validCats = [0, 1, 2, 3, 4, 5];
|
|
|
|
public function __construct(string $pageParam)
|
|
{
|
|
$this->getCategoryFromUrl($pageParam);
|
|
|
|
if (isset($this->category[0]))
|
|
$this->forward('?areatriggers&filter=ty='.$this->category[0]);
|
|
|
|
parent::__construct($pageParam);
|
|
|
|
$this->filter = new AreaTriggerListFilter($this->_get['filter'] ?? '');
|
|
if ($this->filter->shouldReload)
|
|
{
|
|
$_SESSION['error']['fi'] = $this->filter::class;
|
|
$get = $this->filter->buildGETParam();
|
|
$this->forward('?' . $this->pageName . ($get ? '&filter=' . $get : ''));
|
|
}
|
|
$this->filterError = $this->filter->error;
|
|
}
|
|
|
|
protected function generate() : void
|
|
{
|
|
$this->h1 = Util::ucFirst(Lang::game('areatriggers'));
|
|
|
|
$fiForm = $this->filter->values;
|
|
|
|
|
|
/**************/
|
|
/* Page Title */
|
|
/**************/
|
|
|
|
array_unshift($this->title, $this->h1);
|
|
|
|
if (count($fiForm['ty']) == 1)
|
|
array_unshift($this->title, Lang::areatrigger('types', $fiForm['ty'][0]));
|
|
|
|
|
|
/*************/
|
|
/* Menu Path */
|
|
/*************/
|
|
|
|
if (count($fiForm['ty']) == 1)
|
|
$this->breadcrumb[] = $fiForm['ty'];
|
|
|
|
|
|
/****************/
|
|
/* Main Content */
|
|
/****************/
|
|
|
|
$this->redButtons[BUTTON_WOWHEAD] = false;
|
|
|
|
$conditions = [];
|
|
if ($_ = $this->filter->getConditions())
|
|
$conditions[] = $_;
|
|
|
|
$tabData = [];
|
|
$trigger = new AreaTriggerList($conditions, ['calcTotal' => true]);
|
|
if (!$trigger->error)
|
|
{
|
|
$tabData['data'] = $trigger->getListviewData();
|
|
|
|
// create note if search limit was exceeded; overwriting 'note' is intentional
|
|
if ($trigger->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
|
|
{
|
|
$tabData['note'] = sprintf(Util::$tryFilteringEntityString, $trigger->getMatches(), '"'.Lang::game('areatriggers').'"', Cfg::get('SQL_LIMIT_DEFAULT'));
|
|
$tabData['_truncated'] = 1;
|
|
}
|
|
}
|
|
|
|
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]);
|
|
|
|
$this->lvTabs->addListviewTab(new Listview($tabData, AreaTriggerList::$brickFile, 'areatrigger'));
|
|
|
|
parent::generate();
|
|
}
|
|
}
|
|
|
|
?>
|