function display_content() { $team = $this->get_item(); $db = new KKL_DB(); $seasons = $db->getSeasons(); $season_options = array("" => __('please_select', 'kkl-ligatool')); foreach ($seasons as $season) { $season_options[$season->id] = $season->name; } $clubs = $db->getClubs(); $club_options = array("" => __('please_select', 'kkl-ligatool')); foreach ($clubs as $club) { $club_options[$club->id] = $club->name; } $locations = $db->getLocations(); $location_options = array("" => __('please_select', 'kkl-ligatool')); foreach ($locations as $location) { $location_options[$location->id] = $location->title; } $leaguewinner_checked = $team->properties && array_key_exists('current_league_winner', $team->properties); if ($this->errors && $_POST['current_league_winner']) { $leaguewinner_checked = true; } $cupwinner_checked = $team->properties && array_key_exists('current_cup_winner', $team->properties); if ($this->errors && $_POST['current_cup_winner']) { $cupwinner_checked = true; } echo $this->form_table(array(array('type' => 'hidden', 'name' => 'id', 'value' => $team->id), array('title' => __('name', 'kkl-ligatool'), 'type' => 'text', 'name' => 'name', 'value' => $this->errors ? $_POST['name'] : $team->name, 'extra' => $this->errors['name'] ? array('style' => "border-color: red;") : array()), array('title' => __('url_code', 'kkl-ligatool'), 'type' => 'text', 'name' => 'short_name', 'value' => $this->errors ? $_POST['short_name'] : $team->short_name, 'extra' => $this->errors['short_name'] ? array('style' => "border-color: red;") : array()), array('title' => __('season', 'kkl-ligatool'), 'type' => 'select', 'name' => 'season', 'choices' => $season_options, 'selected' => $this->errors ? $_POST['season'] : $team->season_id, 'extra' => $this->errors['season'] ? array('style' => "border-color: red;") : array()), array('title' => __('club', 'kkl-ligatool'), 'type' => 'select', 'name' => 'club', 'choices' => $club_options, 'selected' => $this->errors ? $_POST['club'] : $team->club_id, 'extra' => $this->errors['club'] ? array('style' => "border-color: red;") : array()), array('title' => __('location', 'kkl-ligatool'), 'type' => 'select', 'name' => 'location', 'choices' => $location_options, 'selected' => $this->errors ? $_POST['location'] : $team->properties['location']), array('title' => __('current_league_winner', 'kkl-ligatool'), 'type' => 'checkbox', 'name' => 'current_league_winner', 'checked' => $leaguewinner_checked), array('title' => __('current_cup_winner', 'kkl-ligatool'), 'type' => 'checkbox', 'name' => 'current_cup_winner', 'checked' => $cupwinner_checked))); }
function get_clubs() { if ($this->clubs) { return $this->clubs; } $db = new KKL_DB(); $clubs = $db->getClubs(); $keyed = array(); foreach ($clubs as $club) { $keyed[$club->id] = $club; } $this->clubs = $keyed; return $keyed; }