Template/Update (Part 23)

* convert dbtype 'skill'
This commit is contained in:
Sarjuuk
2025-08-11 14:53:47 +02:00
parent cdb7e1e7ec
commit 64ef350e0d
3 changed files with 188 additions and 168 deletions

View File

@@ -6,65 +6,85 @@ if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 14: Skill g_initPath()
// tabId 0: Database g_initHeader()
class SkillPage extends GenericPage
class SkillBaseResponse extends TemplateResponse implements ICache
{
use TrDetailPage;
use TrDetailPage, TrCache;
protected $type = Type::SKILL;
protected $typeId = 0;
protected $tpl = 'detail-page-generic';
protected $path = [0, 14];
protected $tabId = 0;
protected $mode = CACHE_TYPE_PAGE;
protected int $cacheType = CACHE_TYPE_PAGE;
private $cat = 0;
protected string $template = 'detail-page-generic';
protected string $pageName = 'skill';
protected ?int $activeTab = parent::TAB_DATABASE;
protected array $breadcrumb = [0, 14];
public function __construct($pageCall, $id)
public int $type = Type::SKILL;
public int $typeId = 0;
private SkillList $subject;
public function __construct(string $id)
{
parent::__construct($pageCall, $id);
parent::__construct($id);
$this->typeId = intVal($id);
$this->typeId = intVal($id);
$this->contribute = Type::getClassAttrib($this->type, 'contribute') ?? CONTRIBUTE_NONE;
}
protected function generate() : void
{
$this->subject = new SkillList(array(['id', $this->typeId]));
if ($this->subject->error)
$this->notFound(Lang::game('skill'), Lang::skill('notFound'));
$this->generateNotFound(Lang::game('skill'), Lang::skill('notFound'));
$this->name = $this->subject->getField('name', true);
$this->cat = $this->subject->getField('typeCat');
}
$this->h1 = $this->subject->getField('name', true);
protected function generatePath()
{
$this->path[] = (in_array($this->cat, [9, 11]) || $this->typeId == 762) ? $this->typeId : $this->cat;
}
$this->gPageInfo += array(
'type' => $this->type,
'typeId' => $this->typeId,
'name' => $this->h1
);
$_cat = $this->subject->getField('typeCat');
/*************/
/* Menu Path */
/*************/
if (in_array($this->typeId, SKILLS_TRADE_PRIMARY) || in_array($this->typeId, SKILLS_TRADE_SECONDARY))
$this->breadcrumb[] = $this->typeId;
else
$this->breadcrumb[] = $_cat;
/**************/
/* Page Title */
/**************/
array_unshift($this->title, $this->h1, Util::ucFirst(Lang::game('skill')));
protected function generateTitle()
{
array_unshift($this->title, $this->name, Util::ucFirst(Lang::game('skill')));
}
protected function generateContent()
{
/***********/
/* Infobox */
/**********/
/***********/
$infobox = Lang::getInfoBoxForFlags(intval($this->subject->getField('cuFlags')));
$infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
// icon
if ($_ = $this->subject->getField('iconId'))
{
$infobox[] = Util::ucFirst(lang::game('icon')).Lang::main('colon').'[icondb='.$_.' name=true]';
$infobox[] = Util::ucFirst(Lang::game('icon')).Lang::main('colon').'[icondb='.$_.' name=true]';
$this->extendGlobalIds(Type::ICON, $_);
}
if ($infobox)
$this->infobox = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF, 'dbpage' => true], 'infobox-contents0');
/****************/
/* Main Content */
/****************/
$this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null;
$this->headIcons = [$this->subject->getField('iconString')];
$this->redButtons = array(
BUTTON_WOWHEAD => true,
@@ -72,13 +92,18 @@ class SkillPage extends GenericPage
);
if ($_ = $this->subject->getField('description', true))
$this->extraText = $_;
$this->extraText = new Markup($_, ['dbpage' => true, 'allow' => Markup::CLASS_ADMIN], 'text-generic');
/**************/
/* Extra Tabs */
/**************/
if (in_array($this->cat, [-5, 9, 11]))
parent::generate();
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated', true);
if (in_array($_cat, [-5, 9, 11]))
{
// tab: recipes [spells] (crafted)
$condition = array(
@@ -91,18 +116,17 @@ class SkillPage extends GenericPage
if (!$recipes->error)
{
$this->extendGlobalData($recipes->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$this->lvTabs[] = [SpellList::$brickFile, array(
'data' => array_values($recipes->getListviewData()),
$this->lvTabs->addListviewTab(new Listview(array(
'data' => $recipes->getListviewData(),
'id' => 'recipes',
'name' => '$LANG.tab_recipes',
'visibleCols' => ['reagents', 'source'],
'note' => sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.$this->typeId.'&filter=cr=20;crs=1;crv=0')
)];
'note' => sprintf(Util::$filterResultString, '?spells='.$_cat.'.'.$this->typeId.'&filter=cr=20;crs=1;crv=0')
), SpellList::$brickFile));
}
// tab: recipe Items [items] (Books)
$filterRecipe = [null, 165, 197, 202, 164, 185, 171, 129, 333, 356, 755, 773, 186, 182];
$filterRecipe = [null, SKILL_LEATHERWORKING, SKILL_TAILORING, SKILL_ENGINEERING, SKILL_BLACKSMITHING, SKILL_COOKING, SKILL_ALCHEMY, SKILL_FIRST_AID, SKILL_ENCHANTING, SKILL_FISHING, SKILL_JEWELCRAFTING, SKILL_INSCRIPTION, SKILL_MINING, SKILL_HERBALISM];
$conditions = array(
['requiredSkill', $this->typeId],
['class', ITEM_CLASS_RECIPE],
@@ -115,7 +139,7 @@ class SkillPage extends GenericPage
$this->extendGlobalData($recipeItems->getJSGlobals(GLOBALINFO_SELF));
$tabData = array(
'data' => array_values($recipeItems->getListviewData()),
'data' => $recipeItems->getListviewData(),
'id' => 'recipe-items',
'name' => '$LANG.tab_recipeitems',
);
@@ -123,12 +147,11 @@ class SkillPage extends GenericPage
if ($_ = array_search($this->typeId, $filterRecipe))
$tabData['note'] = sprintf(Util::$filterResultString, "?items=9.".$_);
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
$this->lvTabs->addListviewTab(new Listview($tabData, ItemList::$brickFile));
}
// tab: crafted items [items]
$filterItem = [null, 171, 164, 185, 333, 202, 129, 755, 165, 186, 197, null, null, 356, 182, 773];
$created = [];
$created = [];
foreach ($recipes->iterate() as $__)
if ($idx = $recipes->canCreateItem())
foreach ($idx as $i)
@@ -142,15 +165,15 @@ class SkillPage extends GenericPage
$this->extendGlobalData($created->getJSGlobals(GLOBALINFO_SELF));
$tabData = array(
'data' => array_values($created->getListviewData()),
'data' => $created->getListviewData(),
'id' => 'crafted-items',
'name' => '$LANG.tab_crafteditems',
);
if ($_ = array_search($this->typeId, $filterItem))
if (!is_null($_ = ItemListFilter::getCriteriaIndex(86, $this->typeId)))
$tabData['note'] = sprintf(Util::$filterResultString, "?items&filter=cr=86;crs=".$_.";crv=0");
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
$this->lvTabs->addListviewTab(new Listview($tabData, ItemList::$brickFile));
}
}
@@ -167,15 +190,15 @@ class SkillPage extends GenericPage
$this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF));
$tabData = array(
'data' => array_values($reqBy->getListviewData()),
'data' => $reqBy->getListviewData(),
'id' => 'required-by',
'name' => '$LANG.tab_requiredby',
);
if ($_ = array_search($this->typeId, $filterItem))
$tabData['note'] = sprintf(Util::$filterResultString, "?items&filter=99:168;crs=".$_.":2;crv=0:0");
if (!is_null($_ = ItemListFilter::getCriteriaIndex(99, $this->typeId)))
$tabData['note'] = sprintf(Util::$filterResultString, "?items&filter=cr=99:168;crs=".$_.":2;crv=0:0");
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
$this->lvTabs->addListviewTab(new Listview($tabData, ItemList::$brickFile));
}
// tab: required by [itemset]
@@ -189,11 +212,11 @@ class SkillPage extends GenericPage
{
$this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF));
$this->lvTabs[] = [ItemsetList::$brickFile, array(
'data' => array_values($reqBy->getListviewData()),
$this->lvTabs->addListviewTab(new Listview(array(
'data' => $reqBy->getListviewData(),
'id' => 'required-by-set',
'name' => '$LANG.tab_requiredby'
)];
), ItemsetList::$brickFile));
}
}
@@ -207,8 +230,8 @@ class SkillPage extends GenericPage
);
foreach (Game::$skillLineMask as $line1 => $sets)
foreach ($sets as $idx => $set)
if ($set[1] == $this->typeId)
foreach ($sets as $idx => [, $skillLineId])
if ($skillLineId == $this->typeId)
{
$condition[1][] = array('AND', ['s.skillLine1', $line1], ['s.skillLine2OrMask', 1 << $idx, '&']);
break 2;
@@ -226,90 +249,81 @@ class SkillPage extends GenericPage
$this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF));
$tabData = array(
'data' => array_values($spells->getListviewData()),
'data' => $spells->getListviewData(),
'visibleCols' => ['source']
);
switch ($this->cat)
{
case -4:
$tabData['note'] = sprintf(Util::$filterResultString, '?spells=-4');
break;
case 7:
if ($this->typeId != 769) // Internal
$tabData['note'] = sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.(log($reqClass, 2) + 1).'.'.$this->typeId); // doesn't matter what spell; reqClass should be identical for all Class Spells
break;
case 9:
case 11:
$tabData['note'] = sprintf(Util::$filterResultString, '?spells='.$this->cat.'.'.$this->typeId);
break;
}
if ($this->typeId != 769) // Internal
$tabData['note'] = match ($_cat)
{
-4, 7 => sprintf(Util::$filterResultString, '?spells=-4'),
7 => sprintf(Util::$filterResultString, '?spells='.$_cat.'.'.ChrClass::fromMask($reqClass)[0].'.'.$this->typeId), // doesn't matter what spell; reqClass should be identical for all Class Spells
9, 11 => sprintf(Util::$filterResultString, '?spells='.$_cat.'.'.$this->typeId),
default => null
};
$this->lvTabs[] = [SpellList::$brickFile, $tabData];
$this->lvTabs->addListviewTab(new Listview($tabData, SpellList::$brickFile));
}
// tab: trainers [npcs]
if (in_array($this->cat, [-5, 6, 7, 8, 9, 11]))
if (in_array($_cat, [-5, 6, 7, 8, 9, 11]))
{
$mask = 0;
foreach (Game::$skillLineMask[-3] as $idx => $pair)
if ($pair[1] == $this->typeId)
foreach (Game::$skillLineMask[-3] as $idx => [, $skillLineId])
if ($skillLineId == $this->typeId)
$mask |= 1 << $idx;
$spellIds = DB::Aowow()->selectCol(
'SELECT id FROM ?_spell WHERE (skillLine1 = ?d OR (skillLine1 > 0 AND skillLine2OrMask = ?d) {OR (skillLine1 = -3 AND skillLine2OrMask = ?d)})',
'SELECT `id` FROM ?_spell WHERE (`skillLine1` = ?d OR (`skillLine1` > 0 AND `skillLine2OrMask` = ?d) {OR (`skillLine1` = -3 AND `skillLine2OrMask` = ?d)})',
$this->typeId,
$this->typeId,
$mask ?: DBSIMPLE_SKIP
);
$list = $spellIds ? DB::World()->selectCol('SELECT cdt.CreatureId FROM creature_default_trainer cdt JOIN trainer_spell ts ON ts.TrainerId = cdt.TrainerId WHERE ts.SpellID IN (?a)', $spellIds) : [];
$list = $spellIds ? DB::World()->selectCol('SELECT cdt.`CreatureId` FROM creature_default_trainer cdt JOIN trainer_spell ts ON ts.`TrainerId` = cdt.`TrainerId` WHERE ts.`SpellID` IN (?a)', $spellIds) : [];
if ($list)
{
$this->addScript([SC_JS_FILE, '?data=zones']);
$trainer = new CreatureList(array(Cfg::get('SQL_LIMIT_NONE'), ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&']));
if (!$trainer->error)
{
$this->extendGlobalData($trainer->getJSGlobals());
$this->lvTabs[] = [CreatureList::$brickFile, array(
'data' => array_values($trainer->getListviewData()),
$this->addDataLoader('zones');
$this->lvTabs->addListviewTab(new Listview(array(
'data' => $trainer->getListviewData(),
'id' => 'trainer',
'name' => '$LANG.tab_trainers',
)];
), CreatureList::$brickFile));
}
}
}
// tab: quests [quests]
if (in_array($this->cat, [9, 11])) // only for professions
// only for professions
$sort = match ($this->typeId)
{
$sort = 0;
switch ($this->typeId)
{
case SKILL_HERBALISM: $sort = 24; break;
case SKILL_FISHING: $sort = 101; break;
case SKILL_BLACKSMITHING: $sort = 121; break;
case SKILL_ALCHEMY: $sort = 181; break;
case SKILL_LEATHERWORKING: $sort = 182; break;
case SKILL_ENGINEERING: $sort = 201; break;
case SKILL_TAILORING: $sort = 264; break;
case SKILL_COOKING: $sort = 304; break;
case SKILL_FIRST_AID: $sort = 324; break;
case SKILL_INSCRIPTION: $sort = 371; break;
case SKILL_JEWELCRAFTING: $sort = 373; break;
}
SKILL_HERBALISM => 24,
SKILL_FISHING => 101,
SKILL_BLACKSMITHING => 121,
SKILL_ALCHEMY => 181,
SKILL_LEATHERWORKING => 182,
SKILL_ENGINEERING => 201,
SKILL_TAILORING => 264,
SKILL_COOKING => 304,
SKILL_FIRST_AID => 324,
SKILL_INSCRIPTION => 371,
SKILL_JEWELCRAFTING => 373,
default => 0
};
if ($sort)
if ($sort)
{
$quests = new QuestList(array(['zoneOrSort', -$sort], Cfg::get('SQL_LIMIT_NONE')));
if (!$quests->error)
{
$quests = new QuestList(array(['zoneOrSort', -$sort], Cfg::get('SQL_LIMIT_NONE')));
if (!$quests->error)
{
$this->extendGlobalData($quests->getJSGlobals());
$this->lvTabs[] = [QuestList::$brickFile, ['data' => array_values($quests->getListviewData())]];
}
$this->extendGlobalData($quests->getJSGlobals());
$this->lvTabs->addListviewTab(new Listview(['data' => $quests->getListviewData()], QuestList::$brickFile));
}
}
@@ -318,7 +332,7 @@ class SkillPage extends GenericPage
{
$classes = new CharClassList(array(['id', $class]));
if (!$classes->error)
$this->lvTabs[] = [CharClassList::$brickFile, ['data' => array_values($classes->getListviewData())]];
$this->lvTabs->addListviewTab(new Listview(['data' => $classes->getListviewData()], CharClassList::$brickFile));
}
// tab: related races (apply races from [spells])
@@ -326,7 +340,7 @@ class SkillPage extends GenericPage
{
$races = new CharRaceList(array(['id', $race]));
if (!$races->error)
$this->lvTabs[] = [CharRaceList::$brickFile, ['data' => array_values($races->getListviewData())]];
$this->lvTabs->addListviewTab(new Listview(['data' => $races->getListviewData()], CharRaceList::$brickFile));
}
// tab: condition-for
@@ -335,10 +349,9 @@ class SkillPage extends GenericPage
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{
$this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $tab;
$this->lvTabs->addDataTab(...$tab);
}
}
}
?>

View File

@@ -0,0 +1,66 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class SkillsBaseResponse extends TemplateResponse implements ICache
{
use TrListPage, TrCache;
protected int $type = Type::SKILL;
protected int $cacheType = CACHE_TYPE_PAGE;
protected string $template = 'list-page-generic';
protected string $pageName = 'skills';
protected ?int $activeTab = parent::TAB_DATABASE;
protected array $breadcrumb = [0, 14];
protected array $validCats = [-6, -5, -4, 6, 7, 8, 9, 10, 11];
public function __construct(string $pageParam)
{
$this->getCategoryFromUrl($pageParam);
parent::__construct($pageParam);
}
protected function generate() : void
{
$this->h1 = Util::ucFirst(Lang::game('skills'));
if ($this->category)
$this->breadcrumb[] = $this->category[0];
array_unshift($this->title, $this->h1);
if ($this->category)
array_unshift($this->title, Lang::skill('cat', $this->category[0]));
$this->redButtons[BUTTON_WOWHEAD] = true;
$conditions = [];
if (!User::isInGroup(U_GROUP_EMPLOYEE))
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
if ($this->category)
$conditions[] = ['typeCat', $this->category[0]];
$tabData = ['data' => []];
$skills = new SkillList($conditions);
if (!$skills->error)
$tabData['data'] = $skills->getListviewData();
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]);
$this->lvTabs->addListviewTab(new Listview($tabData, SkillList::$brickFile));
parent::generate();
}
}
?>

View File

@@ -1,59 +0,0 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 14: Skill g_initPath()
// tabId 0: Database g_initHeader()
class SkillsPage extends GenericPage
{
use TrListPage;
protected $type = Type::SKILL;
protected $tpl = 'list-page-generic';
protected $path = [0, 14];
protected $tabId = 0;
protected $mode = CACHE_TYPE_PAGE;
protected $validCats = [-6, -5, -4, 6, 7, 8, 9, 10, 11];
public function __construct($pageCall, $pageParam)
{
$this->getCategoryFromUrl($pageParam);
parent::__construct($pageCall, $pageParam);
$this->name = Util::ucFirst(Lang::game('skills'));
}
protected function generateContent()
{
$conditions = [];
if (!User::isInGroup(U_GROUP_EMPLOYEE))
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
if ($this->category)
$conditions[] = ['typeCat', $this->category[0]];
$skills = new SkillList($conditions);
$this->lvTabs[] = [SkillList::$brickFile, ['data' => array_values($skills->getListviewData())]];
}
protected function generateTitle()
{
if ($this->category)
array_unshift($this->title, Lang::skill('cat', $this->category[0]));
}
protected function generatePath()
{
if ($this->category)
$this->path[] = $this->category[0];
}
}
?>