本文整理汇总了PHP中Match::GetGround方法的典型用法代码示例。如果您正苦于以下问题:PHP Match::GetGround方法的具体用法?PHP Match::GetGround怎么用?PHP Match::GetGround使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::GetGround方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
}
}
示例2: SendMatchUpdatedEmail
/**
* Helper to build and send the email when a match has been added by a public user
*
* @param Match $o_match
* @param User $o_user
* @param bool $b_is_new_match
* @param bool $b_is_deleted_match
* @param string $s_email
* @param Season[] $seasons
*/
private function SendMatchUpdatedEmail(Match $o_match, User $o_user, $b_is_new_match, $b_is_deleted_match, $s_email, $seasons = null)
{
# text of email
$s_season_list = '';
if (is_array($seasons)) {
$i_total_seasons = count($seasons);
for ($i = 0; $i < $i_total_seasons; $i++) {
if ($i == 0) {
$s_season_list = "'" . $seasons[$i]->GetCompetitionName() . "'";
} else {
if ($i == $i_total_seasons - 1) {
$s_season_list .= " and '" . $seasons[$i]->GetCompetitionName() . "'";
} else {
$s_season_list .= ", '" . $seasons[$i]->GetCompetitionName() . "'";
}
}
}
}
$s_season = $s_season_list ? " in the {$s_season_list}" : '';
$s_why = $s_season_list ? $s_season_list : 'matches';
$new = $b_is_new_match ? 'new ' : '';
$verb = $b_is_new_match ? 'added' : 'updated';
if ($b_is_deleted_match) {
$verb = 'deleted';
}
$match_text = $o_match->GetMatchType() == MatchType::TOURNAMENT ? 'tournament' : 'match';
$s_title = html_entity_decode($o_match->GetTitle());
$s_date = ucfirst($o_match->GetStartTimeFormatted());
$s_ground = is_object($o_match->GetGround()) ? $o_match->GetGround()->GetNameAndTown() : '';
$s_notes = $o_match->GetNotes();
$s_domain = $this->settings->GetDomain();
$s_url = 'https://' . $s_domain . $o_match->GetNavigateUrl();
$s_contact_url = 'https://' . $s_domain . $this->settings->GetFolder('Contact');
$s_home_name = $o_match->GetMatchType() == MatchType::TOURNAMENT ? '' : html_entity_decode($o_match->GetHomeTeam()->GetName());
$s_away_name = $o_match->GetMatchType() == MatchType::TOURNAMENT ? '' : html_entity_decode($o_match->GetAwayTeam()->GetName());
$s_bat_first = is_null($o_match->Result()->GetHomeBattedFirst()) ? 'Not known which team batted first' : ($o_match->Result()->GetHomeBattedFirst() ? $s_home_name : $s_away_name) . ' batted first';
$s_home_runs = is_null($o_match->Result()->GetHomeRuns()) ? '(not known)' : $o_match->Result()->GetHomeRuns();
$s_home_wickets = is_null($o_match->Result()->GetHomeWickets()) ? '(not known)' : $o_match->Result()->GetHomeWickets();
if ($s_home_wickets == -1) {
$s_home_wickets = 'all out';
} else {
$s_home_wickets = 'for ' . $s_home_wickets . ' wickets';
}
$s_away_runs = is_null($o_match->Result()->GetAwayRuns()) ? '(not known)' : $o_match->Result()->GetAwayRuns();
$s_away_wickets = is_null($o_match->Result()->GetAwayWickets()) ? '(not known)' : $o_match->Result()->GetAwayWickets();
if ($s_away_wickets == -1) {
$s_away_wickets = 'all out';
} else {
$s_away_wickets = 'for ' . $s_away_wickets . ' wickets';
}
$s_user = $o_user->GetName();
$s_body = wordwrap("A {$new}{$match_text} has been {$verb} on the Stoolball England website at {$s_domain}{$s_season}.\n\n" . "The {$match_text} was {$verb} by {$s_user}.\n\n" . "The {$match_text} details are as follows:\n\n" . " {$s_title}\n" . " {$s_date}\n" . " {$s_ground}");
if ($s_notes) {
$s_notes = "\n\n" . wordwrap($s_notes, 70);
$s_notes = str_replace("\n", "\n ", $s_notes);
$s_body .= $s_notes;
}
if ($o_match->GetStartTime() <= gmdate('U') and !$b_is_new_match and $o_match->GetMatchType() != MatchType::TOURNAMENT) {
$s_body .= <<<EMAILBODY
\t{$s_bat_first}
EMAILBODY;
if ($o_match->Result()->GetHomeBattedFirst() === false) {
$s_body .= <<<EMAILBODY
\t{$s_away_name} score: {$s_away_runs} runs {$s_away_wickets}
\t{$s_home_name} score: {$s_home_runs} runs {$s_home_wickets}
EMAILBODY;
} else {
$s_body .= <<<EMAILBODY
\t{$s_home_name} score: {$s_home_runs} runs {$s_home_wickets}
\t{$s_away_name} score: {$s_away_runs} runs {$s_away_wickets}
EMAILBODY;
}
}
$s_body .= "\n\n";
if (!$b_is_deleted_match) {
$s_body .= wordwrap("You can view the {$match_text} at {$s_url}\n\n");
}
$s_body .= wordwrap("You have received this email because you are the administrative contact for {$s_why} on {$s_domain}.\n\n" . "We let you know when a {$match_text} is {$verb} by a member of the public, so that you can check there's nothing wrong.\n\n" . "If this email has been sent to the wrong address, or if the {$match_text} details are wrong, please let us know using the contact form at {$s_contact_url}.\n\n");
# send email, copy to me
require_once 'Zend/Mail.php';
$o_email = new Zend_Mail('UTF-8');
$o_email->addTo($s_email);
$o_email->setFrom('alerts@stoolball.org.uk', 'Stoolball England alerts');
$o_email->setSubject(ucfirst($match_text) . " {$verb}: {$s_title}, {$s_date}");
$o_email->setBodyText($s_body);
try {
//.........这里部分代码省略.........
示例3: SaveOrMatchTournamentTeam
/**
* Finds an existing team or saves a new team and returns the id
* @param Match $tournament
* @param Team $team
* @return int
*/
public function SaveOrMatchTournamentTeam(Match $tournament, Team $team)
{
if (is_null($team->GetPlayerType())) {
$team->SetPlayerType($tournament->GetPlayerType());
}
$team = $this->MatchExistingTeam($team);
if (!$team->GetId()) {
$team->SetShortUrlPrefix($tournament->GetShortUrl());
$team = $this->MatchExistingTeam($team);
}
if (!$team->GetId()) {
$team->SetTeamType(Team::ONCE);
$team->SetGround($tournament->GetGround());
$this->SaveTeam($team);
}
return $team->GetId();
}
示例4: OnPreRender
protected function OnPreRender()
{
/* @var $o_home Team */
/* @var $o_away Team */
/* @var $o_tourney Match */
# Date and tournament
$o_date_para = new XhtmlElement('p');
$o_date = new XhtmlElement('abbr', htmlentities($this->o_match->GetStartTimeFormatted(), ENT_QUOTES, "UTF-8", false));
$o_date->SetTitle(Date::Microformat($this->o_match->GetStartTime()));
# hCalendar
$o_date->SetCssClass('dtstart');
# hCalendar
$o_date->AddAttribute("property", "schema:startDate");
$o_date->AddAttribute("datatype", "xsd:date");
$o_date->AddAttribute("content", Date::Microformat($this->o_match->GetStartTime()));
$o_date_para->AddControl('When: ');
$o_date_para->AddControl($o_date);
# hCalendar end date
if ($this->o_match->GetIsStartTimeKnown()) {
$i_end_time = $this->o_match->GetStartTime() + 60 * 90;
$o_hcal_end = new XhtmlElement('abbr', ' until around ' . htmlentities(Date::Time($i_end_time), ENT_QUOTES, "UTF-8", false));
$o_hcal_end->SetTitle(Date::Microformat($i_end_time));
$o_hcal_end->SetCssClass('metadata dtend');
$o_date_para->AddControl($o_hcal_end);
}
# If we know the time and place, show when the sun sets
# TODO: Assumes UK
if ($this->o_match->GetGround() instanceof Ground and $this->o_match->GetGround()->GetAddress()->GetLatitude() and $this->o_match->GetGround()->GetAddress()->GetLongitude()) {
$o_date_para->AddControl(' <span class="sunset">sunset ' . htmlentities(Date::Time(date_sunset($this->o_match->GetStartTime(), SUNFUNCS_RET_TIMESTAMP, $this->o_match->GetGround()->GetAddress()->GetLatitude(), $this->o_match->GetGround()->GetAddress()->GetLongitude())), ENT_QUOTES, "UTF-8", false) . '</span>');
}
# Display match type/season/tournament
if ($this->o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) {
$o_date_para->SetCssClass('description');
# hCal
$o_tourney = $this->o_match->GetTournament();
if (is_object($o_tourney)) {
$tournament_link = new XhtmlAnchor(htmlentities($o_tourney->GetTitle(), ENT_QUOTES, "UTF-8", false), $o_tourney->GetNavigateUrl());
$tournament_link->AddAttribute("typeof", "schema:SportsEvent");
$tournament_link->AddAttribute("about", $o_tourney->GetLinkedDataUri());
$tournament_link->AddAttribute("rel", "schema:url");
$tournament_link->AddAttribute("property", "schema:name");
$tournament_container = new XhtmlElement("span", $tournament_link);
$tournament_container->AddAttribute("rel", "schema:superEvent");
# Check for 'the' to get the grammar right
$s_title = strtolower($o_tourney->GetTitle());
if (strlen($s_title) >= 4 and substr($s_title, 0, 4) == 'the ') {
$o_date_para->AddControl(', in ');
} else {
$o_date_para->AddControl(', in the ');
}
$o_date_para->AddControl($tournament_container);
$o_date_para->AddControl('.');
} else {
$o_date_para->AddControl(', in a tournament.');
}
} else {
# hCalendar desc, built up at the same time as the date and league/tournament
$hcal_desc = new XhtmlElement('div', null, 'description');
$this->AddControl($hcal_desc);
$s_detail_xhtml = ucfirst(MatchType::Text($this->o_match->GetMatchType()));
$season_list_xhtml = null;
if ($this->o_match->Seasons()->GetCount() == 1) {
$season = $this->o_match->Seasons()->GetFirst();
$season_name = new XhtmlAnchor(htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false), $season->GetNavigateUrl());
$b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0);
$s_detail_xhtml .= ' in ' . ($b_the ? 'the ' : '') . $season_name->__toString() . '.';
} elseif ($this->o_match->Seasons()->GetCount() > 1) {
$s_detail_xhtml .= ' in the following seasons: ';
$season_list_xhtml = new XhtmlElement('ul');
$seasons = $this->o_match->Seasons()->GetItems();
$total_seasons = count($seasons);
for ($i = 0; $i < $total_seasons; $i++) {
$season = $seasons[$i];
/* @var $season Season */
$season_name = new XhtmlAnchor(htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false), $season->GetNavigateUrl());
$li = new XhtmlElement('li', $season_name);
if ($i < $total_seasons - 2) {
$li->AddControl(new XhtmlElement('span', ', ', 'metadata'));
} else {
if ($i < $total_seasons - 1) {
$li->AddControl(new XhtmlElement('span', ' and ', 'metadata'));
}
}
$season_list_xhtml->AddControl($li);
}
} else {
$s_detail_xhtml .= '.';
}
$hcal_desc->AddControl(new XhtmlElement('p', $s_detail_xhtml));
if (!is_null($season_list_xhtml)) {
$hcal_desc->AddControl($season_list_xhtml);
}
}
# Who
$o_home = $this->o_match->GetHomeTeam();
$o_away = $this->o_match->GetAwayTeam();
$has_home = $o_home instanceof Team;
$has_away = $o_away instanceof Team;
if ($has_home or $has_away) {
$who = new XhtmlElement("p", "Who: ");
//.........这里部分代码省略.........