-
Notifications
You must be signed in to change notification settings - Fork 217
/
Copy patharenateam.php
150 lines (118 loc) · 5.03 KB
/
arenateam.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
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 = '') : void
{
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();
}
}
?>