mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Template/Update (Part 43)
* split 'arena-teams' into separate endpoints
This commit is contained in:
146
endpoints/arena-team/arena-team.php
Normal file
146
endpoints/arena-team/arena-team.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class ArenateamBaseResponse extends TemplateResponse
|
||||
{
|
||||
use TrProfilerDetail;
|
||||
|
||||
protected string $template = 'roster';
|
||||
protected string $pageName = 'arena-team';
|
||||
protected ?int $activeTab = parent::TAB_TOOLS;
|
||||
protected array $breadcrumb = [1, 5, 3]; // Tools > Profiler > Arena Team
|
||||
|
||||
protected array $dataLoader = ['realms', 'weight-presets'];
|
||||
protected array $scripts = array(
|
||||
[SC_JS_FILE, 'js/profile_all.js'],
|
||||
[SC_JS_FILE, 'js/profile.js'],
|
||||
[SC_CSS_FILE, 'css/Profiler.css']
|
||||
);
|
||||
|
||||
public int $type = Type::ARENA_TEAM;
|
||||
|
||||
public function __construct(string $idOrProfile)
|
||||
{
|
||||
parent::__construct($idOrProfile);
|
||||
|
||||
if (!Cfg::get('PROFILER_ENABLE'))
|
||||
$this->generateError();
|
||||
|
||||
if (!$idOrProfile)
|
||||
$this->generateError();
|
||||
|
||||
$this->getSubjectFromUrl($idOrProfile);
|
||||
|
||||
// we have an ID > ok
|
||||
if ($this->typeId)
|
||||
return;
|
||||
|
||||
// param was incomplete profile > error
|
||||
if (!$this->subjectName)
|
||||
$this->generateError();
|
||||
|
||||
// 3 possibilities
|
||||
// 1) already synced to aowow
|
||||
if ($subject = DB::Aowow()->selectRow('SELECT `id`, `realmGUID`, `cuFlags` FROM ?_profiler_arena_team WHERE `realm` = ?d AND `nameUrl` = ?', $this->realmId, Profiler::urlize($this->subjectName)))
|
||||
{
|
||||
$this->typeId = $subject['id'];
|
||||
|
||||
if ($subject['cuFlags'] & PROFILER_CU_NEEDS_RESYNC)
|
||||
$this->handleIncompleteData(Type::ARENA_TEAM, $subject['realmGUID']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 2) not yet synced but exists on realm (wont work if we get passed an urlized name, but there is nothing we can do about it)
|
||||
else if ($subject = DB::Characters($this->realmId)->selectRow('SELECT at.`arenaTeamId` AS "realmGUID", at.`name`, at.`type` FROM arena_team at WHERE at.`name` = ?', Util::ucFirst($this->subjectName)))
|
||||
{
|
||||
$subject['realm'] = $this->realmId;
|
||||
$subject['cuFlags'] = PROFILER_CU_NEEDS_RESYNC;
|
||||
|
||||
// create entry from realm with basic info
|
||||
DB::Aowow()->query('INSERT IGNORE INTO ?_profiler_arena_team (?#) VALUES (?a)', array_keys($subject), array_values($subject));
|
||||
|
||||
$this->handleIncompleteData(Type::ARENA_TEAM, $subject['realmGUID']);
|
||||
return;
|
||||
}
|
||||
|
||||
// 3) does not exist at all
|
||||
$this->notFound();
|
||||
}
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
if ($this->doResync)
|
||||
{
|
||||
parent::generate();
|
||||
return;
|
||||
}
|
||||
|
||||
$subject = new LocalArenaTeamList(array(['at.id', $this->typeId]));
|
||||
if ($subject->error)
|
||||
$this->notFound();
|
||||
|
||||
// arena team accessed by id
|
||||
if (!$this->subjectName)
|
||||
$this->forward($subject->getProfileUrl());
|
||||
|
||||
$this->h1 = Lang::profiler('arenaRoster', [$subject->getField('name')]);
|
||||
|
||||
|
||||
/*************/
|
||||
/* Menu Path */
|
||||
/*************/
|
||||
|
||||
$this->followBreadcrumbPath();
|
||||
|
||||
|
||||
/**************/
|
||||
/* Page Title */
|
||||
/**************/
|
||||
|
||||
array_unshift(
|
||||
$this->title,
|
||||
$subject->getField('name').' ('.$this->realm.' - '.Lang::profiler('regions', $this->region).')',
|
||||
Util::ucFirst(Lang::profiler('profiler'))
|
||||
);
|
||||
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
parent::generate();
|
||||
|
||||
$this->redButtons[BUTTON_RESYNC] = [$this->typeId, 'arena-team'];
|
||||
|
||||
// statistic calculations here
|
||||
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated');
|
||||
|
||||
// tab: members
|
||||
$member = new LocalProfileList(array(['atm.arenaTeamId', $this->typeId]));
|
||||
$this->lvTabs->addListviewTab(new Listview(array(
|
||||
'data' => $member->getListviewData(PROFILEINFO_CHARACTER | PROFILEINFO_ARENA),
|
||||
'sort' => [-15],
|
||||
'visibleCols' => ['race', 'classs', 'level', 'talents', 'gearscore', 'rating', 'wins', 'losses'],
|
||||
'hiddenCols' => ['guild', 'location']
|
||||
), ProfileList::$brickFile));
|
||||
}
|
||||
|
||||
private function notFound() : never
|
||||
{
|
||||
parent::generateNotFound(Lang::game('arenateam'), Lang::profiler('notFound', 'arenateam'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
48
endpoints/arena-team/resync.php
Normal file
48
endpoints/arena-team/resync.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class ArenaTeamResyncResponse extends TextResponse
|
||||
{
|
||||
protected array $expectedGET = array(
|
||||
'id' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkIdList'] ],
|
||||
'profile' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkEmptySet']]
|
||||
);
|
||||
|
||||
public function __construct(string $pageParam)
|
||||
{
|
||||
parent::__construct($pageParam);
|
||||
|
||||
if (!Cfg::get('PROFILER_ENABLE'))
|
||||
$this->generate404();
|
||||
}
|
||||
|
||||
/* params
|
||||
id: <prId1,prId2,..,prIdN>
|
||||
user: <string> [optional, not used]
|
||||
profile: <empty> [optional, also get related chars]
|
||||
return: 1
|
||||
*/
|
||||
protected function generate() : void
|
||||
{
|
||||
if (!$this->assertGET('id'))
|
||||
return;
|
||||
|
||||
if ($teams = DB::Aowow()->select('SELECT `realm`, `realmGUID` FROM ?_profiler_arena_team WHERE `id` IN (?a)', $this->_get['id']))
|
||||
foreach ($teams as $t)
|
||||
Profiler::scheduleResync(Type::ARENA_TEAM, $t['realm'], $t['realmGUID']);
|
||||
|
||||
if ($this->_get['profile'])
|
||||
if ($chars = DB::Aowow()->select('SELECT `realm`, `realmGUID` FROM ?_profiler_profiles p JOIN ?_profiler_arena_team_member atm ON atm.`profileId` = p.`id` WHERE atm.`arenaTeamId` IN (?a)', $this->_get['id']))
|
||||
foreach ($chars as $c)
|
||||
Profiler::scheduleResync(Type::PROFILE, $c['realm'], $c['realmGUID']);
|
||||
|
||||
$this->result = 1; // as string?
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
29
endpoints/arena-team/status.php
Normal file
29
endpoints/arena-team/status.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class ArenaTeamStatusResponse extends TextResponse
|
||||
{
|
||||
protected array $expectedGET = array(
|
||||
'id' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkIdList']]
|
||||
);
|
||||
|
||||
public function __construct(string $pageParam)
|
||||
{
|
||||
parent::__construct($pageParam);
|
||||
|
||||
if (!Cfg::get('PROFILER_ENABLE'))
|
||||
$this->generate404();
|
||||
}
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$this->result = Profiler::resyncStatus(Type::ARENA_TEAM, $this->_get['id']);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
152
endpoints/arena-teams/arena-teams.php
Normal file
152
endpoints/arena-teams/arena-teams.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class ArenateamsBaseResponse extends TemplateResponse implements IProfilerList
|
||||
{
|
||||
use TrProfilerList, TrListPage;
|
||||
|
||||
protected string $template = 'arena-teams';
|
||||
protected string $pageName = 'arena-teams';
|
||||
protected ?int $activeTab = parent::TAB_TOOLS;
|
||||
protected array $breadcrumb = [1, 5, 3]; // Tools > Profiler > Arena Teams
|
||||
|
||||
protected array $dataLoader = ['realms'];
|
||||
protected array $scripts = array(
|
||||
[SC_JS_FILE, 'js/filters.js'],
|
||||
[SC_JS_FILE, 'js/profile_all.js'],
|
||||
[SC_JS_FILE, 'js/profile.js']
|
||||
);
|
||||
protected array $expectedGET = array(
|
||||
'filter' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => Filter::PATTERN_PARAM]]
|
||||
);
|
||||
|
||||
public int $type = Type::ARENA_TEAM;
|
||||
|
||||
private int $sumSubjects = 0;
|
||||
|
||||
public function __construct(string $pageParam)
|
||||
{
|
||||
if (!Cfg::get('PROFILER_ENABLE'))
|
||||
$this->generateError();
|
||||
|
||||
$this->getSubjectFromUrl($pageParam);
|
||||
|
||||
parent::__construct($pageParam);
|
||||
|
||||
$realms = [];
|
||||
foreach (Profiler::getRealms() as $idx => $r)
|
||||
{
|
||||
if ($this->region && $r['region'] != $this->region)
|
||||
continue;
|
||||
|
||||
if ($this->realm && $r['name'] != $this->realm)
|
||||
continue;
|
||||
|
||||
$this->sumSubjects += DB::Characters($idx)->selectCell('SELECT count(*) FROM arena_team');
|
||||
$realms[] = $idx;
|
||||
}
|
||||
|
||||
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
|
||||
$this->filter = new ArenaTeamListFilter($this->_get['filter'] ?? '', ['realms' => $realms]);
|
||||
$this->filterError = $this->filter->error;
|
||||
}
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$this->h1 = Lang::game('arenateams');
|
||||
|
||||
|
||||
/*************/
|
||||
/* Menu Path */
|
||||
/*************/
|
||||
|
||||
$this->followBreadcrumbPath();
|
||||
|
||||
|
||||
/**************/
|
||||
/* Page Title */
|
||||
/**************/
|
||||
|
||||
if ($this->realm)
|
||||
array_unshift($this->title, $this->realm,/* Cfg::get('BATTLEGROUP'),*/ Lang::profiler('regions', $this->region), Lang::game('arenateams'));
|
||||
else if ($this->region)
|
||||
array_unshift($this->title, Lang::profiler('regions', $this->region), Lang::game('arenateams'));
|
||||
else
|
||||
array_unshift($this->title, Lang::game('arenateams'));
|
||||
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
$conditions = [];
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
$conditions[] = ['at.seasonGames', 0, '>'];
|
||||
|
||||
if ($_ = $this->filter->getConditions())
|
||||
$conditions[] = $_;
|
||||
|
||||
$this->getRegions();
|
||||
|
||||
$tabData = array(
|
||||
'id' => 'arena-teams',
|
||||
'data' => [],
|
||||
'hideCount' => 1,
|
||||
'sort' => [-16],
|
||||
'extraCols' => ['$Listview.extraCols.members'],
|
||||
'visibleCols' => ['rank', 'wins', 'losses', 'rating'],
|
||||
'hiddenCols' => ['arenateam', 'guild']
|
||||
);
|
||||
|
||||
if (!$this->filter->values['sz'])
|
||||
$tabData['visibleCols'][] = 'size';
|
||||
|
||||
if ($this->filter->values['si'])
|
||||
$tabData['hiddenCols'][] = 'faction';
|
||||
|
||||
$miscParams = ['calcTotal' => true];
|
||||
if ($this->realm)
|
||||
$miscParams['sv'] = $this->realm;
|
||||
if ($this->region)
|
||||
$miscParams['rg'] = $this->region;
|
||||
|
||||
$teams = new RemoteArenaTeamList($conditions, $miscParams);
|
||||
if (!$teams->error)
|
||||
{
|
||||
$teams->initializeLocalEntries();
|
||||
|
||||
$tabData['data'] = $teams->getListviewData();
|
||||
|
||||
// create note if search limit was exceeded
|
||||
if ($this->filter->query && $teams->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
|
||||
{
|
||||
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_arenateamsfound2', $this->sumSubjects, $teams->getMatches());
|
||||
$tabData['_truncated'] = 1;
|
||||
}
|
||||
else if ($teams->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
|
||||
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_arenateamsfound', $this->sumSubjects, 0);
|
||||
}
|
||||
|
||||
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated');
|
||||
|
||||
$this->lvTabs->addListviewTab(new Listview($tabData, ArenaTeamList::$brickFile, 'membersCol'));
|
||||
|
||||
parent::generate();
|
||||
|
||||
$this->result->registerDisplayHook('filter', [self::class, 'filterFormHook']);
|
||||
}
|
||||
|
||||
public static function filterFormHook(Template\PageTemplate &$pt, ArenaTeamListFilter $filter) : void
|
||||
{
|
||||
// sort for dropdown-menus
|
||||
Lang::sort('game', 'cl');
|
||||
Lang::sort('game', 'ra');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
class AjaxArenaTeam extends AjaxHandler
|
||||
{
|
||||
protected $validParams = ['resync', 'status'];
|
||||
protected $_get = array(
|
||||
'id' => ['filter' => FILTER_CALLBACK, 'options' => 'Aowow\AjaxHandler::checkIdList' ],
|
||||
'profile' => ['filter' => FILTER_CALLBACK, 'options' => 'Aowow\AjaxHandler::checkEmptySet'],
|
||||
);
|
||||
|
||||
public function __construct(array $params)
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
if (!$this->params)
|
||||
return;
|
||||
|
||||
switch ($this->params[0])
|
||||
{
|
||||
case 'resync':
|
||||
$this->handler = 'handleResync';
|
||||
break;
|
||||
case 'status':
|
||||
$this->handler = 'handleStatus';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* params
|
||||
id: <prId1,prId2,..,prIdN>
|
||||
user: <string> [optional, not used]
|
||||
profile: <empty> [optional, also get related chars]
|
||||
return: 1
|
||||
*/
|
||||
protected function handleResync() : string
|
||||
{
|
||||
if ($teams = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_arena_team WHERE id IN (?a)', $this->_get['id']))
|
||||
foreach ($teams as $t)
|
||||
Profiler::scheduleResync(Type::ARENA_TEAM, $t['realm'], $t['realmGUID']);
|
||||
|
||||
if ($this->_get['profile'])
|
||||
if ($chars = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_profiles p JOIN ?_profiler_arena_team_member atm ON atm.profileId = p.id WHERE atm.arenaTeamId IN (?a)', $this->_get['id']))
|
||||
foreach ($chars as $c)
|
||||
Profiler::scheduleResync(Type::PROFILE, $c['realm'], $c['realmGUID']);
|
||||
|
||||
return '1';
|
||||
}
|
||||
|
||||
/* params
|
||||
id: <prId1,prId2,..,prIdN>
|
||||
return
|
||||
<status object>
|
||||
[
|
||||
nQueueProcesses,
|
||||
[statusCode, timeToRefresh, curQueuePos, errorCode, nResyncTries],
|
||||
[<anotherStatus>]
|
||||
...
|
||||
]
|
||||
|
||||
not all fields are required, if zero they are omitted
|
||||
statusCode:
|
||||
0: end the request
|
||||
1: waiting
|
||||
2: working...
|
||||
3: ready; click to view
|
||||
4: error / retry
|
||||
errorCode:
|
||||
0: unk error
|
||||
1: char does not exist
|
||||
2: armory gone
|
||||
*/
|
||||
protected function handleStatus() : string
|
||||
{
|
||||
return Profiler::resyncStatus(Type::ARENA_TEAM, $this->_get['id']);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -58,7 +58,8 @@ class ArenaTeamListFilter extends Filter
|
||||
'si' => [parent::V_LIST, [1, 2], false], // side
|
||||
'sz' => [parent::V_LIST, [2, 3, 5], false], // tema size
|
||||
'rg' => [parent::V_CALLBACK, 'cbRegionCheck', false], // region
|
||||
'sv' => [parent::V_CALLBACK, 'cbServerCheck', false], // server
|
||||
'bg' => [parent::V_EQUAL, null, false], // battlegroup - unsued here, but var expected by template
|
||||
'sv' => [parent::V_CALLBACK, 'cbServerCheck', false] // server
|
||||
);
|
||||
|
||||
public array $extraOpts = [];
|
||||
|
||||
@@ -232,7 +232,7 @@ $lang = array(
|
||||
'guildRoster' => "Gildenliste für <%s>",
|
||||
'arenaRoster' => "Arena-Teamliste für <%s>",
|
||||
'atCaptain' => "Teamkapitän",
|
||||
|
||||
'atSize' => "Größe: ",
|
||||
'profiler' => "Charakter-Profiler",
|
||||
'notFound' => array(
|
||||
'guild' => "Diese Gilde existiert nicht oder wurde noch nicht in die Datenbank übernommen.",
|
||||
|
||||
@@ -232,7 +232,7 @@ $lang = array(
|
||||
'guildRoster' => "Guild Roster for <%s>",
|
||||
'arenaRoster' => "Arena Team Roster for <%s>",
|
||||
'atCaptain' => "Arena Team Captain",
|
||||
|
||||
'atSize' => "Size: ",
|
||||
'profiler' => "Character Profiler",
|
||||
'notFound' => array(
|
||||
'guild' => "This Guild doesn't exist or is not yet in the database.",
|
||||
|
||||
@@ -232,7 +232,7 @@ $lang = array(
|
||||
'guildRoster' => "Lista de miembros de hermandad para <%s>",
|
||||
'arenaRoster' => "Personajes del Equipo de Arena para <%s>",
|
||||
'atCaptain' => "Capitán de equipo de arena",
|
||||
|
||||
'atSize' => "Tamaño: ",
|
||||
'profiler' => "Gestor de Perfiles", // Perfiles de Personaje? (character profiler)
|
||||
'notFound' => array(
|
||||
'guild' => "Esta hermandad no existe o aún no está en la base de datos.",
|
||||
|
||||
@@ -232,7 +232,7 @@ $lang = array(
|
||||
'guildRoster' => "Liste des membres pour la guilde de <%s>",
|
||||
'arenaRoster' => "[Arena Team Roster for <%s>]", // string probably lost
|
||||
'atCaptain' => "Capitaine d'équipe",
|
||||
|
||||
'atSize' => "Type : ",
|
||||
'profiler' => "Profiler de Personnage",
|
||||
'notFound' => array(
|
||||
'guild' => "[This Guild doesn't exist or is not yet in the database.]",
|
||||
|
||||
@@ -232,7 +232,7 @@ $lang = array(
|
||||
'guildRoster' => "Список членов гильдии <%s>",
|
||||
'arenaRoster' => "[Arena Team Roster for <%s>]", // string probably lost
|
||||
'atCaptain' => "Капитан команды арены",
|
||||
|
||||
'atSize' => "Численности: ",
|
||||
'profiler' => "Профили персонажей",
|
||||
'notFound' => array(
|
||||
'profile' => "Этот персонаж не существует, либо еще не добавлен в базу данных.",
|
||||
|
||||
@@ -232,7 +232,7 @@ $lang = array(
|
||||
'guildRoster' => "公会成员名单 <%s>",
|
||||
'arenaRoster' => "竞技场战队名单 <%s>",
|
||||
'atCaptain' => "竞技场战队队长",
|
||||
|
||||
'atSize' => "团队规模:",
|
||||
'profiler' => "角色概况",
|
||||
'notFound' => array(
|
||||
'guild' => "该公会不存在或尚未被收录到数据库中。",
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
// menuId 5: Profiler g_initPath()
|
||||
// tabId 1: Tools g_initHeader()
|
||||
class ArenaTeamPage extends GenericPage
|
||||
{
|
||||
use TrProfiler;
|
||||
|
||||
protected $lvTabs = [];
|
||||
|
||||
protected $type = Type::ARENA_TEAM;
|
||||
|
||||
protected $subject = null;
|
||||
protected $redButtons = [];
|
||||
protected $extraHTML = null;
|
||||
|
||||
protected $tabId = 1;
|
||||
protected $path = [1, 5, 3];
|
||||
protected $tpl = 'roster';
|
||||
protected $scripts = array(
|
||||
[SC_JS_FILE, 'js/profile_all.js'],
|
||||
[SC_JS_FILE, 'js/profile.js'],
|
||||
[SC_CSS_FILE, 'css/Profiler.css']
|
||||
);
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
{
|
||||
parent::__construct($pageCall, $pageParam);
|
||||
|
||||
if (!Cfg::get('PROFILER_ENABLE'))
|
||||
$this->error();
|
||||
|
||||
$params = array_map('urldecode', explode('.', $pageParam));
|
||||
if ($params[0])
|
||||
$params[0] = Profiler::urlize($params[0]);
|
||||
if (isset($params[1]))
|
||||
$params[1] = Profiler::urlize($params[1]);
|
||||
|
||||
if (count($params) == 1 && intval($params[0]))
|
||||
{
|
||||
$this->subject = new LocalArenaTeamList(array(['at.id', intval($params[0])]));
|
||||
if ($this->subject->error)
|
||||
$this->notFound();
|
||||
|
||||
header('Location: '.$this->subject->getProfileUrl(), true, 302);
|
||||
}
|
||||
else if (count($params) == 3)
|
||||
{
|
||||
$this->getSubjectFromUrl($pageParam);
|
||||
if (!$this->subjectName)
|
||||
$this->notFound();
|
||||
|
||||
// 3 possibilities
|
||||
// 1) already synced to aowow
|
||||
if ($subject = DB::Aowow()->selectRow('SELECT id, realmGUID, cuFlags FROM ?_profiler_arena_team WHERE realm = ?d AND nameUrl = ?', $this->realmId, Profiler::urlize($this->subjectName)))
|
||||
{
|
||||
if ($subject['cuFlags'] & PROFILER_CU_NEEDS_RESYNC)
|
||||
{
|
||||
$this->handleIncompleteData($subject['realmGUID']);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->subjectGUID = $subject['id'];
|
||||
$this->subject = new LocalArenaTeamList(array(['id', $subject['id']]));
|
||||
if ($this->subject->error)
|
||||
$this->notFound();
|
||||
|
||||
$this->name = sprintf(Lang::profiler('arenaRoster'), $this->subject->getField('name'));
|
||||
}
|
||||
// 2) not yet synced but exists on realm (wont work if we get passed an urlized name, but there is nothing we can do about it)
|
||||
else if ($team = DB::Characters($this->realmId)->selectRow('SELECT at.arenaTeamId AS realmGUID, at.name, at.type FROM arena_team at WHERE at.name = ?', Util::ucFirst($this->subjectName)))
|
||||
{
|
||||
$team['realm'] = $this->realmId;
|
||||
$team['cuFlags'] = PROFILER_CU_NEEDS_RESYNC;
|
||||
|
||||
// create entry from realm with basic info
|
||||
DB::Aowow()->query('INSERT IGNORE INTO ?_profiler_arena_team (?#) VALUES (?a)', array_keys($team), array_values($team));
|
||||
|
||||
$this->handleIncompleteData($team['realmGUID']);
|
||||
}
|
||||
// 3) does not exist at all
|
||||
else
|
||||
$this->notFound();
|
||||
}
|
||||
else
|
||||
$this->notFound();
|
||||
}
|
||||
|
||||
protected function generateTitle()
|
||||
{
|
||||
$team = !empty($this->subject) ? $this->subject->getField('name') : $this->subjectName;
|
||||
$team .= ' ('.$this->realm.' - '.Lang::profiler('regions', $this->region).')';
|
||||
|
||||
array_unshift($this->title, $team, Util::ucFirst(Lang::profiler('profiler')));
|
||||
}
|
||||
|
||||
protected function generateContent()
|
||||
{
|
||||
if ($this->doResync)
|
||||
return;
|
||||
|
||||
$this->addScript([SC_JS_FILE, '?data=realms.weight-presets']);
|
||||
|
||||
$this->redButtons[BUTTON_RESYNC] = [$this->subjectGUID, 'arena-team'];
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
|
||||
// statistic calculations here
|
||||
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
// tab: members
|
||||
$member = new LocalProfileList(array(['atm.arenaTeamId', $this->subjectGUID]));
|
||||
if (!$member->error)
|
||||
{
|
||||
$this->lvTabs[] = [ProfileList::$brickFile, array(
|
||||
'data' => array_values($member->getListviewData(PROFILEINFO_CHARACTER | PROFILEINFO_ARENA)),
|
||||
'sort' => [-15],
|
||||
'visibleCols' => ['race', 'classs', 'level', 'talents', 'gearscore', 'rating', 'wins', 'losses'],
|
||||
'hiddenCols' => ['guild', 'location']
|
||||
)];
|
||||
}
|
||||
}
|
||||
|
||||
public function notFound(string $title = '', string $msg = '') : never
|
||||
{
|
||||
parent::notFound($title ?: Util::ucFirst(Lang::profiler('profiler')), $msg ?: Lang::profiler('notFound', 'arenateam'));
|
||||
}
|
||||
|
||||
private function handleIncompleteData($teamGuid)
|
||||
{
|
||||
//display empty page and queue status
|
||||
$newId = Profiler::scheduleResync(Type::ARENA_TEAM, $this->realmId, $teamGuid);
|
||||
|
||||
$this->doResync = ['arena-team', $newId];
|
||||
$this->initialSync();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
// menuId 5: Profiler g_initPath()
|
||||
// tabId 1: Tools g_initHeader()
|
||||
class ArenaTeamsPage extends GenericPage
|
||||
{
|
||||
use TrProfiler;
|
||||
|
||||
protected $filterObj = null;
|
||||
|
||||
protected $subCat = '';
|
||||
protected $lvTabs = [];
|
||||
|
||||
protected $type = Type::ARENA_TEAM;
|
||||
|
||||
protected $tabId = 1;
|
||||
protected $path = [1, 5, 3];
|
||||
protected $tpl = 'arena-teams';
|
||||
protected $scripts = array(
|
||||
[SC_JS_FILE, 'js/filters.js'],
|
||||
[SC_JS_FILE, 'js/profile_all.js'],
|
||||
[SC_JS_FILE, 'js/profile.js']
|
||||
);
|
||||
|
||||
protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
{
|
||||
parent::__construct($pageCall, $pageParam);
|
||||
|
||||
if (!Cfg::get('PROFILER_ENABLE'))
|
||||
$this->error();
|
||||
|
||||
$this->filterObj = new ArenaTeamListFilter($this->_get['filter'] ?? '');
|
||||
|
||||
$this->getSubjectFromUrl($pageParam);
|
||||
|
||||
foreach (Profiler::getRealms() as $idx => $r)
|
||||
{
|
||||
if ($this->region && $r['region'] != $this->region)
|
||||
continue;
|
||||
|
||||
if ($this->realm && $r['name'] != $this->realm)
|
||||
continue;
|
||||
|
||||
$this->sumSubjects += DB::Characters($idx)->selectCell('SELECT count(*) FROM arena_team');
|
||||
}
|
||||
|
||||
$this->name = Lang::profiler('arenaTeams');
|
||||
$this->subCat = $pageParam ? '='.$pageParam : '';
|
||||
}
|
||||
|
||||
protected function generateTitle()
|
||||
{
|
||||
if ($this->realm)
|
||||
array_unshift($this->title, $this->realm,/* Cfg::get('BATTLEGROUP'),*/ Lang::profiler('regions', $this->region), Lang::profiler('arenaTeams'));
|
||||
else if ($this->region)
|
||||
array_unshift($this->title, Lang::profiler('regions', $this->region), Lang::profiler('arenaTeams'));
|
||||
else
|
||||
array_unshift($this->title, Lang::profiler('arenaTeams'));
|
||||
}
|
||||
|
||||
protected function generateContent()
|
||||
{
|
||||
$this->addScript([SC_JS_FILE, '?data=realms']);
|
||||
|
||||
$conditions = [];
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
$conditions[] = ['at.seasonGames', 0, '>'];
|
||||
|
||||
$this->filterObj->evalCriteria();
|
||||
|
||||
if ($_ = $this->filterObj->getConditions())
|
||||
$conditions[] = $_;
|
||||
|
||||
$tabData = array(
|
||||
'id' => 'arena-teams',
|
||||
'hideCount' => 1,
|
||||
'sort' => [-16],
|
||||
'extraCols' => ['$Listview.extraCols.members'],
|
||||
'visibleCols' => ['rank', 'wins', 'losses', 'rating'],
|
||||
'hiddenCols' => ['arenateam', 'guild'],
|
||||
);
|
||||
|
||||
if (!$this->filterObj->values['sz'])
|
||||
$tabData['visibleCols'][] = 'size';
|
||||
|
||||
$miscParams = ['calcTotal' => true];
|
||||
if ($this->realm)
|
||||
$miscParams['sv'] = $this->realm;
|
||||
if ($this->region)
|
||||
$miscParams['rg'] = $this->region;
|
||||
|
||||
$teams = new RemoteArenaTeamList($conditions, $miscParams);
|
||||
if (!$teams->error)
|
||||
{
|
||||
$teams->initializeLocalEntries();
|
||||
|
||||
$dFields = $teams->hasDiffFields('faction', 'type');
|
||||
if (!($dFields & 0x1))
|
||||
$tabData['hiddenCols'][] = 'faction';
|
||||
|
||||
$tabData['data'] = array_values($teams->getListviewData());
|
||||
|
||||
// create note if search limit was exceeded
|
||||
if ($this->filterObj->query && $teams->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
|
||||
{
|
||||
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_arenateamsfound2', $this->sumSubjects, $teams->getMatches());
|
||||
$tabData['_truncated'] = 1;
|
||||
}
|
||||
else if ($teams->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
|
||||
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_arenateamsfound', $this->sumSubjects, 0);
|
||||
|
||||
if ($this->filterObj->error)
|
||||
$tabData['_errors'] = 1;
|
||||
}
|
||||
|
||||
$this->lvTabs[] = [ArenaTeamList::$brickFile, $tabData, 'membersCol'];
|
||||
}
|
||||
|
||||
protected function postCache()
|
||||
{
|
||||
// sort for dropdown-menus
|
||||
Lang::sort('game', 'cl');
|
||||
Lang::sort('game', 'ra');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php namespace Aowow; ?>
|
||||
|
||||
<?php
|
||||
$this->brick('header');
|
||||
$f = $this->filterObj->values // shorthand
|
||||
?>
|
||||
namespace Aowow\Template;
|
||||
|
||||
use \Aowow\Lang;
|
||||
|
||||
$this->brick('header');
|
||||
$f = $this->filter->values; // shorthand
|
||||
?>
|
||||
<div class="main" id="main">
|
||||
<div class="main-precontents" id="main-precontents"></div>
|
||||
<div class="main-contents" id="main-contents">
|
||||
@@ -12,47 +13,48 @@ $f = $this->filterObj->values // shorthand
|
||||
<?php
|
||||
$this->brick('announcement');
|
||||
|
||||
$this->brick('pageTemplate', ['fiQuery' => $this->filterObj->query, 'fiMenuItem' => [2]]);
|
||||
$this->brick('pageTemplate', ['fiQuery' => $this->filter->query, 'fiMenuItem' => array_slice($this->pageTemplate['breadcrumb'], 0, -1)]);
|
||||
|
||||
# for some arcane reason a newline (\n) means, the first childNode is a text instead of the form for the following div
|
||||
# pr_setRegionRealm($WH.ge('fi').firstChild, realm, region) - never have \n\s before <form>, it will become firstChild (a text node)
|
||||
?>
|
||||
<div id="fi" style="display: <?=($this->filterObj->query ? 'block' : 'none'); ?>;"><form
|
||||
<div id="fi" style="display: <?=($this->filter->query ? 'block' : 'none'); ?>;"><form
|
||||
action="?filter=arena-teams&<?=$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>
|
||||
<tr>
|
||||
<td><?=Util::ucFirst(Lang::main('name')).Lang::main('colon'); ?></td>
|
||||
<td><?=$this->ucFirst(Lang::main('name')).Lang::main('colon'); ?></td>
|
||||
<td colspan="3">
|
||||
<table><tr>
|
||||
<td> <input type="text" name="na" size="30" <?=(isset($f['na']) ? 'value="'.Util::htmlEscape($f['na']).'" ' : null); ?>/></td>
|
||||
<td> <input type="checkbox" name="ex" value="on" id="profile-ex" <?=(isset($f['ex']) ? 'checked="checked"' : null); ?>/></td>
|
||||
<td> <input type="text" name="na" size="30" <?=($f['na'] ? 'value="'.$this->escHTML($f['na']).'" ' : ''); ?>/></td>
|
||||
<td> <input type="checkbox" name="ex" value="on" id="profile-ex" <?=($f['ex'] ? 'checked="checked"' : ''); ?>/></td>
|
||||
<td><label for="profile-ex"><span class="tip" onmouseover="$WH.Tooltip.showAtCursor(event, LANG.tooltip_exactprofilesearch, 0, 0, 'q')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"><?=Lang::main('exactMatch'); ?></span></label></td>
|
||||
</tr></table>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td class="padded"><?=Lang::profiler('region').Lang::main('colon'); ?></td>
|
||||
<td class="padded"> <select name="rg" onchange="pr_onChangeRegion(this.form, null, null)">
|
||||
<option></option>
|
||||
<?php
|
||||
foreach (array_unique(array_column(Profiler::getRealms(), 'region')) as $rg):
|
||||
echo " <option value=\"".$rg."\">".Lang::profiler('regions', $rg)."</option>\n";
|
||||
endforeach;
|
||||
?>
|
||||
<option></option>
|
||||
<?=$this->makeOptionsList($this->regions, $f['rg'], 32); ?>
|
||||
</select> </td>
|
||||
<td style="width:50px;" class="padded"> <?=Lang::profiler('realm').Lang::main('colon'); ?></td>
|
||||
<td class="padded"> <select name="sv"><option></option></select><input type="hidden" name="bg" value="<?=(isset($f['bg']) ? Util::htmlEscape($f['bg']) : null); ?>" /></td>
|
||||
<td class="padded"> <select name="sv"><option></option></select><input type="hidden" name="bg" value="<?=($f['bg'] ? $this->escHTML($f['bg']) : ''); ?>" /></td>
|
||||
</tr><tr>
|
||||
<td class="padded"><?=Lang::main('side').Lang::main('colon'); ?></td>
|
||||
<td class="padded" style="width:80px;"> <select name="si">
|
||||
<option></option>
|
||||
<option value="1"<?=(!empty($f['si']) && $f['si'] == 1 ? ' selected' : null);?>><?=Lang::game('si', 1); ?></option>
|
||||
<option value="2"<?=(!empty($f['si']) && $f['si'] == 2 ? ' selected' : null);?>><?=Lang::game('si', 2); ?></option>
|
||||
<?=$this->makeOptionsList(Lang::game('si'), $f['si'], 32, fn($v, $k) => in_array($k, [SIDE_ALLIANCE, SIDE_HORDE])); ?>
|
||||
</select></td>
|
||||
<td class="padded"> Size<?=Lang::main('colon'); ?></td>
|
||||
<td class="padded"> <?=Lang::profiler('atSize'); ?></td>
|
||||
<td class="padded"> <select name="sz">
|
||||
<option></option>
|
||||
<option value="2"<?=(!empty($f['sz']) && $f['sz'] == 2 ? ' selected' : null);?>>2v2</option>
|
||||
<option value="3"<?=(!empty($f['sz']) && $f['sz'] == 3 ? ' selected' : null);?>>3v3</option>
|
||||
<option value="5"<?=(!empty($f['sz']) && $f['sz'] == 5 ? ' selected' : null);?>>5v5</option>
|
||||
<?=$this->makeOptionsList([2 => '2v2', 3 => '3v3', 5 => '5v5'], $f['sz'], 32); ?>
|
||||
</select></td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -68,7 +70,7 @@ $this->brick('pageTemplate', ['fiQuery' => $this->filterObj->query, 'fiMenuItem'
|
||||
<div class="pad"></div>
|
||||
</div>
|
||||
|
||||
<?php $this->brick('filter'); ?>
|
||||
<?=$this->renderFilter(12); ?>
|
||||
|
||||
<?php $this->brick('lvTabs'); ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user