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; }
function OnLoadPageData() { # new data managers $o_comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $o_team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); # get comps $o_comp_manager->SetExcludeInactive(true); $o_comp_manager->ReadAllSummaries(); $this->a_comps = $o_comp_manager->GetItems(); # get teams $o_team_manager->FilterByActive(true); foreach ($this->a_comps as $o_comp) { /* @var $o_comp Competition */ $a_seasons = array($o_comp->GetLatestSeason()->GetId()); $o_team_manager->ReadBySeasonId($a_seasons); while ($o_team_manager->MoveNext()) { $o_comp->GetLatestSeason()->AddTeam($o_team_manager->GetItem()); } $o_team_manager->Clear(); } # tidy up unset($o_comp_manager); unset($o_team_manager); }