本文整理汇总了PHP中Match::GetShortUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Match::GetShortUrl方法的具体用法?PHP Match::GetShortUrl怎么用?PHP Match::GetShortUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::GetShortUrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 »');
}
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:tournament-edit-control.class.php
示例2: CreateControls
//.........这里部分代码省略.........
$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());
$option->SetGroupName('Away grounds');
$o_ground_list->AddControl($option);
}
# Select ground
if ($o_match->GetGroundId()) {
$o_ground_list->SelectOption($o_match->GetGroundId());
} elseif ($this->i_match_type == MatchType::PRACTICE and isset($this->context_team)) {
$o_ground_list->SelectOption($this->context_team->GetGround()->GetId());
}
$o_ground_part = new FormPart('Where?', $o_ground_list);
$o_match_box->AddControl($o_ground_part);
# Note which grounds belong to which teams, for use by match-fixture-edit-control.js to select a ground when the home team is changed
# Format is 1,2;2,3;4,5
# where ; separates each team, and for each team the first number identifies the team and the second is the ground
$s_team_ground = '';
foreach ($a_home_ground_ids as $i_team => $i_ground) {
if ($s_team_ground) {
$s_team_ground .= ';';
}
$s_team_ground .= $i_team . ',' . $i_ground;
}
$o_hidden = new TextBox($this->GetNamingPrefix() . 'TeamGround', $s_team_ground);
$o_hidden->SetMode(TextBoxMode::Hidden());
$o_match_box->AddControl($o_hidden);
unset($o_hidden);
# Note which ground was previously saved - this is for JavaScript to know it shouldn't auto-change the ground
if (!$b_is_new_match) {
$o_hidden = new TextBox($this->GetNamingPrefix() . 'SavedGround', $o_match->GetGroundId());
$o_hidden->SetMode(TextBoxMode::Hidden());
$o_match_box->AddControl($o_hidden);
unset($o_hidden);
}
}
# Notes
$o_notes = new TextBox($this->GetNamingPrefix() . 'Notes', $o_match->GetNotes());
$o_notes->SetMode(TextBoxMode::MultiLine());
$o_notes_part = new FormPart('Notes', $o_notes);
$o_match_box->AddControl($o_notes_part);
# Remember match type, tournament and short URL
$o_type = new TextBox($this->GetNamingPrefix() . 'MatchType', $this->GetMatchType());
$o_type->SetMode(TextBoxMode::Hidden());
$o_match_box->AddControl($o_type);
if ($b_is_tournament_match) {
$tourn_box = new TextBox($this->GetNamingPrefix() . 'Tournament', $this->tournament->GetId());
$tourn_box->SetMode(TextBoxMode::Hidden());
$o_match_box->AddControl($tourn_box);
}
$o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $o_match->GetShortUrl());
$o_short_url->SetMode(TextBoxMode::Hidden());
$o_match_box->AddControl($o_short_url);
# Note the context team - to be picked up by JavaScript to enable auto-changing of away team if
# context team is not selected as home team
if (isset($this->context_team)) {
$context_team_box = new TextBox($this->GetNamingPrefix() . 'ContextTeam', $this->context_team->GetId());
$context_team_box->SetMode(TextBoxMode::Hidden());
$o_match_box->AddControl($context_team_box);
}
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:match-fixture-edit-control.class.php
示例3: UpdateMatchUrl
private function UpdateMatchUrl(Match $match, $user_is_match_admin)
{
# Ensure we have the correct details to generate a short URL.
# Particularly important for tournament matches where this may have been updated from the tournament.
$sql = "SELECT start_time FROM nsa_match WHERE match_id = " . Sql::ProtectNumeric($match->GetId(), false);
$result = $this->GetDataConnection()->query($sql);
$row = $result->fetch();
if ($row) {
$match->SetStartTime($row->start_time);
}
# URL generation scenarios
# 1. New match added by public - generate short URL
# 2. Match updated by public - regenerate allowing current url to be kept
# 3. Match added or updated by admin - if blank or generation requested, regenerate allowing current url to be kept, otherwise keep
$new_short_url = null;
if (!$user_is_match_admin or $user_is_match_admin and (!$match->GetShortUrl() or !$match->GetUseCustomShortUrl())) {
# Set up short URL manager
require_once 'http/short-url-manager.class.php';
$url_manager = new ShortUrlManager($this->GetSettings(), $this->GetDataConnection());
$new_short_url = $url_manager->EnsureShortUrl($match, true);
}
# Save the URL for the match, and copy to match statistics
$sql = "UPDATE nsa_match SET\r\n short_url = " . Sql::ProtectString($this->GetDataConnection(), $match->GetShortUrl()) . "\r\n WHERE match_id = " . Sql::ProtectNumeric($match->GetId());
$this->LoggedQuery($sql);
$sql = "UPDATE nsa_player_match SET\r\n match_url = " . Sql::ProtectString($this->GetDataConnection(), $match->GetShortUrl()) . "\r\n WHERE match_id = " . Sql::ProtectNumeric($match->GetId());
$this->GetDataConnection()->query($sql);
# Regenerate short URLs, but check whether manager exists because might've been denied permission above
# and in that same case we do NOT want to regenerate short URLs
if (isset($url_manager)) {
if (is_object($new_short_url)) {
$new_short_url->SetParameterValuesFromObject($match);
$url_manager->Save($new_short_url);
}
unset($url_manager);
}
}
示例4: 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();
}