本文整理汇总了PHP中Match::GetAwayTeamId方法的典型用法代码示例。如果您正苦于以下问题:PHP Match::GetAwayTeamId方法的具体用法?PHP Match::GetAwayTeamId怎么用?PHP Match::GetAwayTeamId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::GetAwayTeamId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnPrePageLoad
public function OnPrePageLoad()
{
/* @var $match Match */
#$this->SetContentConstraint(StoolballPage::ConstrainText());
$this->SetContentCssClass('scorecardPage');
$this->SetContentCssClass('scorecardPage');
if ($this->page_not_found) {
$this->SetPageTitle('Page not found');
return;
# Don't load any JS
}
# Set page title
$edit_or_update = ($this->b_user_is_match_admin or $this->b_user_is_match_owner) ? "Edit" : "Update";
$step = ", step " . $this->editor->GetCurrentPage() . " of 4";
$this->SetPageTitle("{$edit_or_update} " . $this->match->GetTitle() . ', ' . Date::BritishDate($this->match->GetStartTime()) . $step);
# Load JavaScript
$autocomplete_team_ids = array();
if ($this->match->GetHomeTeamId()) {
$autocomplete_team_ids[] = $this->match->GetHomeTeamId();
}
if ($this->match->GetAwayTeamId()) {
$autocomplete_team_ids[] = $this->match->GetAwayTeamId();
}
if (count($autocomplete_team_ids)) {
$this->LoadClientScript("/scripts/lib/jquery-ui-1.8.11.custom.min.js");
$this->LoadClientScript("/play/playersuggest.js.php?v=2&team=" . implode(",", $autocomplete_team_ids));
// . "&time=" . time());
?>
<link rel="stylesheet" type="text/css" href="/css/custom-theme/jquery-ui-1.8.11.custom.css" media="all" />
<?php
}
$this->LoadClientScript('scorecard.js', true);
}
示例2: BuildPostedItem
/**
* 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)
{
$match = new Match($this->GetSettings());
$match->SetMatchType(MatchType::TOURNAMENT_MATCH);
$key = $this->GetNamingPrefix() . 'MatchId' . $i_counter;
if (isset($_POST[$key]) and is_numeric($_POST[$key])) {
$match->SetId($_POST[$key]);
}
$key = $this->GetNamingPrefix() . 'MatchOrder' . $i_counter;
if (isset($_POST[$key]) and is_numeric($_POST[$key])) {
$match->SetOrderInTournament($_POST[$key]);
}
$key = $this->GetNamingPrefix() . 'MatchIdValue' . $i_counter;
if (isset($_POST[$key])) {
$match->SetTitle($_POST[$key]);
}
$key = $this->GetNamingPrefix() . 'HomeTeamId' . $i_counter;
if (isset($_POST[$key]) and $_POST[$key]) {
$team = new Team($this->GetSettings());
$team->SetId($_POST[$key]);
$match->SetHomeTeam($team);
}
$key = $this->GetNamingPrefix() . 'AwayTeamId' . $i_counter;
if (isset($_POST[$key]) and $_POST[$key]) {
$team = new Team($this->GetSettings());
$team->SetId($_POST[$key]);
$match->SetAwayTeam($team);
}
if ($match->GetId() or $match->GetHomeTeamId() and $match->GetAwayTeamId()) {
$this->DataObjects()->Add($match);
} else {
$this->IgnorePostedItem($i_counter);
}
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:40,代码来源:matches-in-tournament-editor.class.php
示例3: CreateHighlightsControls
/**
* Sets up controls for page 4 of the wizard
* @param Match $match
* @return void
*/
private function CreateHighlightsControls(Match $match)
{
$b_got_teams = !(is_null($match->GetHomeTeam()) || is_null($match->GetAwayTeam()));
// Move CSS class to div element
$match_outer_1 = new XhtmlElement('div');
$match_outer_1->SetCssClass('matchResultEdit panel');
$match_outer_2 = new XhtmlElement('div');
$match_box = new XhtmlElement('div');
$this->AddControl($match_outer_1);
$match_outer_1->AddControl($match_outer_2);
$match_outer_2->AddControl($match_box);
$o_title_inner_1 = new XhtmlElement('span', "Match highlights");
$o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1);
$o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2);
$o_heading = new XhtmlElement('h2', $o_title_inner_3);
$match_box->AddControl($o_heading);
# Who's playing?
$o_home_name = new TextBox($this->GetNamingPrefix() . 'Home');
$o_away_name = new TextBox($this->GetNamingPrefix() . 'Away');
$o_home_name->SetMode(TextBoxMode::Hidden());
$o_away_name->SetMode(TextBoxMode::Hidden());
if (!is_null($match->GetHomeTeam())) {
$o_home_name->SetText($match->GetHomeTeam()->GetId() . MatchHighlightsEditControl::DATA_SEPARATOR . $match->GetHomeTeam()->GetName());
}
if (!is_null($match->GetAwayTeam())) {
$o_away_name->SetText($match->GetAwayTeam()->GetId() . MatchHighlightsEditControl::DATA_SEPARATOR . $match->GetAwayTeam()->GetName());
}
$this->AddControl($o_home_name);
$this->AddControl($o_away_name);
# When? (for validator message only)
$when = new TextBox($this->GetNamingPrefix() . 'Date', $match->GetStartTime());
$when->SetMode(TextBoxMode::Hidden());
$this->AddControl($when);
# Who won?
$o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result');
$o_winner->AddControl(new XhtmlOption("Don't know", ''));
$result_types = array(MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::TIE, MatchResult::ABANDONED);
foreach ($result_types as $result_type) {
if ($b_got_teams) {
$o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $match->GetHomeTeam(), $match->GetAwayTeam()), $result_type));
} else {
$o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type));
}
}
if ($this->IsValidSubmit()) {
if ($match->Result()->GetResultType() == MatchResult::UNKNOWN and !is_null($match->Result()->GetHomeRuns()) and !is_null($match->Result()->GetAwayRuns())) {
# If match result is not known but we can guess from the entered scores, select it
if ($match->Result()->GetHomeRuns() > $match->Result()->GetAwayRuns()) {
$o_winner->SelectOption(MatchResult::HOME_WIN);
} else {
if ($match->Result()->GetHomeRuns() < $match->Result()->GetAwayRuns()) {
$o_winner->SelectOption(MatchResult::AWAY_WIN);
} else {
if ($match->Result()->GetHomeRuns() == $match->Result()->GetAwayRuns()) {
$o_winner->SelectOption(MatchResult::TIE);
}
}
}
} else {
$o_winner->SelectOption($match->Result()->GetResultType());
}
}
$o_win_part = new FormPart('Who won?', $o_winner);
$match_box->AddControl($o_win_part);
# Get current player of match
$player = $match->Result()->GetPlayerOfTheMatch();
$home_player = $match->Result()->GetPlayerOfTheMatchHome();
$away_player = $match->Result()->GetPlayerOfTheMatchAway();
$current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE;
if ($player instanceof Player) {
$current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL;
} else {
if ($home_player instanceof Player or $away_player instanceof Player) {
$current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY;
}
}
# Choose from different types of player of the match
require_once 'xhtml/forms/radio-button.class.php';
$pom_container = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Player of the match', 'formLabel'));
$pom_container->SetCssClass('formPart');
$pom_options = new XhtmlElement('div', null, 'formControl radioButtonList');
$pom_options->SetXhtmlId($this->GetNamingPrefix() . "PlayerOptions");
$pom_container->AddControl($pom_options);
$match_box->AddControl($pom_container);
$pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $this->GetNamingPrefix() . 'POM', "none chosen", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $this->IsValidSubmit()));
$pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $this->GetNamingPrefix() . 'POM', "yes, one chosen", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $this->IsValidSubmit()));
$pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $this->GetNamingPrefix() . 'POM', "yes, one from each team", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $this->IsValidSubmit()));
# Controls for entering a single player of the match
$player_name = new TextBox($this->GetNamingPrefix() . 'Player', $player instanceof Player ? $player->GetName() : '', $this->IsValidSubmit());
$player_name->SetMaxLength(100);
$player_name->AddCssClass("player");
$player_name->AddCssClass("team" . $match->GetHomeTeamId());
$player_name->AddCssClass("team" . $match->GetAwayTeamId());
$player_name->AddAttribute("autocomplete", "off");
$player_box = new XhtmlElement("div", $player_name);
//.........这里部分代码省略.........
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:match-highlights-edit-control.class.php
示例4: SaveScorecard
/**
* @return void
* @param Match $match
* @param bool $is_first_innings
* @desc Saves the batting and bowling scorecards for one innings
*/
public function SaveScorecard(Match $match, $is_first_innings, ISearchIndexProvider $search)
{
# To add a scorecard there must always already be a match to update
if (!$match->GetId()) {
return;
}
# This isn't for tournaments
if ($match->GetMatchType() == MatchType::TOURNAMENT) {
return;
}
# Get tables
$batting_table = $this->GetSettings()->GetTable("Batting");
$bowling_table = $this->GetSettings()->GetTable("Bowling");
$match_table = $this->GetSettings()->GetTable('Match');
$mt = $this->GetSettings()->GetTable('MatchTeam');
# Is this scorecard for the home or the away innings?
$sql = "SELECT home_bat_first FROM {$match_table} WHERE match_id = " . Sql::ProtectNumeric($match->GetId());
$result = $this->GetDataConnection()->query($sql);
$row = $result->fetch();
if (is_null($row->home_bat_first) or (bool) $row->home_bat_first === true) {
$is_home_innings = $is_first_innings;
} else {
$is_home_innings = !$is_first_innings;
}
$result->closeCursor();
# Prepare data for query
if ($is_home_innings) {
$bowling_team_id = $match->GetAwayTeamId();
$batting_team_id = $match->GetHomeTeamId();
$team_bowling = $match->Result()->AwayOvers();
$team_batting = $match->Result()->HomeBatting();
} else {
$bowling_team_id = $match->GetHomeTeamId();
$batting_team_id = $match->GetAwayTeamId();
$team_bowling = $match->Result()->HomeOvers();
$team_batting = $match->Result()->AwayBatting();
}
# Find the match_team_id for the bowling
$sql = "SELECT match_team_id FROM {$mt}\r\n\t\t\t\tWHERE match_id " . Sql::ProtectNumeric($match->GetId(), false, true) . "\r\n\t\t\t\tAND team_id " . Sql::ProtectNumeric($bowling_team_id, false, true) . "\r\n\t\t\t\tAND team_role = " . ($is_home_innings ? TeamRole::Away() : TeamRole::Home());
$result = $this->GetDataConnection()->query($sql);
$row = $result->fetch();
$bowling_match_team_id = $row->match_team_id;
$result->closeCursor();
# Find the match_team_id for the batting
$sql = "SELECT match_team_id FROM {$mt}\r\n\t\t\t\tWHERE match_id " . Sql::ProtectNumeric($match->GetId(), false, true) . "\r\n\t\t\t\tAND team_id " . Sql::ProtectNumeric($batting_team_id, false, true) . "\r\n\t\t\t\tAND team_role = " . ($is_home_innings ? TeamRole::Home() : TeamRole::Away());
$result = $this->GetDataConnection()->query($sql);
$row = $result->fetch();
$batting_match_team_id = $row->match_team_id;
$result->closeCursor();
$affected_players = $this->SaveBattingScorecard($match, $is_home_innings, $batting_match_team_id, $team_batting);
$affected_bowlers = $this->SaveBowlingScorecard($match, $is_home_innings, $batting_match_team_id, $bowling_match_team_id, $team_bowling);
$affected_players = array_merge($affected_players, $affected_bowlers);
$affected_players = array_unique($affected_players);
if (count($affected_players)) {
require_once 'stoolball/statistics/statistics-manager.class.php';
$statistics_manager = new StatisticsManager($this->GetSettings(), $this->GetDataConnection());
# generate player statistics from the data entered
$statistics_manager->UpdateBattingStatistics($affected_players, array($batting_match_team_id));
$statistics_manager->UpdateFieldingStatistics($affected_players, array($bowling_match_team_id));
$statistics_manager->UpdateBowlingStatistics($affected_players, array($bowling_match_team_id));
$statistics_manager->DeleteObsoleteStatistics($match->GetId());
# update overall stats for players
$statistics_manager->UpdatePlayerStatistics($affected_players);
unset($statistics_manager);
# update search engine
require_once "stoolball/player-manager.class.php";
require_once "search/player-search-adapter.class.php";
$player_manager = new PlayerManager($this->GetSettings(), $this->GetDataConnection());
foreach ($affected_players as $player_id) {
$player_manager->ReadPlayerById($player_id);
$player = $player_manager->GetFirst();
$search->DeleteFromIndexById("player" . $player_id);
if ($player instanceof Player) {
$adapter = new PlayerSearchAdapter($player);
$search->Index($adapter->GetSearchableItem());
}
}
$search->CommitChanges();
unset($player_manager);
}
}
示例5: OnPostback
public function OnPostback()
{
# If there's no id, ensure no match object is created. Page will then display a "match not found" message.
# There's a separate page for adding matches, even for admins.
if (!$this->editor->GetDataObjectId()) {
return;
}
# Get the submitted match
$this->match = $this->editor->GetDataObject();
$check_match = $this->match;
# Because this is a new request, if the user isn't admin we need to reverify whether this is the match owner
# before letting anything happen. Can't trust that info from a postback so MUST go to the database to check it.
if (!$this->b_user_is_match_admin) {
$this->match_manager->ReadByMatchId(array($this->editor->GetDataObjectId()));
$check_match = $this->match_manager->GetFirst();
$this->b_user_is_match_owner = ($check_match instanceof Match and AuthenticationManager::GetUser()->GetId() == $check_match->GetAddedBy()->GetId());
if ($this->b_user_is_match_owner) {
# Set the owner of the match. This means the edit control knows who the owner is and therefore
# whether to display the fixture editor on an invalid postback
$this->match->SetAddedBy(AuthenticationManager::GetUser());
} else {
# If user is neither admin nor owner, they won't have the team info. Get it from the $check_match so
# that the match title can be updated correctly with a changed result.
$this->match->SetHomeTeam($check_match->GetHomeTeam());
$this->match->SetAwayTeam($check_match->GetAwayTeam());
}
}
# Don't wan't to edit tournaments on this page, so even as admin make sure we're not trying to save one.
# If user's not admin, can't change the match type, so find out what that is from the db too. For admin,
# $check_match is the submitted one as the match type might've been changed.
$this->b_is_tournament = $check_match->GetMatchType() == MatchType::TOURNAMENT;
# Check whether cancel was clicked
if ($this->editor->CancelClicked()) {
# If so, get the match's short URL and redirect
$this->match_manager->ExpandMatchUrl($this->match);
$this->Redirect($this->match->GetNavigateUrl());
}
# save data if valid
if ($this->IsValid() and !$this->b_is_tournament) {
# Check whether the user has permission to update the fixture as well as the result
if ($this->b_user_is_match_admin or $this->b_user_is_match_owner) {
# Get the ground name from the database. This is used when compiling an email about the updated match result.
if ($this->match->GetGround() instanceof Ground and $this->match->GetGround()->GetId() and !$this->match->GetGround()->GetName()) {
require_once 'stoolball/ground-manager.class.php';
$ground_manager = new GroundManager($this->GetSettings(), $this->GetDataConnection());
$ground_manager->ReadById(array($this->match->GetGround()->GetId()));
if ($ground_manager->GetCount()) {
$this->match->SetGround($ground_manager->GetFirst());
}
unset($ground_manager);
}
$this->match_manager->SaveFixture($this->match);
if ($this->b_user_is_match_admin) {
$this->match_manager->SaveSeasons($this->match, false);
}
$this->editor->SetNavigateUrl($this->match->GetEditNavigateUrl());
# because edit URL may have changed
}
# Save the result
$this->match_manager->SaveIfPlayed($this->match);
$this->match_manager->SaveWhoWonTheToss($this->match);
$this->match_manager->SaveWhoBattedFirst($this->match);
# If match didn't happen or the teams aren't known yet, save and finish, otherwise go to next page
$result = $this->match->Result()->GetResultType();
if ($result == MatchResult::HOME_WIN_BY_FORFEIT or $result == MatchResult::AWAY_WIN_BY_FORFEIT or $result == MatchResult::CANCELLED or $result == MatchResult::POSTPONED or $check_match->GetStartTime() > gmdate('U') or $this->b_user_is_match_admin and (!$this->match->GetHomeTeamId() or !$this->match->GetAwayTeamId())) {
# Match may have been updated so, first, send an email
$this->match_manager->NotifyMatchModerator($this->match->GetId());
http_response_code(303);
$this->Redirect($this->match->GetNavigateUrl());
} else {
http_response_code(303);
$this->Redirect($this->match->EditScorecardUrl());
}
}
}
示例6: CreateControls
//.........这里部分代码省略.........
if (is_string($group_name) and $group_name) {
$home_option->SetGroupName($group_name);
}
$o_home_list->AddControl($home_option);
$away_option = new XhtmlOption($o_team->GetName(), $o_team->GetId());
if (is_string($group_name) and $group_name) {
$away_option->SetGroupName($group_name);
}
$o_away_list->AddControl($away_option);
}
}
$o_home_part = new FormPart('Home team', $o_home_list);
$o_away_part = new FormPart('Away team', $o_away_list);
$o_match_box->AddControl($o_home_part);
$o_match_box->AddControl($o_away_part);
if ($b_got_home) {
$o_home_list->SelectOption($o_match->GetHomeTeamId());
}
if (!$b_got_home and $b_is_new_match) {
// if no home team data, select the first team by default
// unless editing a match, in which case it may be correct to have no teams (eg cup final)
$o_home_list->SelectIndex($first_real_team_index);
}
if (!$b_got_away and $b_is_new_match) {
// if no away team data, select the second team as the away team so that it's not the same as the first
// unless editing a match, in which case it may be correct to have no teams (eg cup final).
$o_away_list->SelectIndex($first_real_team_index + 1);
// if there was a home team but not an away team, make sure we don't select the home team against itself
if ($b_got_home and $o_away_list->GetSelectedValue() == (string) $o_match->GetHomeTeamId()) {
$o_away_list->SelectIndex($first_real_team_index);
}
} else {
if ($b_got_away) {
$o_away_list->SelectOption($o_match->GetAwayTeamId());
}
if (!$b_is_new_match) {
# Note which away team was previously saved, even if it's "not known" - this is for JavaScript to know it shouldn't auto-change the away team
$away_saved = new TextBox($this->GetNamingPrefix() . 'SavedAway', $o_match->GetAwayTeamId());
$away_saved->SetMode(TextBoxMode::Hidden());
$o_match_box->AddControl($away_saved);
unset($away_saved);
}
}
}
# Where?
# If tournament match, assume same ground as tournament. Otherwise ask the user for ground.
if ($b_is_tournament_match) {
$ground = new TextBox($this->GetNamingPrefix() . 'Ground', $this->tournament->GetGroundId() ? $this->tournament->GetGroundId() : $o_match->GetGroundId());
$ground->SetMode(TextBoxMode::Hidden());
$o_match_box->AddControl($ground);
} else {
$o_ground_list = new XhtmlSelect($this->GetNamingPrefix() . 'Ground');
$o_ground_list->AddControl(new XhtmlOption("Don't know", -1));
$o_ground_list->AddControl(new XhtmlOption('Not listed (type the address in the notes field)', -2));
# Promote home grounds for this season to the top of the list
$a_home_ground_ids = array();
foreach ($this->a_teams as $teams) {
foreach ($teams as $o_team) {
$a_home_ground_ids[$o_team->GetId()] = $o_team->GetGround()->GetId();
}
}
$a_home_grounds = array();
$a_other_grounds = array();
/* @var $o_ground Ground */
foreach ($this->a_grounds as $o_ground) {
if (array_search($o_ground->GetId(), $a_home_ground_ids) > -1) {
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:67,代码来源:match-fixture-edit-control.class.php