Template/Update (Part 30)

* convert dbtype 'object'
This commit is contained in:
Sarjuuk
2025-08-13 15:36:25 +02:00
parent f17b4f58bf
commit 253cbcb4d9
12 changed files with 366 additions and 298 deletions

View File

@@ -6,57 +6,62 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); die('illegal access');
// menuId 5: Object g_initPath() class ObjectBaseResponse extends TemplateResponse implements ICache
// tabId 0: Database g_initHeader()
class ObjectPage extends GenericPage
{ {
use TrDetailPage; use TrDetailPage, TrCache;
protected $pageText = []; protected int $cacheType = CACHE_TYPE_PAGE;
protected $relBoss = null;
protected $type = Type::OBJECT; protected string $template = 'object';
protected $typeId = 0; protected string $pageName = 'object';
protected $tpl = 'object'; protected ?int $activeTab = parent::TAB_DATABASE;
protected $path = [0, 5]; protected array $breadcrumb = [0, 5];
protected $tabId = 0;
protected $mode = CACHE_TYPE_PAGE;
protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']];
protected $_get = ['domain' => ['filter' => FILTER_CALLBACK, 'options' => 'Aowow\Locale::tryFromDomain']]; protected array $scripts = [[SC_JS_FILE, 'js/swfobject.js']];
private $powerTpl = '$WowheadPower.registerObject(%d, %d, %s);'; public int $type = Type::OBJECT;
public int $typeId = 0;
public ?Book $book = null;
public ?array $relBoss = null;
public function __construct($pageCall, $id) private GameObjectList $subject;
public function __construct(string $id)
{ {
parent::__construct($pageCall, $id); parent::__construct($id);
// temp locale
if ($this->mode == CACHE_TYPE_TOOLTIP && $this->_get['domain'])
Lang::load($this->_get['domain']);
$this->typeId = intVal($id); $this->typeId = intVal($id);
$this->contribute = Type::getClassAttrib($this->type, 'contribute') ?? CONTRIBUTE_NONE;
}
protected function generate() : void
{
$this->subject = new GameObjectList(array(['id', $this->typeId])); $this->subject = new GameObjectList(array(['id', $this->typeId]));
if ($this->subject->error) if ($this->subject->error)
$this->notFound(Lang::game('object'), Lang::gameObject('notFound')); $this->generateNotFound(Lang::game('object'), Lang::gameObject('notFound'));
$this->name = Lang::unescapeUISequences($this->subject->getField('name', true), Lang::FMT_HTML); $this->h1 = Lang::unescapeUISequences($this->subject->getField('name', true), Lang::FMT_HTML);
}
protected function generatePath() $this->gPageInfo += array(
{ 'type' => $this->type,
$this->path[] = $this->subject->getField('typeCat'); 'typeId' => $this->typeId,
} 'name' => $this->h1
);
/*************/
/* Menu Path */
/*************/
$this->breadcrumb[] = $this->subject->getField('typeCat');
/**************/
/* Page Title */
/**************/
protected function generateTitle()
{
array_unshift($this->title, Lang::unescapeUISequences($this->subject->getField('name', true), Lang::FMT_RAW), Util::ucFirst(Lang::game('object'))); array_unshift($this->title, Lang::unescapeUISequences($this->subject->getField('name', true), Lang::FMT_RAW), Util::ucFirst(Lang::game('object')));
}
protected function generateContent()
{
$this->addScript([SC_JS_FILE, '?data=zones']);
/***********/ /***********/
/* Infobox */ /* Infobox */
@@ -65,45 +70,45 @@ class ObjectPage extends GenericPage
$infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
// Event (ignore events, where the object only gets removed) // Event (ignore events, where the object only gets removed)
if ($_ = DB::World()->selectCol('SELECT DISTINCT ge.eventEntry FROM game_event ge, game_event_gameobject geg, gameobject g WHERE ge.eventEntry = geg.eventEntry AND g.guid = geg.guid AND g.id = ?d', $this->typeId)) if ($_ = DB::World()->selectCol('SELECT DISTINCT ge.`eventEntry` FROM game_event ge, game_event_gameobject geg, gameobject g WHERE ge.`eventEntry` = geg.`eventEntry` AND g.`guid` = geg.`guid` AND g.`id` = ?d', $this->typeId))
{ {
$this->extendGlobalIds(Type::WORLDEVENT, ...$_); $this->extendGlobalIds(Type::WORLDEVENT, ...$_);
$ev = []; $ev = [];
foreach ($_ as $i => $e) foreach ($_ as $i => $e)
$ev[] = ($i % 2 ? '[br]' : ' ') . '[event='.$e.']'; $ev[] = ($i % 2 ? '[br]' : ' ') . '[event='.$e.']';
$infobox[] = Util::ucFirst(Lang::game('eventShort')).Lang::main('colon').implode(',', $ev); $infobox[] = Lang::game('eventShort', [implode(',', $ev)]);
} }
// Faction // Faction
if ($_ = DB::Aowow()->selectCell('SELECT factionId FROM ?_factiontemplate WHERE id = ?d', $this->subject->getField('faction'))) if ($_ = DB::Aowow()->selectCell('SELECT `factionId` FROM ?_factiontemplate WHERE `id` = ?d', $this->subject->getField('faction')))
{ {
$this->extendGlobalIds(Type::FACTION, $_); $this->extendGlobalIds(Type::FACTION, $_);
$infobox[] = Util::ucFirst(Lang::game('faction')).Lang::main('colon').'[faction='.$_.']'; $infobox[] = Util::ucFirst(Lang::game('faction')).Lang::main('colon').'[faction='.$_.']';
} }
// Reaction // Reaction
$_ = function ($r) $color = fn (int $r) : string => match($r)
{ {
if ($r == 1) return 2; // q2 green 1 => 'q2', // q2 green
if ($r == -1) return 10; // q10 red -1 => 'q10', // q10 red
return; // q yellow default => 'q' // q yellow
}; };
$infobox[] = Lang::npc('react').Lang::main('colon').'[color=q'.$_($this->subject->getField('A')).']A[/color] [color=q'.$_($this->subject->getField('H')).']H[/color]'; $infobox[] = Lang::npc('react', ['[color='.$color($this->subject->getField('A')).']A[/color] [color='.$color($this->subject->getField('H')).']H[/color]']);
// reqSkill + difficulty // reqSkill + difficulty
switch ($this->subject->getField('typeCat')) switch ($this->subject->getField('typeCat'))
{ {
case -3: // Herbalism case -3: // Herbalism
$infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 2).' ('.$this->subject->getField('reqSkill').')'); $infobox[] = Lang::game('requires', [Lang::spell('lockType', 2).' ('.$this->subject->getField('reqSkill').')']);
$infobox[] = Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill(SKILL_HERBALISM, $this->subject->getField('reqSkill'))); $infobox[] = Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill(SKILL_HERBALISM, $this->subject->getField('reqSkill')));
break; break;
case -4: // Mining case -4: // Mining
$infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 3).' ('.$this->subject->getField('reqSkill').')'); $infobox[] = Lang::game('requires', [Lang::spell('lockType', 3).' ('.$this->subject->getField('reqSkill').')']);
$infobox[] = Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill(SKILL_MINING, $this->subject->getField('reqSkill'))); $infobox[] = Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill(SKILL_MINING, $this->subject->getField('reqSkill')));
break; break;
case -5: // Lockpicking case -5: // Lockpicking
$infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 1).' ('.$this->subject->getField('reqSkill').')'); $infobox[] = Lang::game('requires', [Lang::spell('lockType', 1).' ('.$this->subject->getField('reqSkill').')']);
$infobox[] = Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill(SKILL_LOCKPICKING, $this->subject->getField('reqSkill'))); $infobox[] = Lang::formatSkillBreakpoints(Game::getBreakpointsForSkill(SKILL_LOCKPICKING, $this->subject->getField('reqSkill')));
break; break;
default: // requires key .. maybe default: // requires key .. maybe
@@ -119,7 +124,7 @@ class ObjectPage extends GenericPage
if ($idx > 0) if ($idx > 0)
$l[] = Lang::gameObject('key').Lang::main('colon').$str; $l[] = Lang::gameObject('key').Lang::main('colon').$str;
else if ($idx < 0) else if ($idx < 0)
$l[] = sprintf(Lang::game('requires'), $str); $l[] = Lang::game('requires', [$str]);
} }
if ($l) if ($l)
@@ -138,114 +143,113 @@ class ObjectPage extends GenericPage
// SpellFocus // SpellFocus
if ($_ = $this->subject->getField('spellFocusId')) if ($_ = $this->subject->getField('spellFocusId'))
if ($sfo = DB::Aowow()->selectRow('SELECT * FROM ?_spellfocusobject WHERE id = ?d', $_)) if ($sfo = DB::Aowow()->selectRow('SELECT * FROM ?_spellfocusobject WHERE `id` = ?d', $_))
$infobox[] = '[tooltip name=focus]'.Lang::gameObject('focusDesc').'[/tooltip][span class=tip tooltip=focus]'.Lang::gameObject('focus').Lang::main('colon').Util::localizedString($sfo, 'name').'[/span]'; $infobox[] = '[tooltip name=focus]'.Lang::gameObject('focusDesc').'[/tooltip][span class=tip tooltip=focus]'.Lang::gameObject('focus').Lang::main('colon').Util::localizedString($sfo, 'name').'[/span]';
// lootinfo: [min, max, restock] // lootinfo: [min, max, restock]
if (($_ = $this->subject->getField('lootStack')) && $_[0]) if ($this->subject->getField('lootStack'))
{ {
$buff = Lang::spell('spellModOp', 4).Lang::main('colon').$_[0]; [$min, $max, $restock] = $this->subject->getField('lootStack');
if ($_[0] < $_[1]) $buff = Lang::spell('spellModOp', 4).Lang::main('colon').$min;
$buff .= Lang::game('valueDelim').$_[1]; if ($min < $max)
$buff .= Lang::game('valueDelim').$max;
// since Veins don't have charges anymore, the timer is questionable // since Veins don't have charges anymore, the timer is questionable
$infobox[] = $_[2] > 1 ? '[tooltip name=restock]'.sprintf(Lang::gameObject('restock'), Util::formatTime($_[2] * 1000)).'[/tooltip][span class=tip tooltip=restock]'.$buff.'[/span]' : $buff; $infobox[] = $restock > 1 ? '[tooltip name=restock]'.Lang::gameObject('restock', [Util::formatTime($restock * 1000)]).'[/tooltip][span class=tip tooltip=restock]'.$buff.'[/span]' : $buff;
} }
// meeting stone [minLevel, maxLevel, zone] // meeting stone [minLevel, maxLevel, zone]
if ($this->subject->getField('type') == OBJECT_MEETINGSTONE) if ($this->subject->getField('type') == OBJECT_MEETINGSTONE && $this->subject->getField('mStone'))
{ {
if ($_ = $this->subject->getField('mStone')) [$minLevel, $maxLevel, $zone] = $this->subject->getField('mStone');
{
$this->extendGlobalIds(Type::ZONE, $_[2]);
$m = Lang::game('meetingStone').Lang::main('colon').'[zone='.$_[2].']';
$l = $_[0]; $this->extendGlobalIds(Type::ZONE, $zone);
if ($_[0] > 1 && $_[1] > $_[0]) $m = Lang::game('meetingStone').'[zone='.$zone.']';
$l .= Lang::game('valueDelim').min($_[1], MAX_LEVEL);
$infobox[] = $l ? '[tooltip name=meetingstone]'.sprintf(Lang::game('reqLevel'), $l).'[/tooltip][span class=tip tooltip=meetingstone]'.$m.'[/span]' : $m; $l = $minLevel;
} if ($minLevel > 1 && $maxLevel > $minLevel)
$l .= Lang::game('valueDelim').min($maxLevel, MAX_LEVEL);
$infobox[] = $l ? '[tooltip name=meetingstone]'.Lang::game('reqLevel', [$l]).'[/tooltip][span class=tip tooltip=meetingstone]'.$m.'[/span]' : $m;
} }
// capture area [minPlayer, maxPlayer, minTime, maxTime, radius] // capture area
if ($this->subject->getField('type') == OBJECT_CAPTURE_POINT) if ($this->subject->getField('type') == OBJECT_CAPTURE_POINT && $this->subject->getField('capture'))
{
if ($_ = $this->subject->getField('capture'))
{ {
[$minPlayer, $maxPlayer, $minTime, $maxTime, $radius] = $this->subject->getField('capture');
$buff = Lang::gameObject('capturePoint'); $buff = Lang::gameObject('capturePoint');
if ($_[2] > 1 || $_[0]) if ($minTime > 1 || $minPlayer || $radius)
$buff .= Lang::main('colon').'[ul]'; $buff .= Lang::main('colon').'[ul]';
if ($_[2] > 1) if ($minTime > 1)
$buff .= '[li]'.Lang::game('duration').Lang::main('colon').($_[3] > $_[2] ? Util::FormatTime($_[3] * 1000, true).' - ' : null).Util::FormatTime($_[2] * 1000, true).'[/li]'; $buff .= '[li]'.Lang::game('duration').Lang::main('colon').($maxTime > $minTime ? Util::FormatTime($maxTime * 1000, true).' - ' : '').Util::FormatTime($minTime * 1000, true).'[/li]';
if ($_[1]) if ($minPlayer)
$buff .= '[li]'.Lang::main('players').Lang::main('colon').$_[0].($_[1] > $_[0] ? ' - '.$_[1] : null).'[/li]'; $buff .= '[li]'.Lang::main('players').Lang::main('colon').$minPlayer.($maxPlayer > $minPlayer ? ' - '.$maxPlayer : '').'[/li]';
if ($_[4]) if ($radius)
$buff .= '[li]'.sprintf(Lang::spell('range'), $_[4]).'[/li]'; $buff .= '[li]'.Lang::spell('range', [$radius]).'[/li]';
if ($_[2] > 1 || $_[0]) if ($minTime > 1 || $minPlayer || $radius)
$buff .= '[/ul]'; $buff .= '[/ul]';
}
$infobox[] = $buff; $infobox[] = $buff;
} }
// AI // AI
if (User::isInGroup(U_GROUP_EMPLOYEE)) if (User::isInGroup(U_GROUP_EMPLOYEE))
{
if ($_ = $this->subject->getField('ScriptOrAI')) if ($_ = $this->subject->getField('ScriptOrAI'))
{ $infobox[] = ($_ == 'SmartGameObjectAI' ? 'AI' : 'Script').Lang::main('colon').$_;
if ($_ == 'SmartGameObjectAI')
$infobox[] = 'AI'.Lang::main('colon').$_; if ($infobox)
else $this->infobox = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF, 'dbpage' => true], 'infobox-contents0');
$infobox[] = 'Script'.Lang::main('colon').$_;
}
}
/****************/ /****************/
/* Main Content */ /* Main Content */
/****************/ /****************/
// pageText // pageText / book
if ($this->pageText = Game::getBook($this->subject->getField('pageTextId'))) if ($this->book = Game::getBook($this->subject->getField('pageTextId')))
$this->addScript( $this->addScript(
[SC_JS_FILE, 'js/Book.js'], [SC_JS_FILE, 'js/Book.js'],
[SC_CSS_FILE, 'css/Book.css'] [SC_CSS_FILE, 'css/Book.css']
); );
// get spawns and path // get spawns and path
$map = null;
if ($spawns = $this->subject->getSpawns(SPAWNINFO_FULL)) if ($spawns = $this->subject->getSpawns(SPAWNINFO_FULL))
{ {
$map = ['data' => ['parent' => 'mapper-generic'], 'mapperData' => &$spawns, 'foundIn' => Lang::gameObject('foundIn')]; $this->addDataLoader('zones');
foreach ($spawns as $areaId => &$areaData) $this->map = array(
$map['extra'][$areaId] = ZoneList::getName($areaId); ['parent' => 'mapper-generic'], // Mapper
$spawns, // mapperData
null, // ShowOnMap
[Lang::gameObject('foundIn')] // foundIn
);
foreach ($spawns as $areaId => $_)
$this->map[3][$areaId] = ZoneList::getName($areaId);
} }
// todo (low): consider pooled spawns // todo (low): consider pooled spawns
$relBoss = null;
if ($ll = DB::Aowow()->selectRow('SELECT * FROM ?_loot_link WHERE `objectId` = ?d ORDER BY `priority` DESC LIMIT 1', $this->typeId)) if ($ll = DB::Aowow()->selectRow('SELECT * FROM ?_loot_link WHERE `objectId` = ?d ORDER BY `priority` DESC LIMIT 1', $this->typeId))
{ {
// group encounter // group encounter
if ($ll['encounterId']) if ($ll['encounterId'])
$relBoss = [$ll['npcId'], Lang::profiler('encounterNames', $ll['encounterId'])]; $this->relBoss = [$ll['npcId'], Lang::profiler('encounterNames', $ll['encounterId'])];
// difficulty dummy // difficulty dummy
else if ($c = DB::Aowow()->selectRow('SELECT `id`, `name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8` FROM ?_creature WHERE `difficultyEntry1` = ?d OR `difficultyEntry2` = ?d OR `difficultyEntry3` = ?d', $ll['npcId'], $ll['npcId'], $ll['npcId'])) else if ($c = DB::Aowow()->selectRow('SELECT `id`, `name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8` FROM ?_creature WHERE `difficultyEntry1` = ?d OR `difficultyEntry2` = ?d OR `difficultyEntry3` = ?d', $ll['npcId'], $ll['npcId'], $ll['npcId']))
$relBoss = [$c['id'], Util::localizedString($c, 'name')]; $this->relBoss = [$c['id'], Util::localizedString($c, 'name')];
// base creature // base creature
else if ($c = DB::Aowow()->selectRow('SELECT `id`, `name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8` FROM ?_creature WHERE `id` = ?d', $ll['npcId'])) else if ($c = DB::Aowow()->selectRow('SELECT `id`, `name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8` FROM ?_creature WHERE `id` = ?d', $ll['npcId']))
$relBoss = [$c['id'], Util::localizedString($c, 'name')]; $this->relBoss = [$c['id'], Util::localizedString($c, 'name')];
} }
// smart AI // Smart AI
$sai = null; $sai = null;
if ($this->subject->getField('ScriptOrAI') == 'SmartGameObjectAI') if ($this->subject->getField('ScriptOrAI') == 'SmartGameObjectAI')
{ {
@@ -263,15 +267,14 @@ class ObjectPage extends GenericPage
} }
if ($sai->prepare()) if ($sai->prepare())
{
$this->extendGlobalData($sai->getJSGlobals()); $this->extendGlobalData($sai->getJSGlobals());
$this->smartAI = $sai->getMarkup();
}
else else
trigger_error('Gameobject has AIName set in template but no SmartAI defined.'); trigger_error('Gameobject has AIName set in template but no SmartAI defined.');
} }
$this->map = $map;
$this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null;
$this->relBoss = $relBoss;
$this->smartAI = $sai ? $sai->getMarkup() : null;
$this->redButtons = array( $this->redButtons = array(
BUTTON_WOWHEAD => true, BUTTON_WOWHEAD => true,
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId], BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId],
@@ -283,12 +286,22 @@ class ObjectPage extends GenericPage
/* Extra Tabs */ /* Extra Tabs */
/**************/ /**************/
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated', true);
// tab: summoned by // tab: summoned by
$summonEffects = array(
SPELL_EFFECT_TRANS_DOOR,
SPELL_EFFECT_SUMMON_OBJECT_WILD,
SPELL_EFFECT_SUMMON_OBJECT_SLOT1,
SPELL_EFFECT_SUMMON_OBJECT_SLOT2,
SPELL_EFFECT_SUMMON_OBJECT_SLOT3,
SPELL_EFFECT_SUMMON_OBJECT_SLOT4
);
$conditions = array( $conditions = array(
'OR', 'OR',
['AND', ['effect1Id', [50, 76, 104, 105, 106, 107]], ['effect1MiscValue', $this->typeId]], ['AND', ['effect1Id', $summonEffects], ['effect1MiscValue', $this->typeId]],
['AND', ['effect2Id', [50, 76, 104, 105, 106, 107]], ['effect2MiscValue', $this->typeId]], ['AND', ['effect2Id', $summonEffects], ['effect2MiscValue', $this->typeId]],
['AND', ['effect3Id', [50, 76, 104, 105, 106, 107]], ['effect3MiscValue', $this->typeId]] ['AND', ['effect3Id', $summonEffects], ['effect3MiscValue', $this->typeId]]
); );
$summons = new SpellList($conditions); $summons = new SpellList($conditions);
@@ -296,11 +309,11 @@ class ObjectPage extends GenericPage
{ {
$this->extendGlobalData($summons->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $this->extendGlobalData($summons->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$this->lvTabs[] = [SpellList::$brickFile, array( $this->lvTabs->addListviewTab(new Listview(array(
'data' => array_values($summons->getListviewData()), 'data' => $summons->getListviewData(),
'id' => 'summoned-by', 'id' => 'summoned-by',
'name' => '$LANG.tab_summonedby' 'name' => '$LANG.tab_summonedby'
)]; ), SpellList::$brickFile));
} }
// tab: related spells // tab: related spells
@@ -315,13 +328,13 @@ class ObjectPage extends GenericPage
foreach ($data as $relId => $d) foreach ($data as $relId => $d)
$data[$relId]['trigger'] = array_search($relId, $_); $data[$relId]['trigger'] = array_search($relId, $_);
$this->lvTabs[] = [SpellList::$brickFile, array( $this->lvTabs->addListviewTab(new Listview(array(
'data' => array_values($data), 'data' => $data,
'id' => 'spells', 'id' => 'spells',
'name' => '$LANG.tab_spells', 'name' => '$LANG.tab_spells',
'hiddenCols' => ['skill'], 'hiddenCols' => ['skill'],
'extraCols' => ["\$Listview.funcBox.createSimpleCol('trigger', 'Condition', '10%', 'trigger')"] 'extraCols' => ["\$Listview.funcBox.createSimpleCol('trigger', 'Condition', '10%', 'trigger')"]
)]; ), SpellList::$brickFile));
} }
} }
@@ -331,11 +344,11 @@ class ObjectPage extends GenericPage
{ {
$this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$this->lvTabs[] = [AchievementList::$brickFile, array( $this->lvTabs->addListviewTab(new Listview(array(
'data' => array_values($acvs->getListviewData()), 'data' => $acvs->getListviewData(),
'id' => 'criteria-of', 'id' => 'criteria-of',
'name' => '$LANG.tab_criteriaof' 'name' => '$LANG.tab_criteriaof'
)]; ), AchievementList::$brickFile));
} }
// tab: starts quest // tab: starts quest
@@ -345,30 +358,29 @@ class ObjectPage extends GenericPage
{ {
$this->extendGlobalData($startEnd->getJSGlobals()); $this->extendGlobalData($startEnd->getJSGlobals());
$lvData = $startEnd->getListviewData(); $lvData = $startEnd->getListviewData();
$_ = [[], []]; $start = $end = [];
foreach ($startEnd->iterate() as $id => $__) foreach ($startEnd->iterate() as $id => $__)
{ {
$m = $startEnd->getField('method'); if ($startEnd->getField('method') & 0x1)
if ($m & 0x1) $start[] = $lvData[$id];
$_[0][] = $lvData[$id]; if ($startEnd->getField('method') & 0x2)
if ($m & 0x2) $end[] = $lvData[$id];
$_[1][] = $lvData[$id];
} }
if ($_[0]) if ($start)
$this->lvTabs[] = [QuestList::$brickFile, array( $this->lvTabs->addListviewTab(new Listview(array(
'data' => array_values($_[0]), 'data' => $start,
'name' => '$LANG.tab_starts', 'name' => '$LANG.tab_starts',
'id' => 'starts' 'id' => 'starts'
)]; ), QuestList::$brickFile));
if ($_[1]) if ($end)
$this->lvTabs[] = [QuestList::$brickFile, array( $this->lvTabs->addListviewTab(new Listview(array(
'data' => array_values($_[1]), 'data' => $end,
'name' => '$LANG.tab_ends', 'name' => '$LANG.tab_ends',
'id' => 'ends' 'id' => 'ends'
)]; ), QuestList::$brickFile));
} }
// tab: related quests // tab: related quests
@@ -379,11 +391,11 @@ class ObjectPage extends GenericPage
{ {
$this->extendGlobalData($relQuest->getJSGlobals()); $this->extendGlobalData($relQuest->getJSGlobals());
$this->lvTabs[] = [QuestList::$brickFile, array( $this->lvTabs->addListviewTab(new Listview(array(
'data' => array_values($relQuest->getListviewData()), 'data' => $relQuest->getListviewData(),
'name' => '$LANG.tab_quests', 'name' => '$LANG.tab_quests',
'id' => 'quests' 'id' => 'quests'
)]; ), QuestList::$brickFile));
} }
} }
@@ -402,24 +414,20 @@ class ObjectPage extends GenericPage
foreach ($hiddenCols as $k => $str) foreach ($hiddenCols as $k => $str)
{ {
if ($k == 1 && array_filter(array_column($lootResult, $str), function ($x) { return $x != SIDE_BOTH; })) if ($k == 1 && array_filter(array_column($lootResult, $str), fn ($x) => $x != SIDE_BOTH))
unset($hiddenCols[$k]); unset($hiddenCols[$k]);
else if ($k != 1 && array_column($lootResult, $str)) else if ($k != 1 && !array_filter(array_column($lootResult, $str)))
unset($hiddenCols[$k]); unset($hiddenCols[$k]);
} }
$tabData = array( $this->lvTabs->addListviewTab(new Listview(array(
'data' => array_values($lootResult), 'data' => $lootResult,
'id' => 'contains', 'id' => 'contains',
'name' => '$LANG.tab_contains', 'name' => '$LANG.tab_contains',
'sort' => ['-percent', 'name'], 'sort' => ['-percent', 'name'],
'extraCols' => array_unique($extraCols) 'extraCols' => array_unique($extraCols),
); 'hiddenCols' => $hiddenCols ?: null
), ItemList::$brickFile));
if ($hiddenCols)
$tabData['hiddenCols'] = array_values($hiddenCols);
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
} }
} }
@@ -430,7 +438,7 @@ class ObjectPage extends GenericPage
if (!$focusSpells->error) if (!$focusSpells->error)
{ {
$tabData = array( $tabData = array(
'data' => array_values($focusSpells->getListviewData()), 'data' => $focusSpells->getListviewData(),
'name' => Lang::gameObject('focus'), 'name' => Lang::gameObject('focus'),
'id' => 'focus-for' 'id' => 'focus-for'
); );
@@ -444,7 +452,7 @@ class ObjectPage extends GenericPage
$tabData['_truncated'] = 1; $tabData['_truncated'] = 1;
} }
$this->lvTabs[] = [SpellList::$brickFile, $tabData]; $this->lvTabs->addListviewTab(new Listview($tabData, SpellList::$brickFile));
} }
} }
@@ -454,25 +462,27 @@ class ObjectPage extends GenericPage
{ {
$this->extendGlobalData($trigger->getJSGlobals()); $this->extendGlobalData($trigger->getJSGlobals());
$this->lvTabs[] = [GameObjectList::$brickFile, array( $this->addDataLoader('zones');
'data' => array_values($trigger->getListviewData()), $this->lvTabs->addListviewTab(new Listview(array(
'data' => $trigger->getListviewData(),
'name' => Lang::gameObject('triggeredBy'), 'name' => Lang::gameObject('triggeredBy'),
'id' => 'triggerd-by', 'id' => 'triggerd-by',
'note' => sprintf(Util::$filterResultString, '?objects=6') 'note' => sprintf(Util::$filterResultString, '?objects=6')
)]; ), GameObjectList::$brickFile));
} }
// tab: Same model as .. whats the fucking point..? // tab: Same model as
$sameModel = new GameObjectList(array(['displayId', $this->subject->getField('displayId')], ['id', $this->typeId, '!'])); $sameModel = new GameObjectList(array(['displayId', $this->subject->getField('displayId')], ['id', $this->typeId, '!']));
if (!$sameModel->error) if (!$sameModel->error)
{ {
$this->extendGlobalData($sameModel->getJSGlobals()); $this->extendGlobalData($sameModel->getJSGlobals());
$this->lvTabs[] = [GameObjectList::$brickFile, array( $this->addDataLoader('zones');
'data' => array_values($sameModel->getListviewData()), $this->lvTabs->addListviewTab(new Listview(array(
'data' => $sameModel->getListviewData(),
'name' => '$LANG.tab_samemodelas', 'name' => '$LANG.tab_samemodelas',
'id' => 'same-model-as' 'id' => 'same-model-as'
)]; ), GameObjectList::$brickFile));
} }
// tab: condition-for // tab: condition-for
@@ -481,21 +491,10 @@ class ObjectPage extends GenericPage
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for')) if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
{ {
$this->extendGlobalData($cnd->getJsGlobals()); $this->extendGlobalData($cnd->getJsGlobals());
$this->lvTabs[] = $tab; $this->lvTabs->addDataTab(...$tab);
}
} }
protected function generateTooltip() parent::generate();
{
$power = new \StdClass();
if (!$this->subject->error)
{
$power->{'name_'.Lang::getLocale()->json()} = Lang::unescapeUISequences($this->subject->getField('name', true), Lang::FMT_RAW);
$power->{'tooltip_'.Lang::getLocale()->json()} = $this->subject->renderTooltip();
$power->map = $this->subject->getSpawns(SPAWNINFO_SHORT);
}
return sprintf($this->powerTpl, $this->typeId, Lang::getLocale()->value, Util::toJSON($power, JSON_AOWOW_POWER));
} }
} }

View File

@@ -0,0 +1,50 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class ObjectPowerResponse extends TextResponse implements ICache
{
use TrCache, TrTooltip;
private const /* string */ POWER_TEMPLATE = '$WowheadPower.registerObject(%d, %d, %s);';
protected int $type = Type::OBJECT;
protected int $typeId = 0;
protected int $cacheType = CACHE_TYPE_TOOLTIP;
protected array $expectedGET = array(
'domain' => ['filter' => FILTER_CALLBACK, 'options' => [Locale::class, 'tryFromDomain']]
);
public function __construct(string $id)
{
parent::__construct($id);
// temp locale
if ($this->_get['domain'])
Lang::load($this->_get['domain']);
$this->typeId = intVal($id);
}
protected function generate() : void
{
$object = new GameObjectList(array(['id', $this->typeId]));
if ($object->error)
$this->cacheType = CACHE_TYPE_NONE;
else
$opts = array(
'name' => Lang::unescapeUISequences($object->getField('name', true), Lang::FMT_RAW),
'tooltip' => $object->renderTooltip(),
'map' => $object->getSpawns(SPAWNINFO_SHORT)
);
$this->result = new Tooltip(self::POWER_TEMPLATE, $this->typeId, $opts ?? []);
}
}
?>

View File

@@ -0,0 +1,109 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class ObjectsBaseResponse extends TemplateResponse implements ICache
{
use TrListPage, TrCache;
protected int $type = Type::OBJECT;
protected int $cacheType = CACHE_TYPE_PAGE;
protected string $template = 'objects';
protected string $pageName = 'objects';
protected ?int $activeTab = parent::TAB_DATABASE;
protected array $breadcrumb = [0, 5];
protected array $dataLoader = ['zones'];
protected array $scripts = [[SC_JS_FILE, 'js/filters.js']];
protected array $expectedGET = array(
'filter' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => Filter::PATTERN_PARAM]]
);
protected array $validCats = [-2, -3, -4, -5, -6, 0, 3, 6, 9, 25];
public bool $petFamPanel = false;
public function __construct(string $pageParam)
{
$this->getCategoryFromUrl($pageParam);
parent::__construct($pageParam);
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
$this->filter = new GameObjectListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
$this->filterError = $this->filter->error;
}
protected function generate() : void
{
$this->h1 = Util::ucFirst(Lang::game('objects'));
$conditions = [];
if (!User::isInGroup(U_GROUP_EMPLOYEE))
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
$this->filter->evalCriteria();
if ($_ = $this->filter->getConditions())
$conditions[] = $_;
if ($this->category)
$conditions[] = ['typeCat', (int)$this->category[0]];
$this->filterError = $this->filter->error; // maybe the evalX() caused something
/*************/
/* 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::gameObject('cat', $this->category[0]));
/****************/
/* Main Content */
/****************/
$this->redButtons[BUTTON_WOWHEAD] = true;
if ($fiQuery = $this->filter->buildGETParam())
$this->wowheadLink .= '&filter='.$fiQuery;
$tabData = ['data' => []];
$objects = new GameObjectList($conditions, ['extraOpts' => $this->filter->extraOpts, 'calcTotal' => true]);
if (!$objects->error)
{
$tabData['data'] = $objects->getListviewData();
if ($objects->hasSetFields('reqSkill'))
$tabData['visibleCols'] = ['skill'];
// create note if search limit was exceeded
if ($objects->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
{
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_objectsfound', $objects->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT'));
$tabData['_truncated'] = 1;
}
}
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]);
$this->lvTabs->addListviewTab(new Listview($tabData, GameObjectList::$brickFile));
parent::generate();
}
}
?>

View File

@@ -339,7 +339,7 @@ $lang = array(
'level' => "Stufe", 'level' => "Stufe",
'mechanic' => "Auswirkung", 'mechanic' => "Auswirkung",
'mechAbbr' => "Ausw.: ", 'mechAbbr' => "Ausw.: ",
'meetingStone' => "Versammlungsstein", 'meetingStone' => "Versammlungsstein: ",
'requires' => "Benötigt %s", 'requires' => "Benötigt %s",
'requires2' => "Benötigt", 'requires2' => "Benötigt",
'reqLevel' => "Benötigt Stufe %s", 'reqLevel' => "Benötigt Stufe %s",

View File

@@ -339,7 +339,7 @@ $lang = array(
'level' => "Level", 'level' => "Level",
'mechanic' => "Mechanic", 'mechanic' => "Mechanic",
'mechAbbr' => "Mech.: ", 'mechAbbr' => "Mech.: ",
'meetingStone' => "Meeting Stone", 'meetingStone' => "Meeting Stone: ",
'requires' => "Requires %s", 'requires' => "Requires %s",
'requires2' => "Requires", 'requires2' => "Requires",
'reqLevel' => "Requires Level %s", 'reqLevel' => "Requires Level %s",

View File

@@ -339,7 +339,7 @@ $lang = array(
'level' => "Nivel", 'level' => "Nivel",
'mechanic' => "Mecanica", 'mechanic' => "Mecanica",
'mechAbbr' => "Mec.: ", 'mechAbbr' => "Mec.: ",
'meetingStone' => "Roca de encuentro", 'meetingStone' => "Roca de encuentro: ",
'requires' => "Requiere %s", 'requires' => "Requiere %s",
'requires2' => "Requiere", 'requires2' => "Requiere",
'reqLevel' => "Necesitas ser de nivel %s", 'reqLevel' => "Necesitas ser de nivel %s",

View File

@@ -339,7 +339,7 @@ $lang = array(
'level' => "Niveau", 'level' => "Niveau",
'mechanic' => "Mécanique", 'mechanic' => "Mécanique",
'mechAbbr' => "Mécan. : ", 'mechAbbr' => "Mécan. : ",
'meetingStone' => "Pierre de rencontre", 'meetingStone' => "Pierre de rencontre : ",
'requires' => "%s requis", 'requires' => "%s requis",
'requires2' => "Requiert", 'requires2' => "Requiert",
'reqLevel' => "Niveau %s requis", 'reqLevel' => "Niveau %s requis",

View File

@@ -339,7 +339,7 @@ $lang = array(
'level' => "Уровень", 'level' => "Уровень",
'mechanic' => "Механика", 'mechanic' => "Механика",
'mechAbbr' => "Механика: ", 'mechAbbr' => "Механика: ",
'meetingStone' => "Камень встреч", 'meetingStone' => "Камень встреч: ",
'requires' => "Требует %s", 'requires' => "Требует %s",
'requires2' => "Требуется:", 'requires2' => "Требуется:",
'reqLevel' => "Требуется уровень: %s", 'reqLevel' => "Требуется уровень: %s",

View File

@@ -338,7 +338,7 @@ $lang = array(
'level' => "等级", 'level' => "等级",
'mechanic' => "机制", 'mechanic' => "机制",
'mechAbbr' => "机制:", 'mechAbbr' => "机制:",
'meetingStone' => "集合石", 'meetingStone' => "集合石",
'requires' => "需要%s", 'requires' => "需要%s",
'requires2' => "需要", 'requires2' => "需要",
'reqLevel' => "需要等级%s", 'reqLevel' => "需要等级%s",

View File

@@ -1,90 +0,0 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 5: Object g_initPath()
// tabId 0: Database g_initHeader()
class ObjectsPage extends GenericPage
{
use TrListPage;
protected $type = Type::OBJECT;
protected $tpl = 'objects';
protected $path = [0, 5];
protected $tabId = 0;
protected $mode = CACHE_TYPE_PAGE;
protected $validCats = [-2, -3, -4, -5, -6, 0, 3, 6, 9, 25];
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 GameObjectListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
$this->name = Util::ucFirst(Lang::game('objects'));
$this->subCat = $pageParam ? '='.$pageParam : '';
}
protected function generateContent()
{
$this->addScript([SC_JS_FILE, '?data=zones']);
$conditions = [];
if (!User::isInGroup(U_GROUP_EMPLOYEE))
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
if ($this->category)
$conditions[] = ['typeCat', (int)$this->category[0]];
$this->filterObj->evalCriteria();
if ($_ = $this->filterObj->getConditions())
$conditions[] = $_;
$tabData = ['data' => []];
$objects = new GameObjectList($conditions, ['extraOpts' => $this->filterObj->extraOpts, 'calcTotal' => true]);
if (!$objects->error)
{
$tabData['data'] = array_values($objects->getListviewData());
if ($objects->hasSetFields('reqSkill'))
$tabData['visibleCols'] = ['skill'];
// create note if search limit was exceeded
if ($objects->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
{
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_objectsfound', $objects->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT'));
$tabData['_truncated'] = 1;
}
if ($this->filterObj->error)
$tabData['_errors'] = 1;
}
$this->lvTabs[] = [GameObjectList::$brickFile, $tabData];
}
protected function generateTitle()
{
array_unshift($this->title, $this->name);
if ($this->category)
array_unshift($this->title, Lang::gameObject('cat', $this->category[0]));
}
protected function generatePath()
{
if ($this->category)
$this->path[] = $this->category[0];
}
}
?>

View File

@@ -1,7 +1,10 @@
<?php namespace Aowow; ?> <?php
namespace Aowow\Template;
<?php $this->brick('header'); ?> use \Aowow\Lang;
$this->brick('header');
?>
<div class="main" id="main"> <div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div> <div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents"> <div class="main-contents" id="main-contents">
@@ -17,17 +20,17 @@
<div class="text"> <div class="text">
<?php $this->brick('redButtons'); ?> <?php $this->brick('redButtons'); ?>
<h1><?=$this->name; ?></h1> <h1><?=$this->h1; ?></h1>
<?php <?php
$this->brick('article'); $this->brick('markup', ['markup' => $this->article]);
if ($this->relBoss): if ($this->relBoss):
echo " <div>".sprintf(Lang::gameObject('npcLootPH'), $this->name, $this->relBoss[0], $this->relBoss[1])."</div>\n"; echo " <div>".sprintf(Lang::gameObject('npcLootPH'), $this->h1, $this->relBoss[0], $this->relBoss[1])."</div>\n";
echo ' <div class="pad"></div>'; echo ' <div class="pad"></div>';
endif; endif;
if (!empty($this->map)): if ($this->map):
$this->brick('mapper'); $this->brick('mapper');
else: else:
echo Lang::gameObject('unkPosition'); echo Lang::gameObject('unkPosition');
@@ -35,26 +38,15 @@ endif;
$this->brick('book'); $this->brick('book');
if (isset($this->smartAI)): $this->brick('markup', ['markup' => $this->smartAI]);
?>
<div id="text-generic" class="left"></div>
<script type="text/javascript">//<![CDATA[
Markup.printHtml("<?=$this->smartAI; ?>", "text-generic", {
allow: Markup.CLASS_ADMIN,
dbpage: true
});
//]]></script>
<div class="pad2"></div>
<?php
endif;
?> ?>
<h2 class="clear"><?=Lang::main('related'); ?></h2> <h2 class="clear"><?=Lang::main('related'); ?></h2>
</div> </div>
<?php <?php
$this->brick('lvTabs', ['relTabs' => true]); $this->brick('lvTabs');
$this->brick('contribute'); $this->brick('contribute');
?> ?>

View File

@@ -1,10 +1,11 @@
<?php namespace Aowow; ?>
<?php <?php
$this->brick('header'); namespace Aowow\Template;
$f = $this->filterObj->values // shorthand
?>
use \Aowow\Lang;
$this->brick('header');
$f = $this->filter->values; // shorthand
?>
<div class="main" id="main"> <div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div> <div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents"> <div class="main-contents" id="main-contents">
@@ -12,20 +13,27 @@ $f = $this->filterObj->values // shorthand
<?php <?php
$this->brick('announcement'); $this->brick('announcement');
$this->brick('pageTemplate', ['fiQuery' => $this->filterObj->query, 'fiMenuItem' => [5]]); $this->brick('pageTemplate', ['fiQuery' => $this->filter->query, 'fiMenuItem' => [5]]);
?> ?>
<div id="fi" style="display: <?=($this->filter->query ? 'block' : 'none'); ?>;">
<div id="fi" style="display: <?=($this->filterObj->query ? 'block' : 'none'); ?>;">
<form action="?filter=objects<?=$this->subCat; ?>" method="post" name="fi" onsubmit="return fi_submit(this)" onreset="return fi_reset(this)"> <form action="?filter=objects<?=$this->subCat; ?>" method="post" name="fi" onsubmit="return fi_submit(this)" onreset="return fi_reset(this)">
<div class="text">
<?php
$this->brick('headIcons');
$this->brick('redButtons');
?>
<h1><?=$this->h1; ?></h1>
</div>
<table> <table>
<tr><td><?=Util::ucFirst(Lang::main('name')).Lang::main('colon'); ?></td><td>&nbsp;<input type="text" name="na" size="30" <?=(isset($f['na']) ? 'value="'.Util::htmlEscape($f['na']).'" ' : null); ?>/></td></tr> <tr><td><?=$this->ucFirst(Lang::main('name')).Lang::main('colon'); ?></td><td>&nbsp;<input type="text" name="na" size="30" <?=($f['na'] ? 'value="'.$this->escHTML($f['na']).'" ' : ''); ?>/></td></tr>
</table> </table>
<div id="fi_criteria" class="padded criteria"><div></div></div><div><a href="javascript:;" id="fi_addcriteria" onclick="fi_addCriterion(this); return false"><?=Lang::main('addFilter'); ?></a></div> <div id="fi_criteria" class="padded criteria"><div></div></div><div><a href="javascript:;" id="fi_addcriteria" onclick="fi_addCriterion(this); return false"><?=Lang::main('addFilter'); ?></a></div>
<div class="padded2 clear"> <div class="padded2 clear">
<div style="float: right"><?=Lang::main('refineSearch'); ?></div> <div style="float: right"><?=Lang::main('refineSearch'); ?></div>
<?=Lang::main('match').Lang::main('colon'); ?><input type="radio" name="ma" value="" id="ma-0" <?=(!isset($f['ma']) ? 'checked="checked" ' : null); ?>/><label for="ma-0"><?=Lang::main('allFilter'); ?></label><input type="radio" name="ma" value="1" id="ma-1" <?=(isset($f['ma']) ? 'checked="checked" ' : null); ?> /><label for="ma-1"><?=Lang::main('oneFilter'); ?></label> <?=Lang::main('match'); ?><input type="radio" name="ma" value="" id="ma-0" <?=(!$f['ma'] ? 'checked="checked" ' : ''); ?>/><label for="ma-0"><?=Lang::main('allFilter'); ?></label><input type="radio" name="ma" value="1" id="ma-1" <?=($f['ma'] ? 'checked="checked" ' : ''); ?> /><label for="ma-1"><?=Lang::main('oneFilter'); ?></label>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
@@ -39,7 +47,7 @@ $this->brick('pageTemplate', ['fiQuery' => $this->filterObj->query, 'fiMenuItem'
<div class="pad"></div> <div class="pad"></div>
</div> </div>
<?php $this->brick('filter'); ?> <?=$this->renderFilter(12); ?>
<?php $this->brick('lvTabs'); ?> <?php $this->brick('lvTabs'); ?>