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 OnLoadPageData() { /* @var $o_competition Competition */ /* @var $o_season_manager SeasonManager */ # get id of competition $i_id = $this->o_comp_manager->GetItemId($this->o_competition); # no need to read competition data if creating a new competition # unlike some pages though, re-read after a save because not all info is # posted back if ($i_id) { # get competition info $this->o_comp_manager->ReadById(array($i_id)); $this->o_competition = $this->o_comp_manager->GetFirst(); # Get all seasons $a_comp_ids = array($i_id); $this->o_season_manager->ReadByCompetitionId($a_comp_ids); $this->o_competition->SetSeasons($this->o_season_manager->GetItems()); } # tidy up unset($this->o_comp_manager); unset($this->o_season_manager); }