public function createByName($name) { print_r('[' . $name . ']'); $document = new League(); $document->setName($name); $document->setSlug(); $document->save(); $document = $this->findOneBySlug($document->getSlug()); return $document; }
/** * Gets leagues list from STEAM API and loads them to database (in league table) * * @author Dzianis Kotau <*****@*****.**> * @return int Exit code */ public function actionLeagueList() { echo '12312312'; try { $data = $this->getRawData(self::METHOD_URL_LEAGUE_LIST); var_dump($this->quiet); //die; var_dump($data); die; } catch (Exception $e) { if ($this->quiet) { $this->stderr('An error occurred while fetching data from remote API method URL "' . self::METHOD_URL_LEAGUE_LIST . '" with error: "' . $e->getMessage() . '"' . PHP_EOL, Console::FG_RED); } var_dump($e->getMessage()); die; return self::EXIT_CODE_BAD_RAW_DATA; } $data = $data['result']->{'leagues'}; if (empty($data)) { if (!$this->quiet) { $this->stdout('Nothing to update.' . PHP_EOL, Console::FG_YELLOW); } return self::EXIT_CODE_NORMAL; } $data = array_map(function ($val) { $val->{'id'} = (int) $val->{'id'}; $val->{'name'} = trim($val->{'name'}); $val->{'description'} = trim($val->{'description'}); $val->{'tournament_url'} = trim($val->{'tournament_url'}); $val->{'itemdef'} = (int) $val->{'itemdef'}; return $val; }, $data); //$leagues = League::find()->asArray()->all(); $model = new League(); $leagues = $model->getAllLeagueIds(); $oldLeagueIds = []; foreach ($leagues as $row) { $oldLeagueIds[] = (int) $row['id']; } $newLeagueIds = []; foreach ($data as $row) { $newLeagueIds[] = (int) $row->{'leagueid'}; } $model->completeLeague(array_diff($oldLeagueIds, $newLeagueIds)); $insertLeagueIds = array_diff($newLeagueIds, $oldLeagueIds); $data = array_filter($data, function ($row) use($insertLeagueIds) { return in_array($row->{'leagueid'}, $insertLeagueIds); }); $model->addLeagues($data); if ($this->verbose) { $this->stdout('All done.' . PHP_EOL, Console::FG_GREEN); } return self::EXIT_CODE_NORMAL; }
private function getAllLeagues() { $leagues = array(); $result = db_select('league', 'l')->fields('l')->orderBy('sequence')->orderBy('name')->execute(); while ($record = $result->fetchAssoc()) { $updateLeague = new League($record['leagueid'], $record['sequence'], $record['name']); $updateLeague->setSavedDateTimeAndUser($record['saved_datetime'], $record['saved_userid']); array_push($leagues, $updateLeague); } return $leagues; }
public function load() { $this->clear(); $league = new League('NCAA'); $summer = $this->CI->_level->findOneBySlug('college'); $league->setLevel($summer); $league->save(); print_r(sprintf("Created League: %s (%s)\n", $league->getName(), $league->getId())); $league = new League('Cape Cod Baseball'); $summer = $this->CI->_level->findOneBySlug('summer'); $league->setLevel($summer); $league->save(); print_r(sprintf("Created League: %s (%s)\n", $league->getName(), $league->getId())); }
function process() { global $lr_session; $this->title = $this->team->name; $this->template_name = 'pages/team/view.tpl'; $this->smarty->assign('team', $this->team); if ($this->team->home_field) { $field = Field::load(array('fid' => $this->team->home_field)); $this->smarty->assign('home_field', $field); } $teamSBF = $this->team->calculate_sbf(); if ($teamSBF) { $this->smarty->assign('team_sbf', $teamSBF); $league = League::load(array('league_id' => $this->team->league_id)); $this->smarty->assign('league_sbf', $league->calculate_sbf()); } if ($lr_session->has_permission('team', 'player shirts', $this->team->team_id)) { $this->smarty->assign('display_shirts', true); } $rosterPositions = Team::get_roster_positions(); $this->smarty->assign('roster_positions', $rosterPositions); $this->team->get_roster(); $this->team->check_roster_conflict(); foreach ($this->team->roster as $player) { $player->status = $rosterPositions[$player->status]; } $min_roster = $league->min_roster_size; if ($this->team->roster_count < $min_roster && ($lr_session->is_captain_of($this->team->team_id) || $lr_session->is_admin()) && $this->team->roster_deadline > 0) { $this->smarty->assign('roster_requirement', $min_roster); $this->smarty->assign('display_roster_note', true); } return true; }
function process() { global $lr_session; $this->title = "{$this->team->name} » Spirit"; $this->template_name = 'pages/team/spirit.tpl'; // load the league $league = League::load(array('league_id' => $this->team->league_id)); // if the person doesn't have permission to see this team's spirit, bail out if (!$lr_session->has_permission('team', 'view', $this->team->team_id, 'spirit')) { error_exit("You do not have permission to view this team's spirit results"); } if ($league->display_sotg == 'coordinator_only' && !$lr_session->is_coordinator_of($league->league_id)) { error_exit("Spirit results are restricted to coordinator-only"); } $s = new Spirit(); $s->display_numeric_sotg = $league->display_numeric_sotg(); /* * Grab schedule info */ $games = Game::load_many(array('either_team' => $this->team->team_id, '_order' => 'g.game_date')); if (!is_array($games)) { error_exit('There are no games scheduled for this team'); } $this->smarty->assign('question_keys', array_merge(array('full'), $s->question_keys(), array('score_entry_penalty'))); $this->smarty->assign('question_headings', $s->question_headings()); $this->smarty->assign('num_spirit_columns', count($s->question_headings()) + 1); $this->smarty->assign('num_comment_columns', count($s->question_headings()) + 2); $rows = array(); foreach ($games as $game) { if (!$game->is_finalized()) { continue; } if ($game->home_id == $this->team->team_id) { $opponent_id = $game->away_id; $opponent_name = $game->away_name; $home_away = '(home)'; } else { $opponent_id = $game->home_id; $opponent_name = $game->home_name; $home_away = '(away)'; } $thisrow = array('game_id' => $game->game_id, 'day_id' => $game->day_id, 'given_by_id' => $opponent_id, 'given_by_name' => $opponent_name, 'has_entry' => 0); # Fetch spirit answers for games $entry = $game->get_spirit_entry($this->team->team_id); if (!$entry) { $rows[] = $thisrow; continue; } $thisrow['has_entry'] = 1; // can only see comments if you're a coordinator if ($lr_session->has_permission('league', 'view', $this->team->league_id, 'spirit')) { $thisrow['comments'] = $entry['comments']; } $thisrow = array_merge($thisrow, (array) $s->fetch_game_spirit_items_html($entry)); $rows[] = $thisrow; } $this->smarty->assign('spirit_detail', $rows); return true; }
public function testLeague() { $this->client->shouldReceive('baseUrl')->once(); $this->client->shouldReceive('request')->with('v2.5/league/by-summoner/272354', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/league.272354.json')); Api::setKey('key', $this->client); $leagues = League::league(272354); $this->assertTrue($leagues[0] instanceof LeagueWrap\Dto\League); }
function get_league() { if (!$this->league) { $this->league = League::load(array('league_id' => $this->game->league_id)); league_add_to_menu($this->league); } return $this->league; }
function __construct($id) { $this->league = League::load(array('league_id' => $id)); if (!$this->league) { error_exit("That league does not exist"); } league_add_to_menu($this->league); }
static function _addNames(&$division, $league) { if (!array_key_exists('long_name', $league)) { League::_addNames($league); } if (array_key_exists('name', $league)) { $division['league_name'] = trim($league['name'] . ' ' . $division['name']); $division['long_league_name'] = trim($league['long_name'] . ' ' . $division['name']); $division['full_league_name'] = trim($league['full_name'] . ' ' . $division['name']); } }
/** * Creates a player object with the given data * @param array $data an associative array to fill up the members of the * player class * @return Player a player object with the data given as it's members */ public static function create(array $data) : Player { $player = new Player(); parent::fill($data, $player); if (is_array($player->clan)) { $player->clan = Clan::create($player->clan); } if (is_array($player->league)) { $player->league = League::create($player->league); } return $player; }
/** * Returns all the leagues available in Clash of Clans. Calls the API at * /leagues * @return array of leagues currently available in Clash of Clans */ public function leagues() : array { $curlClient = curl_init(self::BASE_URL . self::LEAGUES_URL); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $results = json_decode(curl_exec($curlClient), true); $leagues = []; foreach ($results['items'] as $result) { $leagues[] = League::create($result); } return $leagues; }
function __construct($what, $id) { $this->league = League::load(array('league_id' => $id)); if (!$this->league) { error_exit("That league does not exist"); } if ($what == 'schedule' || $what == 'combined') { $this->need_schedule = true; } if ($what == 'standings' || $what == 'combined') { $this->need_standings = true; } }
function load_leagues() { if ($this->_leagues_loaded) { return true; } $this->leagues = League::load_many(array('season' => $this->id, '_order' => "FIELD(MAKE_SET((day & 62), 'BUG','Monday','Tuesday','Wednesday','Thursday','Friday'),'Monday','Tuesday','Wednesday','Thursday','Friday'), tier, league_id")); // Cheat. If we didn't find any leagues, set $this->leagues to an empty // array again. if (!is_array($this->leagues)) { $this->leagues = array(); } $this->_leagues_loaded = true; return true; }
function confirm($targetleague, $target_team) { $output .= form_hidden('edit[step]', 'perform'); $output .= form_hidden('edit[target]', $targetleague->league_id); if ($target_team) { $output .= form_hidden('edit[swaptarget]', $target_team->team_id); } $sourceleague = League::load(array('league_id' => $this->team->league_id)); $output .= para("You are attempting to move the team <b>" . $this->team->name . "</b> to <b>{$targetleague->fullname}</b>"); if ($target_team) { $output .= para("This team will be swapped with <b>{$target_team->name}</b>, which will be moved to <b>{$sourceleague->fullname}</b>."); $output .= para("Both teams' schedules will be adjusted so that each team faces any opponents the other had been scheduled for"); } $output .= para("If this is correct, please click 'Submit' below."); $output .= form_submit("Submit"); return form($output); }
public function getView($tid = false) { // Do our checks to make sure things are in place if ($tid) { $match = Match::find($tid); if ($match) { $this->data['leagues'] = League::all(); $this->data['teams'] = Team::all(); $this->data['match'] = $match; $this->layout->content = View::make($this->view . '.edit.match', $this->data); } else { return Redirect::action('Admin_MatchesController@getIndex'); } } else { return Redirect::action('Admin_MatchesController@getIndex'); } }
function process() { global $dbh; $edit =& $_POST['edit']; $this->template_name = 'pages/slot/availability.tpl'; $this->title = "{$this->slot->field->fullname} » Gameslot {$this->slot->slot_id} Availability"; if ($edit['step'] == 'perform') { foreach ($this->slot->leagues as $league) { if (!count($edit['availability']) || !in_array($league->league_id, $edit['availability'])) { $this->slot->remove_league($league); } } if (count($edit['availability']) > 0) { foreach ($edit['availability'] as $league) { $this->slot->add_league($league); } } if (!$this->slot->save()) { error_exit("Internal error: couldn't save gameslot"); } $this->smarty->assign('message', 'Changes saved'); } $this->smarty->assign('slot', $this->slot); $weekday = strftime("%A", $this->slot->date_timestamp); $sth = League::query(array('_day' => $weekday, 'status' => 'open', '_order' => 'l.league_id')); $leagues = array(); while ($league = $sth->fetchObject('League', array(LOAD_OBJECT_ONLY))) { if ($league->tier) { $league->fullname = sprintf("{$league->name} Tier %02d", $league->tier); } else { $league->fullname = $league->name; } $leagues[$league->league_id] = "({$league->season_name}) {$league->fullname}"; } $this->smarty->assign('leagues', $leagues); $current_selections = array(); foreach ($this->slot->leagues as $league) { $current_selections[] = $league->league_id; } $this->smarty->assign('current_leagues', $current_selections); return true; }
<?php require_once 'core/init.php'; $pageTitle = 'Locations'; $user = new User(); if (!$user->isLoggedIn()) { Redirect::to('login.php'); } // Defaults $style = ''; $displayErrors = "none"; $errorDisplay = ""; $leagueOptions = new League(); if (isset($_GET['delete']) && $_GET['delete'] == true && isset($_GET['locationid']) && is_numeric($_GET['locationid'])) { try { $locationId = escape($_GET['locationid']); $leagueOptions->deleteLocation($locationId); Session::flash('deleted', 'Location Deleted Successfully'); Redirect::to('locations.php'); } catch (Exception $e) { die($e->getMessage()); } } else { $locationResults = $leagueOptions->getLocations(); } if (Input::exists()) { if (Token::check(Input::get('token'))) { $validate = new Validation(); $validation = $validate->check($_POST, array('GroundName' => array('name' => 'Ground Name', 'min' => 5, 'max' => 50, 'required' => true), 'Town' => array('name' => 'Town', 'min' => 3, 'max' => 50), 'PostCode' => array('name' => 'Postcode', 'min' => 3, 'max' => 10))); if ($validation->passed()) { try {
private static function translateXML($xmlStr) { $standings = simplexml_load_string($xmlStr); $data = array(); $curID = 1; foreach ($standings->team as $team) { $dataElement = new stdClass(); $dataElement->id = $curID++; $dataElement->code = $team['code']; $dataElement->name = $team->fullname; $dataElement->conf = $team['conference']; $divStr = mb_substr($team['division'], 2, 1); foreach (League::getGroups() as $group) { if (strncasecmp($divStr, $group, 1) == 0) { $dataElement->div = $group; } } $dataElement->wins = $team->totals->wins; $dataElement->loses = $team->totals->losses; $dataElement->ties = $team->totals->ties != null ? $team->totals->ties : '0'; $dataElement->netPts = $team->totals->net; $dataElement->streak = '-'; $data[] = $dataElement; } return $data; }
HTMLOUT::frame_begin(false); title("OBBLM Troubleshooting"); ?> <h1>Leagues</h1> <table> <thead> <th>League ID</th> <th>Tie Teams to Divisions</th> <th>Name</th> <th>Date Created</th> <th>Location</th> <th>Divisions</th> </thead> <tbody style="text-align: center"> <?php foreach (League::getLeagues() as $league) { ?> <tr> <td><?php echo $league->lid; ?> </td> <td><?php echo $league->tie_teams; ?> </td> <td><?php echo $league->name; ?> </td> <td><?php
function stats() { $id = $this->_arg('game'); if (!$id) { $this->Session->setFlash(sprintf(__('Invalid %s', true), __('game', true)), 'default', array('class' => 'info')); $this->redirect('/'); } $team_id = $this->_arg('team'); if ($team_id) { $stat_conditions = array('Stat.team_id' => $team_id); } else { $stat_conditions = array(); } $this->Game->contain(array('Division' => array('League' => array('StatType' => array('conditions' => array('StatType.type' => Configure::read('stat_types.game'))))), 'HomeTeam', 'AwayTeam', 'GameSlot' => array('Field' => 'Facility'), 'ScoreEntry', 'Stat' => array('conditions' => $stat_conditions))); $game = $this->Game->read(null, $id); if (!$game) { $this->Session->setFlash(sprintf(__('Invalid %s', true), __('game', true)), 'default', array('class' => 'info')); $this->redirect('/'); } if (!League::hasStats($game['Division']['League'])) { $this->Session->setFlash(__('This league does not have stat tracking enabled.', true), 'default', array('class' => 'info')); $this->redirect(array('action' => 'view', 'game' => $id)); } if ("{$game['GameSlot']['game_date']} {$game['GameSlot']['game_start']}" > date('Y-m-d H:i:s')) { $this->Session->setFlash(__('This game has not yet started.', true), 'default', array('class' => 'info')); $this->redirect(array('action' => 'view', 'game' => $id)); } if (empty($game['Stat'])) { $this->Session->setFlash(__('No stats have been entered for this game.', true), 'default', array('class' => 'info')); // Redirect coordinators to the stats entry page with whatever parameters were used here if (in_array($game['Division']['id'], $this->UserCache->read('DivisionIDs'))) { $this->redirect(array('action' => 'submit_stats', 'game' => $id, 'team' => $team_id)); } // If there was no team ID given, check if one of the two teams is captained by the current user if (!$team_id) { $teams = array_intersect(array($game['Game']['home_team'], $game['Game']['away_team']), $this->UserCache->read('OwnedTeamIDs')); $team_id = array_pop($teams); } // If we have a team ID and we're a captain of that team, go to the stats entry page if ($team_id && in_array($team_id, $this->UserCache->read('OwnedTeamIDs'))) { $this->redirect(array('action' => 'submit_stats', 'game' => $id, 'team' => $team_id)); } $this->redirect(array('action' => 'view', 'game' => $id)); } $this->Configuration->loadAffiliate($game['Division']['League']['affiliate_id']); $sport_obj = $this->_getComponent('Sport', $game['Division']['League']['sport'], $this); // Team rosters may have changed since the game was played, so use the list of people with stats instead foreach (array('HomeTeam', 'AwayTeam') as $key) { $people = array_unique(Set::extract("/Stat[team_id={$game[$key]['id']}]/person_id", $game)); $game[$key]['Person'] = $this->Game->HomeTeam->Person->find('all', array('contain' => array(), 'conditions' => array('Person.id' => $people))); usort($game[$key]['Person'], array('Person', 'comparePerson')); } if ($game['Game']['home_team'] == $team_id || $team_id === null) { $team = $game['HomeTeam']; $opponent = $game['AwayTeam']; } else { if ($game['Game']['away_team'] == $team_id) { $team = $game['AwayTeam']; $opponent = $game['HomeTeam']; } else { $this->Session->setFlash(__('That team is not playing in this game.', true), 'default', array('class' => 'info')); $this->redirect(array('action' => 'view', 'game' => $id)); } } $this->set(compact('game', 'team_id', 'team', 'opponent', 'sport_obj')); if ($this->params['url']['ext'] == 'csv') { $this->set('download_file_name', "Stats - Game {$game['Game']['id']}"); Configure::write('debug', 0); } }
public static function upcomingGames($obj, $obj_id, $node, $node_id, $opp_obj, $opp_obj_id, array $opts) { /* Make upcoming games table. $opts = array( 'url' => The URL of the page on which this table is to be printed. 'n' => (int) Fetch the n most recent games. If not specified all matches are displayed. 'GET_SS' => GET Sorting suffix ); */ global $lng; $T_ROUNDS = Match::getRounds(); $extra = array('doNr' => false, 'noHelp' => true); if (!array_key_exists('GET_SS', $opts)) { $opts['GET_SS'] = ''; } else { $extra['GETsuffix'] = $opts['GET_SS']; } # GET Sorting Suffix if (!(array_key_exists('n', $opts) && $opts['n'])) { $opts['n'] = false; } if (!$opts['n']) { $N = array(); } else { $N = isset($_GET["page"]) ? array((int) $_GET["page"], $opts['n']) : array(1, $opts['n']); } if ($obj && $obj_id) { list($matches, $pages) = Stats::getMatches($obj, $obj_id, $node, $node_id, $opp_obj, $opp_obj_id, $N, true, true); } else { list($matches, $pages) = Match::getMatches($N, $node ? $node : false, $node ? $node_id : false, true); } $extra['page'] = $N[0]; $extra['pages'] = $pages; foreach ($matches as $m) { $m->date_created_disp = textdate($m->date_created, true); $m->mlink = "<a href='index.php?section=matches&type=report&mid={$m->match_id}'>" . $lng->getTrn('common/view') . "</a>"; $m->tour_name = Tour::getTourUrl($m->f_tour_id); $m->league_name = League::getLeagueUrl(get_parent_id(T_NODE_TOURNAMENT, $m->f_tour_id, T_NODE_LEAGUE)); if (in_array($m->round, array_keys($T_ROUNDS))) { $m->round = $T_ROUNDS[$m->round]; } $m->team1_name = "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $m->team1_id, false, false) . "'>{$m->team1_name}</a> <i>(<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_COACH, $m->coach1_id, false, false) . "'>{$m->coach1_name}</a>)</i>"; $m->team2_name = "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $m->team2_id, false, false) . "'>{$m->team2_name}</a> <i>(<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_COACH, $m->coach2_id, false, false) . "'>{$m->coach2_name}</a>)</i>"; } $fields = array('date_created_disp' => array('desc' => $lng->getTrn('common/datecreated'), 'nosort' => true), 'league_name' => array('desc' => $lng->getTrn('common/league'), 'nosort' => true), 'tour_name' => array('desc' => $lng->getTrn('common/tournament'), 'nosort' => true), 'round' => array('desc' => $lng->getTrn('common/round'), 'nosort' => true), 'team1_name' => array('desc' => $lng->getTrn('common/home'), 'nosort' => true), 'team2_name' => array('desc' => $lng->getTrn('common/away'), 'nosort' => true), 'mlink' => array('desc' => $lng->getTrn('common/match'), 'nosort' => true)); HTMLOUT::sort_table($lng->getTrn('common/upcomingmatches'), $opts['url'], $matches, $fields, array('+round', '+date_created'), isset($_GET["sort{$opts['GET_SS']}"]) ? array(($_GET["dir{$opts['GET_SS']}"] == 'a' ? '+' : '-') . $_GET["sort{$opts['GET_SS']}"]) : array(), $extra); }
function stats() { if (!ini_get('safe_mode')) { set_time_limit(180); } $id = $this->_arg('division'); if (!$id) { $this->Session->setFlash(sprintf(__('Invalid %s', true), __('division', true)), 'default', array('class' => 'info')); $this->redirect(array('controller' => 'leagues', 'action' => 'index')); } $contain = array('League' => array('StatType' => array('conditions' => array('StatType.type' => Configure::read('stat_types.team')))), 'Day', 'Team'); $this->Division->contain($contain); $division = $this->Division->read(null, $id); if (!$division) { $this->Session->setFlash(sprintf(__('Invalid %s', true), __('division', true)), 'default', array('class' => 'info')); $this->redirect(array('controller' => 'leagues', 'action' => 'index')); } if (!League::hasStats($division['League'])) { $this->Session->setFlash(__('This league does not have stat tracking enabled.', true), 'default', array('class' => 'info')); $this->redirect(array('action' => 'view', 'division' => $id)); } $this->Configuration->loadAffiliate($division['League']['affiliate_id']); Configure::load("sport/{$division['League']['sport']}"); $sport_obj = $this->_getComponent('Sport', $division['League']['sport'], $this); // Hopefully, everything we need is already cached $cache_key = 'division/' . intval($id) . '/stats'; $cached = Cache::read($cache_key, 'long_term'); if ($cached) { $stats = $cached; } if (!empty($stats)) { $division += $stats; } else { // Calculate some stats. $teams = Set::extract('/Team/id', $division); $stats = $this->Division->Team->Stat->find('all', array('conditions' => array('team_id' => $teams), 'contain' => array())); $sport_obj->_init_stats($stats); $division['Person'] = $this->Division->Team->TeamsPerson->find('all', array('contain' => array('Person', 'Team'), 'conditions' => array('TeamsPerson.team_id' => $teams, 'TeamsPerson.role' => Configure::read('extended_playing_roster_roles')))); usort($division['Person'], array('Person', 'comparePerson')); AppModel::_reindexOuter($division['Person'], 'Person', 'id'); foreach ($division['League']['StatType'] as $stat_type) { switch ($stat_type['type']) { case 'season_total': $sport_obj->_season_total($stat_type, $stats); break; case 'season_avg': $sport_obj->_season_avg($stat_type, $stats); break; case 'season_calc': $func = "{$stat_type['handler']}_season"; if (method_exists($sport_obj, $func)) { $sport_obj->{$func}($stat_type, $stats); } else { trigger_error("Season stat handler {$stat_type['handler']} was not found in the {$stat_type['sport']} component!", E_USER_ERROR); } break; } } if (!empty($stats['Calculated'])) { $division['Calculated'] = $stats['Calculated']; } else { $division['Calculated'] = array(); } Cache::write($cache_key, array('Person' => $division['Person'], 'Calculated' => $division['Calculated']), 'long_term'); } $this->set(compact('division', 'sport_obj')); $this->set('is_coordinator', in_array($id, $this->UserCache->read('DivisionIDs'))); if ($this->params['url']['ext'] == 'csv') { $this->set('download_file_name', "Stats - {$division['Division']['name']}"); Configure::write('debug', 0); } }
public function getUpdateleague() { $getleague = SteamApi::getleague(); $leagues = $getleague->result->leagues; foreach ($leagues as $item) { $item_row = League::where('id', '=', $item->leagueid)->first(); if ($item_row == false) { $item_row = new League(); $item_row->id = $item->leagueid; $item_row->name = $item->name; $item_row->description = $item->description; $item_row->defindex = $item->itemdef; $item_row->save(); } else { $item_row->id = $item->leagueid; $item_row->name = $item->name; $item_row->description = $item->description; $item_row->defindex = $item->itemdef; $item_row->save(); } } return $view = View::make('default.admin.edit.leagueschema'); }
<?php spl_autoload_register(function ($class_name) { include "../inc/" . $class_name . '.php'; }); $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : PinnacleClient::SOCCER_ID; $fixture = new Fixture($id); $pinnacle_client = new PinnacleClient(); $json = $pinnacle_client->query("https://api.pinnaclesports.com/v1/fixtures?sportid=" . $id . "&since=" . $fixture->get('last')); $fixture->set('last', $json->last); foreach ($json->league as $l) { $league = new League($l->id); $league->set('sportId', $id); foreach ($l->events as $e) { $event = new Event($e->id); $event->set('leagueId', $l->id); $event->set('starts', $e->starts); $event->set('home', $e->home); $event->set('away', $e->away); $event->set('rotNum', $e->rotNum); if (isset($e->homePitcher)) { $event->set('homePitcher', $e->homePitcher); } if (isset($e->awayPitcher)) { $event->set('awayPitcher', $e->awayPitcher); } } }
<?php require_once 'core/init.php'; $pageTitle = 'Update a Location'; $user = new User(); if (!$user->isLoggedIn()) { Redirect::to('login.php'); } // Defaults $style = ''; $displayErrors = "none"; $errorDisplay = ""; $leagueOptions = new League(); if (isset($_GET['locationid']) && is_numeric($_GET['locationid'])) { $location = $leagueOptions->getLocationById(escape($_GET['locationid'])); if (!$location) { die("Location not found"); } else { $results = $location->results(); $GroundName = $location->first()->GroundName; $Town = $location->first()->Town; $PostCode = $location->first()->PostCode; $LocationId = $location->first()->LocationId; } } if (Input::exists()) { if (Token::check(Input::get('token'))) { $validate = new Validation(); $validation = $validate->check($_POST, array('GroundName' => array('name' => 'Ground Name', 'min' => 5, 'max' => 50, 'required' => true), 'Town' => array('name' => 'Town', 'min' => 3, 'max' => 50), 'PostCode' => array('name' => 'Postcode', 'min' => 3, 'max' => 10))); if ($validation->passed()) { try {
function __construct($load_mode = LOAD_RELATED_DATA) { global $dbh; /* set any defaults for unset values */ if (!$this->height) { $this->height = 0; } if (!$this->user_id) { return; } /* set derived attributes */ $this->fullname = "{$this->firstname} {$this->lastname}"; if ($this->user_id == 'new' || $load_mode == LOAD_OBJECT_ONLY) { return; } /* Now fetch team info */ $sth = $dbh->prepare("SELECT\n\t\t\t\tr.status AS position,\n\t\t\t\tr.team_id,\n\t\t\t\tt.name,\n\t\t\t\tl.league_id,\n\t\t\t\tIF(l.tier,CONCAT_WS(' ',l.name,'Tier',l.tier),l.name) AS league_name,\n\t\t\t\tl.season,\n\t\t\t\tl.day,\n\t\t\t\tl.status AS league_status\n\t\t\tFROM\n\t\t\t\tteamroster r\n\t\t\t\tINNER JOIN team t ON (r.team_id = t.team_id)\n\t\t\t\tINNER JOIN leagueteams lt ON (lt.team_id = t.team_id)\n\t\t\t\tINNER JOIN league l ON (lt.league_id = l.league_id)\n\t\t\tWHERE\n\t\t\t\tr.player_id = ?\n\t\t\tORDER BY\n\t\t\t\tl.season DESC, l.day"); $sth->setFetchMode(PDO::FETCH_CLASS, 'Team', array(LOAD_OBJECT_ONLY)); $sth->execute(array($this->user_id)); $this->teams = array(); while ($team = $sth->fetch()) { if ($team->position == 'captain' || $team->position == 'assistant' || $team->position == 'coach') { # TODO: evil hack. $this->is_a_captain = true; } $this->teams[$team->team_id] = $team; $this->teams[$team->team_id]->id = $team->team_id; } /* Fetch league info. Can't use League::load as it calls Person::load, * which makes this recursively painful. */ $sth = $dbh->prepare("SELECT\n\t\t\t\tl.league_id,\n\t\t\t\tl.name,\n\t\t\t\tl.tier,\n\t\t\t\tl.season,\n\t\t\t\tl.day,\n\t\t\t\tl.schedule_type,\n\t\t\t\tl.status AS league_status,\n\t\t\t\tm.status\n\t\t\tFROM\n\t\t\t \tleaguemembers m\n\t\t\t\tINNER JOIN league l ON (m.league_id = l.league_id)\n\t\t\tWHERE\n\t\t\t\tm.status = 'coordinator'\n\t\t\tAND\n\t\t\t\tm.player_id = ?\n\t\t\t ORDER BY l.season, l.day, l.name, l.tier"); $sth->setFetchMode(PDO::FETCH_CLASS, 'League', array(LOAD_OBJECT_ONLY)); $sth->execute(array($this->user_id)); $this->leagues = array(); while ($league = $sth->fetch()) { # TODO: evil hack... this belongs in the league constructor, no? $this->is_a_coordinator = true; if ($league->tier) { $league->fullname = sprintf("{$league->name} Tier %02d", $league->tier); } else { $league->fullname = $league->name; } $this->leagues[$league->league_id] = $league; } /* Evil hack to get 'Inactive Teams' into menu */ if ($this->is_a_coordinator) { $sth = League::query(array('league_id' => 1)); $this->leagues[1] = $sth->fetchObject('League', array(LOAD_OBJECT_ONLY)); } return true; }
<?php require_once 'core/init.php'; $pageTitle = 'Opponents'; $user = new User(); if (!$user->isLoggedIn()) { Redirect::to('login.php'); } // Defaults $style = ''; $displayErrors = "none"; $errorDisplay = ""; $leagueOptions = new League(); if (isset($_GET['delete']) && $_GET['delete'] == true && isset($_GET['opponentid']) && is_numeric($_GET['opponentid'])) { try { $opponentId = escape($_GET['opponentid']); $leagueOptions->deleteOpponent($opponentId); Session::flash('deleted', 'Opponent Deleted Successfully'); Redirect::to('opponents.php'); } catch (Exception $e) { die($e->getMessage()); } } else { $opponentsResults = $leagueOptions->getOpponents(); } if (Input::exists()) { if (Token::check(Input::get('token'))) { $validate = new Validation(); $validation = $validate->check($_POST, array('OpponentName' => array('name' => 'Opponent', 'min' => 5, 'max' => 50, 'unique' => 'opponent', 'required' => true))); if ($validation->passed()) { try {
function generateConfirm(&$edit, $datestamp) { $dataInvalid = $this->isDataInvalid($edit); if ($dataInvalid) { error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again"); } $this->smarty->assign('start_date', $datestamp); $this->smarty->assign('edit', $edit); $leagues = array(); foreach ($edit['availability'] as $league_id) { $league = League::load(array('league_id' => $league_id)); $leagues[$league_id] = $league->fullname; } $this->smarty->assign('leagues', $leagues); return true; }
public static function report() { // Is $match_id valid? $match_id = (int) $_GET['mid']; if (!get_alt_col('matches', 'match_id', $match_id, 'match_id')) { fatal("Invalid match ID."); } global $lng, $stars, $rules, $settings, $coach, $racesHasNecromancer, $racesMayRaiseRotters, $DEA, $T_PMD__ENTRY_EXPECTED; global $T_MOUT_REL, $T_MOUT_ACH, $T_MOUT_IR, $T_MOUT_INJ; global $leagues, $divisions, $tours; $T_ROUNDS = Match::getRounds(); // Perform actions (delete, lock/unlock and reset). Needs the $IS_LOCAL_ADMIN = is_object($coach) && $coach->isNodeCommish(T_NODE_TOURNAMENT, get_alt_col('matches', 'match_id', $match_id, 'f_tour_id')); self::matchActions($IS_LOCAL_ADMIN); // Create objects $m = new Match($match_id); $team1 = new Team($m->team1_id); $team2 = new Team($m->team2_id); // Determine visitor privileges. $lid = $divisions[$tours[$m->f_tour_id]['f_did']]['f_lid']; $ALLOW_EDIT = !$m->locked && is_object($coach) && ($coach->ring == Coach::T_RING_GLOBAL_ADMIN || $leagues[$lid]['ring'] == Coach::T_RING_LOCAL_ADMIN || $coach->isInMatch($m->match_id)); $DIS = $ALLOW_EDIT ? '' : 'DISABLED'; // Lock page for other reasons? (Used journeys etc) $USED_JOURNEYMAN_PRESENT = false; foreach (array(1 => $team1, 2 => $team2) as $id => $t) { foreach ($t->getPlayers() as $p) { if (!self::player_validation($p, $m)) { continue; } if (!$m->is_played && $p->is_journeyman_used) { $USED_JOURNEYMAN_PRESENT = true; } } } if ($USED_JOURNEYMAN_PRESENT) { $DIS = 'DISABLED'; } // Relay to ES report page? if (isset($_GET['es_report'])) { # Don't care what value the GET field has! self::report_ES($match_id, !$ALLOW_EDIT); return; } $easyconvert = new array_to_js(); @$easyconvert->add_array($stars, 'phpStars'); // Load stars array into JavaScript array. echo $easyconvert->output_all(); echo '<script language="JavaScript" type="text/javascript"> var ID_MERCS = ' . ID_MERCS . '; var ID_STARS_BEGIN = ' . ID_STARS_BEGIN . '; </script> '; /***************** * * Submitted form? * *****************/ if (isset($_POST['button']) && $ALLOW_EDIT) { if (get_magic_quotes_gpc()) { $_POST['summary'] = stripslashes($_POST['summary']); } MTS('Report submit STARTED'); // FIRST, if any raised zombies are kept we need to create their player objects in order have the correct player- vs. match creation & played dates. foreach (array(1 => $team1, 2 => $team2) as $id => $t) { if (in_array($t->f_race_id, $racesHasNecromancer) && isset($_POST["t{$id}zombie"])) { $pos_id = $DEA[$t->f_rname]['players']['Zombie']['pos_id']; list($exitStatus, $pid) = Player::create(array('nr' => $t->getFreePlayerNr(), 'f_pos_id' => $pos_id, 'team_id' => $t->team_id, 'name' => 'RAISED ZOMBIE'), array('free' => true)); /* Knowing the new zombie's PID we relocate the zombie match data to regular player data - this allows us to use the same loop for submitting the zombie's match data. */ foreach ($T_PMD__ENTRY_EXPECTED as $f) { $postName = "{$f}_t{$id}zombie"; $_POST["{$f}_{$pid}"] = isset($_POST[$postName]) ? $_POST[$postName] : 0; unset($_POST[$postName]); } } } // SECONDLY, look for raised rotters too, do same as above with zombies... foreach (array(1 => $team1, 2 => $team2) as $id => $t) { if (in_array($t->f_race_id, $racesMayRaiseRotters) && isset($_POST["t{$id}rotterCnt"]) && ($N = (int) $_POST["t{$id}rotterCnt"]) > 0) { foreach (range(1, $N) as $n) { $pos_id = $DEA[$t->f_rname]['players']['Rotter']['pos_id']; list($exitStatus, $pid) = Player::create(array('nr' => $t->getFreePlayerNr(), 'f_pos_id' => $pos_id, 'team_id' => $t->team_id, 'name' => "RAISED ROTTER {$n}"), array('free' => true)); /* Knowing the new rotter's PID we relocate the rotter match data to regular player data - this allows us to use the same loop for submitting the rotter's match data. */ foreach ($T_PMD__ENTRY_EXPECTED as $f) { $postName = "{$f}_t{$id}rotter{$n}"; $_POST["{$f}_{$pid}"] = isset($_POST[$postName]) ? $_POST[$postName] : 0; unset($_POST[$postName]); } } } } // Update general match data status($m->update(array('submitter_id' => (int) $_SESSION['coach_id'], 'stadium' => (int) $_POST['stadium'], 'gate' => (int) $_POST['gate'] * 1000, 'fans' => (int) $_POST['fans'], 'ffactor1' => (int) $_POST['ff1'], 'ffactor2' => (int) $_POST['ff2'], 'income1' => (int) $_POST['inc1'] * 1000, 'income2' => (int) $_POST['inc2'] * 1000, 'team1_score' => (int) $_POST['result1'], 'team2_score' => (int) $_POST['result2'], 'smp1' => (int) $_POST['smp1'], 'smp2' => (int) $_POST['smp2'], 'tcas1' => (int) $_POST['tcas1'], 'tcas2' => (int) $_POST['tcas2'], 'fame1' => (int) $_POST['fame1'], 'fame2' => (int) $_POST['fame2'], 'tv1' => (int) $_POST['tv1'] * 1000, 'tv2' => (int) $_POST['tv2'] * 1000)), 'Saving match report'); if (!empty($_POST['summary'])) { $m->saveText($_POST['summary']); # Save summery. } MTS('matches entry submitted'); // Update match's player data foreach (array(1 => $team1, 2 => $team2) as $id => $t) { /* Save ordinary players */ foreach ($t->getPlayers() as $p) { if (!self::player_validation($p, $m)) { continue; } // We create zero entries for MNG player(s). This is required! $pid = $p->player_id; # Shortcut if ($p->getStatus($m->match_id) == MNG) { $_POST["mvp_{$pid}"] = 0; $_POST["cp_{$pid}"] = 0; $_POST["td_{$pid}"] = 0; $_POST["intcpt_{$pid}"] = 0; $_POST["bh_{$pid}"] = 0; $_POST["si_{$pid}"] = 0; $_POST["ki_{$pid}"] = 0; $_POST["ir1_d1_{$pid}"] = 0; $_POST["ir1_d2_{$pid}"] = 0; $_POST["ir2_d1_{$pid}"] = 0; $_POST["ir2_d2_{$pid}"] = 0; $_POST["ir3_d1_{$pid}"] = 0; $_POST["ir3_d2_{$pid}"] = 0; $_POST["inj_{$pid}"] = NONE; $_POST["agn1_{$pid}"] = NONE; $_POST["agn2_{$pid}"] = NONE; } $m->entry($p->player_id, array('mvp' => $_POST["mvp_{$pid}"], 'cp' => $_POST["cp_{$pid}"], 'td' => $_POST["td_{$pid}"], 'intcpt' => $_POST["intcpt_{$pid}"], 'bh' => $_POST["bh_{$pid}"], 'si' => $_POST["si_{$pid}"], 'ki' => $_POST["ki_{$pid}"], 'ir1_d1' => $_POST["ir1_d1_{$pid}"], 'ir1_d2' => $_POST["ir1_d2_{$pid}"], 'ir2_d1' => $_POST["ir2_d1_{$pid}"], 'ir2_d2' => $_POST["ir2_d2_{$pid}"], 'ir3_d1' => $_POST["ir3_d1_{$pid}"], 'ir3_d2' => $_POST["ir3_d2_{$pid}"], 'inj' => $_POST["inj_{$pid}"], 'agn1' => $_POST["agn1_{$pid}"], 'agn2' => $_POST["agn2_{$pid}"])); } MTS('Saved all REGULAR player entries in match_data for team ' . $id); /* Save stars entries. */ foreach ($stars as $star) { $s = new Star($star['id']); if (isset($_POST['team_' . $star['id']]) && $_POST['team_' . $star['id']] == $id) { $sid = $s->star_id; $m->entry($sid, array('f_team_id' => $t->team_id, 'mvp' => isset($_POST["mvp_{$sid}"]) && $_POST["mvp_{$sid}"] ? 1 : 0, 'cp' => $_POST["cp_{$sid}"], 'td' => $_POST["td_{$sid}"], 'intcpt' => $_POST["intcpt_{$sid}"], 'bh' => $_POST["bh_{$sid}"], 'si' => $_POST["si_{$sid}"], 'ki' => $_POST["ki_{$sid}"], 'ir1_d1' => 0, 'ir1_d2' => 0, 'ir2_d1' => 0, 'ir2_d2' => 0, 'ir3_d1' => 0, 'ir3_d2' => 0, 'inj' => NONE, 'agn1' => NONE, 'agn2' => NONE)); } else { $s->rmMatchEntry($m->match_id, $t->team_id); } } MTS('Saved all STAR player entries in match_data for team ' . $id); /* Save mercenary entries. */ Mercenary::rmMatchEntries($m->match_id, $t->team_id); // Remove all previously saved mercs in this match. for ($i = 0; $i <= 20; $i++) { # We don't expect over 20 mercs. This is just some large random number. $idm = '_' . ID_MERCS . '_' . $i; if (isset($_POST["team{$idm}"]) && $_POST["team{$idm}"] == $id) { $m->entry(ID_MERCS, array('f_team_id' => $t->team_id, 'nr' => $i, 'skills' => $_POST["skills{$idm}"], 'mvp' => isset($_POST["mvp{$idm}"]) && $_POST["mvp{$idm}"] ? 1 : 0, 'cp' => $_POST["cp{$idm}"], 'td' => $_POST["td{$idm}"], 'intcpt' => $_POST["intcpt{$idm}"], 'bh' => $_POST["bh{$idm}"], 'si' => $_POST["si{$idm}"], 'ki' => $_POST["ki{$idm}"], 'ir1_d1' => 0, 'ir1_d2' => 0, 'ir2_d1' => 0, 'ir2_d2' => 0, 'ir3_d1' => 0, 'ir3_d2' => 0, 'inj' => NONE, 'agn1' => NONE, 'agn2' => NONE)); } } MTS('Saved all MERC player entries in match_data for team ' . $id); } $m->finalizeMatchSubmit(); # Required! MTS('Report submit ENDED'); // Refresh objects used to display form. $m = new Match($match_id); $team1 = new Team($m->team1_id); $team2 = new Team($m->team2_id); } // Change round form submitted? if ($IS_LOCAL_ADMIN && isset($_POST['round'])) { status($m->chRound((int) $_POST['round'])); } /**************** * * Generate form * ****************/ $teamUrl1 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $m->team1_id, false, false) . "\">" . $m->team1_name . "</a>"; $teamUrl2 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $m->team2_id, false, false) . "\">" . $m->team2_name . "</a>"; $coachUrl1 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_COACH, $team1->owned_by_coach_id, false, false) . "\">" . $team1->f_cname . "</a>"; $coachUrl2 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_COACH, $team2->owned_by_coach_id, false, false) . "\">" . $team2->f_cname . "</a>"; $raceUrl1 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_RACE, $team1->f_race_id, false, false) . "\">" . $lng->getTrn('race/' . strtolower(str_replace(' ', '', $team1->f_rname))) . "</a>"; $raceUrl2 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_RACE, $team2->f_race_id, false, false) . "\">" . $lng->getTrn('race/' . strtolower(str_replace(' ', '', $team2->f_rname))) . "</a>"; $leagueUrl = League::getLeagueUrl(get_parent_id(T_NODE_MATCH, $m->match_id, T_NODE_LEAGUE)); $divUrl = "<a href=\"" . urlcompile(T_URL_STANDINGS, T_OBJ_TEAM, false, T_NODE_DIVISION, get_parent_id(T_NODE_MATCH, $m->match_id, T_NODE_DIVISION)) . "\">" . get_parent_name(T_NODE_MATCH, $m->match_id, T_NODE_DIVISION) . "</a>"; $tourUrl = Tour::getTourUrl(get_parent_id(T_NODE_MATCH, $m->match_id, T_NODE_TOURNAMENT)); title($teamUrl1 . " - " . $teamUrl2); $CP = 8; // Colspan. ?> <table> <tr><td></td><td style='text-align: right;'><i><?php echo $lng->getTrn('common/home'); ?> </i></td><td>—</td><td style='text-align: left;'><i><?php echo $lng->getTrn('common/away'); ?> </i></td></tr> <tr><td><b><?php echo $lng->getTrn('common/teams'); ?> </b>:</td><td style='text-align: right;'><?php echo "{$teamUrl1}</td><td> — </td><td style='text-align: left;'>{$teamUrl2}"; ?> </td></tr> <tr><td><b><?php echo $lng->getTrn('common/coaches'); ?> </b>:</td><td style='text-align: right;'><?php echo "{$coachUrl1}</td><td> — </td><td style='text-align: left;'>{$coachUrl2}"; ?> </td></tr> <tr><td><b><?php echo $lng->getTrn('common/races'); ?> </b>:</td><td style='text-align: right;'><?php echo "{$raceUrl1}</td><td> — </td><td style='text-align: left;'>{$raceUrl2}"; ?> </td></tr> <tr><td colspan="4"><hr></td></tr> <tr><td><b><?php echo $lng->getTrn('common/league'); ?> </b>:</td><td colspan="3"> <?php echo $leagueUrl; ?> </td></tr> <tr><td><b><?php echo $lng->getTrn('common/division'); ?> </b>:</td><td colspan="3"> <?php echo $divUrl; ?> </td></tr> <tr><td><b><?php echo $lng->getTrn('common/tournament'); ?> </b>:</td><td colspan="3"><?php echo $tourUrl; ?> </td></tr> <tr><td><b><?php echo $lng->getTrn('common/round'); ?> </b>:</td><td colspan="3"> <?php echo $T_ROUNDS[$m->round]; ?> </td></tr> <tr><td><b><?php echo $lng->getTrn('common/dateplayed'); ?> </b>:</td><td colspan="3"><?php echo $m->is_played ? textdate($m->date_played) : '<i>' . $lng->getTrn('matches/report/notplayed') . '</i>'; ?> </td></tr> <?php if (Module::isRegistered('PDFMatchReport')) { $str = '<a href="handler.php?type=pdfmatchreport&tid1=' . $team1->team_id . '&tid2=' . $team2->team_id . '&mid=' . $m->match_id . '" TARGET="_blank">Download PDF report</a>'; echo "<tr><td><b>Match report</b>:</td><td>{$str}</td></tr>"; } if (Module::isRegistered('UPLOAD_BOTOCS')) { echo "<tr><td><b>Replay</b>:</td><td colspan='3'><a href='handler.php?type=leegmgr&replay={$m->match_id}'>View replay</a></td></tr>"; } if ($IS_LOCAL_ADMIN) { ?> <script language="JavaScript" type="text/javascript"> function match_delete() { return confirm('<?php echo $lng->getTrn('matches/tourmatches/matchdelete'); ?> '); } function match_reset() { return confirm('<?php echo $lng->getTrn('matches/tourmatches/reset_notice'); ?> '); } </script> <?php $matchURL = "index.php?section=matches&type=report&mid={$m->match_id}"; $deleteURL = "index.php?section=matches&type=tourmatches&trid={$m->f_tour_id}&mid={$m->match_id}"; echo "<tr><td><b>Admin:</b></td><td colspan='3'><b>"; echo "<a onclick=\"return match_reset();\" href='{$matchURL}&action=reset'>" . $lng->getTrn('common/reset') . "</a> \n"; echo "<a onclick=\"return match_delete();\" href='{$deleteURL}&action=delete' style='color:" . (!empty($m->date_played) ? 'Red' : 'Blue') . ";'>" . $lng->getTrn('common/delete') . "</a> \n"; echo "<a href='{$matchURL}&action=" . ($m->locked ? 'unlock' : 'lock') . "'>" . ($m->locked ? $lng->getTrn('common/unlock') : $lng->getTrn('common/lock')) . "</a> \n"; echo "<br><a href='javascript:void(0);' onClick='slideToggleFast(\"chRound\");'>" . $lng->getTrn('matches/report/chround') . "</a><div id='chRound' style='display:none;'>\n\t\t<form method='POST'>\n\t\t<select name='round'>"; foreach ($T_ROUNDS as $id => $desc) { echo "<option value='{$id}'>" . $desc . "</option>\n"; } echo "</select>\n\t\t<input type='submit' value='" . $lng->getTrn('matches/report/chround') . "'>\n\t\t</form>\n\t\t</div>"; echo "</b></td></tr>"; } ?> </table> <br> <?php echo "<b><a TARGET='_blank' href='" . DOC_URL_GUIDE . "'>" . $lng->getTrn('common/needhelp') . "</a></b><br><br>"; ?> <form method="POST" enctype="multipart/form-data"> <table class="common"> <tr class='commonhead'><td colspan="<?php echo $CP; ?> "><b><?php echo $lng->getTrn('matches/report/info'); ?> </b></td></tr> <tr><td class='seperator' colspan='<?php echo $CP; ?> '></td></tr> <tr><td colspan='<?php echo $CP; ?> '> <b><?php echo $lng->getTrn('matches/report/stadium'); ?> </b> <select name="stadium" <?php echo $DIS; ?> > <?php $stad = $m->stadium ? $m->stadium : $m->team1_id; foreach (array($team1, $team2) as $_t) { echo "<option value='{$_t->team_id}'" . ($stad == $_t->team_id ? 'SELECTED' : '') . ">{$_t->name}</option>\n"; } ?> </select> </td></tr> <tr><td colspan='<?php echo $CP; ?> '> <b><?php echo $lng->getTrn('common/gate'); ?> </b> <input type="text" name="gate" onChange='numError(this);' value="<?php echo $m->gate ? $m->gate / 1000 : 0; ?> " size="4" maxlength="4" <?php echo $DIS; ?> >k </td></tr> <tr><td colspan='<?php echo $CP; ?> '> <b><?php echo $lng->getTrn('matches/report/fans'); ?> </b> <input type="text" name="fans" onChange='numError(this);' value="<?php echo $m->fans; ?> " size="7" maxlength="12" <?php echo $DIS; ?> > </td></tr> <?php if (!$settings['hide_ES_extensions']) { ?> <tr><td colspan='<?php echo $CP; ?> '> <b>E</b>xtra player <b>S</b>tats (ES) <a href="index.php?section=matches&type=report&mid=<?php echo $m->match_id; ?> &es_report=1">report page here</a> </td></tr> <?php } ?> <tr><td class="seperator" colspan='<?php echo $CP; ?> '></td></tr> <tr class='commonhead'> <td><b><?php echo $lng->getTrn('common/teams'); ?> </b></td> <td><b><?php echo $lng->getTrn('common/score'); ?> </b></td> <td><b>Δ <?php echo $lng->getTrn('matches/report/treas'); ?> </b></td> <td><b><?php echo $lng->getTrn('matches/report/ff'); ?> </b></td> <td><b><?php echo $lng->getTrn('matches/report/smp'); ?> </b></td> <td><b><?php echo $lng->getTrn('matches/report/tcas'); ?> </b></td> <td><b><?php echo $lng->getTrn('matches/report/fame'); ?> </b></td> <td><b><?php echo $lng->getTrn('matches/report/tv'); ?> </b></td> </tr> <tr><td class='seperator' colspan='<?php echo $CP; ?> '></td></tr> <?php foreach (array(1, 2) as $N) { echo "<tr>\n"; echo "<td>" . ${"teamUrl{$N}"} . "</td>\n"; echo "<td><input type='text' onChange='numError(this);' name='result{$N}' value='" . (int) $m->{"team{$N}_score"} . "' size='1' maxlength='2' {$DIS}></td>\n"; echo "<td><input type='text' onChange='numErrorAllowNegative(this);' name='inc{$N}' value='" . (int) $m->{"income{$N}"} / 1000 . "' size='4' maxlength='4' {$DIS}>k</td>\n"; echo "<td>"; foreach (array('1' => 'green', '0' => 'blue', '-1' => 'red') as $Nff => $color) { echo "<input {$DIS} type='radio' name='ff{$N}' value='{$Nff}' " . ($m->{"ffactor{$N}"} == (int) $Nff ? 'CHECKED' : '') . "><font color='{$color}'><b>{$Nff}</b></font>"; } echo "</td>\n"; echo "<td><input type='text' onChange='numError(this);' name='smp{$N}' value='" . $m->{"smp{$N}"} . "' size='1' maxlength='2' {$DIS}>" . $lng->getTrn('matches/report/pts') . "</td>\n"; echo "<td><input type='text' onChange='numError(this);' name='tcas{$N}' value='" . $m->{"tcas{$N}"} . "' size='1' maxlength='2' {$DIS}></td>\n"; echo "<td><input type='text' onChange='numError(this);' name='fame{$N}' value='" . $m->{"fame{$N}"} . "' size='1' maxlength='2' {$DIS}></td>\n"; echo "<td><input type='text' onChange='numError(this);' name='tv{$N}' value='" . ($m->is_played ? $m->{"tv{$N}"} / 1000 : ${"team{$N}"}->value / 1000) . "' size='4' maxlength='10' {$DIS}>k</td>\n"; echo "</tr>\n"; } ?> </table> <?php $playerFields = array_merge($T_MOUT_REL, $T_MOUT_ACH, $T_MOUT_IR, $T_MOUT_INJ); $CPP = count($playerFields); foreach (array(1 => $team1, 2 => $team2) as $id => $t) { ?> <table class='common'> <tr><td class='seperator' colspan='<?php echo $CPP; ?> '></td></tr> <tr class='commonhead'><td colspan='<?php echo $CPP; ?> '> <b><a href="<?php echo urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $t->team_id, false, false); ?> "><?php echo $t->name; ?> </a> <?php echo $lng->getTrn('matches/report/report'); ?> </b> </td></tr> <tr><td class='seperator' colspan='<?php echo $CPP; ?> '></td></tr> <?php echo "<tr>\n"; foreach (array_values($playerFields) as $f) { // We need to translate table headers switch (strtolower(str_replace(' ', '', $f))) { case 'name': $header_text = $lng->getTrn('common/name'); break; case 'mvp': $header_text = $lng->getTrn('matches/report/mvp'); break; case 'cp': $header_text = $lng->getTrn('matches/report/cp'); break; case 'bh': $header_text = $lng->getTrn('matches/report/bh'); break; case 'si': $header_text = $lng->getTrn('matches/report/si'); break; case 'ki': $header_text = $lng->getTrn('matches/report/ki'); break; case 'ir1d1': $header_text = $lng->getTrn('matches/report/ir1') . " D1"; break; case 'ir1d2': $header_text = $lng->getTrn('matches/report/ir1') . " D2"; break; case 'ir2d1': $header_text = $lng->getTrn('matches/report/ir2') . " D1"; break; case 'ir2d2': $header_text = $lng->getTrn('matches/report/ir2') . " D2"; break; case 'ir3d1': $header_text = $lng->getTrn('matches/report/ir3') . " D1"; break; case 'ir3d2': $header_text = $lng->getTrn('matches/report/ir3') . " D2"; break; case 'inj': $header_text = $lng->getTrn('matches/report/inj'); break; case 'ageing1': $header_text = $lng->getTrn('matches/report/ageing1'); break; case 'ageing2': $header_text = $lng->getTrn('matches/report/ageing2'); break; default: $header_text = $f; } echo "<td><i>{$header_text}</i></td>\n"; } echo "</tr>\n"; $NORMSTAT = true; // only normal player statuses foreach ($t->getPlayers() as $p) { if (!self::player_validation($p, $m)) { continue; } // Fetch player data from match $status = $p->getStatus($m->match_id); $mdat = $m->getPlayerEntry($p->player_id); // Print player row if ($p->is_journeyman_used && !$m->is_played) { $bgcolor = COLOR_HTML_JOURNEY_USED; $NORMSTAT = false; } elseif ($p->is_journeyman) { $bgcolor = COLOR_HTML_JOURNEY; $NORMSTAT = false; } elseif ($status == MNG) { $bgcolor = COLOR_HTML_MNG; $NORMSTAT = false; } elseif ($p->mayHaveNewSkill()) { $bgcolor = COLOR_HTML_NEWSKILL; $NORMSTAT = false; } else { $bgcolor = false; } self::_print_player_row($p->player_id, '<a href="index.php?section=objhandler&type=1&obj=1&obj_id=' . $p->player_id . '">' . $p->name . '</a>', $p->nr, $lng->getTrn('position/' . strtolower($lng->FilterPosition($p->position))) . ($status == MNG ? ' [MNG]' : ''), $bgcolor, $mdat, $DIS || $status == MNG); } echo "</table>\n"; echo "<br>\n"; if (!$NORMSTAT) { ?> <table class="text"><tr><td style="width: 100%;"></td><?php if (1) { ?> <td style="background-color: <?php echo COLOR_HTML_MNG; ?> ;"><font color='black'><b> MNG </b></font></td> <td style="background-color: <?php echo COLOR_HTML_JOURNEY; ?> ;"><font color='black'><b> Journeyman </b></font></td> <td style="background-color: <?php echo COLOR_HTML_JOURNEY_USED; ?> ;"><font color='black'><b> Used journeyman </b></font></td> <td style="background-color: <?php echo COLOR_HTML_NEWSKILL; ?> ;"><font color='black'><b> New skill available </b></font></td> <?php } ?> </tr></table><?php } // Add raised zombies global $racesHasNecromancer; if (in_array($t->f_race_id, $racesHasNecromancer)) { echo "<hr style='width:200px;float:left;'><br>\n <b>Raised zombie?:</b> <input type='checkbox' name='t{$id}zombie' value='1' onclick='slideToggleFast(\"t{$id}zombie\");'><br>\n"; echo "<div id='t{$id}zombie' style='display:none;'>\n"; echo "<table class='common'>\n"; self::_print_player_row("t{$id}zombie", 'Raised zombie', '—', 'Zombie', false, array(), $DIS); echo "</table>\n"; echo "</div>\n"; } // Add raised rotters global $racesMayRaiseRotters; if (in_array($t->f_race_id, $racesMayRaiseRotters)) { $maxRotters = 6; # Note there is no real limit for raised rotters. echo "<hr style='width:200px;float:left;'><br>\n <b>Raised rotters?:</b>\n <select name='t{$id}rotterCnt' onChange='var i = this.options[this.selectedIndex].value; var j=1; for (j=1; j<={$maxRotters}; j++) {if (j<=i) {slideDownFast(\"t{$id}rotter\"+j);} else {slideUpFast(\"t{$id}rotter\"+j);}}' >"; foreach (range(0, $maxRotters) as $n) { echo "<option value='{$n}'>{$n}</option>"; } echo "</select>\n"; foreach (range(0, $maxRotters) as $n) { echo "<div id='t{$id}rotter{$n}' style='display:none;'><table class='common'>\n"; self::_print_player_row("t{$id}rotter{$n}", "Raised Rotter #{$n}", '—', 'Rotter', false, array(), $DIS); echo "</table></div>\n"; } } ?> <table style='border-spacing: 0px 10px;'> <tr><td align="left" valign="top"> <b>Star Players</b>: <input type='button' id="addStarsBtn_<?php echo $id; ?> " value="<?php echo $lng->getTrn('common/add'); ?> " onClick="stars = document.getElementById('stars_<?php echo $id; ?> '); addStarMerc(<?php echo $id; ?> , stars.options[stars.selectedIndex].value);" <?php echo $DIS; ?> > <select id="stars_<?php echo $id; ?> " <?php echo $DIS; ?> > <?php foreach ($stars as $s => $d) { echo "<option " . (in_array($t->f_race_id, $d['races']) ? 'style="background-color: ' . COLOR_HTML_READY . ';"' : '') . " value='{$d['id']}'>{$s}</option>\n"; } ?> </select> </td></tr> <tr><td align="left" valign="top"> <b>Mercenaries</b>: <input type='button' id="addMercsBtn_<?php echo $id; ?> " value="<?php echo $lng->getTrn('common/add'); ?> " onClick="addStarMerc(<?php echo "{$id}, " . ID_MERCS; ?> );" <?php echo $DIS; ?> > </td></tr> </table> <table class='common' id='<?php echo "starsmercs_{$id}"; ?> '> </table> <?php } ?> <table class='common'> <tr><td class='seperator' colspan='13'></td></tr> <tr class='commonhead'><td colspan='13'><b><?php echo $lng->getTrn('matches/report/summary'); ?> </b></td></tr> <tr><td colspan='13'><textarea name='summary' rows='10' cols='100' <?php echo $DIS . ">" . $m->getText(); ?> </textarea></td></tr> </table> <br> <center> <input type="submit" name='button' value="<?php echo $lng->getTrn('common/save'); ?> " <?php echo $DIS; ?> > <?php if ($USED_JOURNEYMAN_PRESENT) { echo "<br><br><b>" . $lng->getTrn('matches/report/usedjourney') . "</b>"; } ?> </center> </form> <br><br> <?php /* Now, we call javascript routine(s) to fill out stars and mercs rows, if such entries exist in database. */ $i = 0; // Counter. Used to pass PHP-data to Javascript. foreach (array(1 => $team1->team_id, 2 => $team2->team_id) as $id => $t) { foreach (Star::getStars(STATS_TEAM, $t, STATS_MATCH, $m->match_id) as $s) { echo "<script language='JavaScript' type='text/javascript'>\n"; echo "var mdat{$i} = [];\n"; $mdat = $s->getStats(T_NODE_MATCH, $m->match_id); foreach (array_keys($T_MOUT_ACH) as $f) { echo "mdat{$i}['{$f}'] = " . $mdat[$f] . ";\n"; } echo "existingStarMerc({$id}, {$s->star_id}, mdat{$i});\n"; echo "</script>\n"; $i++; } foreach (Mercenary::getMercsHiredByTeam($t, $m->match_id) as $merc) { echo "<script language='JavaScript' type='text/javascript'>\n"; echo "var mdat{$i} = [];\n"; foreach (array_merge(array_keys($T_MOUT_ACH), array('skills')) as $f) { echo "mdat{$i}['{$f}'] = " . $merc->{$f} . ";\n"; } echo "existingStarMerc({$id}, " . ID_MERCS . ", mdat{$i});\n"; echo "</script>\n"; $i++; } } }