本文整理汇总了PHP中Game::load_many方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::load_many方法的具体用法?PHP Game::load_many怎么用?PHP Game::load_many使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::load_many方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process()
{
global $CONFIG;
$this->template_name = 'pages/team/ical.tpl';
$this->smarty->assign('team', $this->team);
$this->smarty->assign('short_league_name', variable_get('app_org_short_name', 'League'));
# Our timezone is specified as US/Eastern, but ical wants US-Eastern. bleh.
$timezone = preg_replace("!/!", "-", $CONFIG['localization']['local_tz']);
$this->smarty->assign('timezone', $timezone);
/*
* Grab schedule info
*/
$games = Game::load_many(array('either_team' => $this->team->team_id, 'published' => 1, '_order' => 'g.game_date DESC,g.game_start,g.game_id'));
// We'll be outputting an ical
header('Content-type: text/calendar; charset=UTF-8');
// Prevent caching
header("Cache-Control: no-cache, must-revalidate");
// get domain URL for signing games
$arr = explode('@', variable_get('app_admin_email', "@{$short_league_name}"));
$this->smarty->assign('domain_url', $arr[1]);
// date stamp this file
// MUST be in UTC
$this->smarty->assign('now', gmstrftime('%Y%m%dT%H%M%SZ'));
while (list(, $game) = each($games)) {
$opponent_id = $game->home_id == $this->team->team_id ? $game->away_id : $game->home_id;
$game->opponent = Team::load(array('team_id' => $opponent_id));
$game->field = Field::load(array('fid' => $game->fid));
}
$this->smarty->assign('games', $games);
}
示例2: process
function process()
{
$games = Game::load_many(array('league_id' => $this->league->league_id, '_order' => 'g.game_date,g.game_id'));
if (!is_array($games)) {
error_exit("There are no games scheduled for this league");
}
$s = new Spirit();
$s->display_numeric_sotg = $this->league->display_numeric_sotg();
// Start the output, let the browser know what type it is
header('Content-type: text/x-csv');
header("Content-Disposition: attachment; filename=\"spirit{$this->league_id}.csv\"");
$out = fopen('php://output', 'w');
$header = array_merge(array('Game #', 'Date', 'Giver Name', 'Giver ID', 'Given To', 'Given To ID', 'SOTG Total'), (array) $s->question_headings(), array('Comments'));
fputcsv($out, $header);
while (list(, $game) = each($games)) {
$teams = array($game->home_team => $game->home_name, $game->away_team => $game->away_name);
while (list($giver, $giver_name) = each($teams)) {
$recipient = $game->get_opponent_id($giver);
# Fetch spirit answers for games
$entry = $game->get_spirit_entry($recipient);
if (!$entry) {
$entry = array(comments => 'Team did not submit a spirit rating');
}
$thisrow = array($game->game_id, strftime('%a %b %d %Y', $game->timestamp), $giver_name, $giver, $teams[$recipient], $recipient, $entry['numeric_sotg'], $entry['timeliness'], $entry['rules_knowledge'], $entry['sportsmanship'], $entry['rating_overall'], $entry['score_entry_penalty'], $entry['comments']);
fputcsv($out, $thisrow);
}
}
fclose($out);
// Returning would cause the Leaguerunner menus to be added
exit;
}
示例3: process
function process()
{
$this->title = "Approve Scores";
$this->template_name = 'pages/league/approvescores.tpl';
$games = Game::load_many(array('league_id' => $this->league->league_id, 'game_date_past' => 1, '_extra_table' => 'score_entry se', '_extra' => 'se.game_id = s.game_id'));
foreach ($games as $game) {
$home = $game->get_score_entry($game->home_id);
if (!$home) {
$game->home_score_for = 'not entered';
$game->home_score_against = 'not entered';
} else {
$game->home_score_for = $home->score_for;
$game->home_score_against = $home->score_against;
}
$away = $game->get_score_entry($game->away_id);
if (!$away) {
$game->away_score_for = 'not entered';
$game->away_score_against = 'not entered';
} else {
$game->away_score_for = $away->score_for;
$game->away_score_against = $away->score_against;
}
$game->captains_email_list = player_rfc2822_address_list($game->get_captains(), true);
}
$this->smarty->assign('games', $games);
}
示例4: process
function process()
{
global $lr_session;
$this->title = "{$this->team->name} » Spirit";
$this->template_name = 'pages/team/spirit.tpl';
// load the league
$league = League::load(array('league_id' => $this->team->league_id));
// if the person doesn't have permission to see this team's spirit, bail out
if (!$lr_session->has_permission('team', 'view', $this->team->team_id, 'spirit')) {
error_exit("You do not have permission to view this team's spirit results");
}
if ($league->display_sotg == 'coordinator_only' && !$lr_session->is_coordinator_of($league->league_id)) {
error_exit("Spirit results are restricted to coordinator-only");
}
$s = new Spirit();
$s->display_numeric_sotg = $league->display_numeric_sotg();
/*
* Grab schedule info
*/
$games = Game::load_many(array('either_team' => $this->team->team_id, '_order' => 'g.game_date'));
if (!is_array($games)) {
error_exit('There are no games scheduled for this team');
}
$this->smarty->assign('question_keys', array_merge(array('full'), $s->question_keys(), array('score_entry_penalty')));
$this->smarty->assign('question_headings', $s->question_headings());
$this->smarty->assign('num_spirit_columns', count($s->question_headings()) + 1);
$this->smarty->assign('num_comment_columns', count($s->question_headings()) + 2);
$rows = array();
foreach ($games as $game) {
if (!$game->is_finalized()) {
continue;
}
if ($game->home_id == $this->team->team_id) {
$opponent_id = $game->away_id;
$opponent_name = $game->away_name;
$home_away = '(home)';
} else {
$opponent_id = $game->home_id;
$opponent_name = $game->home_name;
$home_away = '(away)';
}
$thisrow = array('game_id' => $game->game_id, 'day_id' => $game->day_id, 'given_by_id' => $opponent_id, 'given_by_name' => $opponent_name, 'has_entry' => 0);
# Fetch spirit answers for games
$entry = $game->get_spirit_entry($this->team->team_id);
if (!$entry) {
$rows[] = $thisrow;
continue;
}
$thisrow['has_entry'] = 1;
// can only see comments if you're a coordinator
if ($lr_session->has_permission('league', 'view', $this->team->league_id, 'spirit')) {
$thisrow['comments'] = $entry['comments'];
}
$thisrow = array_merge($thisrow, (array) $s->fetch_game_spirit_items_html($entry));
$rows[] = $thisrow;
}
$this->smarty->assign('spirit_detail', $rows);
return true;
}
示例5: process
function process()
{
global $lr_session;
$this->title = "{$this->team->name} » Schedule";
$this->template_name = 'pages/team/schedule.tpl';
$games = Game::load_many(array('either_team' => $this->team->team_id, 'published' => 1, '_order' => 'g.game_date,g.game_start,g.game_id'));
if (!count($games)) {
error_exit('This team does not yet have any games scheduled');
}
foreach ($games as $g) {
if ($g->is_finalized()) {
/* Already entered */
$g->score_type = 'final';
} else {
/* Not finalized yet, so we will either:
* - display entered score if present
* - display score entry link if game date has passed
* - display a blank otherwise
*/
$entered = $g->get_score_entry($this->team->team_id);
if ($entered) {
$g->score_type = 'unofficial';
if ($g->home_id == $this->team->team_id) {
$g->home_score = $entered->score_for;
$g->away_score = $entered->score_against;
} else {
$g->away_score = $entered->score_for;
$g->home_score = $entered->score_against;
}
} else {
if ($lr_session->has_permission('game', 'submit score', $g, $this->team) && $g->timestamp < time()) {
$g->score_type = l("submit score", "game/submitscore/{$g->game_id}/" . $this->team->team_id);
}
}
}
}
$this->smarty->assign('can_edit', false);
$this->smarty->assign('games', $games);
$this->smarty->assign('team', $this->team);
return true;
}
示例6: swap_team_with
/**
* Swap this team with another team, updating schedules
*/
function swap_team_with($other)
{
if (!$other) {
return false;
}
$this_league_id = $this->league_id;
$other_league_id = $other->league_id;
// Moving to same league is silly
if ($this_league_id == $other_league_id) {
return false;
}
# Move team to other league
$this->move_team_to($other_league_id);
$other->move_team_to($this_league_id);
# Get future games for $this and $other
$this_games = Game::load_many(array('either_team' => $this->team_id, 'game_date_future' => 1));
$other_games = Game::load_many(array('either_team' => $other->team_id, 'game_date_future' => 1));
# Update future unplayed games in both leagues
foreach ($this_games as $game) {
if ($game->home_id == $this->team_id) {
$game->set('home_team', $other->team_id);
} else {
$game->set('away_team', $other->team_id);
}
$game->save();
}
foreach ($other_games as $game) {
if ($game->home_id == $other->team_id) {
$game->set('home_team', $this->team_id);
} else {
$game->set('away_team', $this->team_id);
}
$game->save();
}
return true;
}
示例7: process
function process()
{
$this->title = "{$this->league->fullname} » Scores";
$this->template_name = 'pages/league/headtohead.tpl';
if ($this->league->schedule_type == 'none') {
error_exit("This league does not have a schedule or standings.");
}
// TODO: do we need to handle multiple rounds differently?
list($order, $season, $round) = $this->league->calculate_standings();
$teams = array();
foreach ($order as $tid) {
$row = array();
// grab schedule information
$games = Game::load_many(array('either_team' => $tid, '_order' => 'g.game_date,g.game_start,g.game_id'));
$gameentry = array();
foreach ($games as &$game) {
if ($game->home_id == $tid) {
$opponent_id = $game->away_id;
} else {
$opponent_id = $game->home_id;
}
// if score finalized, save game for printing
if ($game->is_finalized()) {
$gameentry[$opponent_id][] = $game;
}
}
// output game results row
foreach ($order as $opponent_id) {
if ($opponent_id == $tid) {
// no games against my own team
$row[] = array('data' => ' ', 'class' => 'impossible');
continue;
}
if (!array_key_exists($opponent_id, $gameentry)) {
// no games against this team
$row[] = array('data' => ' ');
continue;
}
$results = array();
$wins = $losses = 0;
foreach ($gameentry[$opponent_id] as &$game) {
$game_score = '';
$game_result = "";
switch ($game->status) {
case 'home_default':
$game_score = "(default)";
$game_result = "{$game->home_name} defaulted";
break;
case 'away_default':
$game_score = "(default)";
$game_result = "{$game->away_name} defaulted";
break;
case 'forfeit':
$game_score = "(forfeit)";
$game_result = "forfeit";
break;
default:
//normal finalized game
if ($game->home_id == $tid) {
$opponent_name = $game->away_name;
$game_score = "{$game->home_score}-{$game->away_score}";
if ($game->home_score > $game->away_score) {
$wins++;
} else {
if ($game->home_score < $game->away_score) {
$losses++;
}
}
} else {
$opponent_name = $game->home_name;
$game_score = "{$game->away_score}-{$game->home_score}";
if ($game->away_score > $game->home_score) {
$wins++;
} else {
if ($game->away_score < $game->home_score) {
$losses++;
}
}
}
if ($game->home_score > $game->away_score) {
$game_result = "{$game->home_name} defeated {$game->away_name}" . " {$game->home_score}-{$game->away_score}";
} else {
if ($game->home_score < $game->away_score) {
$game_result = "{$game->away_name} defeated {$game->home_name}" . " {$game->away_score}-{$game->home_score}";
} else {
$game_result = "{$game->home_name} and {$game->away_name} tied {$game_score}";
}
}
$game_result .= " ({$game->rating_points} rating points transferred)";
}
$popup = strftime('%a %b %d', $game->timestamp) . " at {$game->field_code}: {$game_result}";
$results[] = l($game_score, "game/view/{$game->game_id}", array('title' => htmlspecialchars($popup)));
}
$thiscell = implode('<br />', $results);
if ($thiscell == '') {
$thiscell = ' ';
}
if ($wins > $losses) {
/* $row[] = array('data'=>$thiscell, 'bgcolor'=>'#A0FFA0'); */
$row[] = array('data' => $thiscell, 'class' => 'winning');
//.........这里部分代码省略.........
示例8: reschedule_games_for_day
function reschedule_games_for_day($olddate, $newdate)
{
global $dbh;
$dbh->beginTransaction();
$games_list = Game::load_many(array('league_id' => $this->league_id, 'game_date' => strftime("%Y-%m-%d", $olddate)));
$gameslot_sth = $dbh->prepare('UPDATE gameslot SET game_id = NULL where game_id = ?');
$fieldranking_sth = $dbh->prepare('DELETE FROM field_ranking_stats WHERE game_id = ?');
foreach ($games_list as $game) {
$gameslot_sth->execute(array($game->game_id));
$fieldranking_sth->execute(array($game->game_id));
$game->slot_id = null;
}
try {
$this->assign_fields_by_preferences($games_list, $newdate);
} catch (Exception $e) {
$extra_errors = $e->getMessage();
if (!$dbh->rollback()) {
$extra_errors .= "<br />Also, failed to roll back transaction. Please contact the system administrator";
}
return array(false, "Failed to assign gameslots for requested games on " . strftime('%c', $datestamp) . ": {$extra_errors}");
}
$rc = $dbh->commit();
if (!$rc) {
return array(false, 'Transaction commit failed');
}
return array(true, '');
}