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);
         }
     }
 }
 public function __construct(Competition $competition)
 {
     $this->competition = $competition;
     $season = $competition->GetLatestSeason();
     $teams = $season->GetTeams();
     $keywords = array();
     $content = array();
     $keywords[] = $competition->GetName();
     foreach ($teams as $team) {
         $keywords[] = $team->GetName();
         $keywords[] = $team->GetGround()->GetAddress()->GetLocality();
         $keywords[] = $team->GetGround()->GetAddress()->GetTown();
     }
     $content[] = $competition->GetIntro();
     $content[] = $competition->GetContact();
     $this->searchable = new SearchItem("competition", "competition" . $competition->GetId(), $competition->GetNavigateUrl(), $competition->GetName());
     $this->searchable->WeightOfType(700);
     $this->searchable->Description($this->GetSearchDescription());
     $this->searchable->Keywords(implode(" ", $keywords));
     $this->searchable->FullText(implode(" ", $content));
     $related = '<ul>';
     if ($season->GetShowTable()) {
         $related .= '<li><a href="' . $season->GetTableUrl() . '">Table</a></li>';
     }
     $related .= '<li><a href="' . $competition->GetCompetitionMapUrl() . '">Map</a></li>' . '<li><a href="' . $competition->GetStatisticsUrl() . '">Statistics</a></li>' . '</ul>';
     $this->searchable->RelatedLinksHtml($related);
 }
 /**
  * Reads the notification email address for a given competition
  *
  * @param Competition $o_comp
  * @return string
  */
 public function ReadNotificationEmail(Competition $o_comp)
 {
     $s_email = '';
     $s_sql = 'SELECT notification_email FROM ' . $this->GetSettings()->GetTable('Competition') . ' WHERE competition_id = ' . Sql::ProtectNumeric($o_comp->GetId());
     $o_result = $this->GetDataConnection()->query($s_sql);
     if (is_object($o_result)) {
         $o_row = $o_result->fetch();
         $s_email = $o_row->notification_email;
     }
     $o_result->closeCursor();
     unset($o_result);
     return $s_email;
 }