mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Template/Update (Part 22)
* convert dbtype 'pet'
This commit is contained in:
@@ -6,46 +6,61 @@ if (!defined('AOWOW_REVISION'))
|
|||||||
die('illegal access');
|
die('illegal access');
|
||||||
|
|
||||||
|
|
||||||
// menuId 8: Pets g_initPath()
|
class PetBaseResponse extends TemplateResponse implements ICache
|
||||||
// tabid 0: Database g_initHeader()
|
|
||||||
class PetPage extends GenericPage
|
|
||||||
{
|
{
|
||||||
use TrDetailPage;
|
use TrDetailPage, TrCache;
|
||||||
|
|
||||||
protected $type = Type::PET;
|
protected int $cacheType = CACHE_TYPE_PAGE;
|
||||||
protected $typeId = 0;
|
|
||||||
protected $tpl = 'detail-page-generic';
|
|
||||||
protected $path = [0, 8];
|
|
||||||
protected $tabId = 0;
|
|
||||||
protected $mode = CACHE_TYPE_PAGE;
|
|
||||||
protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']];
|
|
||||||
|
|
||||||
public function __construct($pageCall, $id)
|
protected string $template = 'detail-page-generic';
|
||||||
|
protected string $pageName = 'pet';
|
||||||
|
protected ?int $activeTab = parent::TAB_DATABASE;
|
||||||
|
protected array $breadcrumb = [0, 8];
|
||||||
|
|
||||||
|
protected array $scripts = [[SC_JS_FILE, 'js/swfobject.js']];
|
||||||
|
|
||||||
|
public int $type = Type::PET;
|
||||||
|
public int $typeId = 0;
|
||||||
|
public ?string $expansion = null;
|
||||||
|
|
||||||
|
private PetList $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 PetList(array(['id', $this->typeId]));
|
$this->subject = new PetList(array(['id', $this->typeId]));
|
||||||
if ($this->subject->error)
|
if ($this->subject->error)
|
||||||
$this->notFound(Lang::game('pet'), Lang::pet('notFound'));
|
$this->generateNotFound(Lang::game('pet'), Lang::pet('notFound'));
|
||||||
|
|
||||||
$this->name = $this->subject->getField('name', true);
|
$this->h1 = $this->subject->getField('name', true);
|
||||||
}
|
|
||||||
|
|
||||||
protected function generatePath()
|
$this->gPageInfo += array(
|
||||||
{
|
'type' => $this->type,
|
||||||
$this->path[] = $this->subject->getField('type');
|
'typeId' => $this->typeId,
|
||||||
}
|
'name' => $this->h1
|
||||||
|
);
|
||||||
|
|
||||||
protected function generateTitle()
|
|
||||||
{
|
|
||||||
array_unshift($this->title, $this->name, Util::ucFirst(Lang::game('pet')));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generateContent()
|
/*************/
|
||||||
{
|
/* Menu Path */
|
||||||
$this->addScript([SC_JS_FILE, '?data=zones']);
|
/*************/
|
||||||
|
|
||||||
|
$this->breadcrumb[] = $this->subject->getField('type');
|
||||||
|
|
||||||
|
|
||||||
|
/**************/
|
||||||
|
/* Page Title */
|
||||||
|
/**************/
|
||||||
|
|
||||||
|
array_unshift($this->title, $this->h1, Util::ucFirst(Lang::game('pet')));
|
||||||
|
|
||||||
|
|
||||||
/***********/
|
/***********/
|
||||||
/* Infobox */
|
/* Infobox */
|
||||||
@@ -67,11 +82,14 @@ class PetPage extends GenericPage
|
|||||||
$this->extendGlobalIds(Type::ICON, $_);
|
$this->extendGlobalIds(Type::ICON, $_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($infobox)
|
||||||
|
$this->infobox = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF, 'dbpage' => true], 'infobox-contents0');
|
||||||
|
|
||||||
|
|
||||||
/****************/
|
/****************/
|
||||||
/* Main Content */
|
/* Main Content */
|
||||||
/****************/
|
/****************/
|
||||||
|
|
||||||
$this->infobox = '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]';
|
|
||||||
$this->headIcons = [$this->subject->getField('iconString')];
|
$this->headIcons = [$this->subject->getField('iconString')];
|
||||||
$this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
|
$this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
|
||||||
$this->redButtons = array(
|
$this->redButtons = array(
|
||||||
@@ -80,14 +98,17 @@ class PetPage extends GenericPage
|
|||||||
BUTTON_TALENT => ['href' => '?petcalc#'.Util::$tcEncoding[(int)($this->typeId / 10)] . Util::$tcEncoding[(2 * ($this->typeId % 10) + ($this->subject->getField('exotic') ? 1 : 0))], 'pet' => true]
|
BUTTON_TALENT => ['href' => '?petcalc#'.Util::$tcEncoding[(int)($this->typeId / 10)] . Util::$tcEncoding[(2 * ($this->typeId % 10) + ($this->subject->getField('exotic') ? 1 : 0))], 'pet' => true]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**************/
|
/**************/
|
||||||
/* Extra Tabs */
|
/* Extra Tabs */
|
||||||
/**************/
|
/**************/
|
||||||
|
|
||||||
|
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated', true);
|
||||||
|
|
||||||
// tab: tameable & gallery
|
// tab: tameable & gallery
|
||||||
$condition = array(
|
$condition = array(
|
||||||
['ct.type', 1], // Beast
|
['ct.type', 1], // Beast
|
||||||
['ct.typeFlags', 0x1, '&'], // tameable
|
['ct.typeFlags', NPC_TYPEFLAG_TAMEABLE, '&'],
|
||||||
['ct.family', $this->typeId], // displayed petType
|
['ct.family', $this->typeId], // displayed petType
|
||||||
[
|
[
|
||||||
'OR', // at least neutral to at least one faction
|
'OR', // at least neutral to at least one faction
|
||||||
@@ -97,17 +118,17 @@ class PetPage extends GenericPage
|
|||||||
);
|
);
|
||||||
$tng = new CreatureList($condition);
|
$tng = new CreatureList($condition);
|
||||||
|
|
||||||
$this->lvTabs[] = [CreatureList::$brickFile, array(
|
$this->addDataLoader('zones');
|
||||||
'data' => array_values($tng->getListviewData(NPCINFO_TAMEABLE)),
|
$this->lvTabs->addListviewTab(new Listview(array(
|
||||||
|
'data' => $tng->getListviewData(NPCINFO_TAMEABLE),
|
||||||
'name' => '$LANG.tab_tameable',
|
'name' => '$LANG.tab_tameable',
|
||||||
'hiddenCols' => ['type'],
|
'hiddenCols' => ['type'],
|
||||||
'visibleCols' => ['skin'],
|
'visibleCols' => ['skin'],
|
||||||
'note' => sprintf(Util::$filterResultString, '?npcs=1&filter=fa=38'),
|
'note' => sprintf(Util::$filterResultString, '?npcs=1&filter=fa=38'),
|
||||||
'id' => 'tameable'
|
'id' => 'tameable'
|
||||||
)];
|
), CreatureList::$brickFile));
|
||||||
$this->lvTabs[] = ['model', array(
|
|
||||||
'data' => array_values($tng->getListviewData(NPCINFO_MODEL))
|
$this->lvTabs->addListviewTab(new Listview(['data' => $tng->getListviewData(NPCINFO_MODEL)], 'model'));
|
||||||
)];
|
|
||||||
|
|
||||||
// tab: diet
|
// tab: diet
|
||||||
$list = [];
|
$list = [];
|
||||||
@@ -116,22 +137,22 @@ class PetPage extends GenericPage
|
|||||||
if ($mask & (1 << ($i - 1)))
|
if ($mask & (1 << ($i - 1)))
|
||||||
$list[] = $i;
|
$list[] = $i;
|
||||||
|
|
||||||
$food = new ItemList(array(['i.subClass', [5, 8]], ['i.FoodType', $list], Cfg::get('SQL_LIMIT_NONE')));
|
$food = new ItemList(array(['i.subClass', [ITEM_SUBCLASS_FOOD, ITEM_SUBCLASS_MISC_CONSUMABLE]], ['i.FoodType', $list], Cfg::get('SQL_LIMIT_NONE')));
|
||||||
$this->extendGlobalData($food->getJSGlobals());
|
$this->extendGlobalData($food->getJSGlobals());
|
||||||
|
|
||||||
$this->lvTabs[] = [ItemList::$brickFile, array(
|
$this->lvTabs->addListviewTab(new Listview(array(
|
||||||
'data' => array_values($food->getListviewData()),
|
'data' => $food->getListviewData(),
|
||||||
'name' => '$LANG.diet',
|
'name' => '$LANG.diet',
|
||||||
'hiddenCols' => ['source', 'slot', 'side'],
|
'hiddenCols' => ['source', 'slot', 'side'],
|
||||||
'sort' => ['level'],
|
'sort' => ['level'],
|
||||||
'id' => 'diet'
|
'id' => 'diet'
|
||||||
)];
|
), ItemList::$brickFile));
|
||||||
|
|
||||||
// tab: spells
|
// tab: spells
|
||||||
$mask = 0x0;
|
$mask = 0x0;
|
||||||
foreach (Game::$skillLineMask[-1] as $idx => $pair)
|
foreach (Game::$skillLineMask[-1] as $idx => [$familyId,])
|
||||||
{
|
{
|
||||||
if ($pair[0] == $this->typeId)
|
if ($familyId == $this->typeId)
|
||||||
{
|
{
|
||||||
$mask = 1 << $idx;
|
$mask = 1 << $idx;
|
||||||
break;
|
break;
|
||||||
@@ -153,12 +174,12 @@ class PetPage extends GenericPage
|
|||||||
$spells = new SpellList($conditions);
|
$spells = new SpellList($conditions);
|
||||||
$this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF));
|
$this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF));
|
||||||
|
|
||||||
$this->lvTabs[] = [SpellList::$brickFile, array(
|
$this->lvTabs->addListviewTab(new Listview(array(
|
||||||
'data' => array_values($spells->getListviewData()),
|
'data' => $spells->getListviewData(),
|
||||||
'name' => '$LANG.tab_abilities',
|
'name' => '$LANG.tab_abilities',
|
||||||
'visibleCols' => ['schools', 'level'],
|
'visibleCols' => ['schools', 'level'],
|
||||||
'id' => 'abilities'
|
'id' => 'abilities'
|
||||||
)];
|
), SpellList::$brickFile));
|
||||||
|
|
||||||
// tab: talents
|
// tab: talents
|
||||||
$conditions = array(
|
$conditions = array(
|
||||||
@@ -170,24 +191,26 @@ class PetPage extends GenericPage
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
switch ($this->subject->getField('type'))
|
$conditions[] = match($this->subject->getField('type'))
|
||||||
{
|
{
|
||||||
case 0: $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE0, '&']; break;
|
PET_TALENT_TYPE_FEROCITY => ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE0, '&'],
|
||||||
case 1: $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE1, '&']; break;
|
PET_TALENT_TYPE_TENACITY => ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE1, '&'],
|
||||||
case 2: $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE2, '&']; break;
|
PET_TALENT_TYPE_CUNNING => ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE2, '&']
|
||||||
}
|
};
|
||||||
|
|
||||||
$talents = new SpellList($conditions);
|
$talents = new SpellList($conditions);
|
||||||
$this->extendGlobalData($talents->getJSGlobals(GLOBALINFO_SELF));
|
$this->extendGlobalData($talents->getJSGlobals(GLOBALINFO_SELF));
|
||||||
|
|
||||||
$this->lvTabs[] = [SpellList::$brickFile, array(
|
$this->lvTabs->addListviewTab(new Listview(array(
|
||||||
'data' => array_values($talents->getListviewData()),
|
'data' => $talents->getListviewData(),
|
||||||
'visibleCols' => ['tier', 'level'],
|
'visibleCols' => ['tier', 'level'],
|
||||||
'name' => '$LANG.tab_talents',
|
'name' => '$LANG.tab_talents',
|
||||||
'id' => 'talents',
|
'id' => 'talents',
|
||||||
'sort' => ['tier', 'name'],
|
'sort' => ['tier', 'name'],
|
||||||
'_petTalents' => 1
|
'_petTalents' => 1
|
||||||
)];
|
), SpellList::$brickFile));
|
||||||
|
|
||||||
|
parent::generate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
88
endpoints/pets/pets.php
Normal file
88
endpoints/pets/pets.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Aowow;
|
||||||
|
|
||||||
|
if (!defined('AOWOW_REVISION'))
|
||||||
|
die('illegal access');
|
||||||
|
|
||||||
|
|
||||||
|
class PetsBaseResponse extends TemplateResponse implements ICache
|
||||||
|
{
|
||||||
|
use TrListPage, TrCache;
|
||||||
|
|
||||||
|
protected int $type = Type::PET;
|
||||||
|
protected int $cacheType = CACHE_TYPE_PAGE;
|
||||||
|
|
||||||
|
protected string $template = 'list-page-generic';
|
||||||
|
protected string $pageName = 'pets';
|
||||||
|
protected ?int $activeTab = parent::TAB_DATABASE;
|
||||||
|
protected array $breadcrumb = [0, 8];
|
||||||
|
|
||||||
|
protected array $validCats = [PET_TALENT_TYPE_FEROCITY, PET_TALENT_TYPE_TENACITY, PET_TALENT_TYPE_CUNNING];
|
||||||
|
|
||||||
|
public function __construct(string $pageParam)
|
||||||
|
{
|
||||||
|
$this->getCategoryFromUrl($pageParam);
|
||||||
|
|
||||||
|
parent::__construct($pageParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generate() : void
|
||||||
|
{
|
||||||
|
$this->h1 = Util::ucFirst(Lang::game('pets'));
|
||||||
|
|
||||||
|
|
||||||
|
/*************/
|
||||||
|
/* Menu Path */
|
||||||
|
/*************/
|
||||||
|
|
||||||
|
if ($this->category)
|
||||||
|
$this->breadcrumb[] = $this->category[0];
|
||||||
|
|
||||||
|
|
||||||
|
/**************/
|
||||||
|
/* Page Title */
|
||||||
|
/**************/
|
||||||
|
|
||||||
|
array_unshift($this->title, $this->h1);
|
||||||
|
if ($this->category)
|
||||||
|
array_unshift($this->title, Lang::pet('cat', $this->category[0]));
|
||||||
|
|
||||||
|
|
||||||
|
/****************/
|
||||||
|
/* Main Content */
|
||||||
|
/****************/
|
||||||
|
|
||||||
|
$this->redButtons[BUTTON_WOWHEAD] = true;
|
||||||
|
|
||||||
|
$conditions = [];
|
||||||
|
|
||||||
|
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||||
|
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
||||||
|
|
||||||
|
if ($this->category)
|
||||||
|
$conditions[] = ['type', $this->category[0]];
|
||||||
|
|
||||||
|
$tabData = [];
|
||||||
|
$pets = new PetList($conditions);
|
||||||
|
if (!$pets->error)
|
||||||
|
{
|
||||||
|
$this->extendGlobalData($pets->getJSGlobals(GLOBALINFO_RELATED));
|
||||||
|
|
||||||
|
$tabData = array(
|
||||||
|
'data' => $pets->getListviewData(),
|
||||||
|
'visibleCols' => ['abilities'],
|
||||||
|
'computeDataFunc' => '$_',
|
||||||
|
'hiddenCols' => !$pets->hasDiffFields('type') ? ['type'] : null
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]);
|
||||||
|
|
||||||
|
$this->lvTabs->addListviewTab(new Listview($tabData, PetList::$brickFile, 'petFoodCol'));
|
||||||
|
|
||||||
|
parent::generate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Aowow;
|
|
||||||
|
|
||||||
if (!defined('AOWOW_REVISION'))
|
|
||||||
die('illegal access');
|
|
||||||
|
|
||||||
|
|
||||||
// menuId 8: Pets g_initPath()
|
|
||||||
// tabid 0: Database g_initHeader()
|
|
||||||
class PetsPage extends GenericPage
|
|
||||||
{
|
|
||||||
use TrListPage;
|
|
||||||
|
|
||||||
protected $type = Type::PET;
|
|
||||||
protected $tpl = 'list-page-generic';
|
|
||||||
protected $path = [0, 8];
|
|
||||||
protected $tabId = 0;
|
|
||||||
protected $mode = CACHE_TYPE_PAGE;
|
|
||||||
protected $validCats = [0, 1, 2];
|
|
||||||
|
|
||||||
public function __construct($pageCall, $pageParam)
|
|
||||||
{
|
|
||||||
$this->getCategoryFromUrl($pageParam);
|
|
||||||
|
|
||||||
parent::__construct($pageCall, $pageParam);
|
|
||||||
|
|
||||||
$this->name = Util::ucFirst(Lang::game('pets'));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generateContent()
|
|
||||||
{
|
|
||||||
$conditions = [];
|
|
||||||
|
|
||||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
|
||||||
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
|
||||||
|
|
||||||
if ($this->category)
|
|
||||||
$conditions[] = ['type', (int)$this->category[0]];
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
$pets = new PetList($conditions);
|
|
||||||
if (!$pets->error)
|
|
||||||
{
|
|
||||||
$this->extendGlobalData($pets->getJSGlobals(GLOBALINFO_RELATED));
|
|
||||||
|
|
||||||
$data = array(
|
|
||||||
'data' => array_values($pets->getListviewData()),
|
|
||||||
'visibleCols' => ['abilities'],
|
|
||||||
'computeDataFunc' => '$_'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$pets->hasDiffFields('type'))
|
|
||||||
$data['hiddenCols'] = ['type'];
|
|
||||||
};
|
|
||||||
$this->lvTabs[] = [PetList::$brickFile, $data, 'petFoodCol'];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generateTitle()
|
|
||||||
{
|
|
||||||
array_unshift($this->title, Util::ucFirst(Lang::game('pets')));
|
|
||||||
if ($this->category)
|
|
||||||
array_unshift($this->title, Lang::pet('cat', $this->category[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generatePath()
|
|
||||||
{
|
|
||||||
if ($this->category)
|
|
||||||
$this->path[] = $this->category[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user