public static function execute() { error_log("RUNNING GAMEDAY CHECKER:"); $db = new KKL_DB(); $leagues = $db->getLeagues(); foreach ($leagues as $league) { error_log("checking league: " . utf8_decode($league->name)); $current_season = $db->getSeason($league->current_season); if ($current_season && $current_season->active) { error_log("- current season is " . utf8_decode($current_season->name)); $current_day = $db->getGameDay($current_season->current_game_day); if ($current_day) { error_log("-- current day is " . $current_day->number); $next_day = $db->getNextGameDay($current_day); $now = time(); if ($next_day->fixture) { error_log("-- next day is " . $next_day->number); $fixture = strtotime($next_day->fixture); error_log("--- now: " . $now); error_log("--- fixture: " . $fixture); error_log("--- diff: " . ($now - $fixture)); if ($fixture < $now) { error_log("--- setting next day"); $db->setCurrentGameDay($current_season, $next_day); } } } } } }
function get_item() { if ($this->item) { return $this->item; } if ($_GET['id']) { $db = new KKL_DB(); $this->setItem($db->getGameDay($_GET['id'])); } return $this->item; }
function get_game_day() { if ($this->game_day) { return $this->game_day; } $item = $this->get_item(); if ($item) { $db = new KKL_DB(); $this->game_day = $db->getGameDay($item->game_day_id); } else { if ($_GET['gameDayId']) { $db = new KKL_DB(); $this->game_day = $db->getGameDay($_GET['gameDayId']); } } return $this->game_day; }
public static function tableOverview($atts, $content, $tag) { global $kkl_twig; $db = new KKL_DB(); $context = KKL::getContext(); $rankings = array(); foreach ($db->getActiveLeagues() as $league) { $season = $db->getSeason($league->current_season); $day = $db->getGameDay($season->current_game_day); $ranking = new stdClass(); $ranking->league = $league; $ranking->ranks = $db->getRankingForLeagueAndSeasonAndGameDay($league->id, $season->id, $day->number); foreach ($ranking->ranks as $rank) { $team = $db->getTeam($rank->team_id); $club = $db->getClub($team->club_id); $rank->team->link = KKL::getLink('club', array('club' => $club->short_name)); } $ranking->league->link = KKL::getLink('league', array('league' => $league->code, 'season' => date('Y', strtotime($season->start_date)), 'game_day' => $day->number)); $rankings[] = $ranking; } return $kkl_twig->render('shortcodes/table.tpl', array('context' => $context, 'rankings' => $rankings)); }
$league->season = $db->getSeason($league->current_season); $league->teams = $db->getTeamsForSeason($league->season->id); foreach ($league->teams as $team) { $club = $db->getClub($team->club_id); if (!$team->logo) { $team->logo = $club->logo; if (!$club->logo) { $team->logo = "https://www.kickerligakoeln.de/wp-content/themes/kkl_2/img/kkl-logo_172x172.png"; } } else { $team->logo = "/images/team/" . $team->logo; } // HACK $team->link = KKL::getLink('club', array('club' => $club->short_name)); } $day = $db->getGameDay($league->season->current_game_day); $league->link = KKL::getLink('league', array('league' => $league->code, 'season' => date('Y', strtotime($league->season->start_date)), 'game_day' => $day->number)); $leagues[] = $league; } echo json_encode($leagues); die; } ?> ?> <?php get_header(); ?> <section class="kkl-content"> <div class="container"> <div class="row">
$home_club = $db->getClub($match->home->club_id); $away_club = $db->getClub($match->away->club_id); $match->home->link = get_site_url() . '/team/' . KKL::getLink('club', array('club' => $home_club->short_name)); $match->away->link = get_site_url() . '/team/' . KKL::getLink('club', array('club' => $away_club->short_name)); } $schedule->link = get_site_url() . '/spielplan/' . KKL::getLink('schedule', array('league' => $context['league']->code, 'season' => date('Y', strtotime($context['season']->start_date)))); $schedules[] = $schedule; $output['schedules'] = $schedules; } else { $context = KKL::getContext(); foreach ($db->getLeagues() as $league) { if ($league->active != 1) { continue; } $season = $db->getSeason($league->current_season); $day = $db->getGameDay($season->current_game_day); $ranking = new stdClass(); $ranking->league = $league; $ranking->ranks = $db->getRankingForLeagueAndSeasonAndGameDay($league->id, $season->id, $day->number); foreach ($ranking->ranks as $rank) { $team = $db->getTeam($rank->team_id); $club = $db->getClub($team->club_id); $rank->team->link = get_site_url() . '/team/' . KKL::getLink('club', array('club' => $club->short_name)); } $ranking->league->link = get_site_url() . '/spielplan/' . KKL::getLink('league', array('league' => $league->code, 'season' => date('Y', strtotime($season->start_date)), 'game_day' => $day->number)); $rankings[] = $ranking; } $output['rankings'] = $rankings; } print json_encode($output); die;