public static function clubDetail($atts, $content, $tag) { global $kkl_twig; $db = new KKL_DB(); $context = KKL::getContext(); $contextClub = $context['club']; $contextClub->logo = $contextClub->logo; $seasonTeams = $db->getTeamsForClub($contextClub->id); $teams = array(); foreach ($seasonTeams as $seasonTeam) { $seasonTeam->season = $db->getSeason($seasonTeam->season_id); $seasonTeam->season->league = $db->getLeague($seasonTeam->season->league_id); $ranking = $db->getRankingForLeagueAndSeasonAndGameDay($seasonTeam->season->league_id, $seasonTeam->season->id, $seasonTeam->season->current_game_day); $position = 1; foreach ($ranking as $rank) { if ($rank->team_id == $seasonTeam->id) { $seasonTeam->scores = $rank; $seasonTeam->scores->position = $position; break; } $position++; } $seasonTeam->link = KKL::getLink('club', array('club' => $contextClub->short_name)); $seasonTeam->schedule_link = KKL::getLink('schedule', array('league' => $seasonTeam->season->league->code, 'season' => date('Y', strtotime($seasonTeam->season->start_date)), 'team' => $seasonTeam->short_name)); $teams[$seasonTeam->id] = $seasonTeam; } $currentTeam = $db->getCurrentTeamForClub($contextClub->id); $currentLocation = $db->getLocation($currentTeam->properties['location']); return $kkl_twig->render('shortcodes/club_detail.tpl', array('context' => $context, 'club' => $contextClub, 'teams' => $teams, 'current_location' => $currentLocation)); }
$overview = true; } } } $KKL->setContext($context); if (isset($wp_query->query_vars['json'])) { header('Content-Type: application/json'); global $kkl_twig; $db = new KKL_DB(); $context = KKL::getContext(); $rankings = array(); $output = array(); if (!$overview) { $ranking = new stdClass(); $ranking->league = $context['league']; $ranking->ranks = $db->getRankingForLeagueAndSeasonAndGameDay($context['league']->id, $context['season']->id, $context['game_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)); } $rankings[] = $ranking; $output['rankings'] = $rankings; $schedules = array(); $schedule = $db->getScheduleForGameDay($context['game_day']); foreach ($schedule->matches as $match) { $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)); }