本文整理汇总了PHP中Team::SetName方法的典型用法代码示例。如果您正苦于以下问题:PHP Team::SetName方法的具体用法?PHP Team::SetName怎么用?PHP Team::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Team
的用法示例。
在下文中一共展示了Team::SetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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)
{
$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);
}
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:39,代码来源:teams-in-tournament-editor.class.php
示例2: Test
/**
* (non-PHPdoc)
* @see data/validation/DataValidator#Test($s_input, $a_keys)
*/
public function Test($a_data, $a_keys)
{
/* Only way to be sure of testing name against what it will be matched against is to use the code that transforms it when saving */
$team = new Team($this->GetSiteSettings());
$team->SetName($a_data[$a_keys[1]]);
$team->SetPlayerType($a_data[$a_keys[2]]);
$team_manager = new TeamManager($this->GetSiteSettings(), $this->GetDataConnection());
$team = $team_manager->MatchExistingTeam($team);
unset($team_manager);
$current_id = isset($a_data[$a_keys[0]]) ? $a_data[$a_keys[0]] : null;
return !$team->GetId() or $team->GetId() == $current_id;
}
示例3: 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)
{
$s_key = $this->GetNamingPrefix() . 'Team' . $i_counter;
$o_team = null;
$o_team = new Team($this->GetSettings());
if (isset($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
$o_team->SetId($_POST[$s_key]);
}
$s_key = $this->GetNamingPrefix() . 'TeamValue' . $i_counter;
if (isset($_POST[$s_key])) {
$o_team->SetName($_POST[$s_key]);
}
$s_key = $this->GetNamingPrefix() . 'WithdrawnLeague' . $i_counter;
$b_withdrawn_league = (isset($_POST[$s_key]) and $_POST[$s_key] == '1');
if ($o_team->GetId() or $b_withdrawn_league) {
$team_in_season = new TeamInSeason($o_team, null, $b_withdrawn_league);
$this->DataObjects()->Add($team_in_season);
} else {
$this->IgnorePostedItem($i_counter);
}
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:27,代码来源:teams-in-season-editor.class.php
示例4: BuildPostedDataObject
/**
* @return void
* @desc Re-build from data posted by this control the data object this control is editing
*/
function BuildPostedDataObject()
{
$team = new Team($this->GetSettings());
if (isset($_POST['item'])) {
$team->SetId($_POST['item']);
}
if (isset($_POST['name'])) {
$team->SetName($_POST['name']);
}
$team->SetWebsiteUrl($_POST['websiteUrl']);
$team->SetIsActive(isset($_POST['playing']));
$team->SetIntro(ucfirst(trim($_POST['intro'])));
$team->SetPlayingTimes($_POST['times']);
$team->SetCost($_POST['yearCost']);
$team->SetContact($_POST['contact']);
$team->SetPrivateContact($_POST['private']);
$ground = new Ground($this->GetSettings());
$ground->SetId($_POST['ground']);
$team->SetGround($ground);
if (isset($_POST['team_type'])) {
$team->SetTeamType($_POST['team_type']);
if ($team->GetTeamType() == Team::SCHOOL_YEARS) {
$team->SetSchoolYears(array(1 => isset($_POST['year1']), 2 => isset($_POST['year2']), 3 => isset($_POST['year3']), 4 => isset($_POST['year4']), 5 => isset($_POST['year5']), 6 => isset($_POST['year6']), 7 => isset($_POST['year7']), 8 => isset($_POST['year8']), 9 => isset($_POST['year9']), 10 => isset($_POST['year10']), 11 => isset($_POST['year11']), 12 => isset($_POST['year12'])));
}
}
if ($this->is_admin) {
$team->SetShortUrl($_POST[$this->GetNamingPrefix() . 'ShortUrl']);
$team->SetPlayerType($_POST['playerType']);
if (isset($_POST['club']) and is_numeric($_POST['club'])) {
$club = new Club($this->GetSettings());
$club->SetId($_POST['club']);
$team->SetClub($club);
}
}
$this->SetDataObject($team);
}
示例5: BuildPostedDataObject
/**
* @return void
* @desc Re-build from data posted by this control the data object this control is editing
*/
function BuildPostedDataObject()
{
$match = new Match($this->GetSettings());
$match->SetId($this->GetDataObjectId());
# Get match date
$s_key = $this->GetNamingPrefix() . 'Date';
if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
$match->SetStartTime($_POST[$s_key]);
}
# Get team names
$s_key = $this->GetNamingPrefix() . 'Home';
if (isset($_POST[$s_key])) {
$team_data = explode(MatchHighlightsEditControl::DATA_SEPARATOR, $_POST[$s_key], 2);
if (count($team_data) == 2) {
$o_home = new Team($this->GetSettings());
$o_home->SetId($team_data[0]);
$o_home->SetName($team_data[1]);
$match->SetHomeTeam($o_home);
}
}
$s_key = $this->GetNamingPrefix() . 'Away';
if (isset($_POST[$s_key])) {
$team_data = explode(MatchHighlightsEditControl::DATA_SEPARATOR, $_POST[$s_key], 2);
if (count($team_data) == 2) {
$o_away = new Team($this->GetSettings());
$o_away->SetId($team_data[0]);
$o_away->SetName($team_data[1]);
$match->SetAwayTeam($o_away);
}
}
# Get the result
$s_key = $this->GetNamingPrefix() . 'Result';
if (isset($_POST[$s_key])) {
$s_result = $_POST[$s_key];
if (strlen($s_result)) {
$match->Result()->SetResultType($s_result);
}
}
# Get players of the match. Fields to use depend on which radio button was selected.
$s_key = $this->GetNamingPrefix() . 'POM';
if (isset($_POST[$s_key])) {
$pom_type = (int) $_POST[$s_key];
if ($pom_type == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL) {
$s_key = $this->GetNamingPrefix() . 'Player';
if (isset($_POST[$s_key]) and $_POST[$s_key]) {
$player = new Player($this->GetSettings());
$player->SetName($_POST[$s_key]);
$s_key = $this->GetNamingPrefix() . 'PlayerTeam';
if (isset($_POST[$s_key])) {
$player->Team()->SetId($_POST[$s_key]);
}
$match->Result()->SetPlayerOfTheMatch($player);
}
} else {
if ($pom_type == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY) {
$s_key = $this->GetNamingPrefix() . 'PlayerHome';
if (isset($_POST[$s_key]) and $_POST[$s_key]) {
$player = new Player($this->GetSettings());
$player->SetName($_POST[$s_key]);
$player->Team()->SetId($match->GetHomeTeamId());
$match->Result()->SetPlayerOfTheMatchHome($player);
}
$s_key = $this->GetNamingPrefix() . 'PlayerAway';
if (isset($_POST[$s_key]) and $_POST[$s_key]) {
$player = new Player($this->GetSettings());
$player->SetName($_POST[$s_key]);
$player->Team()->SetId($match->GetAwayTeamId());
$match->Result()->SetPlayerOfTheMatchAway($player);
}
}
}
}
$s_key = $this->GetNamingPrefix() . 'Comments';
if (isset($_POST[$s_key])) {
$match->SetNewComment($_POST[$s_key]);
}
$this->SetDataObject($match);
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:82,代码来源:match-highlights-edit-control.class.php
示例6: BuildItems
/**
* Populates the collection of business objects from raw data
*
* @return bool
* @param MySqlRawData $o_result
*/
protected function BuildItems(MySqlRawData $o_result)
{
# use CollectionBuilder to handle duplicates
$o_ground_builder = new CollectionBuilder();
$o_ground = null;
while ($row = $o_result->fetch()) {
# check whether this is a new ground
if (!$o_ground_builder->IsDone($row->ground_id)) {
# store any exisiting ground
if ($o_ground != null) {
$this->Add($o_ground);
}
# create the new ground
$o_ground = new Ground($this->o_settings);
$o_ground->SetId($row->ground_id);
$o_ground->SetDirections($row->directions);
$o_ground->SetParking($row->parking);
$o_ground->SetFacilities($row->facilities);
$o_ground->SetShortUrl($row->short_url);
$o_ground->SetDateUpdated($row->date_changed);
if (isset($row->update_search) and $row->update_search == 1) {
$o_ground->SetSearchUpdateRequired();
}
$o_address = $o_ground->GetAddress();
$o_address->SetSaon($row->saon);
$o_address->SetPaon($row->paon);
$o_address->SetStreetDescriptor($row->street_descriptor);
$o_address->SetLocality($row->locality);
$o_address->SetTown($row->town);
$o_address->SetAdministrativeArea($row->administrative_area);
$o_address->SetPostcode($row->postcode);
if (isset($row->latitude)) {
$o_address->SetGeoLocation($row->latitude, $row->longitude, $row->geo_precision);
}
$o_ground->SetAddress($o_address);
}
if (isset($row->team_name)) {
$team = new Team($this->GetSettings());
$team->SetName($row->team_name);
$team->SetShortUrl($row->team_short_url);
$team->SetPlayerType($row->player_type_id);
$o_ground->Teams()->Add($team);
}
}
# store final ground
if ($o_ground != null) {
$this->Add($o_ground);
}
}
示例7: BuildPostedDataObject
/**
* Builds a match object containing the result information posted by the control
*
*/
public function BuildPostedDataObject()
{
$o_match = new Match($this->GetSettings());
$o_match->SetId($this->GetDataObjectId());
# Get match date
$s_key = $this->GetNamingPrefix() . 'Date';
if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
$o_match->SetStartTime($_POST[$s_key]);
}
# Get team names
$s_key = $this->GetNamingPrefix() . 'Home';
if (isset($_POST[$s_key])) {
$team_data = explode(";", $_POST[$s_key], 2);
if (count($team_data) == 2) {
$o_home = new Team($this->GetSettings());
$o_home->SetId($team_data[0]);
$o_home->SetName($team_data[1]);
$o_match->SetHomeTeam($o_home);
}
}
$s_key = $this->GetNamingPrefix() . 'Away';
if (isset($_POST[$s_key])) {
$team_data = explode(";", $_POST[$s_key], 2);
if (count($team_data) == 2) {
$o_away = new Team($this->GetSettings());
$o_away->SetId($team_data[0]);
$o_away->SetName($team_data[1]);
$o_match->SetAwayTeam($o_away);
}
}
# Get who batted first
$s_key = $this->GetNamingPrefix() . 'BatFirst';
if (isset($_POST[$s_key])) {
$s_batted = $_POST[$s_key];
if ($s_batted == 'home') {
$o_match->Result()->SetHomeBattedFirst(true);
} else {
if ($s_batted == 'away') {
$o_match->Result()->SetHomeBattedFirst(false);
}
}
}
# Get the result
$s_key = $this->GetNamingPrefix() . 'Result';
if (isset($_POST[$s_key])) {
$s_result = $_POST[$s_key];
if (strlen($s_result)) {
$o_match->Result()->SetResultType($s_result);
}
}
# Get the home score
$s_key = $this->GetNamingPrefix() . 'HomeRuns';
if (isset($_POST[$s_key])) {
$s_home_runs = $_POST[$s_key];
if (strlen($s_home_runs)) {
$o_match->Result()->SetHomeRuns($s_home_runs);
}
}
$s_key = $this->GetNamingPrefix() . 'HomeWickets';
if (isset($_POST[$s_key])) {
$s_home_wickets = $_POST[$s_key];
if (strlen($s_home_wickets)) {
$o_match->Result()->SetHomeWickets($s_home_wickets);
}
}
# Get the away score
$s_key = $this->GetNamingPrefix() . 'AwayRuns';
if (isset($_POST[$s_key])) {
$s_away_runs = $_POST[$s_key];
if (strlen($s_away_runs)) {
$o_match->Result()->SetAwayRuns($s_away_runs);
}
}
$s_key = $this->GetNamingPrefix() . 'AwayWickets';
if (isset($_POST[$s_key])) {
$s_away_wickets = $_POST[$s_key];
if (strlen($s_away_wickets)) {
$o_match->Result()->SetAwayWickets($s_away_wickets);
}
}
$s_key = $this->GetNamingPrefix() . 'Comments';
if (isset($_POST[$s_key])) {
$o_match->SetNewComment($_POST[$s_key]);
}
$this->SetDataObject($o_match);
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:90,代码来源:match-result-edit-control.class.php
示例8: BuildItems
/**
* Populates the collection of business objects from raw data
*
* @return bool
* @param MySqlRawData $o_result
*/
protected function BuildItems(MySqlRawData $o_result)
{
$this->Clear();
$o_match_builder = new CollectionBuilder();
$o_team_builder = new CollectionBuilder();
$o_tournament_match_builder = new CollectionBuilder();
$season_builder = new CollectionBuilder();
while ($o_row = $o_result->fetch()) {
if (!$o_match_builder->IsDone($o_row->match_id)) {
if (isset($o_match)) {
$this->Add($o_match);
$o_team_builder->Reset();
$o_tournament_match_builder->Reset();
$season_builder->Reset();
}
# create new
$o_match = new Match($this->GetSettings());
$this->BuildMatchSummary($o_match, $o_row);
if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH and isset($o_row->tournament_match_id)) {
$o_tourn = new Match($this->o_settings);
$o_tourn->SetMatchType(MatchType::TOURNAMENT);
$o_tourn->SetId($o_row->tournament_match_id);
if (isset($o_row->tournament_title)) {
$o_tourn->SetTitle($o_row->tournament_title);
}
if (isset($o_row->tournament_url)) {
$o_tourn->SetShortUrl($o_row->tournament_url);
}
$o_match->SetTournament($o_tourn);
unset($o_tourn);
}
if (isset($o_row->home_team_id) and !is_null($o_row->home_team_id)) {
$o_home = new Team($this->o_settings);
$o_home->SetId($o_row->home_team_id);
if (isset($o_row->home_team_name)) {
$o_home->SetName($o_row->home_team_name);
}
if (isset($o_row->home_short_url)) {
$o_home->SetShortUrl($o_row->home_short_url);
}
$o_match->SetHomeTeam($o_home);
unset($o_home);
}
$this->BuildGround($o_match, $o_row);
}
# Add away teams
if (isset($o_row->away_team_id) && !$o_team_builder->IsDone($o_row->away_team_id)) {
$o_away = new Team($this->o_settings);
$o_away->SetId($o_row->away_team_id);
if (isset($o_row->away_team_name)) {
$o_away->SetName($o_row->away_team_name);
}
if (isset($o_row->away_short_url)) {
$o_away->SetShortUrl($o_row->away_short_url);
}
$o_match->AddAwayTeam($o_away);
unset($o_away);
}
# Add matches in tournament
if (isset($o_row->match_id_in_tournament) and is_numeric($o_row->match_id_in_tournament) and !$o_tournament_match_builder->IsDone($o_row->match_id_in_tournament)) {
$o_tmatch = new Match($this->o_settings);
$o_tmatch->SetMatchType(MatchType::TOURNAMENT_MATCH);
$o_tmatch->SetId($o_row->match_id_in_tournament);
$o_tmatch->SetTitle($o_row->tournament_match_title);
$o_tmatch->SetShortUrl($o_row->tournament_match_url);
$o_tmatch->SetStartTime($o_row->tournament_match_time);
$o_tmatch->SetIsStartTimeKnown($o_row->tournament_match_start_time_known);
$o_tmatch->SetOrderInTournament($o_row->order_in_tournament);
$o_match->AddMatchInTournament($o_tmatch);
unset($o_tmatch);
}
# Add seasons
$this->BuildSeason($o_match, $o_row, $season_builder);
}
# Add final match
if (isset($o_match)) {
$this->Add($o_match);
}
return true;
}
示例9: BuildItems
/**
* Populates the collection of business objects from raw data
*
* @return bool
* @param MySqlRawData $result
*/
protected function BuildItems(MySqlRawData $result)
{
# use CollectionBuilder to handle duplicates
$school_builder = new CollectionBuilder();
$school = null;
while ($row = $result->fetch()) {
# check whether this is a new school
if (!$school_builder->IsDone($row->club_id)) {
# store any exisiting school
if ($school != null) {
$this->Add($school);
}
# create the new school
$school = new School($this->GetSettings());
$school->SetId($row->club_id);
$school->SetName($row->club_name);
$school->SetTypeOfClub($row->club_type);
$school->SetHowManyPlayers($row->how_many_players);
$school->SetAgeRangeLower($row->age_range_lower);
$school->SetAgeRangeUpper($row->age_range_upper);
$school->SetPlaysOutdoors($row->plays_outdoors);
$school->SetPlaysIndoors($row->plays_indoors);
$school->SetShortUrl($row->short_url);
$school->SetTwitterAccount($row->twitter);
$school->SetFacebookUrl($row->facebook);
$school->SetInstagramAccount($row->instagram);
$school->SetClubmarkAccredited($row->clubmark);
# Infer partial address from school name
$school_name = $school->GetName();
$comma = strrpos($school_name, ",");
if ($comma !== false) {
$school->Ground()->GetAddress()->SetTown(trim(substr($school_name, $comma + 1)));
$school->Ground()->GetAddress()->SetPaon(substr($school_name, 0, $comma));
}
}
# team the only cause of multiple rows (so far) so add to current school
if ($row->team_id) {
$team = new Team($this->GetSettings());
$team->SetId($row->team_id);
$team->SetName($row->team_name);
$team->SetShortUrl($row->team_short_url);
$school->Add($team);
}
}
# store final club
if ($school != null) {
$this->Add($school);
}
}
示例10: BuildItems
/**
* Populates the collection of business objects from raw data
*
* @return bool
* @param MySqlRawData $o_result
*/
protected function BuildItems(MySqlRawData $o_result)
{
$this->Clear();
/* @var $o_team Team */
# use CollectionBuilder to handle duplicates
$o_team_builder = new CollectionBuilder();
$o_season_builder = new CollectionBuilder();
$o_team = null;
while ($row = $o_result->fetch()) {
# check whether this is a new team
if (!$o_team_builder->IsDone($row->team_id)) {
# store any exisiting team
if ($o_team != null) {
$this->Add($o_team);
$o_season_builder->Reset();
}
# create the new team
$o_team = new Team($this->o_settings);
$o_team->SetId($row->team_id);
$o_team->SetName($row->team_name);
if (isset($row->website)) {
$o_team->SetWebsiteUrl($row->website);
}
if (isset($row->active)) {
$o_team->SetIsActive($row->active);
}
if (isset($row->team_type)) {
$o_team->SetTeamType($row->team_type);
}
if (isset($row->intro)) {
$o_team->SetIntro($row->intro);
}
if (isset($row->playing_times)) {
$o_team->SetPlayingTimes($row->playing_times);
}
if (isset($row->cost)) {
$o_team->SetCost($row->cost);
}
if (isset($row->contact)) {
$o_team->SetContact($row->contact);
}
if (isset($row->contact_nsa)) {
$o_team->SetPrivateContact($row->contact_nsa);
}
if (isset($row->short_url)) {
$o_team->SetShortUrl($row->short_url);
}
if (isset($row->player_type_id)) {
$o_team->SetPlayerType($row->player_type_id);
}
$o_team->SetSchoolYears(array(1 => isset($row->year1) and $row->year1, 2 => isset($row->year2) and $row->year2, 3 => isset($row->year3) and $row->year3, 4 => isset($row->year4) and $row->year4, 5 => isset($row->year5) and $row->year5, 6 => isset($row->year6) and $row->year6, 7 => isset($row->year7) and $row->year7, 8 => isset($row->year8) and $row->year8, 9 => isset($row->year9) and $row->year9, 10 => isset($row->year10) and $row->year10, 11 => isset($row->year11) and $row->year11, 12 => isset($row->year12) and $row->year12));
if (isset($row->update_search) and $row->update_search == 1) {
$o_team->SetSearchUpdateRequired();
}
if (isset($row->date_changed)) {
$o_team->SetLastAudit(new AuditData($row->modified_by_id, $row->known_as, $row->date_changed));
}
$club = new Club($this->GetSettings());
if (isset($row->club_id)) {
$club->SetId($row->club_id);
if (isset($row->club_name)) {
$club->SetName($row->club_name);
}
if (isset($row->twitter)) {
$club->SetTwitterAccount($row->twitter);
}
if (isset($row->facebook)) {
$club->SetFacebookUrl($row->facebook);
}
if (isset($row->instagram)) {
$club->SetInstagramAccount($row->instagram);
}
if (isset($row->clubmark)) {
$club->SetClubmarkAccredited($row->clubmark);
}
if (isset($row->club_short_url)) {
$club->SetShortUrl($row->club_short_url);
}
}
# If the website is actually a Facebook page, move it, overriding the club Facebook page is necessary
if (strpos($o_team->GetWebsiteUrl(), 'facebook.com/') !== false) {
$club->SetFacebookUrl($o_team->GetWebsiteUrl());
$o_team->SetWebsiteUrl('');
}
$o_team->SetClub($club);
if (isset($row->ground_id) and $row->ground_id) {
$o_ground = new Ground($this->o_settings);
$o_ground->SetId($row->ground_id);
$address = $o_ground->GetAddress();
if (isset($row->saon)) {
$address->SetSaon($row->saon);
}
if (isset($row->town)) {
if (isset($row->paon)) {
//.........这里部分代码省略.........
示例11: BuildItems
/**
* Populates the collection of business objects from raw data
*
* @return bool
* @param MySqlRawData $o_result
*/
protected function BuildItems(MySqlRawData $o_result)
{
/* @var $o_season Season */
$this->Clear();
# use CollectionBuilder to handle duplicates
$o_season_builder = new CollectionBuilder();
$o_team_builder = new CollectionBuilder();
$o_rule_builder = new CollectionBuilder();
$o_points_builder = new CollectionBuilder();
$o_type_builder = new CollectionBuilder();
$o_season = null;
while ($o_row = $o_result->fetch()) {
# check whether this is a new season
if (!$o_season_builder->IsDone($o_row->season_id)) {
# store any exisiting season and reset
if ($o_season != null) {
$this->Add($o_season);
$o_team_builder->Reset();
$o_rule_builder->Reset();
$o_points_builder->Reset();
$o_type_builder->Reset();
}
# create the new season
$o_season = new Season($this->GetSettings());
$this->BuildSeason($o_season, $o_row);
}
# Teams the first cause of multiple rows
if (isset($o_row->team_id)) {
if (!$o_team_builder->IsDone($o_row->team_id)) {
if (isset($o_team)) {
unset($o_team);
}
$o_team = new Team($this->GetSettings());
$o_team->SetId($o_row->team_id);
$o_team->SetName($o_row->team_name);
$ground = new Ground($this->GetSettings());
$ground->SetId($o_row->team_ground_id);
$o_team->SetGround($ground);
if (isset($o_row->team_short_url)) {
$o_team->SetShortUrl($o_row->team_short_url);
}
$o_season->AddTeam($o_team);
if (isset($o_row->withdrawn_league) and (bool) $o_row->withdrawn_league) {
$o_season->TeamsWithdrawnFromLeague()->Add($o_team);
}
}
# Points adjustments - should come with team and in order of team
if (isset($o_row->point_id) and !$o_points_builder->IsDone($o_row->point_id)) {
$o_point = new PointsAdjustment($o_row->point_id, $o_row->points, $o_team, $o_row->reason, $o_row->points_date);
$o_season->PointsAdjustments()->Add($o_point);
}
}
# Season rules
if (isset($o_row->season_rule_id) and !$o_rule_builder->IsDone($o_row->season_rule_id)) {
$o_mr = new MatchResult($o_row->match_result_id);
$o_mr->SetHomePoints($o_row->home_points);
$o_mr->SetAwayPoints($o_row->away_points);
$o_season->PossibleResults()->Add($o_mr);
unset($o_mr);
}
# Match types
if (isset($o_row->season_match_type) and !$o_type_builder->IsDone($o_row->season_match_type)) {
$o_season->MatchTypes()->Add((int) $o_row->season_match_type);
}
}
# store final season
if ($o_season != null) {
$this->Add($o_season);
}
return true;
}
示例12: BuildItems
/**
* Populates the collection of business objects from raw data
*
* @return bool
* @param MySqlRawData $o_result
*/
protected function BuildItems(MySqlRawData $o_result)
{
$this->Clear();
$o_match_builder = new CollectionBuilder();
$o_team_builder = new CollectionBuilder();
while ($o_row = $o_result->fetch()) {
if (!$o_match_builder->IsDone($o_row->match_id)) {
if (isset($o_match)) {
$this->Add($o_match);
$o_team_builder->Reset();
}
# create new
$o_match = new Match($this->GetSettings());
$o_match->SetId($o_row->match_id);
if (isset($o_row->start_time)) {
$o_match->SetStartTime($o_row->start_time);
}
if (isset($o_row->home_runs)) {
$o_match->Result()->SetHomeRuns($o_row->home_runs);
}
if (isset($o_row->away_runs)) {
$o_match->Result()->SetAwayRuns($o_row->away_runs);
}
if (isset($o_row->match_result_id)) {
$o_match->Result()->SetResultType($o_row->match_result_id);
}
if (isset($o_row->home_team_id) and !is_null($o_row->home_team_id)) {
$o_home = new Team($this->o_settings);
$o_home->SetId($o_row->home_team_id);
if (isset($o_row->home_team_name)) {
$o_home->SetName($o_row->home_team_name);
}
if (isset($o_row->home_short_url)) {
$o_home->SetShortUrl($o_row->home_short_url);
}
$o_match->SetHomeTeam($o_home);
unset($o_home);
}
if (isset($o_row->ground_id)) {
$o_ground = new Ground($this->GetSettings());
$o_ground->SetId($o_row->ground_id);
$o_match->SetGround($o_ground);
unset($o_ground);
}
}
# Add away teams
if (isset($o_row->away_team_id) && !$o_team_builder->IsDone($o_row->away_team_id)) {
$o_away = new Team($this->o_settings);
$o_away->SetId($o_row->away_team_id);
if (isset($o_row->away_team_name)) {
$o_away->SetName($o_row->away_team_name);
}
if (isset($o_row->away_short_url)) {
$o_away->SetShortUrl($o_row->away_short_url);
}
$o_match->AddAwayTeam($o_away);
unset($o_away);
}
}
# Add final match
if (isset($o_match)) {
$this->Add($o_match);
}
return true;
}
示例13: BuildPostedScorecard
/**
* Builds data posted on pages 2/3 back into a match object
* @return Match
*/
private function BuildPostedScorecard()
{
$match = new Match($this->GetSettings());
$match->SetId($this->GetDataObjectId());
# Must have data on which team is which, otherwise none of the rest makes sense
# Team ids are essential for saving data, while team names and match title are
# purely so they can be redisplayed if the page is invalid
$key = "teams";
if (!isset($_POST[$key]) or strpos($_POST[$key], ScorecardEditControl::DATA_SEPARATOR) === false) {
return $match;
}
$teams = explode(ScorecardEditControl::DATA_SEPARATOR, $_POST[$key], 6);
if (count($teams) != 6) {
return $match;
}
switch ($teams[0]) {
case "0":
$match->Result()->SetHomeBattedFirst(false);
$home_batting = $this->GetCurrentPage() == 3;
break;
case "1":
$match->Result()->SetHomeBattedFirst(true);
$home_batting = $this->GetCurrentPage() == 2;
break;
default:
$home_batting = $this->GetCurrentPage() == 2;
}
$home_team = new Team($this->GetSettings());
$home_team->SetId($teams[1]);
$home_team->SetName($teams[2]);
$match->SetHomeTeam($home_team);
$away_team = new Team($this->GetSettings());
$away_team->SetId($teams[3]);
$away_team->SetName($teams[4]);
$match->SetAwayTeam($away_team);
$match->SetTitle($teams[5]);
# Read posted batting data
$key = "batRows";
if (isset($_POST[$key])) {
# This controls not only which fields are read, but also which are redisplayed on an invalid postback or for the next innings.
$match->SetMaximumPlayersPerTeam(intval($_POST[$key]));
}
for ($i = 1; $i <= $match->GetMaximumPlayersPerTeam(); $i++) {
$key = "batName{$i}";
if (isset($_POST[$key])) {
# The row exists - has it been filled in?
if (trim($_POST[$key])) {
# Read the batter data in this row
$player = new Player($this->GetSettings());
$player->SetName($_POST[$key]);
$player->Team()->SetId($home_batting ? $home_team->GetId() : $away_team->GetId());
$key = "batHowOut{$i}";
$how_out = (isset($_POST[$key]) and is_numeric($_POST[$key])) ? (int) $_POST[$key] : null;
$key = "batOutBy{$i}";
$dismissed_by = null;
if (isset($_POST[$key]) and trim($_POST[$key])) {
$dismissed_by = new Player($this->GetSettings());
$dismissed_by->SetName($_POST[$key]);
$dismissed_by->Team()->SetId($home_batting ? $away_team->GetId() : $home_team->GetId());
}
$key = "batBowledBy{$i}";
$bowler = null;
if (isset($_POST[$key]) and trim($_POST[$key])) {
$bowler = new Player($this->GetSettings());
$bowler->SetName($_POST[$key]);
$bowler->Team()->SetId($home_batting ? $away_team->GetId() : $home_team->GetId());
}
# Correct caught and bowled if marked as caught
if ($how_out == Batting::CAUGHT and !is_null($dismissed_by) and !is_null($bowler) and trim($dismissed_by->GetName()) == trim($bowler->GetName())) {
$how_out = Batting::CAUGHT_AND_BOWLED;
$dismissed_by = null;
}
$key = "batRuns{$i}";
$runs = (isset($_POST[$key]) and is_numeric($_POST[$key])) ? (int) $_POST[$key] : null;
$key = "batBalls{$i}";
$balls = (isset($_POST[$key]) and is_numeric($_POST[$key])) ? (int) $_POST[$key] : null;
# Add that batting performance to the match result
$batting = new Batting($player, $how_out, $dismissed_by, $bowler, $runs, $balls);
if ($home_batting) {
$match->Result()->HomeBatting()->Add($batting);
} else {
$match->Result()->AwayBatting()->Add($batting);
}
}
}
}
$key = "batByes";
if (isset($_POST[$key]) and is_numeric($_POST[$key])) {
$player = new Player($this->GetSettings());
$player->SetPlayerRole(Player::BYES);
$player->Team()->SetId($home_batting ? $home_team->GetId() : $away_team->GetId());
$batting = new Batting($player, null, null, null, (int) $_POST[$key]);
if ($home_batting) {
$match->Result()->HomeBatting()->Add($batting);
} else {
$match->Result()->AwayBatting()->Add($batting);
//.........这里部分代码省略.........
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:scorecard-edit-control.class.php
示例14: BuildItems
/**
* Populates the collection of business objects from raw data
*
* @return bool
* @param MySqlRawData $result
*/
protected function BuildItems(MySqlRawData $result)
{
# use CollectionBuilder to handle duplicates
$club_builder = new CollectionBuilder();
$club = null;
while ($row = $result->fetch()) {
# check whether this is a new club
if (!$club_builder->IsDone($row->club_id)) {
# store any exisiting club
if ($club != null) {
$this->Add($club);
}
# create the new club
$club = new Club($this->GetSettings());
$club->SetId($row->club_id);
$club->SetName($row->club_name);
$club->SetTypeOfClub($row->club_type);
$club->SetHowManyPlayers($row->how_many_players);
$club->SetAgeRangeLower($row->age_range_lower);
$club->SetAgeRangeUpper($row->age_range_upper);
$club->SetPlaysOutdoors($row->plays_outdoors);
$club->SetPlaysIndoors($row->plays_indoors);
$club->SetShortUrl($row->short_url);
$club->SetTwitterAccount($row->twitter);
$club->SetFacebookUrl($row->facebook);
$club->SetInstagramAccount($row->instagram);
$club->SetClubmarkAccredited($row->clubmark);
}
# team the only cause of multiple rows (so far) so add to current club
if ($row->team_id) {
$team = new Team($this->GetSettings());
$team->SetId($row->team_id);
$team->SetName($row->team_name);
$team->SetShortUrl($row->team_short_url);
$club->Add($team);
}
}
# store final club
if ($club != null) {
$this->Add($club);
}
}
示例15: BuildItems
/**
* Populates the collection of business objects from raw data
*
* @return bool
* @param MySqlRawData $o_result
*/
protected function BuildItems(MySqlRawData $o_result)
{
/* @var $o_competition Competition */
# use CollectionBuilder to handle duplicates
$o_comp_builder = new CollectionBuilder();
$o_season_builder = new CollectionBuilder();
$o_team_builder = new CollectionBuilder();
$o_points_builder = new CollectionBuilder();
$o_matchtype_builder = new CollectionBuilder();
$o_competition = null;
$o_season = null;
while ($o_row = $o_result->fetch()) {
# check whether this is a new competition
if (!$o_comp_builder->IsDone($o_row->competition_id)) {
# store any exisiting competition and reset
if ($o_competition != null) {
if ($o_season != null) {
$o_competition->AddSeason($o_season, true);
}
$o_season = null;
$o_matchtype_builder->Reset();
$this->Add($o_competition);
$o_season_builder->Reset();
}
# create the new competition
$o_competition = new Competition($this->o_settings);
$o_competition->SetId($o_row->competition_id);
$o_competition->SetName($o_row->competition_name);
if (isset($o_row->intro)) {
$o_competition->SetIntro($o_row->intro);
}
if (isset($o_row->contact)) {
$o_competition->SetContact($o_row->contact);
}
if (isset($o_row->notification_email)) {
$o_competition->SetNotificationEmail($o_row->notification_email);
}
if (isset($o_row->website)) {
$o_competition->SetWebsiteUrl($o_row->website);
}
if (isset($o_row->short_url)) {
$o_competition->SetShortUrl($o_row->short_url);
}
if (isset($o_row->active)) {
$o_competition->SetIsActive($o_row->active);
}
if (isset($o_row->players_per_team)) {
$o_competition->SetMaximumPlayersPerTeam($o_row->players_per_team);
}
if (isset($o_row->overs)) {
$o_competition->SetOvers($o_row->overs);
}
$o_competition->SetPlayerType($o_row->player_type_id);
if (isset($o_row->update_search) and $o_row->update_search == 1) {
$o_competition->SetSearchUpdateRequired();
}
if (isset($o_row->category_id) && !is_null($o_row->category_id)) {
$cat = new Category();
$cat->SetId($o_row->category_id);
if (isset($o_row->category_name)) {
$cat->SetName($o_row->category_name);
}
if (isset($o_row->code)) {
$cat->SetUrl($o_row->code);
}
$o_competition->SetCategory($cat);
}
}
# Seasons are the first cause of multiple rows (first in sort order after competition)
if (isset($o_row->season_id)) {
if (!$o_season_builder->IsDone($o_row->season_id)) {
if ($o_season != null) {
$o_competition->AddSeason($o_season, true);
}
$o_season = new Season($this->o_settings);
$o_season->SetId($o_row->season_id);
$o_season->SetName($o_row->season_name);
$o_season->SetIsLatest($o_row->is_latest);
$o_season->SetStartYear($o_row->start_year);
$o_season->SetEndYear($o_row->end_year);
if (isset($o_row->season_intro)) {
$o_season->SetIntro($o_row->season_intro);
}
if (isset($o_row->results)) {
$o_season->SetResults($o_row->results);
}
if (isset($o_row->show_table)) {
$o_season->SetShowTable($o_row->show_table);
}
if (isset($o_row->show_runs_scored)) {
$o_season->SetShowTableRunsScored($o_row->show_runs_scored);
}
if (isset($o_row->show_runs_conceded)) {
$o_season->SetShowTableRunsConceded($o_row->show_runs_conceded);
//.........这里部分代码省略.........