public function form($instance)
    {
        $db = new KKL_DB();
        $leagues = $db->getLeagues();
        if (isset($instance['title'])) {
            $title = $instance['title'];
        } else {
            $title = __('New title', 'text_domain');
        }
        ?>
		<p>
		<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
</label> 
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" />		
		</p>
		<?php 
    }
 function save()
 {
     $team = new stdClass();
     $team->id = $_POST['id'];
     $team->name = $_POST['name'];
     $team->short_name = $_POST['short_name'];
     $team->season_id = $_POST['season'];
     $team->club_id = $_POST['club'];
     $db = new KKL_DB();
     $team = $db->createOrUpdateTeam($team);
     $properties = array();
     $properties['location'] = false;
     $properties['current_league_winner'] = false;
     $properties['current_cup_winner'] = false;
     if ($_POST['location']) {
         $properties['location'] = $_POST['location'];
     }
     if ($_POST['current_league_winner']) {
         $properties['current_league_winner'] = "true";
     }
     if ($_POST['current_cup_winner']) {
         $properties['current_cup_winner'] = "true";
     }
     if (!empty($properties)) {
         $db->setTeamProperties($team, $properties);
     }
     return $db->getTeam($team->id);
 }
 function save()
 {
     $location = new stdClass();
     $location->id = $_POST['id'];
     $location->title = $_POST['title'];
     $location->description = $_POST['description'];
     $location->lat = $_POST['lat'];
     $location->lng = $_POST['lng'];
     $db = new KKL_DB();
     return $db->createOrUpdateLocation($location);
 }
 function save()
 {
     $league = new stdClass();
     $league->id = $_POST['id'];
     $league->name = $_POST['name'];
     $league->code = $_POST['url_code'];
     $league->active = $_POST['active'] ? 1 : 0;
     $league->current_season = $_POST['season'];
     $db = new KKL_DB();
     $league = $db->createOrUpdateLeague($league);
     return $league;
 }
 function save()
 {
     $club = new stdClass();
     $club->id = $_POST['id'];
     $club->name = $_POST['name'];
     $club->short_name = $_POST['short_name'];
     $club->description = $_POST['description'];
     if ($_FILES['logo']['name']) {
         $club->logo = $this->handleLogoChange();
     }
     $db = new KKL_DB();
     $club = $db->createOrUpdateClub($club);
     return $club;
 }
 function save()
 {
     $start_date = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $_POST['start_date'])));
     $end_date = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $_POST['end_date'])));
     $day = new stdClass();
     $day->id = $_POST['id'];
     $day->number = $_POST['number'];
     $day->start_date = $start_date;
     $day->end_date = $end_date;
     $day->season_id = $_POST['season'];
     $db = new KKL_DB();
     $day = $db->createOrUpdateGameDay($day);
     return $day;
 }
 function save()
 {
     $start_date = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $_POST['start_date'])));
     $end_date = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $_POST['end_date'])));
     $season = new stdClass();
     $season->id = $_POST['id'];
     $season->name = $_POST['name'];
     $season->start_date = $start_date;
     $season->end_date = $end_date;
     $season->active = $_POST['active'] ? 1 : 0;
     $season->current_game_day = $_POST['current_game_day'];
     $season->league_id = $_POST['league'];
     $db = new KKL_DB();
     $season = $db->createOrUpdateSeason($season);
     return $season;
 }
Exemple #8
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);
                     }
                 }
             }
         }
     }
 }
<?php

$KKL = new KKL();
$db = new KKL_DB();
$currentGameDay = $db->getCurrentGameDayForLeague(1);
/*
Template Name: Spieltag Übersicht
*/
get_header();
?>

<section class="kkl-content">
  <div class="container">
    <div class="row">
      
      <div class="col-sm-10 col-md-8 col-sm-offset-1 col-md-offset-2">
        <?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>

          <article id="post-<?php 
        the_ID();
        ?>
" <?php 
        post_class();
        ?>
>
            <header class="text-center">
              <small class="entry-metadata">
 function column_goals_away($item)
 {
     $db = new KKL_DB();
     $match = $db->getMatch($item['id']);
     return $match->goals_away;
 }
 function get_current_game_day()
 {
     if ($this->currentGameDay) {
         return $this->currentGameDay;
     }
     $day = null;
     $db = new KKL_DB();
     if ($_GET['game_day_filter']) {
         $day = $db->getGameday($_GET['game_day_filter']);
     } elseif ($this->get_current_season()) {
         $day = $db->getCurrentGameDayForSeason($this->get_current_season()->id);
     } elseif ($this->get_current_league()) {
         $day = $db->getCurrentGameDayForLeague($this->get_current_league()->id);
     }
     $this->currentGameDay = $day;
     return $day;
 }
Exemple #12
0
    public function form($instance)
    {
        $db = new KKL_DB();
        $leagues = $db->getLeagues();
        if (isset($instance['title'])) {
            $title = $instance['title'];
        } else {
            $title = __('New title', 'text_domain');
        }
        if (isset($instance['league'])) {
            $league = $instance['league'];
        } else {
            $league = __('Set League', 'text_domain');
        }
        ?>
		<p>
		<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
</label> 
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" />
		<br/><br/>
		<label for="<?php 
        echo $this->get_field_id('league');
        ?>
"><?php 
        _e('League:');
        ?>
</label> 
		<select id="<?php 
        echo $this->get_field_id('league');
        ?>
" name="<?php 
        echo $this->get_field_name('league');
        ?>
">
			<option value=""><?php 
        echo __('get from context', 'kkl-ligatool');
        ?>
</option>
			<?php 
        foreach ($leagues as $l) {
            $selected = false;
            if ($l->id == $league) {
                $selected = true;
            }
            echo "<option value=\"{$l->id}\"";
            if ($selected) {
                echo ' selected="selected"';
            }
            echo ">";
            echo $l->name;
            echo "</option>";
        }
        ?>
		</select>
		</p>
		<?php 
    }
Exemple #13
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));
 }
 function save()
 {
     $match = new stdClass();
     $match->id = $_POST['id'];
     $match->game_day_id = $_POST['game_day'];
     $match->fixture = $this->cleanDate($_POST['fixture']);
     $match->home_team = $_POST['team_home'];
     $match->away_team = $_POST['team_away'];
     $match->location = $_POST['location'];
     $match->goals_home = $_POST['goals_home'];
     $match->goals_away = $_POST['goals_away'];
     $match->score_home = $_POST['score_home'];
     $match->score_away = $_POST['score_away'];
     $match->notes = $_POST['description'];
     if ($_POST['final_score']) {
         $match->status = 3;
     } else {
         $match->status = -1;
     }
     $db = new KKL_DB();
     $this->match = $db->createOrUpdateMatch($match);
     return $this->match;
 }
Exemple #15
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));
Exemple #16
0
    if ($league && $season) {
        $context = $KKL->getContextByLeagueAndSeason($league, $season, $game_day);
    } else {
        if ($league) {
            $context = $KKL->getContextByLeague($league, $season, $game_day);
        } else {
            $context = null;
            $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();