public function OnLoadPageData() { /* @var $topic ForumTopic */ /* @var $match Match */ # new data manager $match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection()); # get match $match_manager->ReadByMatchId(array($_GET['item'])); $match_manager->ExpandMatchScorecards(); $this->match = $match_manager->GetFirst(); # must have found a match if (!$this->match instanceof Match) { header('Location: /matches/'); exit; } # Update search engine if ($this->match->GetSearchUpdateRequired()) { require_once "search/match-search-adapter.class.php"; $this->SearchIndexer()->DeleteFromIndexById("match" . $this->match->GetId()); $adapter = new MatchSearchAdapter($this->match); $this->SearchIndexer()->Index($adapter->GetSearchableItem()); $this->SearchIndexer()->CommitChanges(); $match_manager->SearchUpdated($this->match->GetId()); } # tidy up unset($match_manager); # Get comments $this->review_item = new ReviewItem($this->GetSettings()); $this->review_item->SetId($this->match->GetId()); $this->review_item->SetType(ContentType::STOOLBALL_MATCH); $this->review_item->SetTitle($this->match->GetTitle()); $this->review_item->SetNavigateUrl("https://" . $this->GetSettings()->GetDomain() . $this->review_item->GetNavigateUrl()); $this->review_item->SetLinkedDataUri($this->match->GetLinkedDataUri()); $topic_manager = new TopicManager($this->GetSettings(), $this->GetDataConnection()); if ($this->IsPostback()) { $this->SavePostedComments($topic_manager); } $topic_manager->ReadCommentsForReviewItem($this->review_item); $this->topic = $topic_manager->GetFirst(); unset($topic_manager); if ($this->match->GetMatchType() == MatchType::TOURNAMENT or $this->match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { # Get stats highlights require_once 'stoolball/statistics/statistics-manager.class.php'; $statistics_manager = new StatisticsManager($this->GetSettings(), $this->GetDataConnection()); if ($this->match->GetMatchType() == MatchType::TOURNAMENT) { $statistics_manager->FilterByTournament(array($this->match->GetId())); } else { $statistics_manager->FilterByTournament(array($this->match->GetTournament()->GetId())); } $statistics_manager->FilterMaxResults(1); $this->best_batting = $statistics_manager->ReadBestBattingPerformance(); $this->best_bowling = $statistics_manager->ReadBestBowlingPerformance(); $this->most_runs = $statistics_manager->ReadBestPlayerAggregate("runs_scored"); $this->most_wickets = $statistics_manager->ReadBestPlayerAggregate("wickets"); $this->most_catches = $statistics_manager->ReadBestPlayerAggregate("catches"); # See what stats we've got available $best_batting_count = count($this->best_batting); $best_bowling_count = count($this->best_bowling); $best_batters = count($this->most_runs); $best_bowlers = count($this->most_wickets); $best_catchers = count($this->most_catches); $this->has_player_stats = ($best_batting_count or $best_batters or $best_bowling_count or $best_bowlers or $best_catchers); if (!$this->has_player_stats) { $player_of_match = $statistics_manager->ReadBestPlayerAggregate("player_of_match"); $this->has_player_stats = (bool) count($player_of_match); } unset($statistics_manager); } }