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;
     }
 }
 function get_item()
 {
     if ($this->item) {
         return $this->item;
     }
     if ($_GET['id']) {
         $db = new KKL_DB();
         $this->setItem($db->getLeague($_GET['id']));
     }
     return $this->item;
 }
 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;
 }
 function get_current_league()
 {
     if ($this->currentLeague) {
         return $this->currentLeague;
     }
     $league = null;
     $db = new KKL_DB();
     if ($_GET['game_day_filter']) {
         $league = $db->getLeagueForGameday($_GET['game_day_filter']);
     } elseif ($_GET['season_filter']) {
         $league = $db->getLeagueForSeason($_GET['season_filter']);
     } elseif ($_GET['league_filter']) {
         $league = $db->getLeague($_GET['league_filter']);
     } else {
         $default_league = get_user_option('kkl_ligatool_default_league');
         if ($default_league) {
             $league = $db->getLeague($default_league);
         }
     }
     $this->currentLeague = $league;
     return $league;
 }
Exemple #5
0
 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));
 }