当前位置: 首页>>代码示例>>PHP>>正文


PHP Match::GetGroundId方法代码示例

本文整理汇总了PHP中Match::GetGroundId方法的典型用法代码示例。如果您正苦于以下问题:PHP Match::GetGroundId方法的具体用法?PHP Match::GetGroundId怎么用?PHP Match::GetGroundId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Match的用法示例。


在下文中一共展示了Match::GetGroundId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetDuplicateFixture

 /**
  * Checks whether the given match fixture data is already in the database; returns the duplicate match or null
  *
  * @param Match $match_to_compare
  * @param bool $b_user_is_match_admin
  * @return Match
  */
 private function GetDuplicateFixture(Match $match_to_compare, $b_user_is_match_admin)
 {
     # Make sure it's not a duplicate. If it is, return the duplicate match.
     $is_duplicate = false;
     $is_new_match = !(bool) $match_to_compare->GetId();
     $id_of_duplicate = null;
     $s_match = $this->GetSettings()->GetTable('Match');
     $s_mt = $this->GetSettings()->GetTable('MatchTeam');
     $i_tournament = is_null($match_to_compare->GetTournament()) ? null : $match_to_compare->GetTournament()->GetId();
     $i_ground = $match_to_compare->GetGroundId() > 0 ? $match_to_compare->GetGroundId() : null;
     $s_sql = "SELECT {$s_match}.match_id FROM {$s_match} INNER JOIN {$s_mt} ON {$s_match}.match_id = {$s_mt}.match_id AND {$s_mt}.team_role = " . TeamRole::Home();
     $s_where = $this->SqlAddCondition('', 'tournament_match_id' . Sql::ProtectNumeric($i_tournament, true, true));
     $s_where = $this->SqlAddCondition($s_where, 'ground_id' . Sql::ProtectNumeric($i_ground, true, true));
     $s_where = $this->SqlAddCondition($s_where, 'start_time = ' . Sql::ProtectNumeric($match_to_compare->GetStartTime()));
     $s_where = $this->SqlAddCondition($s_where, 'start_time_known = ' . Sql::ProtectBool($match_to_compare->GetIsStartTimeKnown()));
     $s_where = $this->SqlAddCondition($s_where, 'match_notes = ' . Sql::ProtectString($this->GetDataConnection(), $match_to_compare->GetNotes()));
     $s_where = $this->SqlAddCondition($s_where, "{$s_mt}.team_id" . Sql::ProtectNumeric($match_to_compare->GetHomeTeamId(), true, true));
     # If it's a new match we want to check that it's not a duplicate match type of one already added.
     # If it's an updated match only an admin can change that. If not an admin, data's not even available so don't compare.
     if ($is_new_match or $b_user_is_match_admin) {
         $s_where = $this->SqlAddCondition($s_where, 'match_type = ' . Sql::ProtectNumeric($match_to_compare->GetMatchType()));
     }
     # If it's a tournament the player type should be specified by the user so check whether it's changed.
     # For any other match it's inferred automatically from other metadata about the match as it's saved,
     # and we're already checking whether that other data has changed so don't check for player type.
     if ($match_to_compare->GetMatchType() == MatchType::TOURNAMENT) {
         $s_where = $this->SqlAddCondition($s_where, 'player_type_id' . Sql::ProtectNumeric($match_to_compare->GetPlayerType(), true, true));
     }
     # If there's an id we're comparing whether the existing match has changed.
     # If no id we're looking whether the match has already been added, probably by someone else.
     if (!$is_new_match) {
         $s_where = $this->SqlAddCondition($s_where, "{$s_match}.match_id" . Sql::ProtectNumeric($match_to_compare->GetId(), false, true));
         # Only compare title properties for an update to a match, not for a match being added. If a new match is being added
         # the same match may exist with a different title because a result has been filled in - we still want to treat that as
         # a duplicate and not add the new match. But if the match is being updated it can only come from the match editing screen,
         # where the existing title is visible. The title may have changed due to an updated result, but OK to treat this as a changed
         # fixture in that event - an email about the match update is going to be sent and the match marked as updated anyway, so no problem.
         $s_where = $this->SqlAddCondition($s_where, 'match_title = ' . Sql::ProtectString($this->GetDataConnection(), $match_to_compare->GetTitle(), false));
         $s_where = $this->SqlAddCondition($s_where, 'custom_title' . Sql::ProtectBool($match_to_compare->GetUseCustomTitle(), false, true));
         # A new match would have either no or a newly-generated short URL, which inevitably would be different from the existing match
         # had it already been entered. But if we're updating the match the short URL may have been changed deliberately and we want to
         # recognise that change, not throw it away as a duplicate.
         $s_where = $this->SqlAddCondition($s_where, 'short_url = ' . Sql::ProtectString($this->GetDataConnection(), $match_to_compare->GetShortUrl(), false));
     }
     $s_sql = $this->SqlAddWhereClause($s_sql, $s_where);
     $result = $this->GetDataConnection()->query($s_sql);
     if ($o_row = $result->fetch()) {
         $id_of_duplicate = $o_row->match_id;
         # if it's a new match, this gives info on the match as it already exists
         $is_duplicate = true;
     }
     $result->closeCursor();
     # If basic match details appear to be a duplicate, does it have the same away team(s) too?
     if ($is_duplicate) {
         $s_sql = "SELECT team_id FROM {$s_mt} WHERE match_id =  " . Sql::ProtectNumeric($id_of_duplicate) . " AND team_role = " . TeamRole::Away();
         $result = $this->GetDataConnection()->query($s_sql);
         $existing_away_team_ids = array();
         while ($row = $result->fetch()) {
             $existing_away_team_ids[] = (int) $row->team_id;
         }
         $result->closeCursor();
         if (count($existing_away_team_ids) != count($match_to_compare->GetAwayTeams())) {
             # Different number of teams...
             $is_duplicate = false;
         }
         # Same number of away teams... now are those away teams the same ones as in the match we're comparing?
         if ($is_duplicate) {
             foreach ($match_to_compare->GetAwayTeams() as $team) {
                 /* @var $team Team */
                 if (!in_array($team->GetId(), $existing_away_team_ids, true)) {
                     $is_duplicate = false;
                     break;
                 }
             }
         }
     }
     # If basic match details and away teams appear to be a duplicate, does it have the same season(s) too?
     if ($is_duplicate) {
         # 1. If the user isn't admin and is updating match, don't check. They're not allowed to change season data so it's not even available.
         # 2. If the user isn't admin and it's a new match, is the existing match in the given season - don't care if it's in others too
         # 3. If the user is an admin, we want to look for an exact match
         if ($b_user_is_match_admin or $is_new_match) {
             $s_sql = "SELECT season_id FROM " . $this->GetSettings()->GetTable('SeasonMatch') . " WHERE match_id =  " . Sql::ProtectNumeric($id_of_duplicate);
             $result = $this->GetDataConnection()->query($s_sql);
             $existing_season_ids = array();
             while ($row = $result->fetch()) {
                 $existing_season_ids[] = (int) $row->season_id;
             }
             $result->closeCursor();
             if (count($existing_season_ids) == $match_to_compare->Seasons()->GetCount() or !$b_user_is_match_admin and $is_new_match) {
                 # Same number of seasons...
             } else {
                 # Different number of seasons...
//.........这里部分代码省略.........
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:match-manager.class.php

示例2: CreateFixtureControls


//.........这里部分代码省略.........
     $o_date->SetRequireTime(false);
     $o_date->SetMinuteInterval(5);
     # if only one season to choose from, limit available dates to the length of that season
     if ($this->context_season instanceof Season) {
         if ($this->context_season->GetStartYear() == $this->context_season->GetEndYear()) {
             $i_mid_season = gmmktime(0, 0, 0, 6, 30, $this->context_season->GetStartYear());
         } else {
             $i_mid_season = gmmktime(0, 0, 0, 12, 31, $this->context_season->GetStartYear());
         }
         $season_dates = Season::SeasonDates($i_mid_season);
         $season_start_month = gmdate('n', $season_dates[0]);
         $season_end_month = gmdate('n', $season_dates[1]);
         if ($season_start_month) {
             $o_date->SetMonthStart($season_start_month);
         }
         if ($season_end_month) {
             $o_date->SetMonthEnd($season_end_month);
         }
         $season_start_year = $this->context_season->GetStartYear();
         $season_end_year = $this->context_season->GetEndYear();
         if ($season_start_year) {
             $o_date->SetYearStart($season_start_year);
         }
         if ($season_end_year) {
             $o_date->SetYearEnd($season_end_year);
         }
     }
     $o_date_part = new FormPart('When?', $o_date);
     $o_date_part->SetIsFieldset(true);
     $match_box->AddControl($o_date_part);
     # Where?
     $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 the most likely grounds to the top of the list
     $likely_ground_ids = array();
     if ($match->GetGroundId()) {
         $likely_ground_ids[] = $match->GetGroundId();
     }
     foreach ($this->probable_teams as $o_team) {
         $likely_ground_ids[] = $o_team->GetGround()->GetId();
     }
     if (isset($this->context_season)) {
         foreach ($this->context_season->GetTeams() as $o_team) {
             $likely_ground_ids[] = $o_team->GetGround()->GetId();
         }
     }
     if (isset($this->context_team) and is_object($this->context_team->GetGround())) {
         $likely_ground_ids[] = $this->context_team->GetGround()->GetId();
     }
     $likely_grounds = array();
     $a_other_grounds = array();
     /* @var $o_ground Ground */
     foreach ($this->grounds->GetItems() as $o_ground) {
         if (array_search($o_ground->GetId(), $likely_ground_ids) > -1) {
             $likely_grounds[] = $o_ground;
         } else {
             $a_other_grounds[] = $o_ground;
         }
     }
     # Add home grounds
     foreach ($likely_grounds as $o_ground) {
         $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId());
         $option->SetGroupName('Likely grounds');
         $o_ground_list->AddControl($option);
     }
     # Add away grounds
     foreach ($a_other_grounds as $o_ground) {
         $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId());
         $option->SetGroupName('Other grounds');
         $o_ground_list->AddControl($option);
     }
     # Select ground
     if ($match->GetGroundId()) {
         $o_ground_list->SelectOption($match->GetGroundId());
     } elseif (isset($this->context_team)) {
         $o_ground_list->SelectOption($this->context_team->GetGround()->GetId());
     }
     $o_ground_part = new FormPart('Where?', $o_ground_list);
     $match_box->AddControl($o_ground_part);
     # Notes
     $o_notes = new TextBox($this->GetNamingPrefix() . 'Notes', $match->GetNotes());
     $o_notes->SetMode(TextBoxMode::MultiLine());
     $o_notes_part = new FormPart('Notes<br />(remember to include contact details)', $o_notes);
     $match_box->AddControl($o_notes_part);
     # Remember short URL
     $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $match->GetShortUrl());
     $o_short_url->SetMode(TextBoxMode::Hidden());
     $match_box->AddControl($o_short_url);
     # Note the context team to be added to the tournament by default
     if (isset($this->context_team)) {
         $context_team_box = new TextBox($this->GetNamingPrefix() . 'ContextTeam', $this->context_team->GetId());
         $context_team_box->SetMode(TextBoxMode::Hidden());
         $match_box->AddControl($context_team_box);
     }
     # Change Save button to "Next" button
     if ($this->show_step_number) {
         $this->SetButtonText('Next &raquo;');
     }
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:tournament-edit-control.class.php

示例3: CreateControls


//.........这里部分代码省略.........
         $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) {
                 $a_home_grounds[] = $o_ground;
             } else {
                 $a_other_grounds[] = $o_ground;
             }
         }
         # Add home grounds
         foreach ($a_home_grounds as $o_ground) {
             $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId());
             $option->SetGroupName('Home grounds');
             $o_ground_list->AddControl($option);
         }
         # Add away grounds
         foreach ($a_other_grounds as $o_ground) {
             $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId());
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:67,代码来源:match-fixture-edit-control.class.php


注:本文中的Match::GetGroundId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。