示例#1
0
 public function widget($args, $instance)
 {
     extract($args);
     $db = new KKL_DB();
     $league_id = $instance['league'];
     if (!$league_id) {
         $context = KKL::getContext();
         $league = $context['league'];
     } else {
         $league = $db->getLeague($league_id);
     }
     $seasons = $db->getSeasonsByLeague($league->id);
     foreach ($seasons as $season) {
         $season->link = KKL::getLink('league', array('league' => $league->code, 'season' => date('Y', strtotime($season->start_date))));
     }
     if (!empty($seasons)) {
         $title = apply_filters('widget_title', $instance['title']);
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title . $title . $after_title;
         }
         echo $this->tpl->render('widgets/other_seasons.tpl', array('seasons' => $seasons));
         echo $after_widget;
     }
 }
示例#2
0
 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;
 }
示例#3
0
 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));
 }
示例#4
0
<?php

$KKL = new KKL();
/*
Template Name: Liga Übersicht (Teams)
*/
if (isset($wp_query->query_vars['json'])) {
    header('Content-Type: application/json');
    global $kkl_twig;
    $db = new KKL_DB();
    $context = KKL::getContext();
    $all_leagues = $db->getActiveLeagues();
    $leagues = array();
    foreach ($all_leagues as $league) {
        $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));