function OnLoadPageData() { /* @var Team $team */ # check parameter if (!isset($_GET['item']) or !is_numeric($_GET['item'])) { $this->Redirect(); } # get team $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); $team_manager->FilterByTeamType(array()); $team_manager->ReadById(array($_GET['item'])); $this->team = $team_manager->GetFirst(); unset($team_manager); # must have found a team if (!$this->team instanceof Team) { $this->Redirect('/teams/'); } # get match stats require_once 'stoolball/statistics/statistics-manager.class.php'; $statistics_manager = new StatisticsManager($this->GetSettings(), $this->GetDataConnection()); $statistics_manager->FilterByTeam(array($this->team->GetId())); $statistics_manager->ReadMatchStatistics(); $this->stats = $statistics_manager->GetItems(); # Get some stats on the best players $this->statistics_query = "?team=" . $this->team->GetId(); if ($this->season) { # use midpoint of season to get season dates for filter $start_year = substr($this->season, 0, 4); $end_year = strlen($this->season) == 7 ? $start_year + 1 : $start_year; if ($start_year == $end_year) { $season_dates = Season::SeasonDates(mktime(0, 0, 0, 7, 1, $start_year)); } else { $season_dates = Season::SeasonDates(mktime(0, 0, 0, 12, 31, $start_year)); } $statistics_manager->FilterAfterDate($season_dates[0]); $statistics_manager->FilterBeforeDate($season_dates[1]); $this->statistics_query .= "&from=" . $season_dates[0] . "&to=" . $season_dates[1]; } $statistics_manager->FilterMaxResults(10); $this->most_runs = $statistics_manager->ReadBestPlayerAggregate("runs_scored"); $this->most_wickets = $statistics_manager->ReadBestPlayerAggregate("wickets"); $this->most_catches = $statistics_manager->ReadBestPlayerAggregate("catches"); $this->most_run_outs = $statistics_manager->ReadBestPlayerAggregate("run_outs"); $this->most_player_of_match = $statistics_manager->ReadBestPlayerAggregate("player_of_match"); unset($statistics_manager); }