public static function profile($rid) { global $lng, $DEA; $race = new Race($rid); $roster = $DEA[$race->name]; title($lng->getTrn('race/' . strtolower(str_replace(' ', '', $race->name)))); ?> <center><img src="<?php echo RACE_ICONS . '/' . $roster['other']['icon']; ?> " alt="Race icon"></center> <ul> <li><?php echo $lng->getTrn('common/reroll'); ?> : <?php echo $roster['other']['rr_cost'] / 1000; ?> k</li> </ul><br> <?php $players = array(); foreach ($roster['players'] as $player => $d) { $p = (object) array_merge(array('position' => $player), $d); $p->skills = implode(', ', skillsTrans($p->def)); $p->N = implode('', $p->norm); $p->D = implode('', $p->doub); $p->position = $lng->getTrn("position/" . strtolower(str_replace(' ', '', $p->position))); $players[] = $p; } $fields = array('position' => array('desc' => $lng->getTrn('common/pos')), 'pos_id' => array('desc' => 'ID'), 'ma' => array('desc' => 'Ma'), 'st' => array('desc' => 'St'), 'ag' => array('desc' => 'Ag'), 'av' => array('desc' => 'Av'), 'skills' => array('desc' => $lng->getTrn('common/skills'), 'nosort' => true), 'N' => array('desc' => 'Normal', 'nosort' => true), 'D' => array('desc' => 'Double', 'nosort' => true), 'cost' => array('desc' => $lng->getTrn('common/price'), 'kilo' => true, 'suffix' => 'k'), 'qty' => array('desc' => 'Max. qty')); HTMLOUT::sort_table('Roster', urlcompile(T_URL_PROFILE, T_OBJ_RACE, $race->race_id, false, false), $players, $fields, sort_rule('race_page'), isset($_GET['sortpl']) ? array(($_GET['dirpl'] == 'a' ? '+' : '-') . $_GET['sortpl']) : array(), array('GETsuffix' => 'pl', 'noHelp' => true, 'doNr' => false)); // Teams of the chosen race. $url = urlcompile(T_URL_PROFILE, T_OBJ_RACE, $race->race_id, false, false); HTMLOUT::standings(STATS_TEAM, false, false, array('url' => $url, 'teams_from' => STATS_RACE, 'teams_from_id' => $race->race_id)); echo '<br>'; HTMLOUT::recentGames(STATS_RACE, $race->race_id, false, false, false, false, array('url' => $url, 'n' => MAX_RECENT_GAMES, 'GET_SS' => 'gp')); }
private function _HHMerc($DETAILED) { global $lng; $team = $this; // Copy. Used instead of $this for readability. title("<a name='anc'>" . $lng->getTrn('common/merchh') . "</a>"); $mdat = array(); foreach (Mercenary::getMercsHiredByTeam($team->team_id, false) as $merc) { $o = (object) array(); $m = new Match($merc->match_id); $o->date_played = $m->date_played; $o->opponent = $m->team1_id == $team->team_id ? $m->team1_name : $m->team2_name; foreach (array('match_id', 'skills', 'mvp', 'cp', 'td', 'intcpt', 'bh', 'ki', 'si') as $f) { $o->{$f} = $merc->{$f}; } $o->cas = $o->bh + $o->ki + $o->si; $o->match = '[view]'; $o->tour = get_alt_col('tours', 'tour_id', $m->f_tour_id, 'name'); $o->score = "{$m->team1_score} - {$m->team2_score}"; $o->result = matchresult_icon($m->team1_id == $team->team_id && $m->team1_score > $m->team2_score || $m->team2_id == $team->team_id && $m->team1_score < $m->team2_score ? 'W' : ($m->team1_score == $m->team2_score ? 'D' : 'L')); array_push($mdat, $o); } $fields = array('date_played' => array('desc' => $lng->getTrn('common/dateplayed')), 'tour' => array('desc' => $lng->getTrn('common/tournament')), 'opponent' => array('desc' => $lng->getTrn('common/opponent')), 'skills' => array('desc' => $lng->getTrn('common/skills')), 'cp' => array('desc' => 'Cp'), 'td' => array('desc' => 'Td'), 'intcpt' => array('desc' => 'Int'), 'cas' => array('desc' => 'Cas'), 'bh' => array('desc' => 'BH'), 'si' => array('desc' => 'Si'), 'ki' => array('desc' => 'Ki'), 'mvp' => array('desc' => 'MVP'), 'score' => array('desc' => $lng->getTrn('common/score'), 'nosort' => true), 'result' => array('desc' => $lng->getTrn('common/result'), 'nosort' => true), 'match' => array('desc' => $lng->getTrn('common/match'), 'href' => array('link' => 'index.php?section=matches&type=report', 'field' => 'mid', 'value' => 'match_id'), 'nosort' => true)); HTMLOUT::sort_table("<a name='tp_mhhanc'>" . $lng->getTrn('common/merchh') . "</a>", urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $team->team_id, false, false) . '&subsec=hhmerc' . ($DETAILED ? '&detailed=1' : '&detailed=0'), $mdat, $fields, sort_rule('star_HH'), isset($_GET['sorttp_mhh']) ? array(($_GET['dirtp_mhh'] == 'a' ? '+' : '-') . $_GET['sorttp_mhh']) : array(), array('GETsuffix' => 'tp_mhh', 'doNr' => false)); }
public static function standings($obj, $node, $node_id, array $opts) { /* Makes various kinds of standings tables. $obj and $node types are STATS_* types. $opts = array( 'url' => page URL on which table is to be displayed (required!) 'GET_SS' => GET Sorting suffix 'return_objects' => bool 'teams_from' => [T_OBJ_COACH|T_OBJ_RACE] when $obj = T_OBJ_TEAM and this is set, only teams related to this object type (teams_from), of ID = $opts[teams_from_id] are fetched. 'teams_from_id' => ID (int) see "teams_from" for details. ); */ global $lng, $settings, $objFields_avg; $tblTitle = ''; $objs = $fields = $extra = array(); $fields_before = $fields_after = array(); // To be merged with $fields. if (!array_key_exists('GET_SS', $opts)) { $opts['GET_SS'] = ''; } else { $extra['GETsuffix'] = $opts['GET_SS']; } # GET Sorting Suffix $PAGE = isset($_GET["page"]) ? (int) $_GET["page"] : 1; $PAGELENGTH = 0; # Infinite, is overrided in below switch/case.. $extra['noHelp'] = false; $W_TEAMS_FROM = array_key_exists('teams_from', $opts); $enableRaceSelector = $obj == T_OBJ_PLAYER || $obj == T_OBJ_TEAM && (!isset($opts['teams_from']) || $opts['teams_from'] != T_OBJ_RACE); # NO filters for teams of a coach on the coach's teams list. $_COACH_TEAM_LIST = $W_TEAMS_FROM && $opts['teams_from'] == T_OBJ_COACH; if ($_COACH_TEAM_LIST) { list(, , $T_STATE) = HTMLOUT::nodeSelector(array('nonodes' => true, 'state' => true)); # Produces a state selector. $_SELECTOR = array(false, false, $T_STATE, T_RACE_ALL, 'GENERAL', 'mv_played', self::T_NS__ffilter_ineq_gt, 0); } else { $_SELECTOR = HTMLOUT::nodeSelector(array('force_node' => array($node, $node_id), 'race' => $enableRaceSelector, 'sgrp' => true, 'ffilter' => true, 'obj' => $obj)); } list($sel_node, $sel_node_id, $sel_state, $sel_race, $sel_sgrp, $sel_ff_field, $sel_ff_ineq, $sel_ff_limit) = $_SELECTOR; $filter_node = array($sel_node => $sel_node_id); $filter_race = $sel_race != T_RACE_ALL ? array(T_OBJ_RACE => $sel_race) : array(); $filter_having = array('having' => array($sel_ff_field . ($sel_ff_ineq == self::T_NS__ffilter_ineq_gt ? '>=' : '<=') . $sel_ff_limit)); if ($_COACH_TEAM_LIST && $sel_state != T_STATE_ALLTIME) { $filter_having['having'][] = 'rdy IS TRUE'; $filter_having['having'][] = 'retired IS FALSE'; } $SGRP_GEN = $sel_sgrp == 'GENERAL'; $ALL_TIME = self::_isNodeAllTime($obj, $sel_node, $sel_node_id); $manualSort = isset($_GET["sort{$opts['GET_SS']}"]); $sortRule = array_merge($manualSort ? array(($_GET["dir{$opts['GET_SS']}"] == 'a' ? '+' : '-') . $_GET["sort{$opts['GET_SS']}"]) : array(), $obj == T_OBJ_TEAM && $sel_node == T_NODE_TOURNAMENT && is_object($tr = new Tour($sel_node_id)) ? array_map(create_function('$val', 'return $val[0]."mv_".substr($val,1);'), $tr->getRSSortRule()) : sort_rule($obj)); $set_avg = isset($_GET['pms']) && $_GET['pms']; // Per match stats? echo '<br><a href="' . $opts['url'] . '&pms=' . ($set_avg ? 0 : 1) . '"><b>' . $lng->getTrn('common/' . ($set_avg ? 'ats' : 'pms')) . "</b></a><br><br>\n"; // Common $obj type fields. $fields = self::_getDefFields($obj, $sel_node, $sel_node_id); // Was a different (non-general) stats group selected? if (!$SGRP_GEN) { $grps_short = getESGroups(true, true); $grps_long = getESGroups(true, false); $fields_short = $grps_short[$sel_sgrp]; $fields_long = $grps_long[$sel_sgrp]; $fields = array_combine(array_strpack('mv_%s', $fields_long), array_map(create_function('$f', 'return array("desc" => $f);'), $fields_short)); $objFields_avg = array_merge($objFields_avg, array_map(create_function('$k', 'return substr($k, 3);'), array_keys($fields))); } switch ($obj) { case STATS_PLAYER: $tblTitle = $lng->getTrn('menu/statistics_menu/player_stn'); $fields_before = array('name' => array('desc' => $lng->getTrn('common/player'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_PLAYER, false, false, false), 'field' => 'obj_id', 'value' => 'player_id')), 'f_tname' => array('desc' => $lng->getTrn('common/team'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_TEAM, false, false, false), 'field' => 'obj_id', 'value' => 'owned_by_team_id'))); $PAGELENGTH = $settings['standings']['length_players']; list($objs, $PAGES) = Stats::getRaw(T_OBJ_PLAYER, $filter_node + $filter_having + $filter_race, array($PAGE, $PAGELENGTH), $sortRule, $set_avg); break; case STATS_TEAM: $tblTitle = $lng->getTrn('menu/statistics_menu/team_stn'); $fields_before = array('name' => array('desc' => $lng->getTrn('common/name'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_TEAM, false, false, false), 'field' => 'obj_id', 'value' => 'team_id'))); // Show teams standings list only for teams owned by... ? switch ($W_TEAMS_FROM ? $opts['teams_from'] : false) { case T_OBJ_COACH: $fields_before['f_rname'] = array('desc' => $lng->getTrn('common/race'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_RACE, false, false, false), 'field' => 'obj_id', 'value' => 'f_race_id')); list($objs, $PAGES) = Stats::getRaw(T_OBJ_TEAM, $filter_node + $filter_having + $filter_race + array(T_OBJ_COACH => (int) $opts['teams_from_id']), false, $sortRule, $set_avg); break; case T_OBJ_RACE: $fields_before['f_cname'] = array('desc' => $lng->getTrn('common/coach'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_COACH, false, false, false), 'field' => 'obj_id', 'value' => 'owned_by_coach_id')); $PAGELENGTH = $settings['standings']['length_teams']; list($objs, $PAGES) = Stats::getRaw(T_OBJ_TEAM, $filter_node + $filter_having + array(T_OBJ_RACE => (int) $opts['teams_from_id']), array($PAGE, $PAGELENGTH), $sortRule, $set_avg); break; // All teams // All teams default: $PAGELENGTH = $settings['standings']['length_teams']; list($objs, $PAGES) = Stats::getRaw(T_OBJ_TEAM, $filter_node + $filter_having + $filter_race, array($PAGE, $PAGELENGTH), $sortRule, $set_avg); } // Translating race name foreach ($objs as &$o) { $o['f_rname'] = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $o['f_rname']))); } break; case STATS_RACE: $tblTitle = $lng->getTrn('menu/statistics_menu/race_stn'); $fields_before = array('name' => array('desc' => $lng->getTrn('common/race'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_RACE, false, false, false), 'field' => 'obj_id', 'value' => 'race_id'))); $dash_empty = false; if ($sel_node == T_NODE_TOURNAMENT) { $dash_empty = 'mv_team_cnt'; } else { if ($ALL_TIME) { $dash_empty = 'rg_team_cnt'; } } if ($dash_empty) { $extra['dashed'] = array('condField' => $dash_empty, 'fieldVal' => 0, 'noDashFields' => array('name')); } list($objs, $PAGES) = Stats::getRaw(T_OBJ_RACE, $filter_node + $filter_having, false, $sortRule, $set_avg); // Translating race name foreach ($objs as &$o) { $o['name'] = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $o['name']))); } break; case STATS_COACH: $tblTitle = $lng->getTrn('menu/statistics_menu/coach_stn'); $fields_before = array('name' => array('desc' => $lng->getTrn('common/coach'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_COACH, false, false, false), 'field' => 'obj_id', 'value' => 'coach_id'))); $PAGELENGTH = $settings['standings']['length_coaches']; list($objs, $PAGES) = Stats::getRaw(T_OBJ_COACH, $filter_node + $filter_having, array($PAGE, $PAGELENGTH), $sortRule, $set_avg); break; case STATS_STAR: $tblTitle = $lng->getTrn('menu/statistics_menu/star_stn'); $fields_before = array('name' => array('desc' => $lng->getTrn('common/star'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_STAR, false, false, false), 'field' => 'obj_id', 'value' => 'star_id')), 'cost' => array('desc' => 'Price', 'kilo' => true, 'suffix' => 'k'), 'ma' => array('desc' => 'Ma'), 'st' => array('desc' => 'St'), 'ag' => array('desc' => 'Ag'), 'av' => array('desc' => 'Av')); $extra['dashed'] = array('condField' => 'mv_played', 'fieldVal' => 0, 'noDashFields' => array('name')); list($objs, $PAGES) = Stats::getRaw(T_OBJ_STAR, $filter_node + $filter_having, false, $sortRule, $set_avg); break; } foreach ($objs as $idx => $obj) { $objs[$idx] = (object) $obj; } if (!$SGRP_GEN) { $tmp = $fields_before['name']; $fields_before = $fields_after = array(); $fields_before['name'] = $tmp; } $fields = array_merge($fields_before, $fields, $fields_after); // Add average marker on fields (*). if ($set_avg) { foreach (array_keys($fields) as $f) { $f_cut = preg_replace('/^\\w\\w\\_/', '', $f); if (in_array($f_cut, $objFields_avg)) { $fields[$f]['desc'] .= '*'; } } } $extra['page'] = $PAGE; $extra['pages'] = $PAGES; $extra['pagelength'] = $PAGELENGTH; HTMLOUT::sort_table($tblTitle, $opts['url'] . ($set_avg ? '&pms=1' : ''), $objs, $fields, $sortRule, array(), $extra); return array_key_exists('return_objects', $opts) && $opts['return_objects'] ? array($objs, $sortRule) : true; }
public static function starHireHistory($obj, $obj_id, $node, $node_id, $star_id = false, $opts = array()) { global $lng; /* If $star_id is false, then the HH from all stars of $obj = $obj_id will be displayed, instead of only the HH of star = $star_id */ if (!array_key_exists('GET_SS', $opts)) { $opts['GET_SS'] = ''; } else { $extra['GETsuffix'] = $opts['GET_SS']; } # GET Sorting Suffix $extra['doNr'] = false; $extra['noHelp'] = true; if ($ANC = array_key_exists('anchor', $opts)) { $extra['anchor'] = $opts['anchor']; } $mdat = array(); foreach ($star_id ? array(new Star($star_id)) : Star::getStars($obj, $obj_id, $node, $node_id) as $s) { foreach ($s->getHireHistory($obj, $obj_id, $node, $node_id) as $m) { $o = (object) array(); foreach (array('match_id', 'date_played', 'hiredBy', 'hiredAgainst', 'hiredByName', 'hiredAgainstName') as $k) { $o->{$k} = $m->{$k}; } foreach ($s->getStats(T_NODE_MATCH, $m->match_id) as $k => $v) { $o->{$k} = $v; } $o->match = $lng->getTrn('common/view'); $o->tour = get_alt_col('tours', 'tour_id', $m->f_tour_id, 'name'); $o->score = "{$m->team1_score} - {$m->team2_score}"; $o->result = matchresult_icon($m->team1_id == $m->hiredBy && $m->team1_score > $m->team2_score || $m->team2_id == $m->hiredBy && $m->team1_score < $m->team2_score ? 'W' : ($m->team1_score == $m->team2_score ? 'D' : 'L')); $o->star_id = $s->star_id; $o->name = $s->name; array_push($mdat, $o); } } $fields = array('date_played' => array('desc' => $lng->getTrn('common/dateplayed')), 'name' => array('desc' => $lng->getTrn('common/star'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_STAR, false, false, false), 'field' => 'obj_id', 'value' => 'star_id')), 'tour' => array('desc' => $lng->getTrn('common/tournament')), 'hiredByName' => array('desc' => $lng->getTrn('profile/star/hiredby'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_TEAM, false, false, false), 'field' => 'obj_id', 'value' => 'hiredBy')), 'hiredAgainstName' => array('desc' => $lng->getTrn('common/opponent'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_TEAM, false, false, false), 'field' => 'obj_id', 'value' => 'hiredAgainst')), 'cp' => array('desc' => 'Cp'), 'td' => array('desc' => 'Td'), 'intcpt' => array('desc' => 'Int'), 'cas' => array('desc' => 'Cas'), 'bh' => array('desc' => 'BH'), 'si' => array('desc' => 'Si'), 'ki' => array('desc' => 'Ki'), 'mvp' => array('desc' => 'MVP'), 'score' => array('desc' => $lng->getTrn('common/score'), 'nosort' => true), 'result' => array('desc' => $lng->getTrn('common/result'), 'nosort' => true), 'match' => array('desc' => $lng->getTrn('common/match'), 'href' => array('link' => 'index.php?section=matches&type=report', 'field' => 'mid', 'value' => 'match_id'), 'nosort' => true)); if ($star_id) { unset($fields['name']); } if ($obj && $obj_id) { unset($fields['hiredByName']); } $title = $lng->getTrn('common/starhh'); if ($ANC) { $title = "<a name='{$opts['anchor']}'>" . $title . '<a>'; } HTMLOUT::sort_table($title, $opts['url'], $mdat, $fields, sort_rule('star_HH'), isset($_GET["sort{$opts['GET_SS']}"]) ? array(($_GET["dir{$opts['GET_SS']}"] == 'a' ? '+' : '-') . $_GET["sort{$opts['GET_SS']}"]) : array(), $extra); }