function OnPostback() { $this->season = $this->edit->GetDataObject(); if (!$this->season->GetId()) { $existing_season_id = $this->season_manager->CheckIfSeasonExists($this->season->GetCompetition()->GetId(), $this->season->GetStartYear(), $this->season->GetEndYear()); if ($existing_season_id) { require_once 'data/validation/required-field-validator.class.php'; $season = new Season($this->GetSettings()); $season->SetId($existing_season_id); $validator = new RequiredFieldValidator('This_Validator_Will_Fail', "The season you're adding already exists – <a href=\"" . $season->GetNavigateUrl() . "\">edit season</a>"); $validator->SetValidIfNotFound(false); $this->edit->AddValidator($validator); } } # Get the competition. This is used to build the page title and, when saving, the short URL. # It is also re-indexed in search below. $this->competition_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $this->competition_manager->ReadById(array($this->season->GetCompetition()->GetId())); $this->season->SetCompetition($this->competition_manager->GetFirst()); unset($this->competition_manager); # save data if valid if ($this->IsValid()) { $b_saved_new = !(bool) $this->season->GetId(); $id = $this->season_manager->SaveSeason($this->season); $this->season->SetId($id); # Add the competition to the search engine. Re-request so we have team names as well as IDs. require_once "search/competition-search-adapter.class.php"; $this->SearchIndexer()->DeleteFromIndexById("competition" . $this->season->GetCompetition()->GetId()); $adapter = new CompetitionSearchAdapter($this->season->GetCompetition()); $this->SearchIndexer()->Index($adapter->GetSearchableItem()); $this->SearchIndexer()->CommitChanges(); # If just saved a new season, redirect to load this page from scratch # (When just loading data on this page, didn't load correctly into aggregated editors) if ($b_saved_new) { $this->Redirect($this->season->GetEditSeasonUrl()); } $this->Redirect($this->season->GetNavigateUrl()); } }
function OnPageLoad() { echo new XhtmlElement('h1', Html::Encode('Delete season: ' . $this->data_object->GetCompetitionName())); if ($this->deleted) { ?> <p>The season has been deleted.</p> <p><a href="<?php echo Html::Encode($this->data_object->GetCompetition()->GetNavigateUrl()); ?> ">View <?php echo Html::Encode($this->data_object->GetCompetition()->GetName()); ?> </a></p> <?php } else { # 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 ($this->has_permission and $this->seasons_in_competition > 1) { ?> <p>Deleting a season cannot be undone. Matches will not be deleted, but they will no longer be a part of this season.</p> <p>Are you sure you want to delete this season?</p> <form action="<?php echo Html::Encode($this->data_object->GetDeleteSeasonUrl()); ?> " method="post" class="deleteButtons"> <div> <input type="submit" value="Delete season" 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 season'); $panel->AddLink('view this season', $this->data_object->GetNavigateUrl()); $panel->AddLink('edit this season', $this->data_object->GetEditSeasonUrl()); echo $panel; } else { ?> <p>Sorry, you're not allowed to delete this season.</p> <p><a href="<?php echo Html::Encode($this->data_object->GetNavigateUrl()); ?> ">Go back to the season</a></p> <?php } } }
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"); } }