Template/Update (Part 42)

* split 'guilds' into separate endpoints
This commit is contained in:
Sarjuuk
2025-08-20 02:46:43 +02:00
parent 69df20af63
commit 398ff16b65
16 changed files with 434 additions and 418 deletions

151
endpoints/guild/guild.php Normal file
View File

@@ -0,0 +1,151 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class GuildBaseResponse extends TemplateResponse
{
use TrProfilerDetail;
protected string $template = 'roster';
protected string $pageName = 'guild';
protected ?int $activeTab = parent::TAB_TOOLS;
protected array $breadcrumb = [1, 5, 2]; // Tools > Profiler > Guilds
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::GUILD;
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_guild 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::GUILD, $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 `guildid` AS "realmGUID", `name` FROM guild WHERE `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_guild (?#) VALUES (?a)', array_keys($subject), array_values($subject));
$this->handleIncompleteData(Type::GUILD, $subject['realmGUID']);
return;
}
// 3) does not exist at all
$this->notFound();
}
protected function generate() : void
{
if ($this->doResync)
{
parent::generate();
return;
}
$subject = new LocalGuildList(array(['id', $this->typeId]));
if ($subject->error)
$this->notFound();
// guild accessed by id
if (!$this->subjectName)
$this->forward($subject->getProfileUrl());
$this->h1 = Lang::profiler('guildRoster', [$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 */
/****************/
$this->redButtons[BUTTON_RESYNC] = [$this->typeId, 'guild'];
// statistic calculations here
// smuggle the guild ranks into the html
if ($ranks = DB::Aowow()->selectCol('SELECT `rank` AS ARRAY_KEY, `name` FROM ?_profiler_guild_rank WHERE `guildId` = ?d', $this->typeId))
$this->extraHTML = '<script type="text/javascript">var guild_ranks = '.Util::toJSON($ranks).';</script>';
/**************/
/* Extra Tabs */
/**************/
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated');
// tab: members
$member = new LocalProfileList(array(['p.guild', $this->typeId], Cfg::get('SQL_LIMIT_NONE')));
$this->lvTabs->addListviewTab(new Listview(array(
'data' => $member->getListviewData(PROFILEINFO_CHARACTER | PROFILEINFO_GUILD),
'sort' => [-15],
'visibleCols' => ['race', 'classs', 'level', 'talents', 'gearscore', 'achievementpoints', 'guildrank'],
'hiddenCols' => ['guild', 'location']
), ProfileList::$brickFile));
parent::generate();
}
public function notFound() : never
{
parent::generateNotFound(Lang::game('guild'), Lang::profiler('notFound', 'guild'));
}
}
?>

View File

@@ -0,0 +1,48 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class GuildResyncResponse 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 ($guilds = DB::Aowow()->select('SELECT `realm`, `realmGUID` FROM ?_profiler_guild WHERE `id` IN (?a)', $this->_get['id']))
foreach ($guilds as $g)
Profiler::scheduleResync(Type::GUILD, $g['realm'], $g['realmGUID']);
if ($this->_get['profile'])
if ($chars = DB::Aowow()->select('SELECT `realm`, `realmGUID` FROM ?_profiler_profiles WHERE `guild` IN (?a)', $this->_get['id']))
foreach ($chars as $c)
Profiler::scheduleResync(Type::PROFILE, $c['realm'], $c['realmGUID']);
$this->result = 1; // as string?
}
}
?>

View File

@@ -0,0 +1,29 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class GuildStatusResponse 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::GUILD, $this->_get['id']);
}
}
?>

149
endpoints/guilds/guilds.php Normal file
View File

@@ -0,0 +1,149 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class GuildsBaseResponse extends TemplateResponse implements IProfilerList
{
use TrProfilerList, TrListPage;
protected string $template = 'guilds';
protected string $pageName = 'guilds';
protected ?int $activeTab = parent::TAB_TOOLS;
protected array $breadcrumb = [1, 5, 2]; // Tools > Profiler > Guilds
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::GUILD;
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 guild');
$realms[] = $idx;
}
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
$this->filter = new GuildListFilter($this->_get['filter'] ?? '', ['realms' => $realms]);
$this->filterError = $this->filter->error;
}
protected function generate() : void
{
$this->h1 = Lang::game('guilds');
/*************/
/* 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('guilds'));
else if ($this->region)
array_unshift($this->title, Lang::profiler('regions', $this->region), Lang::game('guilds'));
else
array_unshift($this->title, Lang::game('guilds'));
/****************/
/* Main Content */
/****************/
$conditions = array(
['c.deleteInfos_Account', null],
['c.level', MAX_LEVEL, '<='], // prevents JS errors
[['c.extra_flags', Profiler::CHAR_GMFLAGS, '&'], 0]
);
if ($_ = $this->filter->getConditions())
$conditions[] = $_;
$this->getRegions();
$tabData = array(
'id' => 'guilds',
'data' => [],
'hideCount' => 1,
'sort' => [-3],
'visibleCols' => ['members', 'achievementpoints', 'gearscore'],
'hiddenCols' => ['guild']
);
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;
$guilds = new RemoteGuildList($conditions, $miscParams);
if (!$guilds->error)
{
$guilds->initializeLocalEntries();
$tabData['data'] = $guilds->getListviewData();
// create note if search limit was exceeded
if ($this->filter->query && $guilds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
{
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_guildsfound2', $this->sumSubjects, $guilds->getMatches());
$tabData['_truncated'] = 1;
}
else if ($guilds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_guildsfound', $this->sumSubjects, 0);
}
$this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated');
$this->lvTabs->addListviewTab(new Listview($tabData, GuildList::$brickFile, 'membersCol'));
parent::generate();
$this->result->registerDisplayHook('filter', [self::class, 'filterFormHook']);
}
public static function filterFormHook(Template\PageTemplate &$pt, GuildListFilter $filter) : void
{
// sort for dropdown-menus
Lang::sort('game', 'cl');
Lang::sort('game', 'ra');
}
}
?>

View File

@@ -1,83 +0,0 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class AjaxGuild 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 ($guilds = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_guild WHERE id IN (?a)', $this->_get['id']))
foreach ($guilds as $g)
Profiler::scheduleResync(Type::GUILD, $g['realm'], $g['realmGUID']);
if ($this->_get['profile'])
if ($chars = DB::Aowow()->select('SELECT realm, realmGUID FROM ?_profiler_profiles WHERE guild 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::GUILD, $this->_get['id']);
}
}
?>

View File

@@ -101,7 +101,8 @@ class GuildListFilter extends Filter
'ex' => [parent::V_EQUAL, 'on', false], // only match exact 'ex' => [parent::V_EQUAL, 'on', false], // only match exact
'si' => [parent::V_LIST, [SIDE_ALLIANCE, SIDE_HORDE], false], // side 'si' => [parent::V_LIST, [SIDE_ALLIANCE, SIDE_HORDE], false], // side
'rg' => [parent::V_CALLBACK, 'cbRegionCheck', false], // region '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 = []; public array $extraOpts = [];

View File

@@ -234,9 +234,6 @@ $lang = array(
'atCaptain' => "Teamkapitän", 'atCaptain' => "Teamkapitän",
'profiler' => "Charakter-Profiler", 'profiler' => "Charakter-Profiler",
'arenaTeams' => "Arena Teams",
'guilds' => "Gilden",
'notFound' => array( 'notFound' => array(
'guild' => "Diese Gilde existiert nicht oder wurde noch nicht in die Datenbank übernommen.", 'guild' => "Diese Gilde existiert nicht oder wurde noch nicht in die Datenbank übernommen.",
'arenateam' => "Dieses Arena Team existiert nicht oder wurde noch nicht in die Datenbank übernommen.", 'arenateam' => "Dieses Arena Team existiert nicht oder wurde noch nicht in die Datenbank übernommen.",
@@ -332,6 +329,10 @@ $lang = array(
'icons' => "Icons", 'icons' => "Icons",
'profile' => "Profil", // 100 'profile' => "Profil", // 100
'profiles' => "Profile", 'profiles' => "Profile",
'guild' => "Gilde", // 101
'guilds' => "Gilden",
'arenateam' => "Arena Team", // 102
'arenateams' => "Arena Teams",
'guide' => "Leitfaden", // 300 'guide' => "Leitfaden", // 300
'guides' => "Leitfäden", 'guides' => "Leitfäden",
'emote' => "Emote", // 501 'emote' => "Emote", // 501

View File

@@ -234,9 +234,6 @@ $lang = array(
'atCaptain' => "Arena Team Captain", 'atCaptain' => "Arena Team Captain",
'profiler' => "Character Profiler", 'profiler' => "Character Profiler",
'arenaTeams' => "Arena Teams",
'guilds' => "Guilds",
'notFound' => array( 'notFound' => array(
'guild' => "This Guild doesn't exist or is not yet in the database.", 'guild' => "This Guild doesn't exist or is not yet in the database.",
'arenateam' => "This Arena Team doesn't exist or is not yet in the database.", 'arenateam' => "This Arena Team doesn't exist or is not yet in the database.",
@@ -332,6 +329,10 @@ $lang = array(
'icons' => "icons", 'icons' => "icons",
'profile' => "profile", 'profile' => "profile",
'profiles' => "Profiles", 'profiles' => "Profiles",
'guild' => "Guild",
'guilds' => "Guilds",
'arenateam' => "Arena Team",
'arenateams' => "Arena Teams",
'guide' => "Guide", 'guide' => "Guide",
'guides' => "Guides", 'guides' => "Guides",
'emote' => "emote", 'emote' => "emote",

View File

@@ -234,9 +234,6 @@ $lang = array(
'atCaptain' => "Capitán de equipo de arena", 'atCaptain' => "Capitán de equipo de arena",
'profiler' => "Gestor de Perfiles", // Perfiles de Personaje? (character profiler) 'profiler' => "Gestor de Perfiles", // Perfiles de Personaje? (character profiler)
'arenaTeams' => "Equipos de Arena",
'guilds' => "Hermandades",
'notFound' => array( 'notFound' => array(
'guild' => "Esta hermandad no existe o aún no está en la base de datos.", 'guild' => "Esta hermandad no existe o aún no está en la base de datos.",
'arenateam' => "Este equipo de arena no existe o aún no está en la base de datos.", 'arenateam' => "Este equipo de arena no existe o aún no está en la base de datos.",
@@ -332,6 +329,10 @@ $lang = array(
'icons' => "Iconos", 'icons' => "Iconos",
'profile' => "Perfile", 'profile' => "Perfile",
'profiles' => "Perfiles", 'profiles' => "Perfiles",
'guild' => "Hermandad",
'guilds' => "Hermandades",
'arenateam' => "Equipo de arena",
'arenateams' => "Equipos de arena",
'guide' => "Guía", 'guide' => "Guía",
'guides' => "Guías", 'guides' => "Guías",
'emote' => "emoción", 'emote' => "emoción",

View File

@@ -234,9 +234,6 @@ $lang = array(
'atCaptain' => "Capitaine d'équipe", 'atCaptain' => "Capitaine d'équipe",
'profiler' => "Profiler de Personnage", 'profiler' => "Profiler de Personnage",
'arenaTeams' => "Équipes d'Aréna",
'guilds' => "Guildes",
'notFound' => array( 'notFound' => array(
'guild' => "[This Guild doesn't exist or is not yet in the database.]", 'guild' => "[This Guild doesn't exist or is not yet in the database.]",
'arenateam' => "[This Arena Team doesn't exist or is not yet in the database.]", 'arenateam' => "[This Arena Team doesn't exist or is not yet in the database.]",
@@ -332,6 +329,10 @@ $lang = array(
'icons' => "Icônes", 'icons' => "Icônes",
'profile' => "Profil", 'profile' => "Profil",
'profiles' => "Profils", 'profiles' => "Profils",
'guild' => "Guilde",
'guilds' => "Guildes",
'arenateam' => "Équipe d'arène",
'arenateams' => "Équipes d'aréna",
'guide' => "Guide", 'guide' => "Guide",
'guides' => "Guides", 'guides' => "Guides",
'emote' => "emote", 'emote' => "emote",

View File

@@ -234,9 +234,6 @@ $lang = array(
'atCaptain' => "Капитан команды арены", 'atCaptain' => "Капитан команды арены",
'profiler' => "Профили персонажей", 'profiler' => "Профили персонажей",
'arenaTeams' => "Команды арен",
'guilds' => "Гильдии",
'notFound' => array( 'notFound' => array(
'profile' => "Этот персонаж не существует, либо еще не добавлен в базу данных.", 'profile' => "Этот персонаж не существует, либо еще не добавлен в базу данных.",
'arenateam' => "[This Arena Team doesn't exist or is not yet in the database.]", 'arenateam' => "[This Arena Team doesn't exist or is not yet in the database.]",
@@ -332,6 +329,10 @@ $lang = array(
'icons' => "Иконки", 'icons' => "Иконки",
'profile' => "Профиль", 'profile' => "Профиль",
'profiles' => "Профили", 'profiles' => "Профили",
'guild' => "Гильдия",
'guilds' => "Гильдии",
'arenateam' => "Команда арены",
'arenateams' => "Команды арен",
'guide' => "Руководство", 'guide' => "Руководство",
'guides' => "Руководство", 'guides' => "Руководство",
'emote' => "Эмоция", 'emote' => "Эмоция",

View File

@@ -234,9 +234,6 @@ $lang = array(
'atCaptain' => "竞技场战队队长", 'atCaptain' => "竞技场战队队长",
'profiler' => "角色概况", 'profiler' => "角色概况",
'arenaTeams' => "竞技场战队",
'guilds' => "公会",
'notFound' => array( 'notFound' => array(
'guild' => "该公会不存在或尚未被收录到数据库中。", 'guild' => "该公会不存在或尚未被收录到数据库中。",
'arenateam' => "该竞技场战队不存在或尚未被收录到数据库中。", 'arenateam' => "该竞技场战队不存在或尚未被收录到数据库中。",
@@ -332,6 +329,10 @@ $lang = array(
'icons' => "图标", 'icons' => "图标",
'profile' => "简介", 'profile' => "简介",
'profiles' => "简介", 'profiles' => "简介",
'guild' => "公会",
'guilds' => "公会",
'arenateam' => "竞技场战队",
'arenateams' => "竞技场战队",
'guide' => "指南", 'guide' => "指南",
'guides' => "指南", 'guides' => "指南",
'emote' => "表情", 'emote' => "表情",

View File

@@ -1,156 +0,0 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 5: Profiler g_initPath()
// tabId 1: Tools g_initHeader()
class GuildPage extends GenericPage
{
use TrProfiler;
protected $lvTabs = [];
protected $type = Type::GUILD;
protected $subject = null;
protected $redButtons = [];
protected $extraHTML = null;
protected $tabId = 1;
protected $path = [1, 5, 2];
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 LocalGuildList(array(['g.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_guild 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 LocalGuildList(array(['id', $subject['id']]));
if ($this->subject->error)
$this->notFound();
$this->name = sprintf(Lang::profiler('guildRoster'), $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 guildid AS realmGUID, name FROM guild WHERE 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_guild (?#) 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, 'guild'];
/****************/
/* Main Content */
/****************/
// statistic calculations here
// smuggle the guild ranks into the html
if ($ranks = DB::Aowow()->selectCol('SELECT `rank` AS ARRAY_KEY, name FROM ?_profiler_guild_rank WHERE guildId = ?d', $this->subjectGUID))
$this->extraHTML = '<script type="text/javascript">var guild_ranks = '.Util::toJSON($ranks).';</script>';
/**************/
/* Extra Tabs */
/**************/
// tab: members
$member = new LocalProfileList(array(['p.guild', $this->subjectGUID], Cfg::get('SQL_LIMIT_NONE')));
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', 'achievementpoints', 'guildrank'],
'hiddenCols' => ['guild', 'location']
)];
}
}
public function notFound(string $title = '', string $msg = '') : never
{
parent::notFound($title ?: Util::ucFirst(Lang::profiler('profiler')), $msg ?: Lang::profiler('notFound', 'guild'));
}
private function handleIncompleteData($teamGuid)
{
//display empty page and queue status
$newId = Profiler::scheduleResync(Type::GUILD, $this->realmId, $teamGuid);
$this->doResync = ['guild', $newId];
$this->initialSync();
}
}
?>

View File

@@ -1,132 +0,0 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 5: Profiler g_initPath()
// tabId 1: Tools g_initHeader()
class GuildsPage extends GenericPage
{
use TrProfiler;
protected $filterObj = null;
protected $subCat = '';
protected $lvTabs = [];
protected $type = Type::GUILD;
protected $tabId = 1;
protected $path = [1, 5, 2];
protected $tpl = 'guilds';
protected $scripts = [[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->getSubjectFromUrl($pageParam);
$this->filterObj = new GuildListFilter($this->_get['filter'] ?? '');
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 guild');
}
$this->name = Lang::profiler('guilds');
$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('guilds'));
else if ($this->region)
array_unshift($this->title, Lang::profiler('regions', $this->region), Lang::profiler('guilds'));
else
array_unshift($this->title, Lang::profiler('guilds'));
}
protected function generateContent()
{
$this->addScript([SC_JS_FILE, '?data=realms']);
$conditions = array(
['c.deleteInfos_Account', null],
['c.level', MAX_LEVEL, '<='], // prevents JS errors
[['c.extra_flags', Profiler::CHAR_GMFLAGS, '&'], 0]
);
$this->filterObj->evalCriteria();
if ($_ = $this->filterObj->getConditions())
$conditions[] = $_;
$tabData = array(
'id' => 'guilds',
'hideCount' => 1,
'sort' => [-3],
'visibleCols' => ['members', 'achievementpoints', 'gearscore'],
'hiddenCols' => ['guild'],
);
$miscParams = ['calcTotal' => true];
if ($this->realm)
$miscParams['sv'] = $this->realm;
if ($this->region)
$miscParams['rg'] = $this->region;
$guilds = new RemoteGuildList($conditions, $miscParams);
if (!$guilds->error)
{
$guilds->initializeLocalEntries();
$dFields = $guilds->hasDiffFields('faction', 'type');
if (!($dFields & 0x1))
$tabData['hiddenCols'][] = 'faction';
if (($dFields & 0x2))
$tabData['visibleCols'][] = 'size';
$tabData['data'] = array_values($guilds->getListviewData());
// create note if search limit was exceeded
if ($this->filterObj->query && $guilds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
{
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_guildsfound2', $this->sumSubjects, $guilds->getMatches());
$tabData['_truncated'] = 1;
}
else if ($guilds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT'))
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_guildsfound', $this->sumSubjects, 0);
if ($this->filterObj->error)
$tabData['_errors'] = 1;
}
$this->lvTabs[] = [GuildList::$brickFile, $tabData, 'membersCol'];
}
protected function postCache()
{
// sort for dropdown-menus
Lang::sort('game', 'cl');
Lang::sort('game', 'ra');
}
}
?>

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,40 +13,43 @@ $f = $this->filterObj->values // shorthand
<?php <?php
$this->brick('announcement'); $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=guilds&<?=$this->subCat; ?>" method="post" name="fi" onsubmit="return fi_submit(this)" onreset="return fi_reset(this)"> action="?filter=guilds&<?=$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> <tr>
<td><?=Util::ucFirst(Lang::main('name')).Lang::main('colon'); ?></td> <td><?=$this->ucFirst(Lang::main('name')).Lang::main('colon'); ?></td>
<td colspan="3"> <td colspan="3">
<table><tr> <table><tr>
<td>&nbsp;<input type="text" name="na" size="30" <?=(isset($f['na']) ? 'value="'.Util::htmlEscape($f['na']).'" ' : null); ?>/></td> <td>&nbsp;<input type="text" name="na" size="30" <?=($f['na'] ? 'value="'.$this->escHTML($f['na']).'" ' : ''); ?>/></td>
<td>&nbsp; <input type="checkbox" name="ex" value="on" id="profile-ex" <?=(isset($f['ex']) ? 'checked="checked"' : null); ?>/></td> <td>&nbsp; <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> <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> </tr></table>
</td> </td>
</tr><tr> </tr><tr>
<td class="padded"><?=Lang::profiler('region').Lang::main('colon'); ?></td> <td class="padded"><?=Lang::profiler('region').Lang::main('colon'); ?></td>
<td class="padded">&nbsp;<select name="rg" onchange="pr_onChangeRegion(this.form, null, null)"> <td class="padded">&nbsp;<select name="rg" onchange="pr_onChangeRegion(this.form, null, null)">
<option></option> <option></option>
<?php <?=$this->makeOptionsList($this->regions, $f['rg'], 32); ?>
foreach (array_unique(array_column(Profiler::getRealms(), 'region')) as $rg):
echo " <option value=\"".$rg."\">".Lang::profiler('regions', $rg)."</option>\n";
endforeach;
?>
</select>&nbsp;</td> </select>&nbsp;</td>
<td style="width:50px;" class="padded">&nbsp;&nbsp;&nbsp;<?=Lang::profiler('realm').Lang::main('colon'); ?></td> <td style="width:50px;" class="padded">&nbsp;&nbsp;&nbsp;<?=Lang::profiler('realm').Lang::main('colon'); ?></td>
<td class="padded">&nbsp;<select name="sv"><option></option></select><input type="hidden" name="bg" value="<?=(isset($f['bg']) ? Util::htmlEscape($f['bg']) : null); ?>" /></td> <td class="padded">&nbsp;<select name="sv"><option></option></select><input type="hidden" name="bg" value="<?=($f['bg'] ? $this->escHTML($f['bg']) : ''); ?>" /></td>
</tr><tr> </tr><tr>
<td class="padded"><?=Lang::main('side').Lang::main('colon'); ?></td> <td class="padded"><?=Lang::main('side').Lang::main('colon'); ?></td>
<td class="padded" style="width:80px;">&nbsp;<select name="si"> <td class="padded" style="width:80px;">&nbsp;<select name="si">
<option></option> <option></option>
<option value="1"<?=(!empty($f['si']) && $f['si'] == 1 ? ' selected' : null);?>><?=Lang::game('si', 1); ?></option> <?=$this->makeOptionsList(Lang::game('si'), $f['si'], 32, fn($v, $k) => in_array($k, [SIDE_ALLIANCE, SIDE_HORDE])); ?>
<option value="2"<?=(!empty($f['si']) && $f['si'] == 2 ? ' selected' : null);?>><?=Lang::game('si', 2); ?></option>
</select></td> </select></td>
<td class="padded">&nbsp;</td> <td class="padded">&nbsp;</td>
<td class="padded">&nbsp;</td> <td class="padded">&nbsp;</td>
@@ -63,7 +67,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'); ?>

View File

@@ -1,7 +1,8 @@
<?php namespace Aowow; ?> <?php
namespace Aowow\Template;
<?php $this->brick('header'); ?>
$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">
@@ -16,13 +17,11 @@ $this->brick('pageTemplate');
<div class="text"> <div class="text">
<?php $this->brick('redButtons'); ?> <?php $this->brick('redButtons'); ?>
<h1 class="first"><?=$this->name; ?></h1> <h1 class="first"><?=$this->h1; ?></h1>
<?php <?php
// subject statistics here // subject statistics here
if (isset($this->extraHTML)): echo $this->extraHTML ?? '';
echo $this->extraHTML;
endif;
?> ?>
</div> </div>