Exemple #1
0
 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);
                     }
                 }
             }
         }
     }
 }
 function get_item()
 {
     if ($this->item) {
         return $this->item;
     }
     if ($_GET['id']) {
         $db = new KKL_DB();
         $this->setItem($db->getSeason($_GET['id']));
     }
     return $this->item;
 }
 public function widget($args, $instance)
 {
     extract($args);
     $db = new KKL_DB();
     $leagues = $db->getInactiveLeagues();
     foreach ($leagues as $league) {
         $season = $db->getSeason($league->current_season);
         $league->link = KKL::getLink('league', array('league' => $league->code, 'season' => date('Y', strtotime($season->start_date))));
     }
     if (!empty($leagues)) {
         $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_leagues.tpl', array('leagues' => $leagues));
         echo $after_widget;
     }
 }
 function get_current_season()
 {
     if ($this->currentSeason) {
         return $this->currentSeason;
     }
     $season = null;
     $db = new KKL_DB();
     if ($_GET['game_day_filter']) {
         $season = $db->getSeasonForGameday($_GET['game_day_filter']);
     } elseif ($_GET['season_filter']) {
         $season = $db->getSeason($_GET['season_filter']);
     } elseif ($this->get_current_league()) {
         $season = $db->getCurrentSeason($this->get_current_league()->id);
     }
     $this->currentSeason = $season;
     return $season;
 }
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));
 }
<?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));