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", "Match type", "Overs", "Player type", "Players per team", "Latitude", "Longitude", "SAON", "PAON", "Town", "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(), Date::Microformat($match->GetStartTime()), MatchType::Text($match->GetMatchType()), $match->GetOvers(), PlayerType::Text($match->GetPlayerType()), $match->GetMaximumPlayersPerTeam(), $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetLatitude() : "", $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetLongitude() : "", $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetSaon() : "", $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetPaon() : "", $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetTown() : "", "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; }
protected function OnPreRender() { /* @var $match Match */ $b_label_types = count($this->label_types); $i_next_match_day = 0; if ($this->b_microformats) { $this->AddCssClass('vcalendar'); } # hCalendar foreach ($this->matches as $match) { # Create list item for match $li = new XhtmlElement('li'); $i_next_match_day = $this->AddDateClasses($match, $i_next_match_day, $li); $this->AddControl($li); # Add link to match $link = $this->CreateLinkToMatch($match); $li->AddControl($link); # add match type if not default for season if ($b_label_types and in_array($match->GetMatchType(), $this->label_types, true) and strpos($match->GetTitle(), MatchType::Text($match->GetMatchType())) === false) { $li->AddControl(' (' . htmlentities(MatchType::Text($match->GetMatchType()), ENT_QUOTES, "UTF-8", false) . ')'); } $match_detail = new XhtmlElement("p", null, "match-detail"); $li->AddControl($match_detail); # Add match date if ($match->GetStartTime()) { $date = $this->CreateStartDate($match); if ($match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $date->AddCssClass('metadata'); } $match_detail->AddControl($date); } # More tournament info if ($match->GetMatchType() === MatchType::TOURNAMENT) { $fullstop = false; if ($match->GetQualificationType() === MatchQualification::OPEN_TOURNAMENT) { $match_detail->AddControl(". "); $fullstop = true; $match_detail->AddControl("Open. "); } else { if ($match->GetQualificationType() === MatchQualification::CLOSED_TOURNAMENT) { $match_detail->AddControl(". "); $fullstop = true; $match_detail->AddControl("Invited teams only. "); } } if ($match->GetSpacesLeftInTournament() and $match->GetQualificationType() !== MatchQualification::CLOSED_TOURNAMENT) { if (!$fullstop) { $match_detail->AddControl(". "); $fullstop = true; } $match_detail->AddControl('<strong class="spaces-left">' . $match->GetSpacesLeftInTournament() . " spaces.</strong> "); } } # Add meta data if ($this->b_microformats) { $this->AddMetadata($match, $li); } } }
/** * Gets text to use as the description of this match in search results */ public function GetSearchDescription() { $description = ""; # Display match type/season/tournament if ($this->match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $o_tourney = $this->match->GetTournament(); if (is_object($o_tourney)) { # Check for 'the' to get the grammar right $s_title = strtolower($o_tourney->GetTitle()); $the = (strlen($s_title) >= 4 and substr($s_title, 0, 4) == 'the ') ? "" : "the "; $description = "Match in {$the}" . $o_tourney->GetTitle(); if (is_object($this->match->GetGround())) { $description .= " at " . $this->match->GetGround()->GetNameAndTown(); } $description .= "."; } } else { $description = "Stoolball " . MatchType::Text($this->match->GetMatchType()); if (is_object($this->match->GetGround())) { $description .= " at " . $this->match->GetGround()->GetNameAndTown(); } if ($this->match->GetMatchType() != MatchType::TOURNAMENT) { $season_list = ""; if ($this->match->Seasons()->GetCount() == 1) { $season = $this->match->Seasons()->GetFirst(); $b_the = !(stristr($season->GetCompetition()->GetName(), 'the ') === 0); $description .= ' in ' . ($b_the ? 'the ' : '') . $season->GetCompetition()->GetName(); } elseif ($this->match->Seasons()->GetCount() > 1) { $description .= ' in '; $seasons = $this->match->Seasons()->GetItems(); $total_seasons = count($seasons); for ($i = 0; $i < $total_seasons; $i++) { $season = $seasons[$i]; /* @var $season Season */ $description .= $season->GetCompetition()->GetName(); if ($i < $total_seasons - 2) { $description .= ', '; } else { if ($i < $total_seasons - 1) { $description .= ' and '; } } } } $description .= $season_list; } $description .= '.'; } return $description; }
function CreateControls() { $this->AddCssClass('legacy-form'); /* @var $team Team */ /* @var $comp Competition */ $season = $this->GetDataObject(); /* @var $season Season */ require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; require_once 'xhtml/forms/radio-button.class.php'; require_once 'xhtml/forms/checkbox.class.php'; # Show fewer options for a new season than when editing, beacause a new season gets settings copied from last year to save time $b_is_new_season = !(bool) $season->GetId(); # Add competition $comp = $season->GetCompetition(); $competition = new TextBox($this->GetNamingPrefix() . 'competition', $comp->GetId()); $competition->SetMode(TextBoxMode::Hidden()); $this->AddControl($competition); # Make current short URL available, because then it can match the suggested one and be left alone $short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $season->GetShortUrl()); $short_url->SetMode(TextBoxMode::Hidden()); $this->AddControl($short_url); # add years $start_box = new TextBox('start', is_null($season->GetStartYear()) ? Date::Year(gmdate('U')) : $season->GetStartYear(), $this->IsValidSubmit()); $start_box->AddAttribute('maxlength', 4); $start = new FormPart('Year season starts', $start_box); $this->AddControl($start); $summer = new RadioButton('summer', 'when', 'Summer season', 0); $winter = new RadioButton('winter', 'when', 'Winter season', 1); if ($season->GetEndYear() > $season->GetStartYear()) { $winter->SetChecked(true); } else { $summer->SetChecked(true); } $when = new XhtmlElement('div', $summer); $when->AddControl($winter); $when->SetCssClass('formControl'); $when_legend = new XhtmlElement('legend', 'Time of year'); $when_legend->SetCssClass('formLabel'); $when_fs = new XhtmlElement('fieldset', $when_legend); $when_fs->SetCssClass('formPart'); $when_fs->AddControl($when); $this->AddControl($when_fs); # add intro $intro_box = new TextBox('intro', $season->GetIntro(), $this->IsValidSubmit()); $intro_box->SetMode(TextBoxMode::MultiLine()); $intro = new FormPart('Introduction', $intro_box); $this->AddControl($intro); if (!$b_is_new_season) { # add types of matches if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { foreach ($season->MatchTypes()->GetItems() as $i_type) { $this->match_types_editor->DataObjects()->Add(new IdValue($i_type, ucfirst(MatchType::Text($i_type)))); } } $this->AddControl(new FormPart('Match types', $this->match_types_editor)); # add results $result_container = new XhtmlElement('div'); $result_box = new TextBox('results', $season->GetResults(), $this->IsValidSubmit()); $result_box->SetMode(TextBoxMode::MultiLine()); $result_container->AddControl($result_box); $result = new FormPart('Results', $result_container); $result->GetLabel()->AddAttribute('for', $result_box->GetXhtmlId()); $this->AddControl($result); # Add rules table $rules = new XhtmlTable(); $rules->SetCaption('Points for each result'); $header = new XhtmlRow(array('Result', 'Points for home team', 'Points for away team')); $header->SetIsHeader(true); $rules->AddRow($header); foreach ($this->result_types as $result) { /* @var $result MatchResult */ # Shouldn't ever need to assign points to a postponed match if ($result->GetResultType() == MatchResult::POSTPONED) { continue; } # Populate result with points from season rule $season->PossibleResults()->ResetCounter(); while ($season->PossibleResults()->MoveNext()) { if ($season->PossibleResults()->GetItem()->GetResultType() == $result->GetResultType()) { $result->SetHomePoints($season->PossibleResults()->GetItem()->GetHomePoints()); $result->SetAwayPoints($season->PossibleResults()->GetItem()->GetAwayPoints()); break; } } # Create table row $home_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Home', $result->GetHomePoints(), $this->IsValidSubmit()); $away_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Away', $result->GetAwayPoints(), $this->IsValidSubmit()); $home_box->AddAttribute('class', 'pointsBox'); $away_box->AddAttribute('class', 'pointsBox'); $result_row = new XhtmlRow(array(MatchResult::Text($result->GetResultType()), $home_box, $away_box)); $rules->AddRow($result_row); } $result_container->AddControl($rules); # Add points adjustments $this->adjustments_editor->SetTeams($season->GetTeams()); if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $this->adjustments_editor->DataObjects()->SetItems($season->PointsAdjustments()->GetItems()); } $result_container->AddControl($this->adjustments_editor); # Show league table? $table = new CheckBox('showTable', 'Show results table', 1, $season->GetShowTable()); $this->AddControl($table); $this->AddControl(new CheckBox('runsScored', 'Include runs scored', 1, $season->GetShowTableRunsScored())); $this->AddControl(new CheckBox('runsConceded', 'Include runs conceded', 1, $season->GetShowTableRunsConceded())); # add teams if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $teams_in_season = array(); foreach ($season->GetTeams() as $team) { $teams_in_season[] = new TeamInSeason($team, $season, is_object($season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $team->GetId()))); } $this->teams_editor->DataObjects()->SetItems($teams_in_season); } $this->AddControl(new FormPart('Teams', $this->teams_editor)); } }
/** * Get the match types available for filtering, and if match type parameter is in the query string apply the match type filter * @param StatisticsManager $statistics_manager * @return Array containing match types, current match type id, and text for filter description */ public static function SupportMatchTypeFilter(StatisticsManager $statistics_manager) { require_once "stoolball/match-type.enum.php"; $match_types = array(MatchType::CUP, MatchType::FRIENDLY, MatchType::LEAGUE, MatchType::TOURNAMENT_MATCH); $filter_data = array($match_types, null, ""); if (isset($_GET['match-type']) and is_numeric($_GET['match-type'])) { if (in_array($_GET['match-type'], $match_types)) { $statistics_manager->FilterByMatchType(array((int) $_GET['match-type'])); $filter_data[1] = (int) $_GET['match-type']; $filter_data[2] = "in " . MatchType::Text((int) $_GET['match-type']) . "es "; } } return $filter_data; }
function CreateControls() { $match = $this->GetDataObject(); /* @var $match Match */ $this->b_user_is_match_owner = ($match->GetAddedBy() instanceof User and AuthenticationManager::GetUser()->GetId() == $match->GetAddedBy()->GetId()); $this->AddCssClass('legacy-form'); if ($this->b_user_is_match_admin) { # Add match title editing $b_new = !$match->GetId(); $title = new TextBox('title', $b_new ? '' : $match->GetTitle()); $title->SetMaxLength(100); $this->AddControl(new FormPart('Match title', $title)); $o_generate = new CheckBox('defaultTitle', 'Use default title', 1); if ($b_new) { $o_generate->SetChecked(true); } else { $o_generate->SetChecked(!$match->GetUseCustomTitle()); } $this->AddControl($o_generate); # Add match type if ($match->GetMatchType() != MatchType::TOURNAMENT_MATCH) { $o_type_list = new XhtmlSelect('type'); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::LEAGUE), MatchType::LEAGUE)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::PRACTICE), MatchType::PRACTICE)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::FRIENDLY), MatchType::FRIENDLY)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::CUP), MatchType::CUP)); $o_type_list->SelectOption($match->GetMatchType()); $this->AddControl(new FormPart('Type of match', $o_type_list)); } } if ($this->b_user_is_match_owner or $this->b_user_is_match_admin) { $this->EnsureAggregatedEditors(); $this->fixture_editor->SetDataObject($match); $this->AddControl($this->fixture_editor); } if ($this->b_user_is_match_admin) { # add season if (!$this->IsPostback()) { $this->season_editor->DataObjects()->SetItems($match->Seasons()->GetItems()); } $this->AddControl($this->season_editor); # Hidden data on teams, for use by match-fixture-edit-control.js to re-sort teams when the season is changed # Format is 1,2,3,4,5;2,3,4,5,6 # where ; separates each team, and for each team the first number identifies the team and subsequent numbers identify the season /* @var $o_team Team */ /* @var $o_comp Competition */ $s_team_season = ''; # Build a list of all seasons, so that the "Not known yet" option can be added to all seasons $all_seasons = array(); foreach ($this->fixture_editor->GetTeams() as $group) { foreach ($group as $o_team) { if (!$o_team instanceof Team) { continue; } # Add team id if ($s_team_season) { $s_team_season .= ';'; } $s_team_season .= $o_team->GetId(); # add team seasons foreach ($o_team->Seasons() as $team_in_season) { $s_team_season .= ',' . $team_in_season->GetSeasonId(); $all_seasons[] = $team_in_season->GetSeasonId(); } } } # Add the "Don't know yet" option with all seasons $all_seasons = array_unique($all_seasons); $s_team_season = "0," . implode(",", $all_seasons) . ";{$s_team_season}"; # Put it in a hidden field accessible to JavaScript. $o_ts = new TextBox($this->GetNamingPrefix() . 'TeamSeason', $s_team_season); $o_ts->SetMode(TextBoxMode::Hidden()); $this->AddControl($o_ts); } $got_home_team = !is_null($match->GetHomeTeam()); $got_away_team = !is_null($match->GetAwayTeam()); $b_got_teams = ($got_home_team and $got_away_team); $b_future = ($match->GetId() and $match->GetStartTime() > gmdate('U')); // Move CSS class to div element $match_outer_1 = new XhtmlElement('div'); $match_outer_1->SetCssClass('matchResultEdit panel'); $match_outer_2 = new XhtmlElement('div'); $match_box = new XhtmlElement('div'); $this->AddControl($match_outer_1); $match_outer_1->AddControl($match_outer_2); $match_outer_2->AddControl($match_box); $o_title_inner_1 = new XhtmlElement('span', "Result of this match"); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $o_heading = new XhtmlElement('h2', $o_title_inner_3); $match_box->AddControl($o_heading); # Who batted first? if (!$b_future) { $match_box->AddControl('<h3>If the match went ahead:</h3>'); $toss = $this->SelectOneOfTwoTeams($this->GetNamingPrefix() . 'Toss', $match, $match->Result()->GetTossWonBy() === TeamRole::Home(), $match->Result()->GetTossWonBy() === TeamRole::Away()); $toss_part = new FormPart('Who won the toss?', $toss); $match_box->AddControl($toss_part); $bat_first = $this->SelectOneOfTwoTeams($this->GetNamingPrefix() . 'BatFirst', $match, $match->Result()->GetHomeBattedFirst() === true, $match->Result()->GetHomeBattedFirst() === false); $bat_part = new FormPart('Who batted first?', $bat_first); $match_box->AddControl($bat_part); } # Who won? $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result'); if ($b_future) { $o_winner->AddControl(new XhtmlOption('The match will go ahead', '')); } else { # This option means "no change", therefore it has to have the current value for the match result even though that's # a different value from match to match. If it's not there the submitted match doesn't have result info, so when admin # saves fixture it regenerates its title as "Team A v Team B", which doesn't match the existing title so gets saved to db. # Can't be exactly the current value though, because otherwise a cancelled match has two options with the same value, # so re-selecting the option doesn't work. Instead change it to a negative number, which can be converted back when submitted. $o_winner->AddControl(new XhtmlOption('Not applicable – match went ahead', $match->Result()->GetResultType() * -1)); } $result_types = array(MatchResult::HOME_WIN_BY_FORFEIT, MatchResult::AWAY_WIN_BY_FORFEIT, MatchResult::POSTPONED, MatchResult::CANCELLED, MatchResult::ABANDONED); foreach ($result_types as $result_type) { if (!$b_future or MatchResult::PossibleInAdvance($result_type)) { if ($b_got_teams) { $o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $match->GetHomeTeam(), $match->GetAwayTeam()), $result_type)); } else { $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type)); } } } $o_winner->SelectOption($match->Result()->GetResultType()); if (!$b_future) { $match_box->AddControl('<h3 class="ifNotPlayed">Or, if the match was not played:</h3>'); } $o_win_part = new FormPart($b_future ? 'Will it happen?' : 'Why not?', $o_winner); $match_box->AddControl($o_win_part); # Show audit data if ($match->GetLastAudit() != null) { require_once "data/audit-control.class.php"; $match_box->AddControl(new AuditControl($match->GetLastAudit(), "match")); } # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $match->GetShortUrl()); if ($this->b_user_is_match_admin) { $o_url_part = new FormPart('Short URL', $o_short_url); $this->AddControl($o_url_part); $this->AddControl(new CheckBox($this->GetNamingPrefix() . 'RegenerateUrl', 'Regenerate short URL', 1, !$match->GetUseCustomShortUrl(), $this->IsValidSubmit())); } else { $o_short_url->SetMode(TextBoxMode::Hidden()); $this->AddControl($o_short_url); } if ($b_future and !$this->b_user_is_match_admin and !$this->b_user_is_match_owner) { $this->SetButtonText("Save result"); } }
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"); } }
protected function CreateControls() { $o_match = $this->GetDataObject(); if (is_null($o_match)) { $o_match = new Match($this->GetSettings()); } /* @var $o_match Match */ /* @var $o_team Team */ $b_got_home = !is_null($o_match->GetHomeTeam()); $b_got_away = !is_null($o_match->GetAwayTeam()); $b_is_new_match = !(bool) $o_match->GetId(); $b_is_tournament_match = false; if ($this->i_match_type == MatchType::TOURNAMENT_MATCH) { $b_is_tournament_match = $this->tournament instanceof Match; } else { if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH and $o_match->GetTournament() instanceof Match) { $this->SetTournament($o_match->GetTournament()); $this->SetMatchType($o_match->GetMatchType()); $b_is_tournament_match = true; } } $o_match_outer_1 = new XhtmlElement('div'); $o_match_outer_1->SetCssClass('MatchFixtureEdit'); $o_match_outer_1->AddCssClass($this->GetCssClass()); $this->SetCssClass(''); $o_match_outer_1->SetXhtmlId($this->GetNamingPrefix()); $o_match_outer_2 = new XhtmlElement('div'); $o_match_box = new XhtmlElement('div'); $this->AddControl($o_match_outer_1); $o_match_outer_1->AddControl($o_match_outer_2); $o_match_outer_2->AddControl($o_match_box); if ($this->GetShowHeading()) { $s_heading = str_replace('{0}', MatchType::Text($this->i_match_type), $this->GetHeading()); # Add match type if required $o_title_inner_1 = new XhtmlElement('span', htmlentities($s_heading, ENT_QUOTES, "UTF-8", false)); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $o_match_box->AddControl(new XhtmlElement('h2', $o_title_inner_3, "medium large")); } # Offer choice of season if appropriate $season_count = $this->seasons->GetCount(); if ($season_count == 1 and $this->i_match_type != MatchType::PRACTICE) { $o_season_id = new TextBox($this->GetNamingPrefix() . 'Season', $this->seasons->GetFirst()->GetId()); $o_season_id->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_season_id); } elseif ($season_count > 1 and $this->i_match_type != MatchType::PRACTICE) { $o_season_id = new XhtmlSelect($this->GetNamingPrefix() . 'Season', '', $this->IsValidSubmit()); foreach ($this->Seasons()->GetItems() as $season) { $o_season_id->AddControl(new XhtmlOption($season->GetCompetitionName(), $season->GetId())); } $o_match_box->AddControl(new FormPart('Competition', $o_season_id)); } # Start date and time $match_time_known = (bool) $o_match->GetStartTime(); if (!$match_time_known) { # if no date set, use specified default if ($this->i_default_time) { $o_match->SetStartTime($this->i_default_time); if ($b_is_tournament_match) { $o_match->SetIsStartTimeKnown(false); } } else { # if no date set and no default, default to today at 6.30pm BST $i_now = gmdate('U'); $o_match->SetStartTime(gmmktime(17, 30, 00, (int) gmdate('n', $i_now), (int) gmdate('d', $i_now), (int) gmdate('Y', $i_now))); } } $o_date = new DateControl($this->GetNamingPrefix() . 'Start', $o_match->GetStartTime(), $o_match->GetIsStartTimeKnown(), $this->IsValidSubmit()); $o_date->SetShowTime(true); $o_date->SetRequireTime(false); $o_date->SetMinuteInterval(5); # if no date set and only one season to choose from, limit available dates to the length of that season if (!$match_time_known and $season_count == 1) { if ($this->Seasons()->GetFirst()->GetStartYear() == $this->Seasons()->GetFirst()->GetEndYear()) { $i_mid_season = gmmktime(0, 0, 0, 6, 30, $this->Seasons()->GetFirst()->GetStartYear()); } else { $i_mid_season = gmmktime(0, 0, 0, 12, 31, $this->Seasons()->GetFirst()->GetStartYear()); } $season_dates = Season::SeasonDates($i_mid_season); $season_start_month = gmdate('n', $season_dates[0]); $season_end_month = gmdate('n', $season_dates[1]); if ($season_start_month) { $o_date->SetMonthStart($season_start_month); } if ($season_end_month) { $o_date->SetMonthEnd($season_end_month + 1); } // TODO: need a better way to handle this, allowing overlap. Shirley has indoor matches until early April. $season_start_year = $this->Seasons()->GetFirst()->GetStartYear(); $season_end_year = $this->Seasons()->GetFirst()->GetEndYear(); if ($season_start_year) { $o_date->SetYearStart($season_start_year); } if ($season_end_year) { $o_date->SetYearEnd($season_end_year); } } if ($b_is_tournament_match) { $o_date->SetShowDate(false); $o_date->SetShowTime(false); $o_match_box->AddControl($o_date); } else { $o_date_part = new FormPart('When?', $o_date); $o_date_part->SetIsFieldset(true); $o_match_box->AddControl($o_date_part); } # Who's playing? if ($this->i_match_type == MatchType::PRACTICE and isset($this->context_team)) { $home_id = new TextBox($this->GetNamingPrefix() . 'Home', $this->context_team->GetId()); $home_id->SetMode(TextBoxMode::Hidden()); $away_id = new TextBox($this->GetNamingPrefix() . 'Away', $this->context_team->GetId()); $away_id->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($home_id); $o_match_box->AddControl($away_id); } else { $o_home_list = new XhtmlSelect($this->GetNamingPrefix() . 'Home'); $o_away_list = new XhtmlSelect($this->GetNamingPrefix() . 'Away'); $first_real_team_index = 0; if ($this->b_user_is_admin) { # Option of not specifying teams is currently admin-only # Value of 0 is important because PHP sees it as boolean negative, but it can be used as the indexer of an array in JavaScript $o_home_list->AddControl(new XhtmlOption("Don't know yet", '0')); $o_away_list->AddControl(new XhtmlOption("Don't know yet", '0')); $first_real_team_index = 1; } foreach ($this->a_teams as $group_name => $teams) { foreach ($teams as $o_team) { $home_option = new XhtmlOption($o_team->GetName(), $o_team->GetId()); if (is_string($group_name) and $group_name) { $home_option->SetGroupName($group_name); } $o_home_list->AddControl($home_option); $away_option = new XhtmlOption($o_team->GetName(), $o_team->GetId()); if (is_string($group_name) and $group_name) { $away_option->SetGroupName($group_name); } $o_away_list->AddControl($away_option); } } $o_home_part = new FormPart('Home team', $o_home_list); $o_away_part = new FormPart('Away team', $o_away_list); $o_match_box->AddControl($o_home_part); $o_match_box->AddControl($o_away_part); if ($b_got_home) { $o_home_list->SelectOption($o_match->GetHomeTeamId()); } if (!$b_got_home and $b_is_new_match) { // if no home team data, select the first team by default // unless editing a match, in which case it may be correct to have no teams (eg cup final) $o_home_list->SelectIndex($first_real_team_index); } if (!$b_got_away and $b_is_new_match) { // if no away team data, select the second team as the away team so that it's not the same as the first // unless editing a match, in which case it may be correct to have no teams (eg cup final). $o_away_list->SelectIndex($first_real_team_index + 1); // if there was a home team but not an away team, make sure we don't select the home team against itself if ($b_got_home and $o_away_list->GetSelectedValue() == (string) $o_match->GetHomeTeamId()) { $o_away_list->SelectIndex($first_real_team_index); } } else { if ($b_got_away) { $o_away_list->SelectOption($o_match->GetAwayTeamId()); } if (!$b_is_new_match) { # Note which away team was previously saved, even if it's "not known" - this is for JavaScript to know it shouldn't auto-change the away team $away_saved = new TextBox($this->GetNamingPrefix() . 'SavedAway', $o_match->GetAwayTeamId()); $away_saved->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($away_saved); unset($away_saved); } } } # Where? # If tournament match, assume same ground as tournament. Otherwise ask the user for ground. if ($b_is_tournament_match) { $ground = new TextBox($this->GetNamingPrefix() . 'Ground', $this->tournament->GetGroundId() ? $this->tournament->GetGroundId() : $o_match->GetGroundId()); $ground->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($ground); } else { $o_ground_list = new XhtmlSelect($this->GetNamingPrefix() . 'Ground'); $o_ground_list->AddControl(new XhtmlOption("Don't know", -1)); $o_ground_list->AddControl(new XhtmlOption('Not listed (type the address in the notes field)', -2)); # Promote home grounds for this season to the top of the list $a_home_ground_ids = array(); foreach ($this->a_teams as $teams) { foreach ($teams as $o_team) { $a_home_ground_ids[$o_team->GetId()] = $o_team->GetGround()->GetId(); } } $a_home_grounds = array(); $a_other_grounds = array(); /* @var $o_ground Ground */ foreach ($this->a_grounds as $o_ground) { if (array_search($o_ground->GetId(), $a_home_ground_ids) > -1) { $a_home_grounds[] = $o_ground; } else { $a_other_grounds[] = $o_ground; } } # Add home grounds foreach ($a_home_grounds as $o_ground) { $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId()); $option->SetGroupName('Home grounds'); $o_ground_list->AddControl($option); } # Add away grounds foreach ($a_other_grounds as $o_ground) { $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId()); $option->SetGroupName('Away grounds'); $o_ground_list->AddControl($option); } # Select ground if ($o_match->GetGroundId()) { $o_ground_list->SelectOption($o_match->GetGroundId()); } elseif ($this->i_match_type == MatchType::PRACTICE and isset($this->context_team)) { $o_ground_list->SelectOption($this->context_team->GetGround()->GetId()); } $o_ground_part = new FormPart('Where?', $o_ground_list); $o_match_box->AddControl($o_ground_part); # Note which grounds belong to which teams, for use by match-fixture-edit-control.js to select a ground when the home team is changed # Format is 1,2;2,3;4,5 # where ; separates each team, and for each team the first number identifies the team and the second is the ground $s_team_ground = ''; foreach ($a_home_ground_ids as $i_team => $i_ground) { if ($s_team_ground) { $s_team_ground .= ';'; } $s_team_ground .= $i_team . ',' . $i_ground; } $o_hidden = new TextBox($this->GetNamingPrefix() . 'TeamGround', $s_team_ground); $o_hidden->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_hidden); unset($o_hidden); # Note which ground was previously saved - this is for JavaScript to know it shouldn't auto-change the ground if (!$b_is_new_match) { $o_hidden = new TextBox($this->GetNamingPrefix() . 'SavedGround', $o_match->GetGroundId()); $o_hidden->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_hidden); unset($o_hidden); } } # Notes $o_notes = new TextBox($this->GetNamingPrefix() . 'Notes', $o_match->GetNotes()); $o_notes->SetMode(TextBoxMode::MultiLine()); $o_notes_part = new FormPart('Notes', $o_notes); $o_match_box->AddControl($o_notes_part); # Remember match type, tournament and short URL $o_type = new TextBox($this->GetNamingPrefix() . 'MatchType', $this->GetMatchType()); $o_type->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_type); if ($b_is_tournament_match) { $tourn_box = new TextBox($this->GetNamingPrefix() . 'Tournament', $this->tournament->GetId()); $tourn_box->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($tourn_box); } $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $o_match->GetShortUrl()); $o_short_url->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_short_url); # Note the context team - to be picked up by JavaScript to enable auto-changing of away team if # context team is not selected as home team if (isset($this->context_team)) { $context_team_box = new TextBox($this->GetNamingPrefix() . 'ContextTeam', $this->context_team->GetId()); $context_team_box->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($context_team_box); } }
/** * Build the form */ protected function OnPreRender() { $this->AddControl('<div id="statisticsFilter" class="panel"><div><div><h2><span><span><span>Filter these statistics</span></span></span></h2>'); # Track whether to show or hide this filter $filter = '<input type="hidden" id="filter" name="filter" value="'; $filter .= (isset($_GET["filter"]) and $_GET["filter"] == "1") ? 1 : 0; $filter .= '" />'; $this->AddControl($filter); $type_filters = array(); # Support player type filter if (is_array($this->player_type_filter)) { require_once "stoolball/player-type.enum.php"; $player_type_list = new XhtmlSelect("player-type"); $blank = new XhtmlOption("any players", ""); $player_type_list->AddControl($blank); foreach ($this->player_type_filter[0] as $player_type) { $player_type_list->AddControl(new XhtmlOption(strtolower(PlayerType::Text($player_type)), $player_type, $player_type === $this->player_type_filter[1])); } $label = new XhtmlElement("label", "Type of players", "aural"); $label->AddAttribute("for", $player_type_list->GetXhtmlId()); $type_filters[] = $label; $type_filters[] = $player_type_list; } # Support match type filter if (is_array($this->match_type_filter)) { require_once "stoolball/match-type.enum.php"; $match_type_list = new XhtmlSelect("match-type"); $blank = new XhtmlOption("any match", ""); $match_type_list->AddControl($blank); foreach ($this->match_type_filter[0] as $match_type) { $match_type_list->AddControl(new XhtmlOption(str_replace(" match", "", MatchType::Text($match_type)), $match_type, $match_type === $this->match_type_filter[1])); } $label = new XhtmlElement("label", "Type of competition", "aural"); $label->AddAttribute("for", $match_type_list->GetXhtmlId()); $type_filters[] = $label; $type_filters[] = $match_type_list; } if (count($type_filters)) { $type = new XhtmlElement("fieldset", new XhtmlElement("legend", "Match type", "formLabel"), "formPart"); $controls = new XhtmlElement("div", null, "formControl"); foreach ($type_filters as $control) { $controls->AddControl($control); } $type->AddControl($controls); $this->AddControl($type); } # Support team filter if (is_array($this->team_filter)) { $team_list = new XhtmlSelect("team"); $blank = new XhtmlOption("any team", ""); $team_list->AddControl($blank); foreach ($this->team_filter[0] as $team) { $team_list->AddControl(new XhtmlOption($team->GetName(), $team->GetId(), $team->GetId() == $this->team_filter[1])); } $this->AddControl(new FormPart("Team", $team_list)); } # Support opposition team filter if (is_array($this->opposition_filter)) { $opposition_list = new XhtmlSelect("opposition"); $blank = new XhtmlOption("any team", ""); $opposition_list->AddControl($blank); foreach ($this->opposition_filter[0] as $team) { $opposition_list->AddControl(new XhtmlOption($team->GetName(), $team->GetId(), $team->GetId() == $this->opposition_filter[1])); } $this->AddControl(new FormPart("Against", $opposition_list)); } # Support ground filter if (is_array($this->ground_filter)) { $ground_list = new XhtmlSelect("ground"); $blank = new XhtmlOption("any ground", ""); $ground_list->AddControl($blank); foreach ($this->ground_filter[0] as $ground) { $ground_list->AddControl(new XhtmlOption($ground->GetNameAndTown(), $ground->GetId(), $ground->GetId() == $this->ground_filter[1])); } $this->AddControl(new FormPart("Ground", $ground_list)); } # Support competition filter if (is_array($this->competition_filter)) { $competition_list = new XhtmlSelect("competition"); $blank = new XhtmlOption("any competition", ""); $competition_list->AddControl($blank); foreach ($this->competition_filter[0] as $competition) { $competition_list->AddControl(new XhtmlOption($competition->GetName(), $competition->GetId(), $competition->GetId() == $this->competition_filter[1])); } $this->AddControl(new FormPart("Competition", $competition_list)); } # Support date filter # Use text fields rather than HTML 5 date fields because then we can accept dates like "last Tuesday" # which PHP will understand. Jquery calendar is at least as good as native date pickers anyway. $date_fields = '<div class="formPart"> <label for="from" class="formLabel">From date</label> <div class="formControl twoFields"> <input type="text" class="date firstField" id="from" name="from" placeholder="any date" autocomplete="off"'; if (!$this->IsValid()) { $date_fields .= ' value="' . (isset($_GET["from"]) ? $_GET["from"] : "") . '"'; } else { if ($this->after_date_filter) { $date_fields .= ' value="' . Date::BritishDate($this->after_date_filter, false, true, false) . '"'; } } $date_fields .= ' /> <label for="to">Up to date <input type="text" class="date" id="to" name="to" placeholder="any date" autocomplete="off"'; if (!$this->IsValid()) { $date_fields .= ' value="' . (isset($_GET["to"]) ? $_GET["to"] : "") . '"'; } else { if ($this->before_date_filter) { $date_fields .= ' value="' . Date::BritishDate($this->before_date_filter, false, true, false) . '"'; } } $date_fields .= ' /></label> </div> </div>'; $this->AddControl($date_fields); # Support innings filter $innings_list = new XhtmlSelect("innings"); $innings_list->AddControl(new XhtmlOption("either innings", "")); $innings_list->AddControl(new XhtmlOption("first innings", 1, 1 == $this->innings_filter)); $innings_list->AddControl(new XhtmlOption("second innings", 2, 2 == $this->innings_filter)); $this->AddControl('<div class="formPart"> <label for="innings" class="formLabel">Innings</label> <div class="formControl">' . $innings_list . '</div>' . '</div>'); # Support batting position filter if (is_array($this->batting_position_filter)) { $batting_position_list = new XhtmlSelect("batpos"); $blank = new XhtmlOption("any position", ""); $batting_position_list->AddControl($blank); foreach ($this->batting_position_filter[0] as $batting_position) { $batting_position_list->AddControl(new XhtmlOption($batting_position == 1 ? "opening" : $batting_position, $batting_position, $batting_position == $this->batting_position_filter[1])); } $this->AddControl('<div class="formPart"> <label for="batpos" class="formLabel">Batting at</label> <div class="formControl">' . $batting_position_list . '</div>' . '</div>'); } # Support match result filter $result_list = new XhtmlSelect("result"); $result_list->AddControl(new XhtmlOption("any result", "")); $result_list->AddControl(new XhtmlOption("win", 1, 1 === $this->match_result_filter)); $result_list->AddControl(new XhtmlOption("tie", 0, 0 === $this->match_result_filter)); $result_list->AddControl(new XhtmlOption("lose", -1, -1 === $this->match_result_filter)); $this->AddControl('<div class="formPart"> <label for="result" class="formLabel">Match result</label> <div class="formControl">' . $result_list . '</div>' . '</div>'); # Preserve the player filter if applied if (isset($_GET["player"]) and is_numeric($_GET["player"])) { $this->AddControl('<input type="hidden" name="player" id="player" value="' . $_GET["player"] . '" />'); } $this->AddControl('<p class="actions"><input type="submit" value="Apply filter" /></p>'); $this->AddControl('</div></div></div>'); }
function OnPageLoad() { if (!$this->match instanceof Match) { echo new XhtmlElement('h1', ucfirst($this->match_or_tournament) . ' already deleted'); echo new XhtmlElement('p', "The " . $this->match_or_tournament . " you're trying to delete does not exist or has already been deleted."); return; } echo new XhtmlElement('h1', 'Delete ' . $this->match_or_tournament . ': <cite>' . htmlentities($this->match->GetTitle(), ENT_QUOTES, "UTF-8", false) . '</cite>'); if ($this->b_deleted) { ?> <p>The <?php echo $this->match_or_tournament; ?> has been deleted.</p> <?php if ($this->match->GetTournament() instanceof Match) { echo '<p><a href="' . htmlentities($this->match->GetTournament()->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">Go to ' . htmlentities($this->match->GetTournament()->GetTitle(), ENT_QUOTES, "UTF-8", false) . '</a></p>'; } else { if ($this->match->Seasons()->GetCount()) { foreach ($this->match->Seasons() as $season) { echo '<p><a href="' . htmlentities($season->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">Go to ' . htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . '</a></p>'; } } else { echo '<p><a href="/matches/">View all matches</a></p>'; } } } else { $has_permission = (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_MATCHES) or AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId()); if ($has_permission) { $s_detail = 'This is a ' . MatchType::Text($this->match->GetMatchType()); $s_detail .= $this->match->GetIsStartTimeKnown() ? ' starting at ' : ' on '; $s_detail .= $this->match->GetStartTimeFormatted() . '. '; $s_context = ''; if ($this->match->GetTournament() instanceof Match) { $s_context = "It's in the " . $this->match->GetTournament()->GetTitle(); } if ($this->match->Seasons()->GetCount()) { $season = $this->match->Seasons()->GetFirst(); $b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0); $s_context .= $s_context ? ', in ' : 'It\'s in '; $s_context .= $b_the ? 'the ' : ''; if ($this->match->Seasons()->GetCount() == 1) { $s_context .= $season->GetCompetitionName() . '.'; } else { $s_context .= 'following seasons: '; } } $s_detail .= $s_context; echo new XhtmlElement('p', htmlentities($s_detail, ENT_QUOTES, "UTF-8", false)); if ($this->match->Seasons()->GetCount() > 1) { $seasons = new XhtmlElement('ul'); foreach ($this->match->Seasons() as $season) { $seasons->AddControl(new XhtmlElement('li', htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false))); } echo $seasons; } if ($this->match->GetMatchType() == MatchType::TOURNAMENT) { ?> <p>Deleting a tournament cannot be undone.</p> <?php } else { ?> <p>Deleting a match cannot be undone. The match will be removed from all league tables and statistics.</p> <?php } ?> <p>Are you sure you want to delete this <?php echo $this->match_or_tournament; ?> ?</p> <form action="<?php echo htmlentities($this->match->GetDeleteNavigateUrl(), ENT_QUOTES, "UTF-8", false); ?> " method="post" class="deleteButtons"> <div> <input type="submit" value="Delete <?php echo $this->match_or_tournament; ?> " name="delete" /> <input type="submit" value="Cancel" name="cancel" /> </div> </form> <?php $this->AddSeparator(); require_once 'stoolball/user-edit-panel.class.php'; $panel = new UserEditPanel($this->GetSettings(), 'this ' . $this->match_or_tournament); $panel->AddLink('view this ' . $this->match_or_tournament, $this->match->GetNavigateUrl()); $panel->AddLink('edit this ' . $this->match_or_tournament, $this->match->GetEditNavigateUrl()); echo $panel; } else { ?> <p>Sorry, you can't delete a <?php echo $this->match_or_tournament; ?> unless you added it.</p> <p><a href="<?php echo htmlentities($this->match->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false); ?> ">Go back to <?php echo $this->match_or_tournament; ?> </a></p> <?php } } }
protected function OnPreRender() { /* @var $o_home Team */ /* @var $o_away Team */ /* @var $o_tourney Match */ # Date and tournament $o_date_para = new XhtmlElement('p'); $o_date = new XhtmlElement('abbr', htmlentities($this->o_match->GetStartTimeFormatted(), ENT_QUOTES, "UTF-8", false)); $o_date->SetTitle(Date::Microformat($this->o_match->GetStartTime())); # hCalendar $o_date->SetCssClass('dtstart'); # hCalendar $o_date->AddAttribute("property", "schema:startDate"); $o_date->AddAttribute("datatype", "xsd:date"); $o_date->AddAttribute("content", Date::Microformat($this->o_match->GetStartTime())); $o_date_para->AddControl('When: '); $o_date_para->AddControl($o_date); # hCalendar end date if ($this->o_match->GetIsStartTimeKnown()) { $i_end_time = $this->o_match->GetStartTime() + 60 * 90; $o_hcal_end = new XhtmlElement('abbr', ' until around ' . htmlentities(Date::Time($i_end_time), ENT_QUOTES, "UTF-8", false)); $o_hcal_end->SetTitle(Date::Microformat($i_end_time)); $o_hcal_end->SetCssClass('metadata dtend'); $o_date_para->AddControl($o_hcal_end); } # If we know the time and place, show when the sun sets # TODO: Assumes UK if ($this->o_match->GetGround() instanceof Ground and $this->o_match->GetGround()->GetAddress()->GetLatitude() and $this->o_match->GetGround()->GetAddress()->GetLongitude()) { $o_date_para->AddControl(' <span class="sunset">sunset ' . htmlentities(Date::Time(date_sunset($this->o_match->GetStartTime(), SUNFUNCS_RET_TIMESTAMP, $this->o_match->GetGround()->GetAddress()->GetLatitude(), $this->o_match->GetGround()->GetAddress()->GetLongitude())), ENT_QUOTES, "UTF-8", false) . '</span>'); } # Display match type/season/tournament if ($this->o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $o_date_para->SetCssClass('description'); # hCal $o_tourney = $this->o_match->GetTournament(); if (is_object($o_tourney)) { $tournament_link = new XhtmlAnchor(htmlentities($o_tourney->GetTitle(), ENT_QUOTES, "UTF-8", false), $o_tourney->GetNavigateUrl()); $tournament_link->AddAttribute("typeof", "schema:SportsEvent"); $tournament_link->AddAttribute("about", $o_tourney->GetLinkedDataUri()); $tournament_link->AddAttribute("rel", "schema:url"); $tournament_link->AddAttribute("property", "schema:name"); $tournament_container = new XhtmlElement("span", $tournament_link); $tournament_container->AddAttribute("rel", "schema:superEvent"); # Check for 'the' to get the grammar right $s_title = strtolower($o_tourney->GetTitle()); if (strlen($s_title) >= 4 and substr($s_title, 0, 4) == 'the ') { $o_date_para->AddControl(', in '); } else { $o_date_para->AddControl(', in the '); } $o_date_para->AddControl($tournament_container); $o_date_para->AddControl('.'); } else { $o_date_para->AddControl(', in a tournament.'); } } else { # hCalendar desc, built up at the same time as the date and league/tournament $hcal_desc = new XhtmlElement('div', null, 'description'); $this->AddControl($hcal_desc); $s_detail_xhtml = ucfirst(MatchType::Text($this->o_match->GetMatchType())); $season_list_xhtml = null; if ($this->o_match->Seasons()->GetCount() == 1) { $season = $this->o_match->Seasons()->GetFirst(); $season_name = new XhtmlAnchor(htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false), $season->GetNavigateUrl()); $b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0); $s_detail_xhtml .= ' in ' . ($b_the ? 'the ' : '') . $season_name->__toString() . '.'; } elseif ($this->o_match->Seasons()->GetCount() > 1) { $s_detail_xhtml .= ' in the following seasons: '; $season_list_xhtml = new XhtmlElement('ul'); $seasons = $this->o_match->Seasons()->GetItems(); $total_seasons = count($seasons); for ($i = 0; $i < $total_seasons; $i++) { $season = $seasons[$i]; /* @var $season Season */ $season_name = new XhtmlAnchor(htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false), $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_xhtml->AddControl($li); } } else { $s_detail_xhtml .= '.'; } $hcal_desc->AddControl(new XhtmlElement('p', $s_detail_xhtml)); if (!is_null($season_list_xhtml)) { $hcal_desc->AddControl($season_list_xhtml); } } # Who $o_home = $this->o_match->GetHomeTeam(); $o_away = $this->o_match->GetAwayTeam(); $has_home = $o_home instanceof Team; $has_away = $o_away instanceof Team; if ($has_home or $has_away) { $who = new XhtmlElement("p", "Who: "); if ($has_home) { $who->AddControl($this->CreateTeamLink($o_home)); } if ($has_home and $has_away) { $who->AddControl(" and "); } if ($has_away) { $who->AddControl($this->CreateTeamLink($o_away)); } $this->AddControl($who); } # When $this->AddControl($o_date_para); # Ground $o_ground = $this->o_match->GetGround(); if (is_object($o_ground)) { $o_ground_link = new XhtmlElement('a', htmlentities($o_ground->GetNameAndTown(), ENT_QUOTES, "UTF-8", false)); $o_ground_link->AddAttribute('href', $o_ground->GetNavigateUrl()); $o_ground_link->SetCssClass('location'); # hCalendar $o_ground_link->AddAttribute("typeof", "schema:Place"); $o_ground_link->AddAttribute("about", $o_ground->GetLinkedDataUri()); $o_ground_link->AddAttribute("rel", "schema:url"); $o_ground_link->AddAttribute("property", "schema:name"); $o_ground_control = new XhtmlElement('p', 'Where: '); $o_ground_control->AddAttribute("rel", "schema:location"); $o_ground_control->AddControl($o_ground_link); $this->AddControl($o_ground_control); } # Add result $o_result = $this->o_match->Result(); $b_result_known = !$o_result->GetResultType() == MatchResult::UNKNOWN; $toss_known = !is_null($this->o_match->Result()->GetTossWonBy()); $b_batting_order_known = !is_null($this->o_match->Result()->GetHomeBattedFirst()); $has_scorecard_data = ($o_result->HomeBatting()->GetCount() or $o_result->HomeBowling()->GetCount() or $o_result->AwayBatting()->GetCount() or $o_result->AwayBowling()->GetCount() or $o_result->GetHomeRuns() or $o_result->GetHomeWickets() or $o_result->GetAwayRuns() or $o_result->GetAwayWickets()); $has_player_of_match = $this->o_match->Result()->GetPlayerOfTheMatch() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatch()->GetName(); $has_player_of_match_home = $this->o_match->Result()->GetPlayerOfTheMatchHome() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatchHome()->GetName(); $has_player_of_match_away = $this->o_match->Result()->GetPlayerOfTheMatchAway() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatchAway()->GetName(); if ($b_result_known or $b_batting_order_known or $has_scorecard_data) { # Put result in header, so long as we have something to put after it. Otherwise put the result after it. $result_header = "Result"; if ($b_result_known and ($b_batting_order_known or $has_scorecard_data)) { $result_header .= ": " . $this->o_match->GetResultDescription(); } $result_header = new XhtmlElement('h2', htmlentities($result_header, ENT_QUOTES, "UTF-8", false)); if ($has_scorecard_data) { $result_header->AddCssClass("hasScorecard"); } $this->AddControl($result_header); } if ($toss_known) { $toss_team = $this->o_match->Result()->GetTossWonBy() === TeamRole::Home() ? $this->o_match->GetHomeTeam() : $this->o_match->GetAwayTeam(); if ($toss_team instanceof Team) { $toss_text = $toss_team->GetName() . " won the toss"; if ($b_batting_order_known) { $chose_to = ($this->o_match->Result()->GetTossWonBy() === TeamRole::Home()) == $this->o_match->Result()->GetHomeBattedFirst() ? "bat" : "bowl"; $toss_text .= " and chose to " . $chose_to; } $this->AddControl("<p>" . Html::Encode($toss_text) . '.</p>'); } } # If at least one player recorded, create a container for the schema.org metadata if ($has_scorecard_data or $has_player_of_match or $has_player_of_match_home or $has_player_of_match_away) { $this->AddControl('<div rel="schema:performers">'); } if ($has_scorecard_data) { $this->CreateScorecard($this->o_match); } else { # Got to be just result and batting order now. Only include result if batting order's not there, otherwise result will already be in header. if ($b_result_known and !$b_batting_order_known) { $this->AddControl(new XhtmlElement('p', htmlentities($this->o_match->GetResultDescription(), ENT_QUOTES, "UTF-8", false) . '.')); } if ($b_batting_order_known) { $this->AddControl(new XhtmlElement('p', htmlentities(($this->o_match->Result()->GetHomeBattedFirst() ? $o_home->GetName() : $o_away->GetName()) . ' batted first.'), ENT_QUOTES, "UTF-8", false)); } } # Player of the match if ($has_player_of_match) { $player = $this->o_match->Result()->GetPlayerOfTheMatch(); $team = $player->Team()->GetId() == $o_home->GetId() ? $o_home->GetName() : $o_away->GetName(); $player_of_match = new XhtmlElement('p', 'Player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a> ({$team})"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } if ($has_player_of_match_home) { $player = $this->o_match->Result()->GetPlayerOfTheMatchHome(); $player_of_match = new XhtmlElement('p', $o_home->GetName() . ' player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a>"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } if ($has_player_of_match_away) { $player = $this->o_match->Result()->GetPlayerOfTheMatchAway(); $player_of_match = new XhtmlElement('p', $o_away->GetName() . ' player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a>"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } # End container for the schema.org metadata if ($has_scorecard_data or $has_player_of_match or $has_player_of_match_home or $has_player_of_match_away) { $this->AddControl('</div>'); } # Add notes if ($this->o_match->GetNotes()) { $this->AddControl(new XhtmlElement('h2', 'Notes')); $s_notes = htmlentities($this->o_match->GetNotes(), ENT_QUOTES, "UTF-8", false); $s_notes = XhtmlMarkup::ApplyCharacterEntities($s_notes); require_once 'email/email-address-protector.class.php'; $protector = new EmailAddressProtector($this->o_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)); } } # hCalendar metadata $o_hcal_para = new XhtmlElement('p'); $o_hcal_para->SetCssClass('metadata'); $this->AddControl($o_hcal_para); # hCalendar timestamp $o_hcal_para->AddControl('Status: At '); $o_hcal_stamp = new XhtmlElement('abbr', htmlentities(Date::Time(gmdate('U')), ENT_QUOTES, "UTF-8", false)); $o_hcal_stamp->SetTitle(Date::Microformat()); $o_hcal_stamp->SetCssClass('dtstamp'); $o_hcal_para->AddControl($o_hcal_stamp); # hCalendar GUID $o_hcal_para->AddControl(' match '); $o_hcal_guid = new XhtmlElement('span', htmlentities($this->o_match->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false)); $o_hcal_guid->SetCssClass('uid'); $o_hcal_para->AddControl($o_hcal_guid); # work out hCalendar status $s_status = 'CONFIRMED'; switch ($this->o_match->Result()->GetResultType()) { case MatchResult::CANCELLED: case MatchResult::POSTPONED: case MatchResult::AWAY_WIN_BY_FORFEIT: case MatchResult::HOME_WIN_BY_FORFEIT: $s_status = 'CANCELLED'; } # hCalendar URL and status $o_hcal_para->AddControl(' is '); $o_hcal_url = new XhtmlAnchor($s_status, 'http://' . $_SERVER['HTTP_HOST'] . $this->o_match->GetNavigateUrl()); $o_hcal_url->SetCssClass('url status'); $o_hcal_para->AddControl($o_hcal_url); }
function OnPrePageLoad() { if (isset($this->i_season_id)) { $this->SetPageTitle('New ' . MatchType::Text($this->i_match_type) . ' in ' . $this->season->GetCompetitionName()); } else { if ($this->team instanceof Team) { $this->SetPageTitle('New ' . MatchType::Text($this->i_match_type) . ' for ' . $this->team->GetName()); } } $this->SetContentConstraint(StoolballPage::ConstrainText()); $this->SetContentCssClass('matchEdit'); $this->LoadClientScript('/scripts/match-fixture-edit-control-5.js'); }