mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Template/Update (Part 32)
* convert dbtype 'event'
This commit is contained in:
337
endpoints/event/event.php
Normal file
337
endpoints/event/event.php
Normal file
@@ -0,0 +1,337 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class EventBaseResponse extends TemplateResponse implements ICache
|
||||
{
|
||||
use TrDetailPage, TrCache;
|
||||
|
||||
protected int $cacheType = CACHE_TYPE_PAGE;
|
||||
|
||||
protected string $template = 'detail-page-generic';
|
||||
protected string $pageName = 'event';
|
||||
protected ?int $activeTab = parent::TAB_DATABASE;
|
||||
protected array $breadcrumb = [0, 11];
|
||||
|
||||
public int $type = Type::WORLDEVENT;
|
||||
public int $typeId = 0;
|
||||
public array $dates = [];
|
||||
|
||||
private WorldEventList $subject;
|
||||
|
||||
public function __construct(string $id)
|
||||
{
|
||||
parent::__construct($id);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
$this->contribute = Type::getClassAttrib($this->type, 'contribute') ?? CONTRIBUTE_NONE;
|
||||
}
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$this->subject = new WorldEventList(array(['id', $this->typeId]));
|
||||
if ($this->subject->error)
|
||||
$this->generateNotFound(Lang::game('event'), Lang::event('notFound'));
|
||||
|
||||
$this->h1 = $this->subject->getField('name', true);
|
||||
$this->dates = array(
|
||||
'firstDate' => $this->subject->getField('startTime'),
|
||||
'lastDate' => $this->subject->getField('endTime'),
|
||||
'length' => $this->subject->getField('length'),
|
||||
'rec' => $this->subject->getField('occurence')
|
||||
);
|
||||
|
||||
$this->gPageInfo += array(
|
||||
'type' => $this->type,
|
||||
'typeId' => $this->typeId,
|
||||
'name' => $this->h1
|
||||
);
|
||||
|
||||
$_holidayId = $this->subject->getField('holidayId');
|
||||
|
||||
|
||||
/*************/
|
||||
/* Menu Path */
|
||||
/*************/
|
||||
|
||||
$this->breadcrumb[] = match ($this->subject->getField('scheduleType'))
|
||||
{
|
||||
-1 => 1,
|
||||
0, 1 => 2,
|
||||
2 => 3,
|
||||
'' => 0,
|
||||
default => 0
|
||||
};
|
||||
|
||||
|
||||
/**************/
|
||||
/* Page Title */
|
||||
/**************/
|
||||
|
||||
array_unshift($this->title, $this->h1, Util::ucWords(Lang::game('event')));
|
||||
|
||||
|
||||
/***********/
|
||||
/* Infobox */
|
||||
/***********/
|
||||
|
||||
$infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
|
||||
|
||||
// boss
|
||||
if ($_ = $this->subject->getField('bossCreature'))
|
||||
{
|
||||
$this->extendGlobalIds(Type::NPC, $_);
|
||||
$infobox[] = Lang::npc('rank', 3).Lang::main('colon').'[npc='.$_.']';
|
||||
}
|
||||
|
||||
// display internal id to staff
|
||||
if (User::isInGroup(U_GROUP_STAFF))
|
||||
$infobox[] = 'Event-Id'.Lang::main('colon').$this->typeId;
|
||||
|
||||
if ($infobox)
|
||||
$this->infobox = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF, 'dbpage' => true], 'infobox-contents0');
|
||||
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
// no entry in ?_articles? use default HolidayDescription
|
||||
if ($_holidayId && empty($this->article))
|
||||
$this->article = new Markup($this->subject->getField('description', true), ['dbpage' => true]);
|
||||
|
||||
if ($_holidayId)
|
||||
$this->wowheadLink = sprintf(WOWHEAD_LINK, Lang::getLocale()->domain(), 'event=', $_holidayId);
|
||||
|
||||
$this->headIcons = [$this->subject->getField('iconString')];
|
||||
$this->redButtons = array(
|
||||
BUTTON_WOWHEAD => $_holidayId > 0,
|
||||
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId]
|
||||
);
|
||||
|
||||
parent::generate();
|
||||
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated', true);
|
||||
|
||||
// tab: npcs
|
||||
if ($npcIds = DB::World()->selectCol('SELECT `id` AS ARRAY_KEY, IF(ec.`eventEntry` > 0, 1, 0) AS "added" FROM creature c, game_event_creature ec WHERE ec.`guid` = c.`guid` AND ABS(ec.`eventEntry`) = ?d', $this->typeId))
|
||||
{
|
||||
$creatures = new CreatureList(array(['id', array_keys($npcIds)]));
|
||||
if (!$creatures->error)
|
||||
{
|
||||
$data = $creatures->getListviewData();
|
||||
foreach ($data as &$d)
|
||||
$d['method'] = $npcIds[$d['id']];
|
||||
|
||||
$tabData = ['data' => $data];
|
||||
|
||||
if ($_holidayId && CreatureListFilter::getCriteriaIndex(38, $_holidayId))
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=38;crs='.$_holidayId.';crv=0');
|
||||
|
||||
$this->result->addDataLoader('zones'); // req. by secondary tooltip in this tab
|
||||
$this->lvTabs->addListviewTab(new Listview($tabData, CreatureList::$brickFile));
|
||||
}
|
||||
}
|
||||
|
||||
// tab: objects
|
||||
if ($objectIds = DB::World()->selectCol('SELECT `id` AS ARRAY_KEY, IF(eg.`eventEntry` > 0, 1, 0) AS "added" FROM gameobject g, game_event_gameobject eg WHERE eg.`guid` = g.`guid` AND ABS(eg.`eventEntry`) = ?d', $this->typeId))
|
||||
{
|
||||
$objects = new GameObjectList(array(['id', array_keys($objectIds)]));
|
||||
if (!$objects->error)
|
||||
{
|
||||
$data = $objects->getListviewData();
|
||||
foreach ($data as &$d)
|
||||
$d['method'] = $objectIds[$d['id']];
|
||||
|
||||
$tabData = ['data' => $data];
|
||||
|
||||
if ($_holidayId && GameObjectListFilter::getCriteriaIndex(16, $_holidayId))
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?objects&filter=cr=16;crs='.$_holidayId.';crv=0');
|
||||
|
||||
$this->result->addDataLoader('zones'); // req. by secondary tooltip in this tab
|
||||
$this->lvTabs->addListviewTab(new Listview($tabData, GameObjectList::$brickFile));
|
||||
}
|
||||
}
|
||||
|
||||
// tab: achievements
|
||||
if ($_ = $this->subject->getField('achievementCatOrId'))
|
||||
{
|
||||
$condition = $_ > 0 ? [['category', $_]] : [['id', -$_]];
|
||||
$acvs = new AchievementList($condition);
|
||||
if (!$acvs->error)
|
||||
{
|
||||
$this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
|
||||
|
||||
$tabData = array(
|
||||
'data' => $acvs->getListviewData(),
|
||||
'visibleCols' => ['category']
|
||||
);
|
||||
|
||||
if ($_holidayId && AchievementListFilter::getCriteriaIndex(11, $_holidayId))
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?achievements&filter=cr=11;crs='.$_holidayId.';crv=0');
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview($tabData, AchievementList::$brickFile));
|
||||
}
|
||||
}
|
||||
|
||||
$itemCnd = [];
|
||||
if ($_holidayId)
|
||||
{
|
||||
$itemCnd = array(
|
||||
'OR',
|
||||
['eventId', $this->typeId], // direct requirement on item
|
||||
);
|
||||
|
||||
// tab: quests (by table, go & creature)
|
||||
$quests = new QuestList(array(['eventId', $this->typeId]));
|
||||
if (!$quests->error)
|
||||
{
|
||||
$this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS));
|
||||
|
||||
$tabData = ['data'=> $quests->getListviewData()];
|
||||
|
||||
if (QuestListFilter::getCriteriaIndex(33, $_holidayId))
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=33;crs='.$_holidayId.';crv=0');
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview($tabData, QuestList::$brickFile));
|
||||
|
||||
$questItems = [];
|
||||
foreach (array_column($quests->rewards, Type::ITEM) as $arr)
|
||||
$questItems = array_merge($questItems, array_keys($arr));
|
||||
|
||||
foreach (array_column($quests->choices, Type::ITEM) as $arr)
|
||||
$questItems = array_merge($questItems, array_keys($arr));
|
||||
|
||||
foreach (array_column($quests->requires, Type::ITEM) as $arr)
|
||||
$questItems = array_merge($questItems, $arr);
|
||||
|
||||
if ($questItems)
|
||||
$itemCnd[] = ['id', $questItems];
|
||||
}
|
||||
}
|
||||
|
||||
// items from creature
|
||||
if ($npcIds && !$creatures->error)
|
||||
{
|
||||
// vendor
|
||||
$cIds = $creatures->getFoundIDs();
|
||||
if ($sells = DB::World()->selectCol(
|
||||
'SELECT `item` FROM npc_vendor nv WHERE `entry` IN (?a) UNION
|
||||
SELECT nv1.`item` FROM npc_vendor nv1 JOIN npc_vendor nv2 ON -nv1.`entry` = nv2.`item` WHERE nv2.`entry` IN (?a) UNION
|
||||
SELECT `item` FROM game_event_npc_vendor genv JOIN creature c ON genv.`guid` = c.`guid` WHERE c.`id` IN (?a)',
|
||||
$cIds, $cIds, $cIds
|
||||
))
|
||||
$itemCnd[] = ['id', $sells];
|
||||
}
|
||||
|
||||
// tab: items
|
||||
// not checking for loot ... cant distinguish between eventLoot and fillerCrapLoot
|
||||
if ($itemCnd)
|
||||
{
|
||||
$eventItems = new ItemList($itemCnd);
|
||||
if (!$eventItems->error)
|
||||
{
|
||||
$this->extendGlobalData($eventItems->getJSGlobals(GLOBALINFO_SELF));
|
||||
|
||||
$tabData = ['data'=> $eventItems->getListviewData()];
|
||||
|
||||
if ($_holidayId && ItemListFilter::getCriteriaIndex(160, $_holidayId))
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=160;crs='.$_holidayId.';crv=0');
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview($tabData, ItemList::$brickFile));
|
||||
}
|
||||
}
|
||||
|
||||
// tab: see also (event conditions)
|
||||
if ($rel = DB::World()->selectCol('SELECT IF(`eventEntry` = `prerequisite_event`, NULL, IF(`eventEntry` = ?d, `prerequisite_event`, -`eventEntry`)) FROM game_event_prerequisite WHERE `prerequisite_event` = ?d OR `eventEntry` = ?d', $this->typeId, $this->typeId, $this->typeId))
|
||||
{
|
||||
if (array_filter($rel, fn($x) => $x === null))
|
||||
trigger_error('game_event_prerequisite: this event has itself as prerequisite', E_USER_WARNING);
|
||||
|
||||
if ($seeAlso = array_filter($rel, fn($x) => $x > 0))
|
||||
{
|
||||
$relEvents = new WorldEventList(array(['id', $seeAlso]));
|
||||
$this->extendGlobalData($relEvents->getJSGlobals());
|
||||
$relData = $relEvents->getListviewData();
|
||||
foreach ($relEvents->getFoundIDs() as $id)
|
||||
Conditions::extendListviewRow($relData[$id], Conditions::SRC_NONE, $this->typeId, [-Conditions::ACTIVE_EVENT, $this->typeId]);
|
||||
|
||||
$this->extendGlobalData($this->subject->getJSGlobals());
|
||||
$d = $this->subject->getListviewData();
|
||||
foreach ($rel as $r)
|
||||
if ($r > 0)
|
||||
if (Conditions::extendListviewRow($d[$this->typeId], Conditions::SRC_NONE, $this->typeId, [-Conditions::ACTIVE_EVENT, $r]))
|
||||
$this->extendGlobalIds(Type::WORLDEVENT, $r);
|
||||
|
||||
$tabData = array(
|
||||
'data' => array_merge($relData, $d),
|
||||
'id' => 'see-also',
|
||||
'name' => '$LANG.tab_seealso',
|
||||
'hiddenCols' => ['date'],
|
||||
'extraCols' => ['$Listview.extraCols.condition']
|
||||
);
|
||||
$this->lvTabs->addListviewTab(new Listview($tabData, WorldEventList::$brickFile));
|
||||
}
|
||||
}
|
||||
|
||||
// tab: condition for
|
||||
$cnd = new Conditions();
|
||||
$cnd->getByCondition(Type::WORLDEVENT, $this->typeId)->prepare();
|
||||
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
|
||||
{
|
||||
$this->extendGlobalData($cnd->getJsGlobals());
|
||||
$this->lvTabs->addDataTab(...$tab);
|
||||
}
|
||||
|
||||
$this->result->registerDisplayHook('lvTabs', [self::class, 'tabsHook']);
|
||||
$this->result->registerDisplayHook('infobox', [self::class, 'infoboxHook']);
|
||||
}
|
||||
|
||||
// update dates to now()
|
||||
public static function tabsHook(Template\PageTemplate &$pt, Tabs &$lvTabs) : void
|
||||
{
|
||||
foreach ($lvTabs->iterate() as &$listview)
|
||||
if (is_object($listview) && $listview?->getTemplate() == 'holiday')
|
||||
WorldEventList::updateListview($listview);
|
||||
}
|
||||
|
||||
/* finalize infobox */
|
||||
public static function infoboxHook(Template\PageTemplate &$pt, ?InfoboxMarkup &$markup) : void
|
||||
{
|
||||
WorldEventList::updateDates($pt->dates, $start, $end, $rec);
|
||||
$infobox = [];
|
||||
|
||||
// start
|
||||
if ($start)
|
||||
$infobox[] = Lang::event('start').date(Lang::main('dateFmtLong'), $start);
|
||||
|
||||
// end
|
||||
if ($end)
|
||||
$infobox[] = Lang::event('end').date(Lang::main('dateFmtLong'), $end);
|
||||
|
||||
// interval
|
||||
if ($rec > 0)
|
||||
$infobox[] = Lang::event('interval').Util::formatTime($rec * 1000);
|
||||
|
||||
// in progress
|
||||
if ($start < time() && $end > time())
|
||||
$infobox[] = '[span class=q2]'.Lang::event('inProgress').'[/span]';
|
||||
|
||||
if ($infobox && !$markup)
|
||||
$markup = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF, 'dbpage' => true], 'infobox-contents0');
|
||||
else if ($markup)
|
||||
foreach ($infobox as $ib)
|
||||
$markup->addItem($ib);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
79
endpoints/event/event_power.php
Normal file
79
endpoints/event/event_power.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class EventPowerResponse extends TextResponse implements ICache
|
||||
{
|
||||
use TrCache, TrTooltip;
|
||||
|
||||
private const /* string */ POWER_TEMPLATE = '$WowheadPower.registerHoliday(%d, %d, %s);';
|
||||
|
||||
protected int $type = Type::WORLDEVENT;
|
||||
protected int $typeId = 0;
|
||||
protected int $cacheType = CACHE_TYPE_TOOLTIP;
|
||||
|
||||
protected array $expectedGET = array(
|
||||
'domain' => ['filter' => FILTER_CALLBACK, 'options' => [Locale::class, 'tryFromDomain']]
|
||||
);
|
||||
|
||||
private array $dates = [];
|
||||
|
||||
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
|
||||
{
|
||||
$worldevent = new WorldEventList(array(['id', $this->typeId]));
|
||||
if ($worldevent->error)
|
||||
$this->cacheType = CACHE_TYPE_NONE;
|
||||
else
|
||||
{
|
||||
$icon = $worldevent->getField('iconString');
|
||||
if ($icon == 'trade_engineering')
|
||||
$icon = null;
|
||||
|
||||
$opts = array(
|
||||
'name' => $worldevent->getField('name', true),
|
||||
'tooltip' => $worldevent->renderTooltip(),
|
||||
'icon' => $icon
|
||||
);
|
||||
|
||||
$this->dates = array(
|
||||
'firstDate' => $worldevent->getField('startTime'),
|
||||
'lastDate' => $worldevent->getField('endTime'),
|
||||
'length' => $worldevent->getField('length'),
|
||||
'rec' => $worldevent->getField('occurence')
|
||||
);
|
||||
|
||||
$this->setOnCacheLoaded([self::class, 'onBeforeDisplay'], $this->dates);
|
||||
}
|
||||
|
||||
$this->result = new Tooltip(self::POWER_TEMPLATE, $this->typeId, $opts ?? []);
|
||||
}
|
||||
|
||||
public static function onBeforeDisplay(string $tooltip, array $dates) : string
|
||||
{
|
||||
// update dates to now()
|
||||
WorldEventList::updateDates($dates, $start, $end);
|
||||
|
||||
return sprintf(
|
||||
$tooltip,
|
||||
$start ? date(Lang::main('dateFmtLong'), $start) : null,
|
||||
$end ? date(Lang::main('dateFmtLong'), $end) : null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
96
endpoints/events/events.php
Normal file
96
endpoints/events/events.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class EventsBaseResponse extends TemplateResponse implements ICache
|
||||
{
|
||||
use TrListPage, TrCache;
|
||||
|
||||
protected int $type = Type::WORLDEVENT;
|
||||
protected int $cacheType = CACHE_TYPE_PAGE;
|
||||
|
||||
protected string $template = 'list-page-generic';
|
||||
protected string $pageName = 'events';
|
||||
protected ?int $activeTab = parent::TAB_DATABASE;
|
||||
protected array $breadcrumb = [0, 11];
|
||||
|
||||
protected array $validCats = [0, 1, 2, 3];
|
||||
|
||||
public function __construct(string $pageParam)
|
||||
{
|
||||
$this->getCategoryFromUrl($pageParam);
|
||||
|
||||
parent::__construct($pageParam);
|
||||
}
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$this->h1 = Util::ucWords(Lang::game('events'));
|
||||
|
||||
|
||||
/**************/
|
||||
/* Page Title */
|
||||
/**************/
|
||||
|
||||
array_unshift($this->title, $this->h1);
|
||||
if ($this->category)
|
||||
array_unshift($this->title, Lang::event('category')[$this->category[0]]);
|
||||
|
||||
|
||||
/*************/
|
||||
/* Menu Path */
|
||||
/*************/
|
||||
|
||||
if ($this->category)
|
||||
$this->breadcrumb[] = $this->category[0];
|
||||
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
$this->redButtons[BUTTON_WOWHEAD] = true;
|
||||
|
||||
$condition = [];
|
||||
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
$condition[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
||||
|
||||
if ($this->category)
|
||||
$condition[] = match ($this->category[0])
|
||||
{
|
||||
1 => ['h.scheduleType', -1],
|
||||
2 => ['h.scheduleType', [0, 1]],
|
||||
3 => ['h.scheduleType', 2],
|
||||
default => ['e.holidayId', 0] // also cat 0
|
||||
};
|
||||
|
||||
$events = new WorldEventList($condition);
|
||||
$this->extendGlobalData($events->getJSGlobals());
|
||||
|
||||
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]);
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview(['data' => $events->getListviewData()], WorldEventList::$brickFile));
|
||||
|
||||
if ($_ = array_filter($events->getListviewData(), fn($x) => $x['category'] > 0))
|
||||
$this->lvTabs->addListviewTab(new Listview(['data' => $_, 'hideCount' => 1], 'calendar'));
|
||||
|
||||
parent::generate();
|
||||
|
||||
$this->result->registerDisplayHook('lvTabs', [self::class, 'tabsHook']);
|
||||
}
|
||||
|
||||
// recalculate dates with now()
|
||||
public static function tabsHook(Template\PageTemplate &$pt, Tabs &$lvTabs) : void
|
||||
{
|
||||
foreach ($lvTabs->iterate() as &$listview)
|
||||
if (is_object($listview) && ($listview?->getTemplate() == 'holiday' || $listview?->getTemplate() == 'holidaycal'))
|
||||
WorldEventList::updateListview($listview);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -113,7 +113,7 @@ class WorldEventList extends DBTypeList
|
||||
}
|
||||
}
|
||||
|
||||
public function getListviewData(bool $forNow = false) : array
|
||||
public function getListviewData() : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
@@ -132,15 +132,6 @@ class WorldEventList extends DBTypeList
|
||||
);
|
||||
}
|
||||
|
||||
if ($forNow)
|
||||
{
|
||||
foreach ($data as &$d)
|
||||
{
|
||||
self::updateDates($d['_date'], $d['startDate'], $d['endDate'], $d['rec']);
|
||||
unset($d['_date']);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1137,7 +1137,7 @@ $lang = array(
|
||||
'notFound' => "Dieses Weltereignis existiert nicht.",
|
||||
'start' => "Anfang: ",
|
||||
'end' => "Ende: ",
|
||||
'interval' => "Intervall",
|
||||
'interval' => "Intervall: ",
|
||||
'inProgress' => "Ereignis findet gerade statt",
|
||||
'category' => ["Nicht kategorisiert", "Feiertage", "Wiederkehrend", "Spieler vs. Spieler"]
|
||||
),
|
||||
|
||||
@@ -1137,7 +1137,7 @@ $lang = array(
|
||||
'notFound' => "This world event doesn't exist.",
|
||||
'start' => "Start: ",
|
||||
'end' => "End: ",
|
||||
'interval' => "Interval",
|
||||
'interval' => "Interval: ",
|
||||
'inProgress' => "Event is currently in progress",
|
||||
'category' => ["Uncategorized", "Holidays", "Recurring", "Player vs. Player"]
|
||||
),
|
||||
|
||||
@@ -1137,7 +1137,7 @@ $lang = array(
|
||||
'notFound' => "Este evento del mundo no existe.",
|
||||
'start' => "Empieza: ",
|
||||
'end' => "Termina: ",
|
||||
'interval' => "Intervalo",
|
||||
'interval' => "Intervalo: ",
|
||||
'inProgress' => "El evento está en progreso actualmente",
|
||||
'category' => ["Sin categoría", "Vacacionales", "Periódicos", "Jugador contra Jugador"]
|
||||
),
|
||||
|
||||
@@ -1137,7 +1137,7 @@ $lang = array(
|
||||
'notFound' => "Cet évènement mondial n'existe pas.",
|
||||
'start' => "Début : ",
|
||||
'end' => "Fin : ",
|
||||
'interval' => "Intervalle",
|
||||
'interval' => "Intervalle : ",
|
||||
'inProgress' => "L'évènement est présentement en cours",
|
||||
'category' => ["Non classés", "Vacances", "Récurrent", "Joueur ctr. Joueur"]
|
||||
),
|
||||
|
||||
@@ -1137,7 +1137,7 @@ $lang = array(
|
||||
'notFound' => "Это игровое событие не существует.",
|
||||
'start' => "Начало: ",
|
||||
'end' => "Конец: ",
|
||||
'interval' => "[Interval]",
|
||||
'interval' => "[Interval]: ",
|
||||
'inProgress' => "Событие активно в данный момент",
|
||||
'category' => array("Разное", "Праздники", "Периодические", "PvP")
|
||||
),
|
||||
|
||||
@@ -1136,7 +1136,7 @@ $lang = array(
|
||||
'notFound' => "这个世界事件不存在。",
|
||||
'start' => "开始:",
|
||||
'end' => "结束:",
|
||||
'interval' => "间隔",
|
||||
'interval' => "间隔:",
|
||||
'inProgress' => "事件正在进行中",
|
||||
'category' => ["未分类", "节日", "循环", "PvP"]
|
||||
),
|
||||
|
||||
365
pages/event.php
365
pages/event.php
@@ -1,365 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
// menuId 11: Worldevent g_initPath()
|
||||
// tabId 0: Database g_initHeader()
|
||||
class EventPage extends GenericPage
|
||||
{
|
||||
use TrDetailPage;
|
||||
|
||||
protected $dates = [];
|
||||
|
||||
protected $type = Type::WORLDEVENT;
|
||||
protected $typeId = 0;
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 11];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
protected $_get = ['domain' => ['filter' => FILTER_CALLBACK, 'options' => 'Aowow\Locale::tryFromDomain']];
|
||||
|
||||
private $powerTpl = '$WowheadPower.registerHoliday(%d, %d, %s);';
|
||||
private $hId = 0;
|
||||
private $eId = 0;
|
||||
|
||||
public function __construct($pageCall, $id)
|
||||
{
|
||||
parent::__construct($pageCall, $id);
|
||||
|
||||
// temp locale
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP && $this->_get['domain'])
|
||||
Lang::load($this->_get['domain']);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
|
||||
$this->subject = new WorldEventList(array(['id', $this->typeId]));
|
||||
if ($this->subject->error)
|
||||
$this->notFound(Lang::game('event'), Lang::event('notFound'));
|
||||
|
||||
$this->hId = $this->subject->getField('holidayId');
|
||||
$this->eId = $this->typeId;
|
||||
$this->name = $this->subject->getField('name', true);
|
||||
$this->dates = array(
|
||||
'firstDate' => $this->subject->getField('startTime'),
|
||||
'lastDate' => $this->subject->getField('endTime'),
|
||||
'length' => $this->subject->getField('length'),
|
||||
'rec' => $this->subject->getField('occurence')
|
||||
);
|
||||
}
|
||||
|
||||
protected function generatePath()
|
||||
{
|
||||
switch ($this->subject->getField('scheduleType'))
|
||||
{
|
||||
case '': $this->path[] = 0; break;
|
||||
case -1: $this->path[] = 1; break;
|
||||
case 0:
|
||||
case 1: $this->path[] = 2; break;
|
||||
case 2: $this->path[] = 3; break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateTitle()
|
||||
{
|
||||
array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::game('event')));
|
||||
}
|
||||
|
||||
protected function generateContent()
|
||||
{
|
||||
$this->addScript([SC_JS_FILE, '?data=zones']);
|
||||
|
||||
/***********/
|
||||
/* Infobox */
|
||||
/***********/
|
||||
|
||||
$this->infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
|
||||
|
||||
// boss
|
||||
if ($_ = $this->subject->getField('bossCreature'))
|
||||
{
|
||||
$this->extendGlobalIds(Type::NPC, $_);
|
||||
$this->infobox[] = Lang::npc('rank', 3).Lang::main('colon').'[npc='.$_.']';
|
||||
}
|
||||
|
||||
// display internal id to staff
|
||||
if (User::isInGroup(U_GROUP_STAFF))
|
||||
$this->infobox[] = 'Event-Id'.Lang::main('colon').$this->eId;
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
// no entry in ?_articles? use default HolidayDescription
|
||||
if ($this->hId && empty($this->article))
|
||||
$this->article = ['text' => Util::jsEscape($this->subject->getField('description', true)), 'params' => []];
|
||||
|
||||
$this->headIcons = [$this->subject->getField('iconString')];
|
||||
$this->redButtons = array(
|
||||
BUTTON_WOWHEAD => $this->hId > 0,
|
||||
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId]
|
||||
);
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
$hasFilter = in_array($this->hId, [372, 283, 285, 353, 420, 400, 284, 201, 374, 409, 141, 324, 321, 424, 335, 327, 341, 181, 404, 398, 301]);
|
||||
|
||||
// tab: npcs
|
||||
if ($npcIds = DB::World()->selectCol('SELECT id AS ARRAY_KEY, IF(ec.eventEntry > 0, 1, 0) AS added FROM creature c, game_event_creature ec WHERE ec.guid = c.guid AND ABS(ec.eventEntry) = ?d', $this->eId))
|
||||
{
|
||||
$creatures = new CreatureList(array(['id', array_keys($npcIds)]));
|
||||
if (!$creatures->error)
|
||||
{
|
||||
$data = $creatures->getListviewData();
|
||||
foreach ($data as &$d)
|
||||
$d['method'] = $npcIds[$d['id']];
|
||||
|
||||
$tabData = ['data' => array_values($data)];
|
||||
|
||||
if ($hasFilter)
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=38;crs='.$this->hId.';crv=0');
|
||||
|
||||
$this->lvTabs[] = [CreatureList::$brickFile, $tabData];
|
||||
}
|
||||
}
|
||||
|
||||
// tab: objects
|
||||
if ($objectIds = DB::World()->selectCol('SELECT id AS ARRAY_KEY, IF(eg.eventEntry > 0, 1, 0) AS added FROM gameobject g, game_event_gameobject eg WHERE eg.guid = g.guid AND ABS(eg.eventEntry) = ?d', $this->eId))
|
||||
{
|
||||
$objects = new GameObjectList(array(['id', array_keys($objectIds)]));
|
||||
if (!$objects->error)
|
||||
{
|
||||
$data = $objects->getListviewData();
|
||||
foreach ($data as &$d)
|
||||
$d['method'] = $objectIds[$d['id']];
|
||||
|
||||
$tabData = ['data' => array_values($data)];
|
||||
|
||||
if ($hasFilter)
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?objects&filter=cr=16;crs='.$this->hId.';crv=0');
|
||||
|
||||
$this->lvTabs[] = [GameObjectList::$brickFile, $tabData];
|
||||
}
|
||||
}
|
||||
|
||||
// tab: achievements
|
||||
if ($_ = $this->subject->getField('achievementCatOrId'))
|
||||
{
|
||||
$condition = $_ > 0 ? [['category', $_]] : [['id', -$_]];
|
||||
$acvs = new AchievementList($condition);
|
||||
if (!$acvs->error)
|
||||
{
|
||||
$this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
|
||||
|
||||
$tabData = array(
|
||||
'data' => array_values($acvs->getListviewData()),
|
||||
'visibleCols' => ['category']
|
||||
);
|
||||
|
||||
if ($hasFilter)
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?achievements&filter=cr=11;crs='.$this->hId.';crv=0');
|
||||
|
||||
$this->lvTabs[] = [AchievementList::$brickFile, $tabData];
|
||||
}
|
||||
}
|
||||
|
||||
$itemCnd = [];
|
||||
if ($this->hId)
|
||||
{
|
||||
$itemCnd = array(
|
||||
'OR',
|
||||
['eventId', $this->eId], // direct requirement on item
|
||||
);
|
||||
|
||||
// tab: quests (by table, go & creature)
|
||||
$quests = new QuestList(array(['eventId', $this->eId]));
|
||||
if (!$quests->error)
|
||||
{
|
||||
$this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS));
|
||||
|
||||
$tabData = ['data'=> array_values($quests->getListviewData())];
|
||||
|
||||
if ($hasFilter)
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=33;crs='.$this->hId.';crv=0');
|
||||
|
||||
$this->lvTabs[] = [QuestList::$brickFile, $tabData];
|
||||
|
||||
$questItems = [];
|
||||
foreach (array_column($quests->rewards, Type::ITEM) as $arr)
|
||||
$questItems = array_merge($questItems, array_keys($arr));
|
||||
|
||||
foreach (array_column($quests->choices, Type::ITEM) as $arr)
|
||||
$questItems = array_merge($questItems, array_keys($arr));
|
||||
|
||||
foreach (array_column($quests->requires, Type::ITEM) as $arr)
|
||||
$questItems = array_merge($questItems, $arr);
|
||||
|
||||
if ($questItems)
|
||||
$itemCnd[] = ['id', $questItems];
|
||||
}
|
||||
}
|
||||
|
||||
// items from creature
|
||||
if ($npcIds && !$creatures->error)
|
||||
{
|
||||
// vendor
|
||||
$cIds = $creatures->getFoundIDs();
|
||||
if ($sells = DB::World()->selectCol(
|
||||
'SELECT `item` FROM npc_vendor nv WHERE `entry` IN (?a) UNION
|
||||
SELECT nv1.`item` FROM npc_vendor nv1 JOIN npc_Vendor nv2 ON -nv1.`entry` = nv2.`item` WHERE nv2.`entry` IN (?a) UNION
|
||||
SELECT `item` FROM game_event_npc_vendor genv JOIN creature c ON genv.`guid` = c.`guid` WHERE c.`id` IN (?a)',
|
||||
$cIds, $cIds, $cIds
|
||||
))
|
||||
$itemCnd[] = ['id', $sells];
|
||||
}
|
||||
|
||||
// tab: items
|
||||
// not checking for loot ... cant distinguish between eventLoot and fillerCrapLoot
|
||||
if ($itemCnd)
|
||||
{
|
||||
$eventItems = new ItemList($itemCnd);
|
||||
if (!$eventItems->error)
|
||||
{
|
||||
$this->extendGlobalData($eventItems->getJSGlobals(GLOBALINFO_SELF));
|
||||
|
||||
$tabData = ['data'=> array_values($eventItems->getListviewData())];
|
||||
|
||||
if ($hasFilter)
|
||||
$tabData['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=160;crs='.$this->hId.';crv=0');
|
||||
|
||||
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
|
||||
}
|
||||
}
|
||||
|
||||
// tab: see also (event conditions)
|
||||
if ($rel = DB::World()->selectCol('SELECT IF(eventEntry = prerequisite_event, NULL, IF(eventEntry = ?d, prerequisite_event, -eventEntry)) FROM game_event_prerequisite WHERE prerequisite_event = ?d OR eventEntry = ?d', $this->eId, $this->eId, $this->eId))
|
||||
{
|
||||
$list = [];
|
||||
array_walk($rel, function($v, $k) use (&$list) {
|
||||
if ($v > 0)
|
||||
$list[] = $v;
|
||||
else if ($v === null)
|
||||
trigger_error('game_event_prerequisite: this event has itself as prerequisite', E_USER_WARNING);
|
||||
});
|
||||
|
||||
if ($list)
|
||||
{
|
||||
$relEvents = new WorldEventList(array(['id', $list]));
|
||||
$this->extendGlobalData($relEvents->getJSGlobals());
|
||||
$relData = $relEvents->getListviewData();
|
||||
foreach ($relEvents->getFoundIDs() as $id)
|
||||
Conditions::extendListviewRow($relData[$id], Conditions::SRC_NONE, $this->typeId, [-Conditions::ACTIVE_EVENT, $this->eId]);
|
||||
|
||||
$this->extendGlobalData($this->subject->getJSGlobals());
|
||||
$d = $this->subject->getListviewData();
|
||||
foreach ($rel as $r)
|
||||
if ($r > 0)
|
||||
if (Conditions::extendListviewRow($d[$this->eId], Conditions::SRC_NONE, $this->typeId, [-Conditions::ACTIVE_EVENT, $r]))
|
||||
$this->extendGlobalIds(Type::WORLDEVENT, $r);
|
||||
|
||||
$relData = array_merge($relData, $d);
|
||||
|
||||
$this->lvTabs[] = [WorldEventList::$brickFile, array(
|
||||
'data' => array_values($relData),
|
||||
'id' => 'see-also',
|
||||
'name' => '$LANG.tab_seealso',
|
||||
'hiddenCols' => ['date'],
|
||||
'extraCols' => ['$Listview.extraCols.condition']
|
||||
)];
|
||||
}
|
||||
}
|
||||
|
||||
// tab: condition for
|
||||
$cnd = new Conditions();
|
||||
$cnd->getByCondition(Type::WORLDEVENT, $this->typeId)->prepare();
|
||||
if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'))
|
||||
{
|
||||
$this->extendGlobalData($cnd->getJsGlobals());
|
||||
$this->lvTabs[] = $tab;
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateTooltip() : string
|
||||
{
|
||||
$power = new \StdClass();
|
||||
if (!$this->subject->error)
|
||||
{
|
||||
$power->{'name_'.Lang::getLocale()->json()} = $this->subject->getField('name', true);
|
||||
|
||||
if ($this->subject->getField('iconString') != 'trade_engineering')
|
||||
$power->icon = rawurlencode($this->subject->getField('iconString', true, true));
|
||||
|
||||
$power->{'tooltip_'.Lang::getLocale()->json()} = $this->subject->renderTooltip();
|
||||
}
|
||||
|
||||
return sprintf($this->powerTpl, $this->typeId, Lang::getLocale()->value, Util::toJSON($power, JSON_AOWOW_POWER));
|
||||
}
|
||||
|
||||
protected function postCache()
|
||||
{
|
||||
// update dates to now()
|
||||
WorldEventList::updateDates($this->dates, $start, $end, $rec);
|
||||
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP)
|
||||
{
|
||||
return array(
|
||||
date(Lang::main('dateFmtLong'), $start),
|
||||
date(Lang::main('dateFmtLong'), $end)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->hId)
|
||||
$this->wowheadLink = sprintf(WOWHEAD_LINK, Lang::getLocale()->domain(), 'event', $this->hId);
|
||||
|
||||
/********************/
|
||||
/* finalize infobox */
|
||||
/********************/
|
||||
|
||||
// start
|
||||
if ($start)
|
||||
array_push($this->infobox, Lang::event('start').Lang::main('colon').date(Lang::main('dateFmtLong'), $start));
|
||||
|
||||
// end
|
||||
if ($end)
|
||||
array_push($this->infobox, Lang::event('end').Lang::main('colon').date(Lang::main('dateFmtLong'), $end));
|
||||
|
||||
// occurence
|
||||
if ($rec > 0)
|
||||
array_push($this->infobox, Lang::event('interval').Lang::main('colon').Util::formatTime($rec * 1000));
|
||||
|
||||
// in progress
|
||||
if ($start < time() && $end > time())
|
||||
array_push($this->infobox, '[span class=q2]'.Lang::event('inProgress').'[/span]');
|
||||
|
||||
$this->infobox = '[ul][li]'.implode('[/li][li]', $this->infobox).'[/li][/ul]';
|
||||
|
||||
/***************************/
|
||||
/* finalize related events */
|
||||
/***************************/
|
||||
|
||||
foreach ($this->lvTabs as &$view)
|
||||
{
|
||||
if ($view[0] != WorldEventList::$brickFile)
|
||||
continue;
|
||||
|
||||
foreach ($view[1]['data'] as &$data)
|
||||
{
|
||||
WorldEventList::updateDates($data['_date'], $start, $end, $rec);
|
||||
unset($data['_date']);
|
||||
$data['startDate'] = $start ? date(Util::$dateFormatInternal, $start) : false;
|
||||
$data['endDate'] = $end ? date(Util::$dateFormatInternal, $end) : false;
|
||||
$data['rec'] = $rec;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
109
pages/events.php
109
pages/events.php
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
// menuId 11: Event g_initPath()
|
||||
// tabId 0: Database g_initHeader()
|
||||
class EventsPage extends GenericPage
|
||||
{
|
||||
use TrListPage;
|
||||
|
||||
private $dependency = [];
|
||||
|
||||
protected $type = Type::WORLDEVENT;
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 11];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [0, 1, 2, 3];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
{
|
||||
$this->getCategoryFromUrl($pageParam);
|
||||
|
||||
parent::__construct($pageCall, $pageParam);
|
||||
|
||||
$this->name = Util::ucFirst(Lang::game('events'));
|
||||
}
|
||||
|
||||
protected function generateContent()
|
||||
{
|
||||
$condition = [];
|
||||
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
$condition[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
|
||||
|
||||
if ($this->category)
|
||||
{
|
||||
switch ($this->category[0])
|
||||
{
|
||||
case 0: $condition[] = ['e.holidayId', 0]; break;
|
||||
case 1: $condition[] = ['h.scheduleType', -1]; break;
|
||||
case 2: $condition[] = ['h.scheduleType', [0, 1]]; break;
|
||||
case 3: $condition[] = ['h.scheduleType', 2]; break;
|
||||
}
|
||||
}
|
||||
|
||||
$events = new WorldEventList($condition);
|
||||
$this->extendGlobalData($events->getJSGlobals());
|
||||
|
||||
foreach ($events->iterate() as $__)
|
||||
if ($d = $events->getField('requires'))
|
||||
$this->dependency[$events->id] = $d;
|
||||
|
||||
$data = array_values($events->getListviewData());
|
||||
|
||||
$this->lvTabs[] = [WorldEventList::$brickFile, ['data' => $data]];
|
||||
|
||||
if ($_ = array_values(array_filter($data, function($x) {return $x['category'] > 0;})))
|
||||
{
|
||||
$this->lvTabs[] = ['calendar', array(
|
||||
'data' => $_,
|
||||
'hideCount' => 1
|
||||
)];
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateTitle()
|
||||
{
|
||||
array_unshift($this->title, $this->name);
|
||||
if ($this->category)
|
||||
array_unshift($this->title, Lang::event('category')[$this->category[0]]);
|
||||
}
|
||||
|
||||
protected function generatePath()
|
||||
{
|
||||
if ($this->category)
|
||||
$this->path[] = $this->category[0];
|
||||
}
|
||||
|
||||
protected function postCache()
|
||||
{
|
||||
// recalculate dates with now()
|
||||
foreach ($this->lvTabs as &$views)
|
||||
{
|
||||
foreach ($views[1]['data'] as &$data)
|
||||
{
|
||||
// is a followUp-event
|
||||
if (!empty($this->dependency[$data['id']]))
|
||||
{
|
||||
$data['startDate'] = $data['endDate'] = false;
|
||||
unset($data['_date']);
|
||||
continue;
|
||||
}
|
||||
|
||||
WorldEventList::updateDates($data['_date'], $start, $end, $rec);
|
||||
unset($data['_date']);
|
||||
$data['startDate'] = $start ? date(Util::$dateFormatInternal, $start) : false;
|
||||
$data['endDate'] = $end ? date(Util::$dateFormatInternal, $end) : false;
|
||||
$data['rec'] = $rec;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user