function OnLoadPageData()
 {
     # new data manager
     $manager = new MatchManager($this->GetSettings(), $this->GetDataConnection());
     # Check for month value
     if (isset($_GET['month']) and is_numeric($_GET['month'])) {
         # Make sure it looks real
         $i_day = (int) date('d', $_GET['month']);
         $i_year = (int) date('Y', $_GET['month']);
         $i_month = (int) date('m', $_GET['month']);
         if ($i_year >= 2000 and $i_year <= 2050 and $i_month >= 1 and $i_month <= 12 and $i_day == 1) {
             # Read start date specified by user, which will be with DST applied because users don't think in UTC
             $i_start = $_GET['month'];
             $i_end = mktime(11, 59, 59, $i_month, date('t', $_GET['month']), $i_year);
             # Convert to UTC, as that's how match dates are stored
             $i_end = gmdate('U', $i_end);
             $manager->FilterByDateStart($i_start);
             $manager->FilterByDateEnd($i_end);
         }
     } else {
         # get next few matches
         $i_one_day = 86400;
         $i_start = gmdate('U') - $i_one_day * 1;
         # yesterday
         $manager->FilterByDateStart($i_start);
         $manager->FilterByMaximumResults(50);
     }
     # Check for match type
     $i_match_type = null;
     if (isset($_GET['type']) and is_numeric($_GET['type'])) {
         $i_match_type = (int) $_GET['type'];
         if ($i_match_type < 0 or $i_match_type > 50) {
             $i_match_type = null;
         }
     }
     $a_match_types = is_null($i_match_type) ? null : array($i_match_type);
     $manager->FilterByMatchType($a_match_types);
     # Check for player type
     $i_player_type = null;
     if (isset($_GET['player']) and is_numeric($_GET['player'])) {
         $i_player_type = (int) $_GET['player'];
         if ($i_player_type < 0 or $i_player_type > 50) {
             $i_player_type = null;
         }
     }
     $a_player_types = is_null($i_player_type) ? null : array($i_player_type);
     $manager->FilterByPlayerType($a_player_types);
     $manager->ReadMatchSummaries();
     $this->a_matches = $manager->GetItems();
     $this->a_months = $manager->ReadMatchMonths();
     # tidy up
     unset($manager);
 }
 function OnLoadPageData()
 {
     require_once 'stoolball/competition-manager.class.php';
     $comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection());
     $comp_manager->ReadCompetitionsInCategories(array(17, 33, 45, 61, 62, 72, 73));
     $competitions = $comp_manager->GetItems();
     unset($comp_manager);
     $season_ids = array();
     foreach ($competitions as $competition) {
         /*@var $competition Competition */
         $season = $competition->GetLatestSeason();
         $season_ids[] = $season->GetId();
     }
     # Fixtures
     require_once 'stoolball/match-manager.class.php';
     $match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection());
     $match_manager->FilterByMaximumResults(5);
     $match_manager->FilterByDateStart(gmdate('U'));
     $match_manager->ReadBySeasonId($season_ids);
     $this->matches = $match_manager->GetItems();
     unset($match_manager);
     # Get stats highlights
     require_once 'stoolball/statistics/statistics-manager.class.php';
     $statistics_manager = new StatisticsManager($this->GetSettings(), $this->GetDataConnection());
     $statistics_manager->FilterBySeason($season_ids);
     $statistics_manager->FilterMaxResults(1);
     $this->best_batting = $statistics_manager->ReadBestBattingPerformance();
     $this->best_bowling = $statistics_manager->ReadBestBowlingPerformance();
     $this->most_runs = $statistics_manager->ReadBestPlayerAggregate("runs_scored");
     $this->most_wickets = $statistics_manager->ReadBestPlayerAggregate("wickets");
     $this->most_catches = $statistics_manager->ReadBestPlayerAggregate("catches");
     # See what stats we've got available
     $best_batting_count = count($this->best_batting);
     $best_bowling_count = count($this->best_bowling);
     $best_batters = count($this->most_runs);
     $best_bowlers = count($this->most_wickets);
     $best_catchers = count($this->most_catches);
     $this->has_player_stats = ($best_batting_count or $best_batters or $best_bowling_count or $best_bowlers or $best_catchers);
     unset($statistics_manager);
 }