/**
  * Show the league ranking as widget.
  *
  * @param  integer $id_league
  * @return string
  */
 public function widget_ranking_table($id_league)
 {
     global $wpdb;
     $db = new PHPLeague_Database();
     // League not found in the database
     if ($db->is_league_exists($id_league) === FALSE) {
         return;
     }
     $setting = $db->get_league_settings($id_league);
     $nb_teams = (int) $setting->nb_teams;
     $favorite = (int) $setting->id_favorite;
     $output = '<table id="phpleague"><thead><tr>
                 <th class="centered">' . __('Pos', 'phpleague') . '</th>
                 <th>' . __('Team', 'phpleague') . '</th>
                 <th class="centered">' . __('Pts', 'phpleague') . '</th>
                 <th class="centered">' . __('P', 'phpleague') . '</th>
                 <th class="centered">' . __('+/-', 'phpleague') . '</th></tr></thead><tbody>';
     $place = 1;
     foreach ($db->get_league_table_data('general', $id_league, $nb_teams) as $row) {
         if ($place <= $nb_teams) {
             if ($favorite == $row->id_team) {
                 $output .= '<tr class="id-favorite">';
             } else {
                 $output .= '<tr>';
             }
             $points = (int) $row->points;
             $played = (int) $row->played;
             $diff = (int) $row->diff;
             $output .= '<td class="centered">' . $place . '</td>';
             $output .= '<td>' . esc_html($row->club_name) . '</td>';
             $output .= '<td class="centered">' . $points . '</td>';
             $output .= '<td class="centered">' . $played . '</td>';
             $output .= '<td class="centered">' . $diff . '</td></tr>';
             $place++;
         }
     }
     $output .= '</tbody></table>';
     return $output;
 }
Пример #2
0
    foreach ($clubs as $club) {
        $my_clubs[] = $club;
    }
}
$leagues = $db->get_every_league(0, $db->count_leagues());
$my_leagues = array();
foreach ($leagues as $league) {
    foreach ($my_clubs as $club) {
        if (!$db->is_club_already_in_league($league->id, $club->id)) {
            // is_club_already_in_league returns false when in league
            $my_leagues[] = $league;
            break;
        }
    }
}
$id_league = !empty($_GET['id_league']) && $db->is_league_exists($_GET['id_league']) === TRUE ? (int) $_GET['id_league'] : $my_leagues[0]->id;
foreach ($my_clubs as $club) {
    $my_club_ids[] = $db->get_team_id($club->id, $id_league);
}
if ($db->is_league_exists($id_league) === FALSE) {
    wp_die(__('We did not find the league in the database.', 'phpleague'));
}
// Variables
$league_name = $db->return_league_name($id_league);
$setting = $db->get_league_settings($id_league);
$nb_teams = (int) $setting->nb_teams;
$nb_legs = (int) $setting->nb_leg;
$nb_players = (int) $setting->nb_starter + (int) $setting->nb_bench;
$sport = new PHPLeague_Sports::$sports[$setting->sport]();
$page_url = 'admin.php?page=phpleague_my_results&id_league=' . $id_league;
$output = '';