function OnLoadPageData()
 {
     # new data manager
     $manager = new MatchManager($this->GetSettings(), $this->GetDataConnection());
     # get matches
     $i_one_day = 86400;
     $i_start = gmdate('U') - $i_one_day * 1;
     # yesterday
     $i_end = gmdate('U') + $i_one_day * 365;
     # in the next year
     # Check for player type
     $this->player_type = null;
     if (isset($_GET['player'])) {
         $this->player_type = PlayerType::Parse($_GET['player']);
     }
     $a_player_types = is_null($this->player_type) ? null : array($this->player_type);
     if ($this->player_type == PlayerType::JUNIOR_MIXED) {
         $a_player_types[] = PlayerType::GIRLS;
         $a_player_types[] = PlayerType::BOYS;
     }
     $manager->FilterByMatchType(array(MatchType::TOURNAMENT));
     $manager->FilterByPlayerType($a_player_types);
     $manager->FilterByDateStart($i_start);
     $manager->FilterByDateEnd($i_end);
     $manager->ReadMatchSummaries();
     $this->a_matches = $manager->GetItems();
     unset($manager);
 }
 function OnPrePageLoad()
 {
     $title = "Map of stoolball tournaments";
     # Check for player type
     $this->player_type = null;
     if (isset($_GET['player'])) {
         $this->player_type = PlayerType::Parse($_GET['player']);
         $this->player_type_text = PlayerType::Text($this->player_type) . " ";
         if ($this->player_type == PlayerType::JUNIOR_MIXED) {
             $this->player_type_text = "Junior ";
         }
         $title = "Map of " . strtolower($this->player_type_text) . " stoolball tournaments";
     }
     $this->SetPageTitle($title);
     $this->SetPageDescription("See a map of all the " . strtolower($this->player_type_text) . " stoolball tournaments taking place in the next year.");
     $this->LoadClientScript("/scripts/lib/markerclusterer_compiled.js");
     $this->LoadClientScript('/scripts/maps-3.js');
     $this->LoadClientScript("map.js.php?player=" . $this->player_type, true);
 }
 function OnPrePageLoad()
 {
     # Check for player type
     $this->player_type = null;
     if (isset($_GET['player'])) {
         if ($_GET['player'] == "past") {
             $this->player_type = 0;
             $this->player_type_text = "Past ";
         } else {
             $this->player_type = PlayerType::Parse($_GET['player']);
             $this->player_type_text = PlayerType::Text($this->player_type) . " ";
             if ($this->player_type == PlayerType::JUNIOR_MIXED) {
                 $this->player_type_text = "Junior ";
             }
         }
     }
     $this->SetPageTitle("Map of " . strtolower($this->player_type_text) . " stoolball teams");
     $this->SetPageDescription("See a map of all the " . strtolower($this->player_type_text) . "stoolball teams currently playing.");
     $this->LoadClientScript("/scripts/lib/markerclusterer_compiled.js");
     $this->LoadClientScript('/scripts/maps-3.js');
     $this->LoadClientScript("map.js.php?player=" . $this->player_type, true);
 }
 function OnLoadPageData()
 {
     # new data manager
     $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection());
     $team_manager->FilterByActive(true);
     # Check for player type
     $this->player_type = null;
     if (isset($_GET['player'])) {
         if ($_GET['player'] == "past") {
             $this->player_type = 0;
             $team_manager->FilterByActive(false);
         } else {
             $this->player_type = PlayerType::Parse($_GET['player']);
             $a_player_types = is_null($this->player_type) ? null : array($this->player_type);
             if ($this->player_type == PlayerType::JUNIOR_MIXED) {
                 $a_player_types[] = PlayerType::GIRLS;
                 $a_player_types[] = PlayerType::BOYS;
             }
             $team_manager->FilterByPlayerType($a_player_types);
         }
     }
     if (isset($_GET['area']) and $_GET["area"]) {
         $this->administrative_area = preg_replace('/[^a-z]/', "", strtolower($_GET['area']));
         if ($this->administrative_area) {
             $team_manager->FilterByAdministrativeArea(array($this->administrative_area));
         }
     }
     # Get the counties for the filter
     $this->areas = $team_manager->ReadAdministrativeAreas();
     if ($this->administrative_area) {
         # read all teams matching the applied filter
         $team_manager->ReadTeamSummaries();
         $this->teams = $team_manager->GetItems();
     }
     unset($team_manager);
 }
# set up INI options
date_default_timezone_set('Europe/London');
$database = new MySqlConnection($settings->DatabaseHost(), $settings->DatabaseUser(), $settings->DatabasePassword(), $settings->DatabaseName());
$manager = new MatchManager($settings, $database);
# get matches
$i_one_day = 86400;
# from yesterday
$i_start = gmdate('U') - $i_one_day * 1;
# in the next year, or as specified
$days = isset($_GET['days']) ? (int) $_GET['days'] : 365;
$i_end = gmdate('U') + $i_one_day * $days;
# Check for player type
$player_type = null;
$player_types = null;
if (isset($_GET['player'])) {
    $player_type = PlayerType::Parse($_GET['player']);
    if (!is_null($player_type)) {
        $player_types = array($player_type);
        if ($player_type == PlayerType::JUNIOR_MIXED) {
            $player_types[] = PlayerType::GIRLS;
            $player_types[] = PlayerType::BOYS;
        }
        $player_type = PlayerType::Text($player_type) . " ";
    }
}
$manager->FilterByMatchType(array(MatchType::TOURNAMENT));
$manager->FilterByPlayerType($player_types);
$manager->SortBy("date_changed DESC");
$manager->FilterByDateStart($i_start);
$manager->FilterByDateEnd($i_end);
$manager->ReadMatchSummaries();