function OnPreRender()
 {
     /* @var $o_season Season */
     /* @var $o_team Team */
     $this->SetCaption($this->o_competition->GetName());
     $o_headings = new XhtmlRow(array('Name of team', 'Ground address', 'Contact details'));
     $o_headings->SetIsHeader(true);
     $this->AddRow($o_headings);
     foreach ($this->o_competition->GetLatestSeason()->GetTeams() as $o_team) {
         if ($o_team instanceof Team) {
             $o_row = new XhtmlRow();
             $o_row->AddCell(new XhtmlAnchor(Html::Encode($o_team->GetName()), $o_team->GetEditTeamUrl()));
             $o_row->AddCell(new PostalAddressControl($o_team->GetGround()->GetAddress()));
             $private = $o_team->GetPrivateContact();
             $public = $o_team->GetContact();
             $private_header = '<h2 style="margin:0; font-size:1.1em; color: #900;">Private</h2>';
             if ($private and $public) {
                 $contact = $public . $private_header . $private;
             } else {
                 $contact = $private ? $private_header . $private : $public;
             }
             $o_row->AddCell(nl2br(XhtmlMarkup::ApplySimpleTags(XhtmlMarkup::ApplyLinks($contact, true))));
             $this->AddRow($o_row);
         }
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->performance_data as $performance) {
         $current_value = $performance["wickets"];
         if ($current_value != $last_value) {
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $fields = array();
         $position = new XhtmlCell(false, $pos);
         $position->SetCssClass("position");
         $fields[] = $position;
         $bowler = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["bowler_url"] . '">' . $performance["bowler_name"] . "</a>");
         $bowler->SetCssClass("player");
         $bowler->AddAttribute("typeof", "schema:Person");
         $bowler->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["bowler_url"]);
         $fields[] = $bowler;
         $catcher = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["catcher_url"] . '">' . $performance["catcher_name"] . "</a>");
         $catcher->SetCssClass("player");
         $catcher->AddAttribute("typeof", "schema:Person");
         $catcher->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["catcher_url"]);
         $fields[] = $catcher;
         $team = new XhtmlCell(false, $performance["team_name"]);
         $team->SetCssClass("team");
         $fields[] = $team;
         $matches = new XhtmlCell(false, $performance["total_matches"]);
         $matches->SetCssClass("numeric");
         $fields[] = $matches;
         $wickets = new XhtmlCell(false, $performance["wickets"]);
         $wickets->SetCssClass("numeric");
         $fields[] = $wickets;
         $row = new XhtmlRow($fields);
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->bowling_data as $bowling) {
         $current_value = $bowling["wickets"] . "/" . $bowling["runs_conceded"];
         if ($current_value != $last_value) {
             # If 11th value is not same as 10th, stop. This can happen because DB query sees selects all performances with the same number of wickets as the tenth.
             if (!is_null($this->max_results) and $i > $this->max_results) {
                 break;
             }
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $position = new XhtmlCell(false, $pos);
         $position->SetCssClass("position");
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $bowling["player_url"] . '">' . $bowling["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $bowling["player_url"]);
         if ($this->display_team) {
             $team = new XhtmlCell(false, $bowling["team_name"]);
             $team->SetCssClass("team");
         }
         $opposition = new XhtmlCell(false, $bowling["opposition_name"]);
         $opposition->SetCssClass("team");
         $date = new XhtmlCell(false, Date::BritishDate($bowling["match_time"], false, true, $this->display_team));
         $date->SetCssClass("date");
         $wickets = new XhtmlCell(false, $bowling["wickets"]);
         $wickets->SetCssClass("numeric");
         $runs = new XhtmlCell(false, $bowling["runs_conceded"]);
         $runs->SetCssClass("numeric");
         if ($this->display_team) {
             $row = new XhtmlRow(array($position, $player, $team, $opposition, $date, $wickets, $runs));
         } else {
             $row = new XhtmlRow(array($position, $player, $opposition, $date, $wickets, $runs));
         }
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 function OnPreRender()
 {
     /* @var $o_team Team */
     /* @var $o_match Match */
     $a_data_to_bind = array();
     $i_played = 1;
     $i_won = 2;
     $i_lost = 3;
     $i_tie = 4;
     $i_noresult = 5;
     $i_runs_for = 6;
     $i_runs_against = 7;
     $i_points = 8;
     # Build an array of teams, and initiate an array of data for each team
     foreach ($this->o_season->GetTeams() as $o_team) {
         if ($o_team instanceof Team and !is_object($this->o_season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $o_team->GetId()))) {
             $a_team_data = array();
             $a_team_data[0] = new XhtmlAnchor(htmlentities($o_team->GetName(), ENT_QUOTES, "UTF-8", false), $o_team->GetNavigateUrl());
             $a_team_data[$i_played] = 0;
             $a_team_data[$i_won] = 0;
             $a_team_data[$i_lost] = 0;
             $a_team_data[$i_tie] = 0;
             $a_team_data[$i_noresult] = 0;
             if ($this->o_season->GetShowTableRunsScored()) {
                 $a_team_data[$i_runs_for] = 0;
             }
             if ($this->o_season->GetShowTableRunsConceded()) {
                 $a_team_data[$i_runs_against] = 0;
             }
             $a_team_data[$i_points] = 0;
             $a_data_to_bind[$o_team->GetId()] =& $a_team_data;
             unset($a_team_data);
         }
     }
     # Look at matches to build data for each team
     foreach ($this->o_season->GetMatches() as $o_match) {
         # Discount matches in the future
         if ($o_match->GetStartTime() >= gmdate('U')) {
             break;
         }
         # Discount non-league matches
         if ($o_match->GetMatchType() != MatchType::LEAGUE) {
             continue;
         }
         # Discount postponed matches
         if ($o_match->Result()->GetResultType() == MatchResult::POSTPONED) {
             continue;
         }
         # Discount matches where a team has withdrawn from the league
         if (is_object($this->o_season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $o_match->GetHomeTeamId()))) {
             continue;
         }
         if (is_object($this->o_season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $o_match->GetAwayTeamId()))) {
             continue;
         }
         # Make a note of missing results, to excuse inaccuracies
         if ($o_match->Result()->GetResultType() == MatchResult::UNKNOWN) {
             $this->a_results_missing[] = '<a href="' . Html::Encode($o_match->GetNavigateUrl()) . '">' . Html::Encode($o_match->GetTitle()) . '</a> &#8211; ' . Html::Encode($o_match->GetStartTimeFormatted());
             continue;
         }
         # Home team
         $i_home = $o_match->GetHomeTeamId();
         if (array_key_exists($i_home, $a_data_to_bind)) {
             $a_data_to_bind[$i_home][$i_played]++;
             if ($o_match->Result()->GetIsHomeWin()) {
                 $a_data_to_bind[$i_home][$i_won]++;
             } else {
                 if ($o_match->Result()->GetIsAwayWin()) {
                     $a_data_to_bind[$i_home][$i_lost]++;
                 } else {
                     if ($o_match->Result()->GetIsEqualResult()) {
                         $a_data_to_bind[$i_home][$i_tie]++;
                     } else {
                         if ($o_match->Result()->GetIsNoResult()) {
                             $a_data_to_bind[$i_home][$i_noresult]++;
                         } else {
                             $a_data_to_bind[$i_home][$i_played]--;
                         }
                     }
                 }
             }
             // safeguard - shouldn't get here
             if ($this->o_season->GetShowTableRunsScored()) {
                 $a_data_to_bind[$i_home][$i_runs_for] = $a_data_to_bind[$i_home][$i_runs_for] + $o_match->Result()->GetHomeRuns();
             }
             if ($this->o_season->GetShowTableRunsConceded()) {
                 $a_data_to_bind[$i_home][$i_runs_against] = $a_data_to_bind[$i_home][$i_runs_against] + $o_match->Result()->GetAwayRuns();
             }
             $a_data_to_bind[$i_home][$i_points] = $a_data_to_bind[$i_home][$i_points] + $o_match->Result()->GetHomePoints();
         }
         # Away team
         $i_away = $o_match->GetAwayTeamId();
         if (array_key_exists($i_away, $a_data_to_bind)) {
             $a_data_to_bind[$i_away][$i_played]++;
             if ($o_match->Result()->GetIsHomeWin()) {
                 $a_data_to_bind[$i_away][$i_lost]++;
             } else {
                 if ($o_match->Result()->GetIsAwayWin()) {
                     $a_data_to_bind[$i_away][$i_won]++;
                 } else {
                     if ($o_match->Result()->GetIsEqualResult()) {
                         $a_data_to_bind[$i_away][$i_tie]++;
                     } else {
                         if ($o_match->Result()->GetIsNoResult()) {
                             $a_data_to_bind[$i_away][$i_noresult]++;
                         } else {
                             $a_data_to_bind[$i_away][$i_played]--;
                         }
                     }
                 }
             }
             // safeguard - shouldn't get here
             if ($this->o_season->GetShowTableRunsScored()) {
                 $a_data_to_bind[$i_away][$i_runs_for] = $a_data_to_bind[$i_away][$i_runs_for] + $o_match->Result()->GetAwayRuns();
             }
             if ($this->o_season->GetShowTableRunsConceded()) {
                 $a_data_to_bind[$i_away][$i_runs_against] = $a_data_to_bind[$i_away][$i_runs_against] + $o_match->Result()->GetHomeRuns();
             }
             $a_data_to_bind[$i_away][$i_points] = $a_data_to_bind[$i_away][$i_points] + $o_match->Result()->GetAwayPoints();
         }
     }
     # Apply points adjustments
     foreach ($this->o_season->PointsAdjustments()->GetItems() as $o_point) {
         /* @var $o_point PointsAdjustment */
         $a_data_to_bind[$o_point->GetTeam()->GetId()][$i_points] += $o_point->GetPoints();
     }
     # Sort the teams so that the highest points come first
     $a_control_array = array();
     foreach ($a_data_to_bind as $a_team_data) {
         $a_control_array[] = $a_team_data[$i_points];
     }
     $a_control_subarray = array();
     foreach ($a_data_to_bind as $a_team_data) {
         $a_control_subarray[] = $a_team_data[$i_played];
     }
     array_multisort($a_control_array, SORT_DESC, $a_control_subarray, SORT_DESC, $a_data_to_bind);
     # Display the data
     $this->BindArray($a_data_to_bind);
     # Add withdrawn teams at the end of the table
     foreach ($this->o_season->TeamsWithdrawnFromLeague() as $team) {
         /* @var $team Team */
         $withdrawn_row = new XhtmlRow(array(new XhtmlAnchor(htmlentities($team->GetName(), ENT_QUOTES, "UTF-8", false), $team->GetNavigateUrl()), 'Withdrew from league'));
         $withdrawn_row->SetCssClass('withdrawn');
         $this->AddRow($withdrawn_row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->batting_data as $batting) {
         $current_value = $batting["runs_scored"];
         $not_out = ($batting["how_out"] == Batting::NOT_OUT or $batting["how_out"] == Batting::RETIRED or $batting["how_out"] == Batting::RETIRED_HURT);
         if ($not_out) {
             $current_value .= "*";
         }
         if ($current_value != $last_value) {
             # If 11th value is not same as 10th, stop. This can happen because DB query sees 40* and 40 as equal, but they're not.
             if (!is_null($this->max_results) and $i > $this->max_results) {
                 break;
             }
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $position = new XhtmlCell(false, $pos);
         $position->SetCssClass("position");
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $batting["player_url"] . '">' . $batting["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $batting["player_url"]);
         if ($this->display_team) {
             $team = new XhtmlCell(false, $batting["team_name"]);
             $team->SetCssClass("team");
         }
         $opposition = new XhtmlCell(false, $batting["opposition_name"]);
         $opposition->SetCssClass("team");
         $date = new XhtmlCell(false, Date::BritishDate($batting["match_time"], false, true, $this->display_team));
         $date->SetCssClass("date");
         $runs = new XhtmlCell(false, $current_value);
         $runs->SetCssClass("numeric");
         if (!$not_out) {
             $runs->AddCssClass("out");
         }
         $balls_faced = is_null($batting["balls_faced"]) ? "&#8211;" : '<span class="balls-faced">' . $batting["balls_faced"] . '</span>';
         $balls = new XhtmlCell(false, $balls_faced);
         $balls->SetCssClass("numeric");
         if ($this->display_team) {
             $row = new XhtmlRow(array($position, $player, $team, $opposition, $date, $runs, $balls));
         } else {
             $row = new XhtmlRow(array($position, $player, $opposition, $date, $runs, $balls));
         }
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     if (is_array($this->data)) {
         foreach ($this->data as $performance) {
             $current_value = $performance["statistic"];
             if ($current_value !== $last_value) {
                 $pos = $i;
                 $last_value = $current_value;
             } else {
                 $pos = "=";
             }
             $i++;
             $fields = array();
             $position = new XhtmlCell(false, $pos);
             $position->SetCssClass("position");
             $fields[] = $position;
             $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["player_url"] . '">' . $performance["player_name"] . "</a>");
             $player->SetCssClass("player");
             $player->AddAttribute("typeof", "schema:Person");
             $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["player_url"]);
             $fields[] = $player;
             if ($this->display_team) {
                 $team = new XhtmlCell(false, $performance["team_name"]);
                 $team->SetCssClass("team");
                 $fields[] = $team;
             }
             if (array_key_exists("total_matches", $performance)) {
                 $matches = new XhtmlCell(false, $performance["total_matches"]);
                 $matches->SetCssClass("numeric");
                 $fields[] = $matches;
             }
             $aggregate = new XhtmlCell(false, $current_value);
             $aggregate->SetCssClass("numeric");
             $fields[] = $aggregate;
             $row = new XhtmlRow($fields);
             $this->AddRow($row);
         }
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->performance_data as $performance) {
         $current_value = "";
         if (array_key_exists("runs_scored", $performance)) {
             $current_batting_value = $performance["runs_scored"];
             $not_out = ($performance["how_out"] == Batting::NOT_OUT or $performance["how_out"] == Batting::RETIRED or $performance["how_out"] == Batting::RETIRED_HURT);
             if ($not_out) {
                 $current_batting_value .= "*";
             }
             $current_value .= $current_batting_value;
         }
         if (array_key_exists("wickets", $performance)) {
             $current_bowling_value = $performance["wickets"] . "/" . $performance["runs_conceded"];
             $current_value .= $current_bowling_value;
         }
         if (array_key_exists("catches", $performance)) {
             $current_value .= $performance["catches"];
         }
         if (array_key_exists("run_outs", $performance)) {
             $current_value .= $performance["run_outs"];
         }
         if ($current_value != $last_value) {
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $fields = array();
         if ($this->show_position) {
             $position = new XhtmlCell(false, $pos);
             $position->SetCssClass("position");
             $fields[] = $position;
         }
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["player_url"] . '">' . $performance["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["player_url"]);
         $fields[] = $player;
         $match = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["match_url"] . '">' . $performance["match_title"] . "</a>");
         $match->AddAttribute("typeof", "schema:SportsEvent");
         $match->AddAttribute("about", "https://www.stoolball.org.uk/id/match" . $performance["match_url"]);
         $match->SetCssClass("match");
         $fields[] = $match;
         $date = new XhtmlCell(false, Date::BritishDate($performance["match_time"], false, true, true));
         $date->SetCssClass("date");
         $fields[] = $date;
         if (array_key_exists("runs_scored", $performance)) {
             $runs = new XhtmlCell(false, $current_batting_value == "" ? "&#8211;" : $current_batting_value);
             $runs->SetCssClass("numeric");
             if (!$not_out) {
                 $runs->AddCssClass("out");
             }
             $fields[] = $runs;
         }
         if (array_key_exists("wickets", $performance)) {
             $bowling = new XhtmlCell(false, $current_bowling_value == "/" ? "&#8211;" : $current_bowling_value);
             $bowling->SetCssClass("numeric");
             $fields[] = $bowling;
         }
         if (array_key_exists("catches", $performance)) {
             $catches = new XhtmlCell(false, $performance["catches"] == "0" ? "&#8211;" : $performance["catches"]);
             $catches->SetCssClass("numeric");
             $fields[] = $catches;
         }
         if (array_key_exists("run_outs", $performance)) {
             $runouts = new XhtmlCell(false, $performance["run_outs"] == "0" ? "&#8211;" : $performance["run_outs"]);
             $runouts->SetCssClass("numeric");
             $fields[] = $runouts;
         }
         $row = new XhtmlRow($fields);
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     if ($this->matches_with_run_data < 1) {
         $this->SetVisible(false);
         return;
     }
     # Add table of runs
     $this->SetCssClass('runTable');
     $this->SetCaption("Team runs");
     $total_header = new XhtmlCell(true, "Total");
     $total_header->SetCssClass("numeric");
     $run_header = new XhtmlRow(array(new XhtmlCell(true, "Statistic"), $total_header));
     $run_header->SetIsHeader(true);
     $this->AddRow($run_header);
     $matches_cell = new XhtmlCell(false, $this->matches_with_run_data);
     $matches_cell->SetCssClass('numeric');
     $matches_row = new XhtmlRow(array(new XhtmlCell(false, "matches with runs recorded"), $matches_cell));
     $this->AddRow($matches_row);
     if (!is_null($this->runs_scored)) {
         $scored_cell = new XhtmlCell(false, $this->runs_scored);
         $scored_cell->SetCssClass('numeric');
         $scored_row = new XhtmlRow(array(new XhtmlCell(false, "runs scored"), $scored_cell));
         $this->AddRow($scored_row);
     }
     if (!is_null($this->runs_conceded)) {
         $conceded_cell = new XhtmlCell(false, $this->runs_conceded);
         $conceded_cell->SetCssClass('numeric');
         $this->AddRow(new XhtmlRow(array(new XhtmlCell(false, "runs conceded"), $conceded_cell)));
     }
     if (!is_null($this->runs_scored) and !is_null($this->runs_conceded)) {
         $run_difference = $this->runs_scored - $this->runs_conceded;
         if ($run_difference > 0) {
             $run_difference = "+" . $run_difference;
         }
         $difference_cell = new XhtmlCell(false, $run_difference);
         $difference_cell->SetCssClass('numeric');
         $this->AddRow(new XhtmlRow(array(new XhtmlCell(false, "run difference"), $difference_cell)));
     }
     if (!is_null($this->highest_innings)) {
         $best_cell = new XhtmlCell(false, $this->highest_innings);
         $best_cell->SetCssClass('numeric');
         $scored_row = new XhtmlRow(array(new XhtmlCell(false, "highest innings"), $best_cell));
         $this->AddRow($scored_row);
     }
     if (!is_null($this->lowest_innings)) {
         $worst_cell = new XhtmlCell(false, $this->lowest_innings);
         $worst_cell->SetCssClass('numeric');
         $scored_row = new XhtmlRow(array(new XhtmlCell(false, "lowest innings"), $worst_cell));
         $this->AddRow($scored_row);
     }
     if (!is_null($this->average_innings)) {
         $average_cell = new XhtmlCell(false, round($this->average_innings, 0));
         $average_cell->SetCssClass('numeric');
         $average_row = new XhtmlRow(array(new XhtmlCell(false, "average innings"), $average_cell));
         $this->AddRow($average_row);
     }
     parent::OnPreRender();
 }