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); } } } } } }
public static function gameDayPager($atts, $content, $tag) { global $kkl_twig; $db = new KKL_DB(); $context = KKL::getContext(); $day = $context['game_day']; $league = $context['league']; $season = $context['season']; $prev = $db->getPreviousGameDay($day); if (!$prev) { $day->isFirst = true; } else { $prev->link = KKL::getLink('league', array('league' => $league->code, 'season' => date('Y', strtotime($season->start_date)), 'game_day' => $prev->number)); } $next = $db->getNextGameDay($day); if (!$next) { $day->isLast = true; } else { $next->link = KKL::getLink('league', array('league' => $league->code, 'season' => date('Y', strtotime($season->start_date)), 'game_day' => $next->number)); } return $kkl_twig->render('shortcodes/gameday_pager.tpl', array('context' => $context, 'prev' => $prev, 'day' => $day, 'next' => $next)); }