public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $db = new KKL_DB(); $league_id = $instance['league']; if (!$league_id) { $context = KKL::getContext(); $league_id = $context['league']->id; if (!$league_id) { $team = $context['team']; if ($team) { $current_team = $db->getCurrentTeamForClub($team->club_id); $data = $db->getGamesForTeam($current_team->id); echo $this->tpl->render('widgets/upcoming_games.tpl', array('schedule' => $data, 'display_result' => true)); } else { $data = $db->getAllUpcomingGames(); $games = array(); $leagues = array(); foreach ($data as $game) { $leagues[$game->league_id] = true; $games[$game->league_id][] = $game; } foreach (array_keys($leagues) as $league_id) { $league = $db->getLeague($league_id); echo $this->tpl->render('widgets/upcoming_games.tpl', array('schedule' => $games[$league_id], 'league' => $league)); } } } else { $data = $db->getUpcomingGames($league_id); echo $this->tpl->render('widgets/upcoming_games.tpl', array('schedule' => $data)); } } echo $after_widget; }
public static function gameDayOverview($atts, $content, $tag) { global $kkl_twig; $db = new KKL_DB(); $data = $db->getAllUpcomingGames(); $games = array(); $leagues = array(); foreach ($data as $game) { $leagues[$game->league_id] = true; $games[$game->league_id][] = $game; } foreach (array_keys($leagues) as $league_id) { $league = $db->getLeague($league_id); echo $kkl_twig->render('shortcodes/gameday_overview.tpl', array('schedule' => $games[$league_id], 'league' => $league)); } }