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 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); }
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(); $matches = $manager->GetItems(); unset($manager); $database->Disconnect(); $title = 'Stoolball tournaments'; if ($player_type) { $title = $player_type . strtolower($title); } $feedData = array('title' => $title, 'description' => "New or updated " . strtolower($player_type) . "stoolball tournaments on the Stoolball England website", 'link' => 'http://www.stoolball.org.uk/tournaments', 'charset' => 'utf-8', "language" => "en-GB", "author" => "Stoolball England", "image" => "https://www.stoolball.org.uk/images/feed-ident.gif", 'entries' => array()); # Option to tweet new entries to a user, for use with www.iftt.com $tweet = isset($_GET['format']) && $_GET['format'] === "tweet"; foreach ($matches as $tournament) { if ($tweet) { $days = $days != 365; $prefix = $days ? PlayerType::Text($tournament->GetPlayerType()) : "New " . strtolower(PlayerType::Text($tournament->GetPlayerType()));
public function OnLoadPageData() { $i_one_day = 86400; $i_start = gmdate('U') - $i_one_day * 1; # yesterday $i_end = gmdate('U') + $i_one_day * 365; # this year # Check for player type $player_type = null; if (isset($_GET['player']) and is_numeric($_GET['player'])) { $player_type = (int) $_GET['player']; } $a_player_types = is_null($player_type) ? null : array($player_type); if ($player_type == PlayerType::JUNIOR_MIXED) { $a_player_types[] = PlayerType::GIRLS; $a_player_types[] = PlayerType::BOYS; } $manager = new MatchManager($this->GetSettings(), $this->GetDataConnection()); $manager->FilterByMatchType(array(MatchType::TOURNAMENT)); $manager->FilterByPlayerType($a_player_types); $manager->FilterByDateStart($i_start); $manager->FilterByDateEnd($i_end); $manager->ReadMatchSummaries(); $tournaments = $manager->GetItems(); unset($manager); ?> $(function() { // Make the placeholder big enough for a map var mapControl = document.getElementById("map"); mapControl.style.width = '100%'; mapControl.style.height = '400px'; // Create the map var myLatlng = new google.maps.LatLng(51.07064141136184, -0.31114161014556885); // Horsham var myOptions = { zoom : $(window).width() > 400 ? 9 : 8, center : myLatlng, mapTypeId : google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(mapControl, myOptions); var markers = []; var info; <?php # There might be multiple tournaments at one ground. Rearrange tournaments so that they're indexed by ground. $grounds = array(); foreach ($tournaments as $tournament) { /* @var $tournament Match */ $ground_id = $tournament->GetGroundId(); if (!array_key_exists($ground_id, $grounds)) { $grounds[$ground_id] = array(); } $grounds[$ground_id][] = $tournament; } foreach ($grounds as $tournaments) { /* @var $ground Ground */ $ground = $tournaments[0]->GetGround(); if (!is_object($ground) or !$ground->GetAddress()->GetLatitude() or !$ground->GetAddress()->GetLongitude()) { continue; } $content = "'<div class=\"map-info\">' +\n\t'<h2>" . str_replace("'", "\\'", $ground->GetNameAndTown()) . "</h2>"; foreach ($tournaments as $tournament) { /* @var $tournament Match */ $title = $tournament->GetTitle() . ", " . Date::BritishDate($tournament->GetStartTime(), false, true, false); $content .= '<p><a href="' . $tournament->GetNavigateUrl() . '">' . str_replace("'", "\\'", $title) . '</a></p>'; } $content .= "</div>'"; # And marker and click event to trigger info window. Wrap info window in function to isolate marker, otherwise the last marker # is always used for the position of the info window. echo "var marker = new google.maps.Marker({\n\t\t\tposition : new google.maps.LatLng(" . $ground->GetAddress()->GetLatitude() . "," . $ground->GetAddress()->GetLongitude() . "),\n\t\t\tshadow: Stoolball.Maps.WicketShadow(),\n\t\t\ticon: Stoolball.Maps.WicketIcon(),\n\t\t\ttitle : '" . str_replace("'", "\\'", $ground->GetNameAndTown()) . "'\n\t\t });\n\t\t markers.push(marker);\n\n\t\t (function(marker){\n\t\t\t google.maps.event.addListener(marker, 'click', function()\n\t\t\t {\n\t\t\t \tvar content = {$content};\n\t\t\t \tif (!info) info = new google.maps.InfoWindow();\n\t\t\t \tinfo.setContent(content);\n\t\t\t \tinfo.open(map, marker);\n\t\t\t });\n\t\t })(marker);\n\t\t "; } ?> var style = [{ url: '/images/features/map-markers.gif', height: 67, width: 31, textColor: '#ffffff', textSize: 10 }]; var clusterer = new MarkerClusterer(map, markers, { 'gridSize': 30, styles: style }); }); <?php exit; }
function OnLoadPageData() { /* @var $o_match Match */ /* @var $o_team Team */ # new data manager $match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection()); # create repeater control, and save any posted data $this->repeater = new DataEditRepeater($this, 'CreateEditControl'); $this->repeater->SetCssClass('matchResults'); $this->repeater->SetPersistedParameters(array('team', 'season', "tournament")); $this->repeater->SetButtonText('Save all results'); $this->repeater->SetShowButtonsAtTop(true); if ($this->IsPostback() and !$this->IsRefresh() and $this->IsValid()) { require_once 'forums/topic-manager.class.php'; require_once 'forums/review-item.class.php'; require_once 'forums/subscription-manager.class.php'; $topic_manager = new TopicManager($this->GetSettings(), $this->GetDataConnection()); foreach ($this->repeater->GetDataObjects() as $o_current_match) { /* @var $o_current_match Match */ $match_manager->SaveResult($o_current_match); $match_manager->ExpandMatchUrl($o_current_match); $match_manager->NotifyMatchModerator($o_current_match->GetId()); if (trim($o_current_match->GetNewComment())) { $item_to_comment_on = new ReviewItem($this->GetSettings()); $item_to_comment_on->SetType(ContentType::STOOLBALL_MATCH); $item_to_comment_on->SetId($o_current_match->GetId()); $item_to_comment_on->SetNavigateUrl("https://" . $this->GetSettings()->GetDomain() . $o_current_match->GetNavigateUrl()); $message = $topic_manager->SaveComment($item_to_comment_on, $o_current_match->GetNewComment()); # send subscription emails - new object each time to reset list of who's already recieved an email $subs_manager = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection()); $subs_manager->SendCommentsSubscriptions($item_to_comment_on, $message); unset($subs_manager); } } $this->b_saved = true; } # get matches if (!is_null($this->i_team_id)) { $a_season_times = Season::SeasonDates(); $match_manager->FilterByTeam(array($this->i_team_id)); $match_manager->FilterByDateStart($a_season_times[0]); $match_manager->FilterByDateEnd($a_season_times[1]); $match_manager->ReadMatchSummaries(); } else { if (!is_null($this->i_season_id)) { $match_manager->ReadBySeasonId(array($this->i_season_id), true); } else { if (!is_null($this->tournament_id)) { $match_manager->FilterByTournament($this->tournament_id); $this->a_matches = $match_manager->ReadMatchSummaries(); } } } $this->a_matches = $match_manager->GetItems(); # Make sure we have some matches if (count($this->a_matches)) { # If it's matches for a team, get the team if (!is_null($this->i_team_id)) { # Should only need to look at the first match, because the team must be a # part of that match in order for the match to be in this list $o_match =& $this->a_matches[0]; $o_team = $o_match->GetHomeTeam(); if ($o_team instanceof Team and $o_team->GetId() == $this->i_team_id) { $this->team = $o_team; } else { foreach ($o_match->GetAwayTeams() as $o_team) { if ($o_team->GetId() == $this->i_team_id) { $this->team = $o_team; break; } } } if (!is_object($this->team)) { $this->Redirect(); } # Now that we have short URL data, if data has just been saved for team, redirect back to team if ($this->b_saved) { $this->Redirect($this->team->GetNavigateUrl()); } } else { if (!is_null($this->i_season_id)) { # get details of the season require_once 'stoolball/competition-manager.class.php'; $o_comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $o_comp_manager->ReadById(null, array($this->i_season_id)); $o_competition = $o_comp_manager->GetFirst(); unset($o_comp_manager); if ($o_competition instanceof Competition) { $this->season = $o_competition->GetWorkingSeason(); } if (!$this->season instanceof Season) { $this->Redirect(); } # Now that we have short URL data, if data has just been saved for season, redirect back to season if ($this->b_saved) { $this->Redirect($this->season->GetNavigateUrl()); } } else { if (!is_null($this->tournament_id)) { $match_manager->ReadByMatchId(array($this->tournament_id)); $this->tournament = $match_manager->GetFirst(); if (!is_null($this->tournament)) { # If the tournament has just been saved, now we have its URL so redirect to the thanks page if ($this->b_saved) { $this->Redirect($this->tournament->GetNavigateUrl()); } } } } } } else { $this->Redirect(); } unset($match_manager); }