function OnLoadPageData()
 {
     # Require an API key to include personal contact details to avoid spam bots picking them up
     $api_keys = $this->GetSettings()->GetApiKeys();
     $valid_key = false;
     if (isset($_GET['key']) and in_array($_GET['key'], $api_keys)) {
         $valid_key = true;
     }
     $data = array();
     $data[] = array("Match id", "Title", "Start time", "Latitude", "Longitude", "Website", "Description");
     require_once 'stoolball/match-manager.class.php';
     require_once "search/match-search-adapter.class.php";
     $match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection());
     $match_manager->FilterByDateStart(gmdate("U"));
     $match_manager->ReadByMatchId();
     while ($match_manager->MoveNext()) {
         $match = $match_manager->GetItem();
         $adapter = new MatchSearchAdapter($match);
         /* @var $match Match */
         # Add this match to the data array
         $data[] = array($match->GetId(), $match->GetTitle(), $match->GetStartTime(), $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetLatitude() : "", $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetLongitude() : "", "https://" . $this->GetSettings()->GetDomain() . $match->GetNavigateUrl(), $adapter->GetSearchDescription());
     }
     unset($match_manager);
     require_once "data/csv.class.php";
     CSV::PublishData($data);
     # Test code only. Comment out CSV publish line above to enable display as a table.
     require_once "xhtml/tables/xhtml-table.class.php";
     $table = new XhtmlTable();
     $table->BindArray($data, false, false);
     echo $table;
 }
 function OnLoadPageData()
 {
     # Require an API key to include personal contact details to avoid spam bots picking them up
     $api_keys = $this->GetSettings()->GetApiKeys();
     $valid_key = false;
     if (isset($_GET['key']) and in_array($_GET['key'], $api_keys)) {
         $valid_key = true;
     }
     $data = array();
     $data[] = array("Club/ facility name", "Address 1", "Address 2", "Address 3", "Address 4", "Address 5", "City", "Postcode", "Country", "Tel", "Email", "Website", "Activities", "Opening times");
     require_once 'stoolball/team-manager.class.php';
     $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection());
     $team_manager->FilterByActive(true);
     $team_manager->FilterByTeamType(array(Team::REGULAR));
     $team_manager->ReadById();
     while ($team_manager->MoveNext()) {
         /* @var $team Team */
         $team = $team_manager->GetItem();
         # NHS choices can only import records with a postcode
         if (!$team->GetGround()->GetAddress()->GetPostcode()) {
             continue;
         }
         $address = array();
         if ($team->GetGround()->GetAddress()->GetSaon()) {
             $address[] = $team->GetGround()->GetAddress()->GetSaon();
         }
         if ($team->GetGround()->GetAddress()->GetPaon()) {
             $address[] = $team->GetGround()->GetAddress()->GetPaon();
         }
         if ($team->GetGround()->GetAddress()->GetStreetDescriptor()) {
             $address[] = $team->GetGround()->GetAddress()->GetStreetDescriptor();
         }
         if ($team->GetGround()->GetAddress()->GetLocality()) {
             $address[] = $team->GetGround()->GetAddress()->GetLocality();
         }
         if ($team->GetGround()->GetAddress()->GetAdministrativeArea()) {
             $address[] = $team->GetGround()->GetAddress()->GetAdministrativeArea();
         }
         $data[] = array($team->GetName() . " Stoolball Club", isset($address[0]) ? $address[0] : "", isset($address[1]) ? $address[1] : "", isset($address[2]) ? $address[2] : "", isset($address[3]) ? $address[3] : "", isset($address[4]) ? $address[4] : "", $team->GetGround()->GetAddress()->GetTown(), $team->GetGround()->GetAddress()->GetPostcode(), "England", $valid_key ? $team->GetContactPhone() : "", $valid_key ? $team->GetContactEmail() : "", $team->GetWebsiteUrl() ? $team->GetWebsiteUrl() : "https://" . $this->GetSettings()->GetDomain() . $team->GetNavigateUrl(), "stoolball", preg_replace('/\\[[^]]+\\]/', "", $team->GetPlayingTimes()));
     }
     unset($team_manager);
     require_once "data/csv.class.php";
     CSV::PublishData($data);
     # Test code only. Comment out CSV publish line above to enable display as a table.
     require_once "xhtml/tables/xhtml-table.class.php";
     $table = new XhtmlTable();
     $table->BindArray($data, false, false);
     echo $table;
 }
 function OnLoadPageData()
 {
     # Require an API key to include personal contact details to avoid spam bots picking them up
     $api_keys = $this->GetSettings()->GetApiKeys();
     $valid_key = false;
     if (isset($_GET['key']) and in_array($_GET['key'], $api_keys)) {
         $valid_key = true;
     }
     $data = array();
     $data[] = array("Team id", "Team name", "Player type", "Home ground name", "Street name", "Locality", "Town", "Administrative area", "Postcode", "Country", "Latitude", "Longitude", "Contact phone", "Contact email", "Website", "Description");
     require_once 'stoolball/team-manager.class.php';
     $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection());
     $team_manager->FilterByActive(true);
     $team_manager->FilterByTeamType(array(Team::REGULAR));
     $team_manager->ReadById();
     while ($team_manager->MoveNext()) {
         $team = $team_manager->GetItem();
         /* @var $team Team */
         # Spogo can only import records with contact details
         if (!$team->GetContactPhone() and !$team->GetContactEmail()) {
             continue;
         }
         # Combine free text fields into a description field
         $description = $team->GetIntro();
         if ($description) {
             $description .= "\n\n";
         }
         if ($team->GetPlayingTimes()) {
             $description .= $team->GetPlayingTimes() . "\n\n";
         }
         if ($team->GetCost()) {
             $description .= $team->GetCost();
         }
         # Add this team to the data array
         $data[] = array($team->GetId(), $team->GetName() . " Stoolball Club", PlayerType::Text($team->GetPlayerType()), $team->GetGround()->GetAddress()->GetPaon(), $team->GetGround()->GetAddress()->GetStreetDescriptor(), $team->GetGround()->GetAddress()->GetLocality(), $team->GetGround()->GetAddress()->GetTown(), $team->GetGround()->GetAddress()->GetAdministrativeArea(), $team->GetGround()->GetAddress()->GetPostcode(), "England", $team->GetGround()->GetAddress()->GetLatitude(), $team->GetGround()->GetAddress()->GetLongitude(), $valid_key ? $team->GetContactPhone() : "", $valid_key ? $team->GetContactEmail() : "", $team->GetWebsiteUrl() ? $team->GetWebsiteUrl() : "https://" . $this->GetSettings()->GetDomain() . $team->GetNavigateUrl(), trim(html_entity_decode(strip_tags($description), ENT_QUOTES)));
     }
     unset($team_manager);
     require_once "data/csv.class.php";
     CSV::PublishData($data);
     # Test code only. Comment out CSV publish line above to enable display as a table.
     require_once "xhtml/tables/xhtml-table.class.php";
     $table = new XhtmlTable();
     $table->BindArray($data, false, false);
     echo $table;
 }