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


PHP Match::GetMaximumPlayersPerTeam方法代码示例

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


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

示例1: CreateFixtureControls

 /**
  * Creates the controls when the editor is in its fixture view
  *
  */
 private function CreateFixtureControls(Match $match, XhtmlElement $match_box)
 {
     $css_class = 'TournamentEdit';
     if ($this->GetCssClass()) {
         $css_class .= ' ' . $this->GetCssClass();
     }
     $match_outer_1 = new XhtmlElement('div');
     $match_outer_1->SetCssClass($css_class);
     $this->SetCssClass('');
     $match_outer_1->SetXhtmlId($this->GetNamingPrefix());
     $match_outer_2 = new XhtmlElement('div');
     $this->AddControl($match_outer_1);
     $match_outer_1->AddControl($match_outer_2);
     $match_outer_2->AddControl($match_box);
     if ($match->GetId()) {
         $heading = "Edit tournament";
     } else {
         $heading = "Add your tournament";
     }
     if ($this->show_step_number) {
         $heading .= ' – step 1 of 3';
     }
     $o_title_inner_1 = new XhtmlElement('span', $heading);
     $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1);
     $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2);
     $match_box->AddControl(new XhtmlElement('h2', $o_title_inner_3, "large"));
     # Tournament title
     $suggested_title = $match->GetTitle();
     if (isset($this->context_season)) {
         $suggested_title = $this->GetContextSeason()->GetCompetition()->GetName();
         if (strpos(strtolower($suggested_title), 'tournament') === false) {
             $suggested_title .= ' tournament';
         }
     } else {
         if (isset($this->context_team)) {
             $suggested_title = $this->GetContextTeam()->GetName();
             if (strpos(strtolower($suggested_title), 'tournament') === false) {
                 $suggested_title .= ' tournament';
             }
         }
     }
     if ($suggested_title == "To be confirmed tournament") {
         $suggested_title = "";
     }
     if ($suggested_title == "To be confirmed v To be confirmed") {
         $suggested_title = "";
     }
     $title = new TextBox($this->GetNamingPrefix() . 'Title', $suggested_title, $this->IsValidSubmit());
     $title->SetMaxLength(200);
     $match_box->AddControl(new FormPart('Tournament name', $title));
     # Open or invite?
     require_once 'xhtml/forms/radio-button.class.php';
     $qualify_set = new XhtmlElement('fieldset');
     $qualify_set->SetCssClass('formPart radioButtonList');
     $qualify_set->AddControl(new XhtmlElement('legend', 'Who can play?', 'formLabel'));
     $qualify_radios = new XhtmlElement('div', null, 'formControl');
     $qualify_set->AddControl($qualify_radios);
     $qualify_radios->AddControl(new RadioButton($this->GetNamingPrefix() . 'Open', $this->GetNamingPrefix() . 'Qualify', 'any team may enter', MatchQualification::OPEN_TOURNAMENT, $match->GetQualificationType() === MatchQualification::OPEN_TOURNAMENT or !$match->GetId(), $this->IsValidSubmit()));
     $qualify_radios->AddControl(new RadioButton($this->GetNamingPrefix() . 'Qualify', $this->GetNamingPrefix() . 'Qualify', 'only invited or qualifying teams can enter', MatchQualification::CLOSED_TOURNAMENT, $match->GetQualificationType() === MatchQualification::CLOSED_TOURNAMENT, $this->IsValidSubmit()));
     $match_box->AddControl($qualify_set);
     # Player type
     $suggested_type = 2;
     if (isset($this->context_season)) {
         $suggested_type = $this->context_season->GetCompetition()->GetPlayerType();
     } elseif (isset($this->context_team)) {
         $suggested_type = $this->context_team->GetPlayerType();
     }
     if (!is_null($match->GetPlayerType())) {
         $suggested_type = $match->GetPlayerType();
     }
     # Saved value overrides suggestion
     $player_set = new XhtmlElement('fieldset');
     $player_set->SetCssClass('formPart radioButtonList');
     $player_set->AddControl(new XhtmlElement('legend', 'Type of teams', 'formLabel'));
     $player_radios = new XhtmlElement('div', null, 'formControl');
     $player_set->AddControl($player_radios);
     $player_radios_1 = new XhtmlElement('div', null, 'column');
     $player_radios_2 = new XhtmlElement('div', null, 'column');
     $player_radios->AddControl($player_radios_1);
     $player_radios->AddControl($player_radios_2);
     $player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Ladies', $this->GetNamingPrefix() . 'PlayerType', 'Ladies', 2, $suggested_type === 2, $this->IsValidSubmit()));
     $player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Mixed', $this->GetNamingPrefix() . 'PlayerType', 'Mixed', 1, $suggested_type === 1, $this->IsValidSubmit()));
     $player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Girls', $this->GetNamingPrefix() . 'PlayerType', 'Junior girls', 5, $suggested_type === 5, $this->IsValidSubmit()));
     $player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Children', $this->GetNamingPrefix() . 'PlayerType', 'Junior mixed', 4, $suggested_type === 6, $this->IsValidSubmit()));
     $match_box->AddControl($player_set);
     # How many?
     $per_side_box = new XhtmlSelect($this->GetNamingPrefix() . "Players", null, $this->IsValid());
     $per_side_box->SetBlankFirst(true);
     for ($i = 6; $i <= 16; $i++) {
         $per_side_box->AddControl(new XhtmlOption($i));
     }
     if ($match->GetIsMaximumPlayersPerTeamKnown()) {
         $per_side_box->SelectOption($match->GetMaximumPlayersPerTeam());
     } else {
         if (!$match->GetId()) {
             # Use eight as sensible default for new tournaments
//.........这里部分代码省略.........
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:tournament-edit-control.class.php

示例2: CreateTeamScoreControls

 /**
  * Adds controls to edit a team score
  *
  * @param XhtmlElement $o_container
  * @param string $s_id_prefix
  * @param Match $o_match
  * @param Team $o_team
  * @param int $i_runs
  * @param int $i_wickets
  */
 private function CreateTeamScoreControls($o_container, $s_team_role, Match $o_match, Team $o_team = null, $i_runs, $i_wickets)
 {
     $o_box = new XhtmlElement('div');
     $o_runs = new TextBox($this->GetNamingPrefix() . $s_team_role . 'Runs', $i_runs);
     $o_runs->SetCssClass("numeric");
     if ($i_runs == null) {
         $o_runs->PopulateData();
     }
     $s_runs_label = (is_null($o_team) ? $s_team_role : $o_team->GetName()) . ' score';
     $o_part = new FormPart($s_runs_label, $o_box);
     $o_box->AddControl($o_runs);
     $o_part->GetLabel()->AddAttribute('for', $o_runs->GetXhtmlId());
     $o_wickets = new XhtmlSelect($this->GetNamingPrefix() . $s_team_role . 'Wickets', ' for ');
     $o_wickets->SetBlankFirst(true);
     $max_wickets = $o_match->GetMaximumPlayersPerTeam() - 2;
     $season_dates = Season::SeasonDates($o_match->GetStartTime());
     # working with GMT
     if (Date::Year($season_dates[0]) != Date::Year($season_dates[1])) {
         # outdoor needs maximum-2, but indoor needs maximum-1 cos last batter can play on.
         # if there's any chance it's indoor use maximum-1
         $max_wickets = $o_match->GetMaximumPlayersPerTeam() - 1;
     }
     for ($i = 0; $i <= $max_wickets; $i++) {
         $o_wickets->AddControl(new XhtmlOption($i));
     }
     $o_wickets->AddControl(new XhtmlOption('all out', -1));
     $o_wickets->SelectOption($i_wickets);
     $o_box->AddControl($o_wickets);
     $o_container->AddControl($o_part);
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:40,代码来源:match-result-edit-control.class.php

示例3: SaveBattingScorecard


//.........这里部分代码省略.........
     $batting_table = $this->GetSettings()->GetTable("Batting");
     $match_table = $this->GetSettings()->GetTable('Match');
     # Check whether anything's changed and don't re-save if not
     $unchanged_batting = array();
     $new_batting = array();
     $batting_added = false;
     $batting_deleted = false;
     $totals_changed = false;
     $players_affected = array();
     # check if batting changed for this innings
     $position = 0;
     foreach ($team_batting as $batting) {
         $position++;
         /* @var $batting Batting */
         $sql = "SELECT batting_id FROM {$batting_table} WHERE\r\n\t\t\t\t\tmatch_team_id = {$batting_match_team_id}\r\n\t\t\t\t\tAND player_id = " . Sql::ProtectNumeric($player_manager->SaveOrMatchPlayer($batting->GetPlayer())) . "\r\n\t\t\t\t\tAND position = {$position}\r\n\t\t\t\t\tAND how_out " . Sql::ProtectNumeric($batting->GetHowOut(), false, true) . "\r\n\t\t\t\t\tAND dismissed_by_id " . Sql::ProtectNumeric($player_manager->SaveOrMatchPlayer($batting->GetDismissedBy()), true, true) . "\r\n\t\t\t\t\tAND bowler_id " . Sql::ProtectNumeric($player_manager->SaveOrMatchPlayer($batting->GetBowler()), true, true) . "\r\n\t\t\t\t\tAND runs " . Sql::ProtectNumeric($batting->GetRuns(), true, true) . "\r\n                    AND balls_faced " . Sql::ProtectNumeric($batting->GetBallsFaced(), true, true);
         $result = $this->GetDataConnection()->query($sql);
         if ($row = $result->fetch()) {
             $unchanged_batting[] = $row->batting_id;
         } else {
             # Save IDs of players added or updated
             $player_id = $player_manager->SaveOrMatchPlayer($batting->GetPlayer());
             $dismissed_by_id = $player_manager->SaveOrMatchPlayer($batting->GetDismissedBy());
             $bowler_id = $player_manager->SaveOrMatchPlayer($batting->GetBowler());
             $players_affected[] = $player_id;
             if (!is_null($dismissed_by_id)) {
                 $players_affected[] = $dismissed_by_id;
             }
             if (!is_null($bowler_id)) {
                 $players_affected[] = $bowler_id;
             }
             # Prepare insert query
             $player_id = Sql::ProtectNumeric($player_id);
             $dismissed_by_id = Sql::ProtectNumeric($dismissed_by_id, true);
             $bowler_id = Sql::ProtectNumeric($bowler_id, true);
             $new_batting[] = "INSERT INTO {$batting_table} SET\r\n\t\t\t\t\tmatch_team_id = {$batting_match_team_id},\r\n\t\t\t\t\tplayer_id = " . $player_id . ",\r\n\t\t\t\t\tposition = {$position},\r\n\t\t\t\t\thow_out = " . Sql::ProtectNumeric($batting->GetHowOut()) . ",\r\n\t\t\t\t\tdismissed_by_id = {$dismissed_by_id},\r\n\t\t\t\t\tbowler_id = {$bowler_id},\r\n\t\t\t\t\truns = " . Sql::ProtectNumeric($batting->GetRuns(), true) . ",\r\n                    balls_faced = " . Sql::ProtectNumeric($batting->GetBallsFaced(), true) . ",\r\n\t\t\t\t\tdate_added = " . gmdate('U');
             $batting_added = true;
         }
     }
     # See whether any batting records have been changed or removed
     $sql = "SELECT batting_id, player_id, dismissed_by_id, bowler_id FROM {$batting_table} WHERE match_team_id = {$batting_match_team_id}";
     # match_team_id is autonumber from db so can be trusted
     if (count($unchanged_batting)) {
         $sql .= " AND batting_id NOT IN(" . implode(',', $unchanged_batting) . ")";
     }
     $result = $this->GetDataConnection()->query($sql);
     while ($row = $result->fetch()) {
         # Save IDs of players whose records will be updated or deleted
         $players_affected[] = $row->player_id;
         if (!is_null($row->dismissed_by_id)) {
             $players_affected[] = $row->dismissed_by_id;
         }
         if (!is_null($row->bowler_id)) {
             $players_affected[] = $row->bowler_id;
         }
         $batting_deleted = true;
     }
     # Final step for the batting is to update, if necessary, the total runs/wickets in the main match record
     if ($is_home_innings) {
         $runs_and_wickets = "home_runs = " . Sql::ProtectNumeric($match->Result()->GetHomeRuns(), true, false) . "\r\n\t\t\t\t\tAND home_wickets = " . Sql::ProtectNumeric($match->Result()->GetHomeWickets(), true, false);
     } else {
         $runs_and_wickets = "away_runs = " . Sql::ProtectNumeric($match->Result()->GetAwayRuns(), true, false) . "\r\n\t\t\t\t\tAND away_wickets = " . Sql::ProtectNumeric($match->Result()->GetAwayWickets(), true, false);
     }
     $sql = "SELECT match_id FROM {$match_table} WHERE {$runs_and_wickets} AND match_id " . Sql::ProtectNumeric($match->GetId(), false, true);
     $result = $this->GetDataConnection()->query($sql);
     $totals_changed = $result->fetch() === false;
     # All changes to master data from here are logged, because this method can be called from the public interface
     # Delete batting for this innings if changed or removed
     if ($batting_deleted) {
         $sql = "DELETE FROM {$batting_table} WHERE match_team_id = {$batting_match_team_id}";
         # match_team_id is autonumber from db so can be trusted
         if (count($unchanged_batting)) {
             $sql .= " AND batting_id NOT IN(" . implode(',', $unchanged_batting) . ")";
         }
         $this->LoggedQuery($sql);
     }
     # Insert batting for this innings if changed or added
     if ($batting_added) {
         foreach ($new_batting as $sql) {
             $this->LoggedQuery($sql);
         }
     }
     # If run or wicket totals changed update that at the same time as recording match audit data
     $runs_and_wickets = "";
     if ($totals_changed) {
         if ($is_home_innings) {
             $runs_and_wickets = "home_runs = " . Sql::ProtectNumeric($match->Result()->GetHomeRuns(), true, false) . ",\r\n\t\t\t\t\thome_wickets = " . Sql::ProtectNumeric($match->Result()->GetHomeWickets(), true, false) . ", ";
         } else {
             $runs_and_wickets = "away_runs = " . Sql::ProtectNumeric($match->Result()->GetAwayRuns(), true, false) . ",\r\n\t\t\t\t\taway_wickets = " . Sql::ProtectNumeric($match->Result()->GetAwayWickets(), true, false) . ", ";
         }
     }
     # if match data has changed record that for audit, and notify moderator
     # We can also update the number of players per team so that the same number of boxes are shown next time.
     if ($batting_added or $batting_deleted or $totals_changed) {
         $players_per_team = $match->GetMaximumPlayersPerTeam();
         $sql = "UPDATE {$match_table} SET {$runs_and_wickets}\r\n                    players_per_team = {$players_per_team}, \r\n                    date_changed = " . gmdate('U') . ", \r\n                    modified_by_id = " . Sql::ProtectNumeric(AuthenticationManager::GetUser()->GetId()) . ' ' . "WHERE match_id " . Sql::ProtectNumeric($match->GetId(), false, true);
         $this->LoggedQuery($sql);
         $this->QueueForNotification($match->GetId(), false);
     }
     return $players_affected;
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:match-manager.class.php

示例4: CreateWicketsRow

 private function CreateWicketsRow(Match $match, $wickets_taken)
 {
     $wickets_header = new XhtmlCell(true, "Wickets");
     $wickets_header->SetColumnSpan(4);
     $wickets = new XhtmlSelect("batWickets", null, $this->IsValidSubmit());
     $wickets->SetBlankFirst(true);
     $max_wickets = $match->GetMaximumPlayersPerTeam() - 2;
     $season_dates = Season::SeasonDates($match->GetStartTime());
     # working with GMT
     if (Date::Year($season_dates[0]) != Date::Year($season_dates[1])) {
         # outdoor needs maximum-2, but indoor needs maximum-1 cos last batter can play on.
         # if there's any chance it's indoor use maximum-1
         $max_wickets = $match->GetMaximumPlayersPerTeam() - 1;
     }
     for ($i = 0; $i <= $max_wickets; $i++) {
         $wickets->AddControl(new XhtmlOption($i));
     }
     $wickets->AddControl(new XhtmlOption('all out', -1));
     if ($this->IsValidSubmit() and !is_null($wickets_taken)) {
         $wickets->SelectOption($wickets_taken);
     }
     $balls_column = new XhtmlCell(false, null);
     $wickets_row = new XhtmlRow(array($wickets_header, $wickets, $balls_column));
     $wickets_row->SetCssClass("totals");
     return $wickets_row;
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:26,代码来源:scorecard-edit-control.class.php


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