public function OnLoadPageData() { # Read the player data if (a) it's not a new player and (b) it's not in the postback data if ($this->player->GetId() and !$this->IsPostback()) { $this->player_manager->ReadPlayerById($this->player->GetId()); $this->player = $this->player_manager->GetFirst(); } unset($this->player_manager); # ensure we have a player if (!$this->player instanceof Player) { $this->Redirect(); } # if it's a new player, get the team details if (!$this->player->GetId() or $this->add_player_already_exists) { if (!$this->team instanceof Team) { require_once "stoolball/team-manager.class.php"; $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); $team_manager->ReadById(array($this->player->Team()->GetId())); $this->team = $team_manager->GetFirst(); unset($team_manager); } $this->player->Team()->SetName($this->team->GetName()); $this->player->Team()->SetShortUrl($this->team->GetShortUrl()); } # ensure we have permission $this->CheckForPermission($this->player->Team()); }
/** * Create new TeamNameControl * @param Team $team * @param string $container_element */ public function __construct(Team $team, $container_element) { parent::XhtmlElement($container_element); $name = $team->GetName(); $type = is_null($team->GetPlayerType()) ? '' : PlayerType::Text($team->GetPlayerType()); if ($type and strpos(strtolower(str_replace("'", '', $name)), strtolower(str_replace("'", '', $type))) !== false) { $type = ""; } $town = (is_null($team->GetGround()) or is_null($team->GetGround()->GetAddress())) ? "" : $team->GetGround()->GetAddress()->GetTown(); if ($town and strpos(strtolower($name), strtolower($town)) !== false) { $town = ""; } if ($type or $town) { $html = '<span property="schema:name">' . htmlentities($name, ENT_QUOTES, "UTF-8", false) . '</span>'; if ($town) { $html .= htmlentities(", {$town}", ENT_QUOTES, "UTF-8", false); } if ($type) { $html .= htmlentities(" ({$type})", ENT_QUOTES, "UTF-8", false); } $this->AddControl($html); } else { $this->AddAttribute("property", "schema:name"); $this->AddControl(htmlentities($name, ENT_QUOTES, "UTF-8", false)); } }
function OnPrePageLoad() { $this->SetPageTitle(is_object($this->team) ? $this->team->GetName() . ': Edit stoolball team' : 'New stoolball team'); $this->SetContentConstraint(StoolballPage::ConstrainText()); $this->LoadClientScript("/scripts/tiny_mce/jquery.tinymce.js"); $this->LoadClientScript("/scripts/tinymce.js"); $this->LoadClientScript("edit-team.js", true); }
function OnPrePageLoad() { if ($this->team instanceof Team) { $this->SetPageTitle('New tournament for ' . $this->team->GetName()); } else { $this->SetPageTitle('New stoolball tournament'); } $this->SetContentCssClass('matchEdit'); $this->SetContentConstraint(StoolballPage::ConstrainText()); $this->LoadClientScript('/scripts/tournament-edit-control-3.js'); }
/** * Re-build from data posted by this control a single data object which this control is editing * * @param int $i_counter * @param int $i_id */ protected function BuildPostedItem($i_counter = null, $i_id = null) { $s_key = $this->GetNamingPrefix() . 'Team' . $i_counter; $team = new Team($this->GetSettings()); if (isset($_POST[$s_key]) and is_numeric($_POST[$s_key])) { $team->SetId($_POST[$s_key]); } $s_key = $this->GetNamingPrefix() . 'TeamValue' . $i_counter; if (isset($_POST[$s_key])) { $team->SetName($_POST[$s_key]); } # Infer player type from name if (stristr($team->GetName(), "ladies")) { $team->SetPlayerType(PlayerType::LADIES); } else { if (stristr($team->GetName(), "mixed")) { $team->SetPlayerType(PlayerType::MIXED); } else { if (stristr($team->GetName(), "Junior mixed")) { $team->SetPlayerType(PlayerType::JUNIOR_MIXED); } else { if (stristr($team->GetName(), "junior") or stristr($team->GetName(), "girls")) { $team->SetPlayerType(PlayerType::GIRLS); } } } } if ($team->GetId() or $team->GetName()) { $this->DataObjects()->Add($team); } else { $this->IgnorePostedItem($i_counter); } }
function OnPageLoad() { echo new XhtmlElement('h1', 'Delete team: ' . htmlentities($this->data_object->GetName(), ENT_QUOTES, "UTF-8", false)); if ($this->deleted) { ?> <p>The team has been deleted.</p> <p><a href="/teams">View all teams</a></p> <?php } else { if ($this->has_permission) { ?> <p>Deleting a team cannot be undone. All players will be deleted, and the team will be removed from existing matches.</p> <p>Are you sure you want to delete this team?</p> <form action="<?php echo htmlentities($this->data_object->GetDeleteTeamUrl(), ENT_QUOTES, "UTF-8", false); ?> " method="post" class="deleteButtons"> <div> <input type="submit" value="Delete team" name="delete" /> <input type="submit" value="Cancel" name="cancel" /> </div> </form> <?php $this->AddSeparator(); require_once 'stoolball/user-edit-panel.class.php'; $panel = new UserEditPanel($this->GetSettings(), 'this team'); $panel->AddLink('view this team', $this->data_object->GetNavigateUrl()); $panel->AddLink('edit this team', $this->data_object->GetEditTeamUrl()); echo $panel; } else { ?> <p>Sorry, you're not allowed to delete this team.</p> <p><a href="<?php echo htmlentities($this->data_object->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false); ?> ">Go back to the team</a></p> <?php } } }
function OnPrePageLoad() { if (isset($this->i_season_id)) { $this->SetPageTitle('New ' . MatchType::Text($this->i_match_type) . ' in ' . $this->season->GetCompetitionName()); } else { if ($this->team instanceof Team) { $this->SetPageTitle('New ' . MatchType::Text($this->i_match_type) . ' for ' . $this->team->GetName()); } } $this->SetContentConstraint(StoolballPage::ConstrainText()); $this->SetContentCssClass('matchEdit'); $this->LoadClientScript('/scripts/match-fixture-edit-control-5.js'); }
public function __construct(Team $team) { $this->team = $team; $this->searchable = new SearchItem(); $this->searchable->SearchItemId("team" . $team->GetId()); $this->searchable->SearchItemType("team"); $this->searchable->Url($team->GetNavigateUrl()); $this->searchable->Title($team->GetNameAndType()); $this->searchable->Description($this->GetSearchDescription()); $this->searchable->WeightOfType(1000); $keywords = array($team->GetName(), $team->GetGround()->GetAddress()->GetLocality(), $team->GetGround()->GetAddress()->GetTown()); $this->searchable->Keywords(implode(" ", $keywords)); $content = array($team->GetGround()->GetAddress()->GetAdministrativeArea(), $team->GetIntro(), $team->GetPlayingTimes(), $team->GetCost(), $team->GetContact()); $this->searchable->FullText(implode(" ", $content)); $this->searchable->RelatedLinksHtml('<ul>' . '<li><a href="' . $team->GetStatsNavigateUrl() . '">Statistics</a></li>' . '<li><a href="' . $team->GetPlayersNavigateUrl() . '">Players</a></li>' . '<li><a href="' . $team->GetCalendarNavigateUrl() . '">Match calendar</a></li>' . '</ul>'); }
function OnPrePageLoad() { $this->SetOpenGraphType("sports_team"); $this->SetPageTitle($this->team->GetName() . ' stoolball team'); require_once "search/team-search-adapter.class.php"; $adapter = new TeamSearchAdapter($this->team); $this->SetPageDescription($adapter->GetSearchDescription()); $this->SetContentConstraint(StoolballPage::ConstrainColumns()); if (!$this->is_one_time_team) { $this->LoadClientScript("/scripts/lib/chart.min.js"); $this->LoadClientScript("/scripts/chart.js?v=2"); $this->LoadClientScript("team.js", true); ?> <!--[if lte IE 8]><script src="/scripts/lib/excanvas.compiled.js"></script><![endif]--><?php } }
function OnPrePageLoad() { if (!is_null($this->team)) { $this->SetPageTitle('Match results for ' . $this->team->GetName()); } else { if (!is_null($this->season)) { $this->SetPageTitle('Match results for ' . $this->season->GetCompetitionName()); } else { if (!is_null($this->tournament)) { $this->SetPageTitle('Match results for ' . $this->tournament->GetTitle()); } } } $this->LoadClientScript('/scripts/match-results-3.js'); $this->LoadClientScript("/scripts/tiny_mce/jquery.tinymce.js"); $this->LoadClientScript("/scripts/tinymce.js"); }
/** * Replace the words "home" and "away" with the names of the relevant teams * * @param string $s_text * @param Team $o_home * @param Team $o_away * @return string */ private function NameTeams($s_text, Team $o_home, Team $o_away) { $s_text = str_ireplace('Home', $o_home->GetName(), $s_text); $s_text = str_ireplace('Away', $o_away->GetName(), $s_text); return $s_text; }
/** * Gets the name of the team * * @return string */ public function GetTeamName() { return $this->team instanceof Team ? $this->team->GetName() : null; }
function OnPageLoad() { require_once 'stoolball/statistics-calculator.class.php'; $calculator = new StatisticsCalculator(); $calculator->AnalyseMatchData($this->stats, $this->team); $title = "Team statistics for " . $this->team->GetNameAndType(); if ($this->season) { $title .= " in the {$this->season} season"; } echo "<h1>" . htmlentities($title, ENT_QUOTES, "UTF-8", false) . "</h1>"; # See what stats we've got available $has_team_stats = $calculator->EnoughDataForStats($this->season); $has_most_runs = count($this->most_runs); $has_most_wickets = count($this->most_wickets); $has_catch_stats = count($this->most_catches); $has_run_outs = count($this->most_run_outs); $has_player_of_match_stats = count($this->most_player_of_match); $has_player_stats = ($has_most_runs or $has_most_wickets or $has_catch_stats or $has_run_outs or $has_player_of_match_stats); require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => $this->team->GetNavigateUrl()); if ($has_player_stats) { $tabs['Players'] = $this->team->GetPlayersNavigateUrl(); } $tabs['Statistics'] = ''; echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php if (!$has_team_stats and !$has_player_stats) { $scope = $this->team->GetNameAndType(); if ($this->season) { $scope .= " in the {$this->season} season"; } $scope = htmlentities($scope, ENT_QUOTES, "UTF-8", false); echo "<p>There aren't any statistics for {$scope} 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>'; } else { require_once 'stoolball/team-runs-table.class.php'; require_once 'stoolball/statistics/player-statistics-table.class.php'; echo '<div class="statsGroup">'; if ($has_team_stats or $has_most_runs) { echo '<div class="statsColumns"> <h2>Batting statistics</h2> <div class="statsColumn">'; if ($has_most_runs) { echo new PlayerStatisticsTable("Most runs", "Runs", $this->most_runs, false); if ($has_most_runs >= 10) { echo '<p class="statsViewAll"><a href="/play/statistics/most-runs' . $this->statistics_query . '">Most runs – view all and filter</a></p>'; } } echo "</div><div class=\"statsColumn\">"; if ($has_team_stats) { echo new TeamRunsTable($calculator->TotalMatchesWithRunData($this->season), $calculator->RunsScored($this->season), $calculator->RunsConceded($this->season), $calculator->HighestInnings($this->season), $calculator->LowestInnings($this->season), $calculator->AverageInnings($this->season)); } if ($has_most_runs) { echo '<p class="statsViewAll"><a href="/play/statistics/individual-scores' . $this->statistics_query . '">Individual scores</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/most-scores-of-100' . $this->statistics_query . '">Most scores of 100 or more</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/most-scores-of-50' . $this->statistics_query . '">Most scores of 50 or more</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/batting-average' . $this->statistics_query . '">Batting averages</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/batting-strike-rate' . $this->statistics_query . '">Batting strike rates</a></p>'; } echo "</div></div>"; } if ($has_most_wickets or $has_team_stats) { echo '<div class="statsColumns"> <h2>Bowling statistics and match results</h2> <div class="statsColumn">'; if ($has_most_wickets) { # Show top bowlers $table = new PlayerStatisticsTable("Most wickets", "Wickets", $this->most_wickets, false); $table->SetCssClass($table->GetCssClass() . " bowling"); echo $table; if ($has_most_wickets >= 10) { echo '<p class="statsViewAll"><a href="/play/statistics/most-wickets' . $this->statistics_query . '">Most wickets – view all and filter</a></p>'; } echo '<p class="statsViewAll"><a href="/play/statistics/most-5-wickets' . $this->statistics_query . '">Most times taking 5 wickets in an innings</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/most-wickets-by-bowler-and-catcher' . $this->statistics_query . '">Most wickets by a bowling and catching combination</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/bowling-performances' . $this->statistics_query . '">Bowling performances</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/bowling-average' . $this->statistics_query . '">Bowling averages</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/economy-rate' . $this->statistics_query . '">Economy rates</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/bowling-strike-rate' . $this->statistics_query . '">Bowling strike rates</a></p>'; } ?> </div><div class="statsColumn"> <span class="chart-js-template" id="all-results-chart"></span> <span class="chart-js-template" id="home-results-chart"></span> <span class="chart-js-template" id="away-results-chart"></span> </div></div> <?php } ?> <span class="chart-js-template" id="opponents-chart"></span><?php if ($has_catch_stats or $has_run_outs) { echo '<div class="statsColumns"> <h2>Fielding statistics</h2> <div class="statsColumn">'; if ($has_catch_stats) { # Show top catchers $table = new PlayerStatisticsTable("Most catches", "Catches", $this->most_catches, false); $table->SetCssClass($table->GetCssClass() . " bowling"); echo $table; if ($has_catch_stats >= 10) { echo '<p class="statsViewAll"><a href="/play/statistics/most-catches' . $this->statistics_query . '">Most catches – view all and filter</a></p>'; } echo '<p class="statsViewAll"><a href="/play/statistics/most-catches-in-innings' . $this->statistics_query . '">Most catches in an innings – view all and filter</a></p>'; } echo "</div><div class=\"statsColumn\">"; if ($has_run_outs) { $table = new PlayerStatisticsTable("Most run-outs", "Run-outs", $this->most_run_outs, false); $table->SetCssClass($table->GetCssClass() . " bowling"); echo $table; if ($has_run_outs >= 10) { echo '<p class="statsViewAll"><a href="/play/statistics/most-run-outs' . $this->statistics_query . '">Most run-outs – view all and filter</a></p>'; } echo '<p class="statsViewAll"><a href="/play/statistics/most-run-outs-in-innings' . $this->statistics_query . '">Most run-outs in an innings – view all and filter</a></p>'; } echo "</div></div>"; } echo '<h2>All-round performance statistics</h2>'; if ($has_player_of_match_stats) { echo new PlayerStatisticsTable("Most player of the match nominations", "Nominations", $this->most_player_of_match, false); echo '<p class="statsViewAll"><a href="/play/statistics/player-performances' . $this->statistics_query . '">Player performances – view all and filter</a></p>'; echo '<p class="statsViewAll"><a href="/play/statistics/player-of-match' . $this->statistics_query . '">Player of the match nominations – view all and filter</a></p>'; if ($has_player_of_match_stats >= 10) { echo '<p class="statsViewAll"><a href="/play/statistics/most-player-of-match' . $this->statistics_query . '">Most player of the match nominations – view all and filter</a></p>'; } } else { echo '<p><a href="/play/statistics/player-performances' . $this->statistics_query . '">Player performances – view all and filter</a></p>'; } echo "</div>"; # close statsGroup # Link to other seasons if (count($calculator->SeasonYears()) > 1) { echo new XhtmlElement('h2', 'More statistics for ' . htmlentities($this->team->GetName(), ENT_QUOTES, "UTF-8", false)); echo '<div class="season-list"><ul>'; if ($this->season) { echo "<li><a href=\"" . htmlentities($this->team->GetStatsNavigateUrl(), ENT_QUOTES, "UTF-8", false) . "\">All seasons</a></li>"; } foreach ($calculator->SeasonYears() as $season_years) { $season_url = str_replace("/", "-", $season_years); # Link to season if it's not the current season. Important to use !== because # we're comparing numeric strings and with != 2009-10 is equal to 2009 if (!isset($_GET['params']) or $season_url !== $_GET["params"]) { echo "<li><a href=\"" . htmlentities($this->team->GetStatsNavigateUrl() . "/" . $season_url, ENT_QUOTES, "UTF-8", false) . "\">" . htmlentities($season_years, ENT_QUOTES, "UTF-8", false) . " season</a></li>"; } } echo "</ul></div>"; } } ?> </div> </div> <?php }
private function CreateTeamLink(Team $team) { $span = new XhtmlElement('span'); $span->AddAttribute("typeof", "schema:SportsTeam"); $span->AddAttribute("about", $team->GetLinkedDataUri()); $link = new XhtmlElement('a', Html::Encode($team->GetName())); $link->AddAttribute("property", "schema:name"); $link->AddAttribute('href', $team->GetNavigateUrl()); $link->AddAttribute("rel", "schema:url"); $span->AddControl($link); return $span; }
/** * Sets up controls for pages 2/3 of the wizard * @param Match $match * @param Team $batting_team * @param Collection $batting_data * @param Team $bowling_team * @param Collection $bowling_data * @param int $total * @param int $wickets_taken * @return void */ private function CreateScorecardControls(Match $match, Team $batting_team, Collection $batting_data, Team $bowling_team, Collection $bowling_data, $total, $wickets_taken) { require_once "xhtml/tables/xhtml-table.class.php"; $batting_table = new XhtmlTable(); $batting_table->SetCaption($batting_team->GetName() . "'s batting"); $batting_table->SetCssClass("scorecard scorecardEditor batting"); $out_by_header = new XhtmlCell(true, '<span class="small">Fielder</span><span class="large">Caught<span class="wrapping-hair-space"> </span>/<span class="wrapping-hair-space"> </span><span class="nowrap">run-out by</span></span>'); $out_by_header->SetCssClass("dismissedBy"); $bowler_header = new XhtmlCell(true, "Bowler"); $bowler_header->SetCssClass("bowler"); $score_header = new XhtmlCell(true, "Runs"); $score_header->SetCssClass("numeric"); $balls_header = new XhtmlCell(true, "Balls"); $balls_header->SetCssClass("numeric"); $batting_headings = new XhtmlRow(array("Batsman", "How out", $out_by_header, $bowler_header, $score_header, $balls_header)); $batting_headings->SetIsHeader(true); $batting_table->AddRow($batting_headings); $batting_data->ResetCounter(); $byes = null; $wides = null; $no_balls = null; $bonus = null; # Loop = max players + 4, because if you have a full scorecard you have to keep looping to get the 4 extras players for ($i = 1; $i <= $match->GetMaximumPlayersPerTeam() + 4; $i++) { $batting = $batting_data->MoveNext() ? $batting_data->GetItem() : null; /* @var $batting Batting */ # Grab the scores for extras players to use later if (!is_null($batting)) { switch ($batting->GetPlayer()->GetPlayerRole()) { case Player::BYES: $byes = $batting->GetRuns(); break; case Player::WIDES: $wides = $batting->GetRuns(); break; case Player::NO_BALLS: $no_balls = $batting->GetRuns(); break; case Player::BONUS_RUNS: $bonus = $batting->GetRuns(); break; } } # Don't write a table row for the last four loops, we'll do that next because they're different if ($i <= $match->GetMaximumPlayersPerTeam()) { $player = new TextBox("batName{$i}", (is_null($batting) or !$batting->GetPlayer()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetPlayer()->GetName(), $this->IsValidSubmit()); $player->SetMaxLength(100); $player->AddAttribute("autocomplete", "off"); $player->AddCssClass("player batsman team" . $batting_team->GetId()); $how = new XhtmlSelect("batHowOut{$i}", null, $this->IsValidSubmit()); $how->SetCssClass("howOut"); $how->AddOptions(array(Batting::DID_NOT_BAT => Batting::Text(Batting::DID_NOT_BAT), Batting::NOT_OUT => Batting::Text(Batting::NOT_OUT), Batting::CAUGHT => Batting::Text(Batting::CAUGHT), Batting::BOWLED => Batting::Text(Batting::BOWLED), Batting::CAUGHT_AND_BOWLED => str_replace(" and ", "/", Batting::Text(Batting::CAUGHT_AND_BOWLED)), Batting::RUN_OUT => Batting::Text(Batting::RUN_OUT), Batting::BODY_BEFORE_WICKET => "bbw", Batting::HIT_BALL_TWICE => Batting::Text(Batting::HIT_BALL_TWICE), Batting::TIMED_OUT => Batting::Text(Batting::TIMED_OUT), Batting::RETIRED_HURT => Batting::Text(Batting::RETIRED_HURT), Batting::RETIRED => Batting::Text(Batting::RETIRED), Batting::UNKNOWN_DISMISSAL => Batting::Text(Batting::UNKNOWN_DISMISSAL)), null); if (!is_null($batting) and $batting->GetPlayer()->GetPlayerRole() == Player::PLAYER and $this->IsValidSubmit()) { $how->SelectOption($batting->GetHowOut()); } $out_by = new TextBox("batOutBy{$i}", (is_null($batting) or is_null($batting->GetDismissedBy()) or !$batting->GetDismissedBy()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetDismissedBy()->GetName(), $this->IsValidSubmit()); $out_by->SetMaxLength(100); $out_by->AddAttribute("autocomplete", "off"); $out_by->AddCssClass("player team" . $bowling_team->GetId()); $bowled_by = new TextBox("batBowledBy{$i}", (is_null($batting) or is_null($batting->GetBowler()) or !$batting->GetBowler()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetBowler()->GetName(), $this->IsValidSubmit()); $bowled_by->SetMaxLength(100); $bowled_by->AddAttribute("autocomplete", "off"); $bowled_by->AddCssClass("player team" . $bowling_team->GetId()); $runs = new TextBox("batRuns{$i}", (is_null($batting) or $batting->GetPlayer()->GetPlayerRole() != Player::PLAYER) ? "" : $batting->GetRuns(), $this->IsValidSubmit()); $runs->SetCssClass("numeric runs"); $runs->AddAttribute("type", "number"); $runs->AddAttribute("min", "0"); $runs->AddAttribute("autocomplete", "off"); $balls = new TextBox("batBalls{$i}", (is_null($batting) or $batting->GetPlayer()->GetPlayerRole() != Player::PLAYER) ? "" : $batting->GetBallsFaced(), $this->IsValidSubmit()); $balls->SetCssClass("numeric balls"); $balls->AddAttribute("type", "number"); $balls->AddAttribute("min", "0"); $balls->AddAttribute("autocomplete", "off"); $batting_row = new XhtmlRow(array($player, $how, $out_by, $bowled_by, $runs, $balls)); $batting_row->GetFirstCell()->SetCssClass("batsman"); $batting_table->AddRow($batting_row); } } $batting_table->AddRow($this->CreateExtrasRow("batByes", "Byes", "extras", "numeric runs", $byes)); $batting_table->AddRow($this->CreateExtrasRow("batWides", "Wides", "extras", "numeric runs", $wides)); $batting_table->AddRow($this->CreateExtrasRow("batNoBalls", "No balls", "extras", "numeric runs", $no_balls)); $batting_table->AddRow($this->CreateExtrasRow("batBonus", "Bonus or penalty runs", "extras", "numeric runs", $bonus)); $batting_table->AddRow($this->CreateExtrasRow("batTotal", "Total", "totals", "numeric", $total)); $batting_table->AddRow($this->CreateWicketsRow($match, $wickets_taken)); $this->AddControl($batting_table); $total_batsmen = new TextBox("batRows", $match->GetMaximumPlayersPerTeam(), $this->IsValidSubmit()); $total_batsmen->SetMode(TextBoxMode::Hidden()); $this->AddControl($total_batsmen); $bowling_table = new XhtmlTable(); $bowling_table->SetCaption($bowling_team->GetName() . "'s bowling, over-by-over"); $bowling_table->SetCssClass("scorecard scorecardEditor bowling-scorecard bowling"); $over_header = new XhtmlCell(true, 'Balls bowled <span class="qualifier">(excluding extras)</span>'); $over_header->SetCssClass("numeric balls"); $wides_header = new XhtmlCell(true, "Wides"); $wides_header->SetCssClass("numeric"); $no_balls_header = new XhtmlCell(true, "No balls"); $no_balls_header->SetCssClass("numeric"); $runs_header = new XhtmlCell(true, "Over total"); $runs_header->SetCssClass("numeric"); $bowling_headings = new XhtmlRow(array("Bowler", $over_header, $wides_header, $no_balls_header, $runs_header)); $bowling_headings->SetIsHeader(true); $bowling_table->AddRow($bowling_headings); $bowling_data->ResetCounter(); for ($i = 1; $i <= $match->GetOvers(); $i++) { $bowling = $bowling_data->MoveNext() ? $bowling_data->GetItem() : null; /* @var $bowling Over */ $blank_row = (is_null($bowling) or is_null($bowling->GetOverNumber())); // don't list records generated from batting card to record wickets taken $player = new TextBox("bowlerName{$i}", $blank_row ? "" : $bowling->GetPlayer()->GetName(), $this->IsValidSubmit()); $player->SetMaxLength(100); $player->AddAttribute("autocomplete", "off"); $player->AddCssClass("player team" . $bowling_team->GetId()); $balls = new TextBox("bowlerBalls{$i}", $blank_row ? "" : $bowling->GetBalls(), $this->IsValidSubmit()); $balls->AddAttribute("autocomplete", "off"); $balls->AddAttribute("type", "number"); $balls->AddAttribute("min", "0"); $balls->AddAttribute("max", "10"); $balls->SetCssClass("numeric balls"); $wides = new TextBox("bowlerWides{$i}", $blank_row ? "" : $bowling->GetWides(), $this->IsValidSubmit()); $wides->AddAttribute("autocomplete", "off"); $wides->AddAttribute("type", "number"); $wides->AddAttribute("min", "0"); $wides->SetCssClass("numeric wides"); $no_balls = new TextBox("bowlerNoBalls{$i}", $blank_row ? "" : $bowling->GetNoBalls(), $this->IsValidSubmit()); $no_balls->AddAttribute("autocomplete", "off"); $no_balls->AddAttribute("type", "number"); $no_balls->AddAttribute("min", "0"); $no_balls->SetCssClass("numeric no-balls"); $runs = new TextBox("bowlerRuns{$i}", $blank_row ? "" : $bowling->GetRunsInOver(), $this->IsValidSubmit()); $runs->AddAttribute("autocomplete", "off"); $runs->AddAttribute("type", "number"); $runs->AddAttribute("min", "0"); $runs->SetCssClass("numeric runs"); $bowling_row = new XhtmlRow(array($player, $balls, $wides, $no_balls, $runs)); $bowling_row->GetFirstCell()->SetCssClass("bowler"); $bowling_table->AddRow($bowling_row); } $this->AddControl($bowling_table); $total_overs = new TextBox("bowlerRows", $match->GetOvers(), $this->IsValidSubmit()); $total_overs->SetMode(TextBoxMode::Hidden()); $this->AddControl($total_overs); if ($match->GetLastAudit() != null) { require_once "data/audit-control.class.php"; $this->AddControl(new AuditControl($match->GetLastAudit(), "match")); } $home_batted_first = ""; if (!is_null($match->Result()->GetHomeBattedFirst())) { $home_batted_first = (int) $match->Result()->GetHomeBattedFirst(); } $teams = new TextBox("teams", $home_batted_first . ScorecardEditControl::DATA_SEPARATOR . $match->GetHomeTeamId() . ScorecardEditControl::DATA_SEPARATOR . $match->GetHomeTeam()->GetName() . ScorecardEditControl::DATA_SEPARATOR . $match->GetAwayTeamId() . ScorecardEditControl::DATA_SEPARATOR . $match->GetAwayTeam()->GetName() . ScorecardEditControl::DATA_SEPARATOR . $match->GetTitle()); $teams->SetMode(TextBoxMode::Hidden()); $this->AddControl($teams); }
public function OnPageLoad() { echo '<article typeof="schema:SportsTeam" about="' . htmlentities($this->team->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '">'; echo '<h1>Players for <span property="schema:name">' . htmlentities($this->team->GetName(), ENT_QUOTES, "UTF-8", false) . "</span></h1>"; require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => $this->team->GetNavigateUrl()); $tabs['Players'] = ''; $tabs['Statistics'] = $this->team->GetStatsNavigateUrl(); echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php if (count($this->players) > 4) { $threshold = (int) gmdate("Y") - 1; $list_open = false; echo '<div class="player-list">'; foreach ($this->players as $player) { /* @var $player Player */ if ($player->GetPlayerRole() == Player::PLAYER and (gmdate("Y", $player->GetLastPlayedDate()) >= $threshold or $player->GetLastPlayedDate() == 0)) { if (!$list_open) { echo '<h2>Current and recent players</h2><ol rel="schema:members">'; $list_open = true; } echo '<li typeof="schema:Person" about="' . htmlentities($player->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '"><a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a></li>"; } } if ($list_open) { echo "</ol>"; } $list_open = false; foreach ($this->players as $player) { /* @var $player Player */ if ($player->GetPlayerRole() == Player::PLAYER and gmdate("Y", $player->GetLastPlayedDate()) < $threshold and $player->GetLastPlayedDate() != 0) { if (!$list_open) { echo '<h2>Former players</h2><ol rel="schema:members">'; $list_open = true; } echo '<li typeof="schema:Person" about="' . htmlentities($player->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '"><a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a></li>"; } } if ($list_open) { echo "</ol>"; } $list_open = false; foreach ($this->players as $player) { /* @var $player Player */ if ($player->GetPlayerRole() != Player::PLAYER) { if (!$list_open) { echo "<h2>Extras</h2><ul>"; $list_open = true; } echo '<li><a href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a></li>"; } } if ($list_open) { echo "</ul>"; } echo "</div>"; } else { ?> <p>There aren't any player statistics for this team 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> <?php } ?> </div> </div> </article> <?php $this->AddSeparator(); if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS, $this->team->GetLinkedDataUri())) { # Create a panel with actions $panel = new UserEditPanel($this->GetSettings()); $panel->AddCssClass("with-tabs"); #$panel->AddLink("add a player", $this->team->GetPlayerAddNavigateUrl()); echo $panel; $this->BuySomething(); } else { echo '<div class="with-tabs">'; $this->BuySomething(); echo '</div>'; } }