Files
aowow/pages/enchantments.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

109 lines
3.4 KiB
PHP

<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 101: Enchantment g_initPath()
// tabId 0: Database g_initHeader()
class EnchantmentsPage extends GenericPage
{
use TrListPage;
protected $type = Type::ENCHANTMENT;
protected $tpl = 'enchantments';
protected $path = [0, 101];
protected $tabId = 0;
protected $mode = CACHE_TYPE_PAGE;
protected $scripts = [[SC_JS_FILE, 'js/filters.js']];
protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]];
public function __construct($pageCall, $pageParam)
{
$this->getCategoryFromUrl($pageParam);
parent::__construct($pageCall, $pageParam);
$this->filterObj = new EnchantmentListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
$this->name = Util::ucFirst(Lang::game('enchantments'));
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
}
protected function generateContent()
{
$tabData = array(
'data' => [],
'name' => Util::ucFirst(Lang::game('enchantments'))
);
$conditions = [];
if (!User::isInGroup(U_GROUP_EMPLOYEE))
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
$this->filterObj->evalCriteria();
if ($_ = $this->filterObj->getConditions())
$conditions[] = $_;
$ench = new EnchantmentList($conditions, ['calcTotal' => true]);
$tabData['data'] = array_values($ench->getListviewData());
$this->extendGlobalData($ench->getJSGlobals());
$xCols = [];
foreach (Stat::getFilterCriteriumIdFor() as $idx => $fiId)
if (array_filter(array_column($tabData['data'], Stat::getJsonString($idx))))
$xCols[] = $fiId;
// some kind of declaration conflict going on here..., expects colId for WEAPON_DAMAGE_MAX but jsonString is WEAPON_DAMAGE
if (array_filter(array_column($tabData['data'], 'dmg')))
$xCols[] = Stat::getFilterCriteriumId(Stat::WEAPON_DAMAGE_MAX);
if ($xCols)
$this->filterObj->fiExtraCols = array_merge($this->filterObj->fiExtraCols, $xCols);
if ($this->filterObj->fiExtraCols)
$tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
if ($ench->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
{
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_enchantmentsfound', $ench->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT'));
$tabData['_truncated'] = 1;
}
if (array_filter(array_column($tabData['data'], 'spells')))
$tabData['visibleCols'] = ['trigger'];
if (!$ench->hasSetFields('skillLine'))
$tabData['hiddenCols'] = ['skill'];
if ($this->filterObj->error)
$tabData['_errors'] = '$1';
$this->lvTabs[] = [EnchantmentList::$brickFile, $tabData, 'enchantment'];
}
protected function generateTitle()
{
$form = $this->filterObj->values;
if (count($form['ty']) == 1)
array_unshift($this->title, Lang::enchantment('types', $form['ty'][0]));
array_unshift($this->title, $this->name);
}
protected function generatePath()
{
$form = $this->filterObj->values;
if (count($form['ty']) == 1)
$this->path[] = $form['ty'][0];
}
}
?>