public function OnLoadPageData() { require_once 'stoolball/competition-manager.class.php'; $manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); if ($this->season_id) { $manager->ReadById(null, array($this->season_id)); } else { $manager->ReadById(array($this->competition_id)); } $this->competition = $manager->GetFirst(); $this->season = $this->competition->GetWorkingSeason(); unset($manager); # If the competition was requested, redirect to the current season if ($this->competition_id) { http_response_code(303); header("Location: " . $this->season->GetMapUrl()); return; } $this->has_map = count($this->season->GetTeams()); # Get other seasons require_once 'stoolball/season-manager.class.php'; $a_comp_ids = array($this->competition->GetId()); $o_season_manager = new SeasonManager($this->GetSettings(), $this->GetDataConnection()); $o_season_manager->ReadByCompetitionId($a_comp_ids); $a_other_seasons = $o_season_manager->GetItems(); $this->competition->SetSeasons(array()); foreach ($a_other_seasons as $season) { if ($season->GetId() == $this->season->GetId()) { $this->competition->AddSeason($this->season, true); } else { $this->competition->AddSeason($season, false); } } }
function OnPageLoad() { echo "<h1>Statistics for " . htmlentities($this->season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . "</h1>"; require_once "_summary-data-found.php"; require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => $this->season->GetNavigateUrl()); if ($this->season->MatchTypes()->Contains(MatchType::LEAGUE)) { $tabs['Table'] = $this->season->GetTableUrl(); } if (count($this->season->GetTeams())) { $tabs['Map'] = $this->season->GetMapUrl(); } $tabs['Statistics'] = ''; echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php if (!$has_player_stats) { echo "<p>There aren't any statistics for the " . htmlentities($this->season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . ' yet.</p> <p>To find out how to add them, see <a href="/play/manage/website/matches-and-results-why-you-should-add-yours/">Matches and results - why you should add yours</a>.</p>' . "<p>You can also view the <a href=\"" . htmlentities($this->season->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . "\">" . htmlentities($this->season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . " page</a>.</p>"; } else { require_once "_summary-controls.php"; } # 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', htmlentities('More statistics for the ' . $this->competition->GetName(), ENT_QUOTES, "UTF-8", false)); $season_list = new SeasonListControl($this->competition->GetSeasons()); $season_list->SetExcludedSeasons(array($this->season)); $season_list->SetUrlMethod('GetStatisticsUrl'); # Override XHTML to add link to competition stats $season_list_xhtml = $season_list->__toString(); $season_list_xhtml = str_replace("<ul>", "<ul><li><a href=\"" . htmlentities($this->competition->GetStatisticsUrl(), ENT_QUOTES, "UTF-8", false) . "\">All seasons</a></li>", (string) $season_list_xhtml); echo $season_list_xhtml; } ?> </div> </div> <?php }