Plugin Directory

Changeset 743314


Ignore:
Timestamp:
07/19/2013 07:19:08 PM (13 years ago)
Author:
lacroixca
Message:

Updated trunk.

Location:
sportsmanager/trunk
Files:
3 added
19 edited

Legend:

Unmodified
Added
Removed
  • sportsmanager/trunk/classes/Frontend.php

    r713613 r743314  
    1717                'tables' => array ('games', 'clubs', 'locations', 'teams'), //always name primary object first
    1818                'args' => array ('display')
    19             ),
    20             'stats_game' => (object) array (
    21                 'tables' => array ('scoresheets', 'players', 'users'),
    22                 'args' => array ('display', 'game_id', 'sport')
    2319            ),
    2420            'list_games' => (object) array (
     
    4238                'args' => array ('display', array ('league_id', 'league_slug', 'league_name'))
    4339            ),
     40            'player_stats' => (object) array (
     41                'tables' => array ('players', 'scoresheets', 'users'),
     42                'args' => array ('display', array ('league_id', 'league_slug', 'league_name'), 'seasons_array', 'sport')
     43            ),
    4444            'schedule' => (object) array (
    4545                'tables' => array ('games', 'clubs', 'locations', 'teams'),
    4646                'args' => array ('display')
     47            ),
     48            'stats_game' => (object) array (
     49                'tables' => array ('scoresheets', 'players', 'users'),
     50                'args' => array ('display', 'game_id', 'sport')
    4751            ),
    4852            'stats_leaders' => (object) array (
     
    5660            'stats_players' => (object) array (
    5761                'tables' => array ('players', 'scoresheets', 'users'),
    58                 'args' => array ('display', array ('league_id', 'league_slug', 'league_name'), 'season', 'sport')
     62                'args' => array ('display', array ('league_id', 'league_slug', 'league_name'), 'sport')
    5963            ),
    6064            'stats_team_players' => (object) array (
    6165                'tables' => array ('players', 'clubs', 'scoresheets', 'teams', 'users'),
    62                 'args' => array ('display', array ('team_id', 'team_slug', 'team_name'), 'season', 'sport')
     66                'args' => array ('display', 'season', 'sport', array ('team_id', 'team_slug', 'team_name'))
    6367            ),
    6468            'stats_team' => (object) array (
     
    132136            foreach ($this->db->$primary_object as $row) {
    133137                $class = $this->objects->$primary_object->class;
     138                if (isset($row->slug) && $row->slug == '') continue;
    134139                $this->rows[] = new $class($row, $this->db, $this->args);
    135140            };
    136141            if ($primary_object == 'players') {
    137                 if (in_array($this->args->display, array ('list_players', 'stats_team_players')) && $this->args->team_id != '') {
     142                if (in_array($this->args->display, array ('list_players', 'stats_team_players')) && $this->args->team_id !== '') {
    138143                    global $wpdb;
    139144                    $table = $this->objects->teams->table;
    140145                    $team_id = $this->args->team_id;
    141                     $q = "SELECT players_id FROM $table WHERE id = '$team_id'";
    142                     $players_id = json_decode($wpdb->get_var($q));
    143                     foreach ($this->rows as $k => $v) {
    144                         if (!is_array($players_id) || !in_array($v->id, $players_id)) unset($this->rows[$k]);
     146                    if ($this->args->team_id == 0) {
     147                        $this->rows = array ();
     148                    } else {
     149                        $q = "SELECT players_id FROM $table WHERE id = '$team_id'";
     150                        $players_id = json_decode($wpdb->get_var($q));
     151                        foreach ($this->rows as $k => $v) {
     152                            if (!is_array($players_id) || !in_array($v->id, $players_id)) unset($this->rows[$k]);
     153                        };
    145154                    };
    146155                };
  • sportsmanager/trunk/classes/Game.php

    r713613 r743314  
    3939            'away_score' => isset($data->away_score) ? $data->away_score : '',
    4040            'winner_team_id' => isset($data->winner_team_id) ? $data->winner_team_id : '',
    41             'date' => isset($data->date) ? ucfirst(strftime("%m-%d %R", strtotime($data->date))) : '',
     41            'date' => isset($data->date) ? $data->date : '', //ucfirst(strftime("%m-%d %R", strtotime($data->date))) : '',
    4242            'date_str' => isset($data->date) ? ucfirst(strftime("%A, %e %B", strtotime($data->date))) : '',
    4343            'time' => isset($data->date) ? strtotime($data->date) : '',
  • sportsmanager/trunk/classes/Player.php

    r713613 r743314  
    6565            'birth_date' => isset($infos->birth_date) && !in_array($infos->birth_date, array ('', '0')) ? $infos->birth_date : '',
    6666            'hometown' => isset($infos->home_town) && !in_array($infos->home_town, array ('', '0')) ? $infos->home_town : '',
     67            'description' => isset($data->description) ? json_decode($data->description) : '',
    6768            //stats
    6869            //'games' => count($scoresheets) //no because in one scoresheet, you can enter stats for multiple games, or even an entire year! It also depends on what league your refering to!
  • sportsmanager/trunk/classes/SportsManager.php

    r713613 r743314  
    6868            'player_slug' => '',
    6969            'season' => '',
     70            'seasons_array' => array (),
    7071            'sport' => '',
    7172            'team_id' => '',
  • sportsmanager/trunk/classes/Team.php

    r713613 r743314  
    7171            'ranking' => '',
    7272            'wins' => $wins,
     73            'players_id' => isset($data->players_id) ? json_decode($data->players_id) : '',
    7374            'small_logo_url' => isset($club->small_logo_url) ? $club->small_logo_url : '',
    7475            'large_logo_url' => isset($club->large_logo_url) ? $club->large_logo_url : '',
  • sportsmanager/trunk/config.php

    r713613 r743314  
    1111 */
    1212function sm_constants() {
    13     define('SPORTSMANAGER_VERSION', '1.3.0');
     13    define('SPORTSMANAGER_VERSION', '1.3.1');
    1414    define('SPORTSMANAGER_PREFIX', 'sportsmanager_');
    1515    define('SPORTSMANAGER_CAPABILITY_PREFIX', 'edit_sportsmanager_');
  • sportsmanager/trunk/controllers/filters.php

    r713613 r743314  
    5252        'user_id' => array ('WP User ID', '', false),
    5353        'slug' => array ('Slug', '', true),
     54        'description' => array ('Description', '', false),
    5455        'small_logo_url' => array ('Small Logo URL', '', false),
    5556        'large_logo_url' => array ('Large Logo URL', '', false),
     
    9293);
    9394$add_rows = isset($add_rows[$filter]) ? $add_rows[$filter] : $add_rows['default'];
     95$delete_rows = 'Delete a game';
  • sportsmanager/trunk/controllers/frontend_filter_table.php

    r713613 r743314  
    44
    55    //common
    6     'assists' => array ('AST', "Assists", array ('basketball')),
     6    'assists' => array ('AST', "Assists", array ('basketball', 'hockey')),
    77    'blocks' => array ('BLK', "Blocks", array ('basketball')),
     8    'goals' => array ('G', "Goals", array ('hockey', 'soccer')),
    89    'steals' => array ('STL', "Steals", array ('basketball')),
    910    'turnovers' => array ('TO', "Turnovers", array ('basketball')),
     
    4344    'personal_fouls' => array ('PF', "Personal Fouls", array ('basketball')),
    4445
     46    //hockey
     47    'goals_against_average' => array ('GAA', "Goals Against Average", array ('hockey')),
     48    'hockey_points' => array ('P', "Points", array ('hockey')),
     49    'save_percentage' => array ('S%', "Save Percentage", array ('hockey')),
     50
    4551    //soccer
    46     'goals' => array ('G', "Goals", array ('soccer')),
    4752);
    4853$headers = array (
     
    102107    $rows = sm_order_array_objects_by('time', $rows);
    103108    foreach ($rows as $i => $row) {
    104         if (isset($row->time) && $row->time >= time()) {
     109        if (isset($row->time) && $row->time >= time() && $row->cancelled != 1) {
    105110            $next_game = $i;
    106111            break;
  • sportsmanager/trunk/controllers/modal_edit_stats.php

    r698924 r743314  
    77
    88    //common
    9     'assists' => array ('AST', "Assists", array ('basketball')),
     9    'assists' => array ('AST', "Assists", array ('basketball', 'hockey')),
    1010    'blocks' => array ('BLK', "Blocks", array ('basketball')),
     11    'goals' => array ('G', "Goals", array ('hockey', 'soccer')),
    1112    'steals' => array ('STL', "Steals", array ('basketball')),
    1213    'turnovers' => array ('TO', "Turnovers", array ('basketball')),
     
    5253
    5354    //soccer
    54     'goals' => array ('G', "Goals", array ('soccer')),
    5555);
  • sportsmanager/trunk/css/filters.css

    r713613 r743314  
    193193}
    194194.sm_add_row_btn,
    195 .sm_add_rows_btn {
     195.sm_add_rows_btn,
     196.sm_delete_rows_btn {
    196197    margin:5px 0;
    197198    padding:10px;
     
    206207}
    207208.sm_add_row_btn:hover,
    208 .sm_add_rows_btn:hover {
     209.sm_add_rows_btn:hover,
     210.sm_delete_rows_btn:hover {
    209211    background: #f0f0f0;
    210212    box-shadow:0 0 10px 1px rgba(0,0,0,0.2);
  • sportsmanager/trunk/functions/install.php

    r713613 r743314  
    7474                                user_id int(11) NOT NULL,
    7575                                slug varchar(100) NOT NULL,
     76                                description text NOT NULL,
    7677                                small_logo_url varchar(256) NOT NULL,
    7778                                large_logo_url varchar(256) NOT NULL,
  • sportsmanager/trunk/js/modals.js

    r713613 r743314  
    186186        file_frame.on("select", function() { //callback when an image is selected
    187187            attachment = file_frame.state().get("selection").first().toJSON();
    188             var url = attachment.url;
    189188            var data = {
    190189                action: "sm_row",
     
    192191                tab: SM.hash.tab,
    193192                id: SM.settings.current_cell.attr("id"),
    194                 value: url
     193                value: attachment.url
    195194            };
    196195            $.post(SM.settings.ajax_url, data, function(response) {
     
    204203        });
    205204        file_frame.open();
    206 
    207         /*
    208         window.send_to_editor = function(html) {
    209             var url = $(html).attr("href");
    210             var data = {
    211                 action: "sm_row",
    212                 "do": "edit",
    213                 tab: SM.hash.tab,
    214                 id: SM.settings.current_cell.attr("id"),
    215                 value: url
    216             };
    217             $.post(SM.settings.ajax_url, data, function(response) {
    218                 var returned = {name: "", value: ""};
    219                 try {
    220                     var returned = jQuery.parseJSON(response);
    221                 } catch (e) {};
    222                 SM.settings.current_cell.attr("data-value", returned.value).html(returned.name).focus();
    223                 SM.fn.highlight(SM.settings.current_cell, "sm_current_cell");
    224                 tb_remove();
    225             });
    226         }
    227         tb_show("", SM.settings.WP_ADMIN_URL + "media-upload.php?type=image&tab=type&TB_iframe=true");
    228         */
    229 
    230205        return false;
    231206    });
     
    290265    $(".sm_filter_table td.column-stats").live("dblclick", function() {
    291266        SM.settings.current_cell = $(this);
    292         var sport = $(this).siblings(".column-sport").html();
     267        var sport = $(this).siblings(".column-sport").attr("data-value");
    293268        if (sport == "") {
    294269            $("#sm_alerts_modal, #sm_backdrop_disabled").show();
  • sportsmanager/trunk/js/pages.js

    r713613 r743314  
    5656SM.behaviors.import = function() {
    5757    var $ = jQuery;
     58    var file_frame;
    5859    $("#sm_import_type").live("change", function() {
    5960        var type = $("select option:selected").val();
     
    6768
    6869    $(".sm_import_upload_file").live("click", function() {
    69         window.send_to_editor = function(html) {
    70             var url = $(html).attr("href");
    71             $("#sm_import_file_url").val(url);
    72             tb_remove();
     70        if (file_frame) {
     71            file_frame.open();
     72            return;
    7373        }
    74         tb_show("", SM.settings.WP_ADMIN_URL + "media-upload.php?type=image&tab=type&TB_iframe=true");
     74        file_frame = wp.media.frames.file_frame = wp.media({
     75            title: "Sports Manager",
     76            button: {
     77                //text: "Use image"
     78            },
     79            multiple: false
     80        });
     81        file_frame.on("select", function() { //callback when an image is selected
     82            attachment = file_frame.state().get("selection").first().toJSON();
     83            $("#sm_import_file_url").val(attachment.url).focus();
     84        });
     85        file_frame.open();
    7586        return false;
    7687    });
     
    102113                    SM.fn.highlight(form, "sm_current_cell");
    103114                } else {
    104                     $("#sm_import_ajax_return").html("Error: " + response).show();
     115                    $("#sm_import_ajax_return").html("Error: <pre>" + response + "</pre>").show();
    105116                };
    106117            });
  • sportsmanager/trunk/readme.txt

    r713613 r743314  
    55Requires at least: 3.5.1
    66Tested up to: 3.5.1
    7 Stable tag: 1.3.0
     7Stable tag: 1.3.1
    88License: GPL2
    99
     
    4242
    4343== Changelog ==
     44
     45= 1.3.1 =
     46* Hockey added.
     47* Bug fixes.
    4448
    4549= 1.3.0 =
     
    8084== Upgrade Notice ==
    8185
     86= 1.3.1 =
     87Updates and hockey added.
     88
    8289= 1.3.0 =
    8390Major updates.
  • sportsmanager/trunk/sportsmanager.php

    r713613 r743314  
    44Plugin URI: http://lac.roix.ca/en/sportsmanager/
    55Description: Manage your sport league like a pro!
    6 Version: 1.3.0
     6Version: 1.3.1
    77Author: Charles-Alexandre Lacroix
    88Author URI: http://lac.roix.ca/
  • sportsmanager/trunk/views/filters.php

    r713613 r743314  
    88<?php foreach ($headers[$filter] as $k => $v) { ?>
    99
    10             <th class="column-<?php echo $k; ?> <?php echo $v[2] ? 'required' : ''; ?>" scope="col" data-column="<?php echo $k; ?>" data-filter="<?php echo $filter; ?>" title="<?php echo $v[2] ? 'required' : ''; ?>"><?php echo $v[0]; ?></th>
     10<?php
     11    $mask_value = false;
     12    $restricted_type = "";
     13    $restricted_limit = "";
     14    if ($this->is_special_backend_key($k)) {
     15        $mask_value = true;
     16    };
     17    if ($this->is_restricted_backend_key($k)) {
     18        $restricted_type = isset($this->restricted_backend_keys[$k][0]) ? $this->restricted_backend_keys[$k][0] : '';
     19        $restricted_limit = isset($this->restricted_backend_keys[$k][1]) ? $this->restricted_backend_keys[$k][1] : '';
     20    };
     21?>
     22
     23            <th class="column-<?php echo $k; ?> <?php echo $v[2] ? 'required' : ''; ?>" scope="col" data-column="<?php echo $k; ?>" data-filter="<?php echo $filter; ?>" data-mask-value="<?php echo $mask_value ? '1' : '0'; ?>" data-restricted-type="<?php echo $restricted_type; ?>" data-restricted-limit="<?php echo $restricted_limit; ?>" title="<?php echo $v[2] ? 'required' : ''; ?>"><?php echo $v[0]; ?></th>
    1124
    1225<?php }; ?>
     
    6376<?php }; ?>
    6477
     78<?php if ($filter == 'scoresheets') { ?>
     79    <button class="sm_delete_rows_btn" onclick="javascript:alert('Not ready yet');"><?php echo $delete_rows; ?></button>
     80<?php }; ?>
     81
    6582</div>
    6683
  • sportsmanager/trunk/views/frontend_filters.php

    r713613 r743314  
    3232        $row->differential = $row->points_plus - $row->points_minus;
    3333        if ($row->differential > 0) $row->differential = '+'.$row->differential;
    34     };
    35     //game_back
    36     if (isset($this->rows[0]->wins, $this->rows[0]->wins, $row->wins, $row->losses)) {
    37         $leader_wins = $this->rows[0]->wins;
    38         $leader_losses = $this->rows[0]->losses;
    39         $team_wins = $row->wins;
    40         $team_losses = $row->losses;
    41         $row->game_back = (($leader_wins - $leader_losses) - ($team_wins - $team_losses)) / 2;
    42         if ($row->game_back == 0) $row->game_back = '-';
    4334    };
    4435    //on_base_percentage
     
    8071    };
    8172    //cancelled games
    82     if (isset($row->cancelled) && $row->cancelled == 1) {
     73    if ((isset($row->cancelled) && $row->cancelled == 1) || ((isset($row->home_team_id) && $row->home_team_id == 0) || (isset($row->away_team_id) && $row->away_team_id == 0))) {
    8374        $row->home_score = '-';
    8475        $row->away_score = '-';
    8576    };
    8677};
    87 //ranking
    8878$this->rows = sm_order_array_objects_by(array ('wins', 'winning_percentage', 'name'), $this->rows, true);
    8979foreach ($this->rows as $k => $row) {
     80    //ranking
    9081    if (isset($row->ranking)) {
    9182        $row->ranking = $k + 1;
     83    };
     84    //game_back
     85    if (isset($this->rows[0]->wins, $this->rows[0]->wins, $row->wins, $row->losses)) {
     86        $leader_wins = $this->rows[0]->wins;
     87        $leader_losses = $this->rows[0]->losses;
     88        $team_wins = $row->wins;
     89        $team_losses = $row->losses;
     90        $row->game_back = (($leader_wins - $leader_losses) - ($team_wins - $team_losses)) / 2;
     91        if ($row->game_back == 0) $row->game_back = '-';
    9292    };
    9393};
     
    9797} elseif ($this->args->display == 'game_results') {
    9898    $this->include_view('frontend_games_box');
     99} elseif ($this->args->display == 'player_stats') {
     100    $this->include_view('frontend_player_stats_box');
    99101} else {
    100102    $this->include_view('frontend_filter_table');
  • sportsmanager/trunk/views/frontend_games_box.php

    r713613 r743314  
    124124            new_active.addClass("active");
    125125        }
     126        return false;
    126127    });
    127128});
  • sportsmanager/trunk/views/frontend_leaders_box.php

    r713613 r743314  
    88        if (in_array('all', $stat_v[2]) || in_array($sport, $stat_v[2])) {
    99            $rows = sm_order_array_objects_by(array ($stat_k), $rows, true);
    10             $leader = $rows[0];
    11             $img_link = 'http://graph.facebook.com/'.$leader->facebook_id.'/picture?type=square';
     10            $leader = isset($rows[0]) ? $rows[0] : '';
     11            $img_link = isset($leader->facebook_id) ? 'http://graph.facebook.com/'.$leader->facebook_id.'/picture?type=square' : '';
    1212            $stat_url = str_replace(array ('%slug%'), array ($stat_k), $this->args->default_stats_url);
    1313            if ($stat_url == '') $stat_url = '#';
Note: See TracChangeset for help on using the changeset viewer.