本文整理汇总了PHP中Player::SetName方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::SetName方法的具体用法?PHP Player::SetName怎么用?PHP Player::SetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::SetName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BuildPostedDataObject
/**
* @return void
* @desc Re-build from data posted by this control the data object this control is editing
*/
public function BuildPostedDataObject()
{
$player = new Player($this->GetSettings());
$key = $this->GetNamingPrefix() . 'item';
if (isset($_POST[$key])) {
$player->SetId($this->GetNamingPrefix() . $_POST[$key]);
}
$key = $this->GetNamingPrefix() . 'Name';
if (isset($_POST[$key])) {
$player->SetName($this->GetNamingPrefix() . $_POST[$key]);
}
$this->SetDataObject($player);
$key = $this->GetNamingPrefix() . "MergeOptions";
if (isset($_POST[$key]) and $_POST[$key] == "1") {
$this->merge_requested = true;
}
}
示例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 */
$player = new Player($this->GetSiteSettings());
$player->SetName($a_data[$a_keys[0]]);
$comparable_name = $player->GetComparableName();
if ($comparable_name == "noballs") {
return false;
}
if ($comparable_name == "wides") {
return false;
}
if ($comparable_name == "byes") {
return false;
}
if ($comparable_name == "bonusruns") {
return false;
}
return true;
}
示例3: 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
示例4: Delete
/**
* @access public
* @return void
* @param int[] $player_ids
* @desc Delete from the database the players matching the supplied ids
*/
public function Delete($player_ids)
{
# check parameter
$this->ValidateNumericArray($player_ids);
# Get tables
$players = $this->GetSettings()->GetTable('Player');
$matches = $this->GetSettings()->GetTable("Match");
$batting = $this->GetSettings()->GetTable("Batting");
$bowling = $this->GetSettings()->GetTable("Bowling");
$stats = $this->GetSettings()->GetTable('PlayerMatch');
$player_id_list = implode(', ', $player_ids);
# delete from short URL cache
require_once 'http/short-url-manager.class.php';
$o_url_manager = new ShortUrlManager($this->GetSettings(), $this->GetDataConnection());
$sql = "SELECT short_url FROM {$players} WHERE player_id IN ({$player_id_list})";
$result = $this->GetDataConnection()->query($sql);
while ($row = $result->fetch()) {
$o_url_manager->Delete($row->short_url);
}
$result->closeCursor();
unset($o_url_manager);
# remove player of the match awards
$sql = "UPDATE {$matches} SET player_of_match_id = NULL WHERE player_of_match_id IN ({$player_id_list})";
$this->LoggedQuery($sql);
$sql = "UPDATE {$matches} SET player_of_match_home_id = NULL WHERE player_of_match_home_id IN ({$player_id_list})";
$this->LoggedQuery($sql);
$sql = "UPDATE {$matches} SET player_of_match_away_id = NULL WHERE player_of_match_away_id IN ({$player_id_list})";
$this->LoggedQuery($sql);
# Reassign batting and bowling to 'unknown' player
$unknown_player = new Player($this->GetSettings());
$unknown_player->SetName("Unknown");
foreach ($player_ids as $player_id) {
$sql = "SELECT team_id FROM {$players} WHERE player_id = " . Sql::ProtectNumeric($player_id);
$result = $this->GetDataConnection()->query($sql);
$row = $result->fetch();
$unknown_player->Team()->SetId($row->team_id);
$unknown_player->SetId($this->SaveOrMatchPlayer($unknown_player));
$player = new Player($this->GetSettings());
$player->SetId($player_id);
$this->is_internal_delete = true;
$this->MergePlayers($player, $unknown_player);
$this->is_internal_delete = false;
}
# Delete statistics
$sql = "DELETE FROM {$stats} WHERE player_id IN ({$player_id_list})";
$this->LoggedQuery($sql);
# delete the player
$sql = "DELETE FROM {$players} WHERE player_id IN ({$player_id_list})";
$this->LoggedQuery($sql);
}
示例5: BuildMatchSummary
/**
* Helper to build basic info about a match from raw data
*
* @param Match $match
* @param DataRow $row
*/
private function BuildMatchSummary(Match $match, $row)
{
$match->SetId($row->match_id);
if (isset($row->start_time)) {
$match->SetStartTime($row->start_time);
}
if (isset($row->start_time_known)) {
$match->SetIsStartTimeKnown($row->start_time_known);
}
if (isset($row->match_type)) {
$match->SetMatchType($row->match_type);
}
if (isset($row->player_type_id)) {
$match->SetPlayerType($row->player_type_id);
}
if (isset($row->qualification)) {
$match->SetQualificationType($row->qualification);
}
if (isset($row->players_per_team)) {
$match->SetMaximumPlayersPerTeam($row->players_per_team);
}
if (isset($row->max_tournament_teams)) {
$match->SetMaximumTeamsInTournament($row->max_tournament_teams);
}
if (isset($row->tournament_spaces)) {
$match->SetSpacesLeftInTournament($row->tournament_spaces);
}
if (isset($row->overs_per_innings)) {
$match->SetOvers($row->overs_per_innings);
}
if (isset($row->match_title)) {
$match->SetTitle($row->match_title);
}
if (isset($row->custom_title)) {
$match->SetUseCustomTitle($row->custom_title);
}
if (isset($row->home_bat_first) and !is_null($row->home_bat_first)) {
$match->Result()->SetHomeBattedFirst($row->home_bat_first);
}
if (isset($row->won_toss) and !is_null($row->won_toss)) {
$match->Result()->SetTossWonBy($row->won_toss);
}
if (isset($row->home_runs)) {
$match->Result()->SetHomeRuns($row->home_runs);
}
if (isset($row->home_wickets)) {
$match->Result()->SetHomeWickets($row->home_wickets);
}
if (isset($row->away_runs)) {
$match->Result()->SetAwayRuns($row->away_runs);
}
if (isset($row->away_wickets)) {
$match->Result()->SetAwayWickets($row->away_wickets);
}
if (isset($row->home_points)) {
$match->Result()->SetHomePoints($row->home_points);
}
if (isset($row->away_points)) {
$match->Result()->SetAwayPoints($row->away_points);
}
if (isset($row->player_of_match_id)) {
$player = new Player($this->GetSettings());
$player->SetId($row->player_of_match_id);
$player->SetName($row->player_of_match);
$player->SetShortUrl($row->player_of_match_url);
$player->Team()->SetId($row->player_of_match_team_id);
$match->Result()->SetPlayerOfTheMatch($player);
}
if (isset($row->player_of_match_home_id)) {
$player = new Player($this->GetSettings());
$player->SetId($row->player_of_match_home_id);
$player->SetName($row->player_of_match_home);
$player->SetShortUrl($row->player_of_match_home_url);
$player->Team()->SetId($row->player_of_match_home_team_id);
$match->Result()->SetPlayerOfTheMatchHome($player);
}
if (isset($row->player_of_match_away_id)) {
$player = new Player($this->GetSettings());
$player->SetId($row->player_of_match_away_id);
$player->SetName($row->player_of_match_away);
$player->SetShortUrl($row->player_of_match_away_url);
$player->Team()->SetId($row->player_of_match_away_team_id);
$match->Result()->SetPlayerOfTheMatchAway($player);
}
if (isset($row->match_notes)) {
$match->SetNotes($row->match_notes);
}
if (isset($row->short_url)) {
$match->SetShortUrl($row->short_url);
}
if (isset($row->update_search) and $row->update_search == 1) {
$match->SetSearchUpdateRequired();
}
if (isset($row->added_by) and is_numeric($row->added_by)) {
//.........这里部分代码省略.........
示例6: ReadPlayerSummary
/**
* Read when and how often a player has played
*/
public function ReadPlayerSummary()
{
$from = $this->FromFilteredPlayerStatistics() . " INNER JOIN nsa_team AS team ON nsa_player_match.team_id = team.team_id ";
$where = "";
$where = $this->ApplyFilters($where);
if ($where) {
$where = "WHERE " . substr($where, 3, strlen($where) - 3);
}
$sql = "SELECT player_id, player_name, player_role, player_url,\r\n\t\tteam.team_id, team.team_name, team.short_url AS team_short_url,\r\n\t\tCOUNT(nsa_player_match.match_id) AS total_matches, MIN(nsa_player_match.match_time) AS first_played, MAX(nsa_player_match.match_time) AS last_played\r\n\t\t{$from}\r\n\t\t{$where}\r\n\t\tGROUP BY nsa_player_match.player_id\r\n\t\tORDER BY player_name ASC";
$data = array();
$result = $this->GetDataConnection()->query($sql);
if (!$this->GetDataConnection()->isError()) {
while ($row = $result->fetch()) {
$player = new Player($this->GetSettings());
$player->SetId($row->player_id);
$player->SetName($row->player_name);
if (isset($row->total_matches)) {
$player->SetTotalMatches($row->total_matches);
}
if (isset($row->first_played)) {
$player->SetFirstPlayedDate($row->first_played);
}
if (isset($row->last_played)) {
$player->SetLastPlayedDate($row->last_played);
}
if (isset($row->player_role)) {
$player->SetPlayerRole($row->player_role);
}
if (isset($row->player_url)) {
$player->SetShortUrl($row->player_url);
}
$player->Team()->SetId($row->team_id);
$player->Team()->SetName($row->team_name);
if (isset($row->team_short_url)) {
$player->Team()->SetShortUrl($row->team_short_url);
}
$data[] = $player;
}
}
$result->closeCursor();
unset($result);
return $data;
}
示例7: 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