function OnPreRender() { /* @var $match Match */ /* @var $o_home Team */ /* @var $o_away Team */ $match = $this->match; $player_type = PlayerType::Text($match->GetPlayerType()); # Show time and place $date = new XhtmlElement('p', 'When: ' . $match->GetStartTimeFormatted()); $date->AddAttribute("property", "schema:startDate"); $date->AddAttribute("datatype", "xsd:date"); $date->AddAttribute("content", Date::Microformat($match->GetStartTime())); $this->AddControl($date); # If we know the time and place, show when the sun sets # TODO: assumes UK if ($match->GetGround() instanceof Ground and $match->GetGround()->GetAddress()->GetLatitude() and $match->GetGround()->GetAddress()->GetLongitude()) { $date->AddControl(' <span class="sunset">sunset ' . Date::Time(date_sunset($match->GetStartTime(), SUNFUNCS_RET_TIMESTAMP, $match->GetGround()->GetAddress()->GetLatitude(), $match->GetGround()->GetAddress()->GetLongitude())) . '</span>'); } $ground = $match->GetGround(); if (is_object($ground)) { $ground_link = new XhtmlElement('a', $ground->GetNameAndTown()); $ground_link->AddAttribute('href', $ground->GetNavigateUrl()); $ground_link->SetCssClass('location'); # hCalendar $ground_link->AddAttribute("typeof", "schema:Place"); $ground_link->AddAttribute("about", $ground->GetLinkedDataUri()); $ground_link->AddAttribute("rel", "schema:url"); $ground_link->AddAttribute("property", "schema:name"); $ground_control = new XhtmlElement('p', 'Where: '); $ground_control->AddAttribute("rel", "schema:location"); $ground_control->AddControl($ground_link); $this->AddControl($ground_control); } # Format if ($match->GetIsOversKnown()) { $this->AddControl(new XhtmlElement("p", "Matches are " . $match->GetOvers() . " overs.")); } # Add teams $a_teams = $match->GetAwayTeams(); if (!is_array($a_teams)) { $a_teams = array(); } if (!is_null($match->GetHomeTeam())) { array_unshift($a_teams, $match->GetHomeTeam()); } # shouldn't be home teams any more, but doesn't hurt! $how_many_teams = count($a_teams); $qualification = $match->GetQualificationType(); if ($qualification === MatchQualification::OPEN_TOURNAMENT) { $qualification = "Any " . strtolower($player_type) . " team may enter this tournament. "; } else { if ($qualification === MatchQualification::CLOSED_TOURNAMENT) { $qualification = "Only invited or qualifying teams may enter this tournament. "; } else { $qualification = ""; } } $show_spaces_left = ($match->GetMaximumTeamsInTournament() and gmdate('U') < $match->GetStartTime() and $match->GetQualificationType() !== MatchQualification::CLOSED_TOURNAMENT); if ($match->GetIsMaximumPlayersPerTeamKnown() or $show_spaces_left or $how_many_teams or $qualification) { $this->AddControl(new XhtmlElement('h2', 'Teams')); } $who_can_play = ""; if ($match->GetIsMaximumPlayersPerTeamKnown()) { $who_can_play = Html::Encode($match->GetMaximumPlayersPerTeam() . " players per team. "); } $who_can_play .= Html::Encode($qualification); if ($show_spaces_left) { $who_can_play .= '<strong class="spaces-left">' . $match->GetSpacesLeftInTournament() . " spaces left.</strong>"; } if ($who_can_play) { $this->AddControl("<p>" . trim($who_can_play) . "</p>"); } if ($how_many_teams) { $teams = new TeamListControl($a_teams); $this->AddControl('<div rel="schema:performers">' . $teams . '</div>'); } # Add matches $a_matches = $match->GetMatchesInTournament(); if (is_array($a_matches) && count($a_matches)) { $o_hmatches = new XhtmlElement('h2', 'Matches'); $matches = new MatchListControl($a_matches); $matches->AddAttribute("rel", "schema:subEvents"); $this->AddControl($o_hmatches); $this->AddControl($matches); } # Add notes if ($match->GetNotes() or $match->Seasons()->GetCount() > 0) { $this->AddControl(new XhtmlElement('h2', 'Notes')); } if ($match->GetNotes()) { $s_notes = XhtmlMarkup::ApplyCharacterEntities($match->GetNotes()); require_once 'email/email-address-protector.class.php'; $protector = new EmailAddressProtector($this->settings); $s_notes = $protector->ApplyEmailProtection($s_notes, AuthenticationManager::GetUser()->IsSignedIn()); $s_notes = XhtmlMarkup::ApplyHeadings($s_notes); $s_notes = XhtmlMarkup::ApplyParagraphs($s_notes); $s_notes = XhtmlMarkup::ApplyLists($s_notes); $s_notes = XhtmlMarkup::ApplySimpleTags($s_notes); $s_notes = XhtmlMarkup::ApplyLinks($s_notes); if (strpos($s_notes, '<p>') > -1) { $this->AddControl($s_notes); } else { $this->AddControl(new XhtmlElement('p', $s_notes)); } } # Show details of the seasons if ($match->Seasons()->GetCount() == 1) { $season = $match->Seasons()->GetFirst(); $season_name = new XhtmlAnchor($season->GetCompetitionName(), $season->GetNavigateUrl()); $b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0); $this->AddControl(new XhtmlElement('p', 'This tournament is listed in ' . ($b_the ? 'the ' : '') . $season_name->__toString() . '.')); } elseif ($match->Seasons()->GetCount() > 1) { $this->AddControl(new XhtmlElement('p', 'This tournament is listed in the following seasons: ')); $season_list = new XhtmlElement('ul'); $this->AddControl($season_list); $seasons = $match->Seasons()->GetItems(); $total_seasons = count($seasons); for ($i = 0; $i < $total_seasons; $i++) { $season = $seasons[$i]; /* @var $season Season */ $season_name = new XhtmlAnchor($season->GetCompetitionName(), $season->GetNavigateUrl()); $li = new XhtmlElement('li', $season_name); if ($i < $total_seasons - 2) { $li->AddControl(new XhtmlElement('span', ', ', 'metadata')); } else { if ($i < $total_seasons - 1) { $li->AddControl(new XhtmlElement('span', ' and ', 'metadata')); } } $season_list->AddControl($li); } } }
function OnPageLoad() { require_once 'xhtml/navigation/tabs.class.php'; require_once 'stoolball/match-list-control.class.php'; require_once 'stoolball/season-list-control.class.php'; /* @var $season Season */ $season = $this->competition->GetWorkingSeason(); echo new XhtmlElement('h1', Html::Encode($this->season->GetCompetitionName())); $tabs = array('Summary' => ''); if ($season->MatchTypes()->Contains(MatchType::LEAGUE)) { $tabs['Table'] = $season->GetTableUrl(); } if (count($season->GetTeams())) { $tabs['Map'] = $season->GetMapUrl(); } $tabs['Statistics'] = $season->GetStatisticsUrl(); echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php # Add intro if ($this->competition->GetIntro()) { $intro = htmlentities($this->competition->GetIntro(), ENT_QUOTES, "UTF-8", false); $intro = XhtmlMarkup::ApplyParagraphs($intro); $intro = XhtmlMarkup::ApplyLists($intro); $intro = XhtmlMarkup::ApplySimpleXhtmlTags($intro, false); $intro = XhtmlMarkup::ApplyLinks($intro); echo $intro; } # Add season intro if ($season->GetIntro()) { $intro = htmlentities($season->GetIntro(), ENT_QUOTES, "UTF-8", false); $intro = XhtmlMarkup::ApplyCharacterEntities($intro); $intro = XhtmlMarkup::ApplyParagraphs($intro); $intro = XhtmlMarkup::ApplyLinks($intro); $intro = XhtmlMarkup::ApplyLists($intro); $intro = XhtmlMarkup::ApplySimpleTags($intro); $intro = XhtmlMarkup::ApplyTables($intro); echo $intro; } # Add not active, if relevant if (!$this->competition->GetIsActive()) { echo new XhtmlElement('p', new XhtmlElement('strong', 'This competition isn\'t played any more.')); } # Add matches $a_matches = $season->GetMatches(); $i_matches = count($a_matches); if ($i_matches > 0) { echo new XhtmlElement('h2', 'Matches in ' . htmlentities($season->GetName(), ENT_QUOTES, "UTF-8", false) . ' season'); $o_matches = new MatchListControl($a_matches); if ($season->MatchTypes()->Contains(MatchType::LEAGUE)) { $o_matches->SetMatchTypesToLabel(array(MatchType::FRIENDLY, MatchType::CUP, MatchType::PRACTICE)); } else { if ($season->MatchTypes()->Contains(MatchType::CUP)) { $o_matches->SetMatchTypesToLabel(array(MatchType::FRIENDLY, MatchType::PRACTICE)); } else { $o_matches->SetMatchTypesToLabel(array(MatchType::PRACTICE)); } } echo $o_matches; } # Add teams $a_teams = $season->GetTeams(); if (count($a_teams) > 0) { require_once 'stoolball/team-list-control.class.php'; echo new XhtmlElement('h2', 'Teams playing in ' . htmlentities($season->GetName(), ENT_QUOTES, "UTF-8", false) . ' season'); echo new TeamListControl($a_teams); } # Add results if ($season->GetResults()) { $s_results = htmlentities($season->GetResults(), ENT_QUOTES, "UTF-8", false); $s_results = XhtmlMarkup::ApplyCharacterEntities($s_results); $s_results = XhtmlMarkup::ApplyParagraphs($s_results); $s_results = XhtmlMarkup::ApplyLinks($s_results); $s_results = XhtmlMarkup::ApplyLists($s_results); $s_results = XhtmlMarkup::ApplySimpleTags($s_results); $s_results = XhtmlMarkup::ApplyTables($s_results); echo $s_results; } # Add contact details $s_contact = $this->competition->GetContact(); $s_website = $this->competition->GetWebsiteUrl(); if ($s_contact or $s_website) { echo new XhtmlElement('h2', 'Contact details'); } if ($s_contact) { $s_contact = htmlentities($s_contact, ENT_QUOTES, "UTF-8", false); $s_contact = XhtmlMarkup::ApplyCharacterEntities($s_contact); require_once 'email/email-address-protector.class.php'; $protector = new EmailAddressProtector($this->GetSettings()); $s_contact = $protector->ApplyEmailProtection($s_contact, AuthenticationManager::GetUser()->IsSignedIn()); $s_contact = XhtmlMarkup::ApplyParagraphs($s_contact); $s_contact = XhtmlMarkup::ApplyLists($s_contact); $s_contact = XhtmlMarkup::ApplySimpleXhtmlTags($s_contact, false); $s_contact = XhtmlMarkup::ApplyLinks($s_contact); echo $s_contact; } if ($s_website) { echo new XhtmlAnchor("Visit the " . htmlentities($this->competition->GetName(), ENT_QUOTES, "UTF-8", false) . ' website', $s_website); } # Check for other seasons. Check is >2 becuase current season is there twice - added above if (count($this->competition->GetSeasons()) > 2) { require_once "stoolball/season-list-control.class.php"; echo new XhtmlElement('h2', 'Other seasons in the ' . htmlentities($this->competition->GetName(), ENT_QUOTES, "UTF-8", false), "screen"); $season_list = new SeasonListControl($this->competition->GetSeasons()); $season_list->SetExcludedSeasons(array($this->season)); $season_list->AddCssClass("screen"); echo $season_list; } ?> </div> </div> <?php $this->ShowSocial(); $this->AddSeparator(); # Panel for updates $you_can = new UserEditPanel($this->GetSettings(), 'this season'); $you_can->AddCssClass("with-tabs"); if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_COMPETITIONS)) { $you_can->AddLink('edit this competition', $this->competition->GetEditCompetitionUrl()); $you_can->AddLink('delete this competition', $this->competition->GetDeleteCompetitionUrl()); $you_can->AddLink('edit this season', $this->season->GetEditSeasonUrl()); # Only offer delete option if there's more than one season. Don't want to delete last season because # that leaves an empty competition which won't display. Instead, must delete whole competition with its one remaining season. if (count($this->competition->GetSeasons()) > 1) { $you_can->AddLink('delete this season', $this->season->GetDeleteSeasonUrl()); } } foreach ($this->season->MatchTypes() as $i_type) { if ($i_type != MatchType::PRACTICE and $i_type != MatchType::TOURNAMENT_MATCH) { $you_can->AddLink('add a ' . MatchType::Text($i_type), $this->season->GetNewMatchNavigateUrl($i_type)); } } if (count($this->season->GetMatches())) { # Make sure there's at least one match which is not a tournament or a practice foreach ($this->season->GetMatches() as $o_match) { /* @var $o_match Match */ if ($o_match->GetMatchType() == MatchType::PRACTICE or $o_match->GetMatchType() == MatchType::TOURNAMENT or $o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { continue; } else { $you_can->AddLink('update results', $this->season->GetResultsNavigateUrl()); break; } } $you_can->AddLink('add matches to your calendar', $this->season->GetCalendarNavigateUrl()); } echo $you_can; if ($this->has_player_stats) { require_once 'stoolball/statistics-highlight-table.class.php'; echo new StatisticsHighlightTable($this->best_batting, $this->most_runs, $this->best_bowling, $this->most_wickets, $this->most_catches, $this->season->GetName() . " season"); } }
/** * @return void * @desc Fires before closing the body element of the page */ protected function OnBodyClosing() { # Close open divs if ($this->b_col1_open) { echo '</div></div>'; } if ($this->b_col2_open) { echo '</div>'; } if ($this->i_constraint_type != StoolballPage::ConstrainNone()) { echo '</div>'; } # Close <div id="constraint"> ?> </div> <div id="sidebar"> <?php if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::VIEW_ADMINISTRATION_PAGE)) { $o_menu_link = new XhtmlElement('a', 'Menu'); $o_menu_link->AddAttribute('href', '/yesnosorry/'); echo new XhtmlElement('p', $o_menu_link, "screen"); } # Add WordPress edit page link if relevant if (SiteContext::IsWordPress() and AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::VIEW_WORDPRESS_LOGIN)) { global $post; $b_wordpress_edit_allowed = true; echo '<ul>'; if ($post->post_type == 'page') { if (!current_user_can('edit_page', $post->ID)) { $b_wordpress_edit_allowed = false; } } else { if (!current_user_can('edit_post', $post->ID)) { $b_wordpress_edit_allowed = false; } } if ($b_wordpress_edit_allowed) { echo '<li><a href="' . apply_filters('edit_post_link', get_edit_post_link($post->ID), $post->ID) . '">Edit page</a></li>'; } if (function_exists('wp_register')) { wp_register(); echo '<li>'; wp_loginout(); echo '</li>'; wp_meta(); } echo '</ul>'; } echo '<h2 id="your" class="large">Your stoolball.org.uk</h2>'; $authentication = new AuthenticationControl($this->GetSettings(), AuthenticationManager::GetUser()); $authentication->SetXhtmlId('authControl'); echo $authentication; # Add admin options $this->Render(); # Add next matches $num_matches = count($this->a_next_matches); if ($num_matches) { $next_alt = $num_matches > 1 ? "Next {$num_matches} matches" : 'Next match'; echo '<h2 id="next' . $num_matches . '" class="large"><span></span>' . $next_alt . '</h2>'; $o_match_list = new MatchListControl($this->a_next_matches); $o_match_list->UseMicroformats(false); # Because parse should look at other match lists on page $o_match_list->AddCssClass("large"); echo $o_match_list; echo '<p class="large"><a href="/matches">All matches and tournaments</a></p>'; } $this->Render(); ?> </div> <div id="boardBottom"> <div> <div></div> </div> </div> </div></div></div> <div id="post"></div> <?php if (!SiteContext::IsDevelopment() and !AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::EXCLUDE_FROM_ANALYTICS)) { ?> <script> var _gaq=[['_setAccount','UA-1597472-1'],['_trackPageview'],['_setDomainName','.stoolball.org.uk'],['_trackPageLoadTime']]; (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1; g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js'; s.parentNode.insertBefore(g,s)}(document,'script')); </script> <?php } if ($this->GetHasGoogleMap()) { // Load Google AJAX Search API for geocoding (Google Maps API v3 Geocoding is still rubbish 29 Oct 2009) $s_key = SiteContext::IsDevelopment() ? 'ABQIAAAA1HxejNRwsLuCM4npXmWXVRRQNEa9vqBL8sCMeUxGvuXwQDty9RRFMSpVT9x-PVLTvFTpGlzom0U9kQ' : 'ABQIAAAA1HxejNRwsLuCM4npXmWXVRSqn96GdhD_ATNWxDNgWa3A5EXWHxQrao6MHCS6Es_c2v0t0KQ7iP-FTg'; echo '<script src="https://www.google.com/uds/api?file=uds.js&v=1.0&key=' . $s_key . '"></script>'; // Load Google Maps API v3 echo '<script src="https://maps.google.co.uk/maps/api/js?sensor=false"></script>'; } }