Plugin Directory

Changeset 1361999


Ignore:
Timestamp:
03/01/2016 06:38:37 PM (11 years ago)
Author:
koelle
Message:

multiple fixes and some new features

Location:
leaguemanager/trunk
Files:
2 added
40 edited

Legend:

Unmodified
Added
Removed
  • leaguemanager/trunk/admin/admin.php

    r1348420 r1361999  
    363363
    364364        /**
    365          * get point rule depending on selection.
    366          * For details on point rules see http://de.wikipedia.org/wiki/Drei-Punkte-Regel (German)
    367          *
    368          * @param int $rule
    369          * @return array of points
    370          */
    371         function getPointRule( $rule )
    372         {
    373                 $rule = maybe_unserialize($rule);
    374 
    375                 // Manual point rule
    376                 if ( is_array($rule) ) {
    377                         return $rule;
    378                 } else {
    379                         $point_rules = array();
    380                         // One point rule
    381                         $point_rules['one'] = array( 'forwin' => 1, 'fordraw' => 0, 'forloss' => 0 );
    382                         // Two point rule
    383                         $point_rules['two'] = array( 'forwin' => 2, 'fordraw' => 1, 'forloss' => 0 );
    384                         // Three-point rule
    385                         $point_rules['three'] = array( 'forwin' => 3, 'fordraw' => 1, 'forloss' => 0 );
    386                         // Score. One point for each scored goal
    387                         $point_rules['score'] = 'score';
    388 
    389                         $point_rules = apply_filters( 'leaguemanager_point_rules', $point_rules );
    390 
    391                         return $point_rules[$rule];
    392                 }
    393         }
    394 
    395 
    396         /**
    397365         * get available point formats
    398366         *
    … …  
    518486        function calculatePoints( $team_id, $option )
    519487        {
    520                 global $wpdb;
     488                global $wpdb, $leaguemanager;
    521489
    522490                $league = $this->league;
    523491
    524                 $rule = $this->getPointRule( $league->point_rule );
     492                $rule = $leaguemanager->getPointRule( $league->point_rule );
    525493                $team_id = intval($team_id);
    526494                $points = array( 'plus' => 0, 'minus' => 0 );
    … …  
    528496               
    529497                if ( 'score' == $rule ) {
    530                         $home = $this->getMatches( array("home_team" => $team_id) );
     498                        $home = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
    531499                        foreach ( $home AS $match ) {
    532500                                $points['plus'] += $match->home_points;
    … …  
    534502                        }
    535503
    536                         $away = $this->getMatches( array("away_team" => $team_id) );
     504                        $away = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    537505                        foreach ( $away AS $match ) {
    538506                                $points['plus'] += $match->away_points;
    … …  
    541509                } else {
    542510                        extract( (array)$rule );
    543                         $home = $this->getMatches( array("home_team" => $team_id) );
     511                        $home = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
    544512                        foreach ( $home AS $match ) {
    545513                                $team_points += $match->home_points;
    546514                        }
    547515                       
    548                         $away = $this->getMatches( array("away_team" => $team_id) );
     516                        $away = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    549517                        foreach ( $away AS $match ) {
    550518                                $team_points += $match->away_points;
    … …  
    13091277                                $loser = $this->getMatchResult($points['home'], $points['away'], $home_team[$match_id], $away_team[$match_id], 'loser' );
    13101278
    1311                                 $m = $leaguemanager->getMatch( $match_id );
     1279                                $m = $leaguemanager->getMatch( $match_id, false );
    13121280                                $cv = isset($custom[$match_id]) ? $custom[$match_id] : array();
    13131281                                $c = array_merge( (array)$m->custom, (array)$cv );
    … …  
    19741942                return $rs;
    19751943        }
     1944       
     1945       
     1946        function showDatabaseColumns()
     1947        {
     1948                global  $wpdb;
     1949               
     1950                $tables = array($wpdb->leaguemanager, $wpdb->leaguemanager_teams, $wpdb->leaguemanager_matches, $wpdb->leaguemanager_stats);
     1951               
     1952                foreach( $tables AS $table ) {
     1953                        $results = $wpdb->get_results("SHOW COLUMNS FROM {$table}");
     1954                        $columns = array();
     1955                        foreach ( $results AS $result ) {
     1956                                $columns[] = "<li>".$result->Field." ".$result->Type.", NULL: ".$result->Null.", Default: ".$result->Default.", Extra: ".$result->Extra."</li>";
     1957                        }
     1958                        echo "<p>Table ".$table."<ul>";
     1959                        echo implode("", $columns);
     1960                        echo "</ul></p>";
     1961                }
     1962        }
    19761963}
    19771964?>
  • leaguemanager/trunk/admin/show-league.php

    r1344775 r1361999  
    154154
    155155if ( $league_mode != 'championship' ) {
    156         $teams = $leaguemanager->getTeams( array("league_id" => $league->id, "season" => $season['name']), 'OBJECT' );
     156        $teams = $leaguemanager->getTeams( array("league_id" => $league->id, "season" => $season['name'], "cache" => false), 'OBJECT' );
    157157        $matches = $leaguemanager->getMatches( $match_args );
    158158        $leaguemanager->setNumMatches($leaguemanager->getMatches(array_merge($match_args, array('limit' => false, 'count' => true))));
    … …  
    162162        $tab = 2;
    163163
     164if ( isset($_GET['standingstable']) ) {
     165        $get = $_GET['standingstable'];
     166        $match_day = false;
     167        $mode = 'all';
     168        if ( preg_match('/match_day-\d/', $get, $hits) ) {
     169                $res = explode("-", $hits[0]);
     170                $match_day = $res[1];
     171        } elseif ( in_array($get, array('home', 'away')) ) {
     172                $mode = htmlspecialchars($get);
     173        }
     174        $teams = $leaguemanager->getStandings( $teams, $match_day, $mode );
     175}
    164176/*$tmp = $leaguemanager->getTeams( array('league_id' => $league->id) );
    165177foreach ( $tmp AS $t )
    … …  
    222234                        <div id="standings-table" class="league-block-container">
    223235                                <h2 class="header"><?php _e( 'Table', 'leaguemanager' ) ?></h2>
     236                                <div class="alignright">
     237                                        <form action="admin.php" method="get">
     238                                        <input type="hidden" name="page" value="leaguemanager" />
     239                                        <input type="hidden" name="subpage" value="show-league" />
     240                                        <input type="hidden" name="league_id" value="<?php echo $league->id ?>" />
     241                                       
     242                                        <?php echo $leaguemanager->getStandingsSelection( $league ); ?>
     243                                        <input type="submit" class="button-secondary" value="<?php _e( 'Show', 'leaguemanager' ) ?>" />
     244                                        </form>
     245                                </div>
    224246                                <?php include_once('standings.php'); ?>
    225247                        </div>
  • leaguemanager/trunk/admin/standings.php

    r1348420 r1361999  
    2727                <?php if ( !empty($league->groups) && $league->mode == 'championship' ) : ?><th class="num"><?php _e( 'Group', 'leaguemanager' ) ?></th><?php endif; ?>
    2828                <th class="num"><?php if ( isset($league->standings['pld']) && 1 == $league->standings['pld'] ) : ?><?php _e( 'Pld', 'leaguemanager' ) ?><?php endif; ?></th>
    29                 <th class="num"><?php if ( isset($league->standings['won']) && 1 == $league->standings['won'] ) : ?><?php echo _x( 'W','leaguemanager' ) ?><?php endif; ?></th>
    30                 <th class="num"><?php if ( isset($league->standings['tie']) && 1 == $league->standings['tie'] ) : ?><?php echo _x( 'T','leaguemanager' ) ?><?php endif; ?></th>
    31                 <th class="num"><?php if ( isset($league->standings['lost']) && 1 == $league->standings['lost'] ) : ?><?php echo _x( 'L','leaguemanager' ) ?><?php endif; ?></th>
     29                <th class="num"><?php if ( isset($league->standings['won']) && 1 == $league->standings['won'] ) : ?><?php _e( 'W','leaguemanager' ) ?><?php endif; ?></th>
     30                <th class="num"><?php if ( isset($league->standings['tie']) && 1 == $league->standings['tie'] ) : ?><?php _e( 'T','leaguemanager' ) ?><?php endif; ?></th>
     31                <th class="num"><?php if ( isset($league->standings['lost']) && 1 == $league->standings['lost'] ) : ?><?php _e( 'L','leaguemanager' ) ?><?php endif; ?></th>
    3232                <?php do_action( 'leaguemanager_standings_header_'.$sport ) ?>
    3333                <th class="num"><?php _e( 'Pts', 'leaguemanager' ) ?></th>
    … …  
    3737        <tbody id="<?php echo ( $league->mode == 'championship' ) ? "the-list-standings-".$group : "the-list-standings" ?>" class="form-table standings-table <?php if ($league->team_ranking == 'manual') echo 'sortable' ?>">
    3838        <?php if ( count($teams) > 0 ) : $class = ''; ?>
    39         <?php foreach( $teams AS $team ) : $class = ( 'alternate' == $class ) ? '' : 'alternate'; ?>
     39        <?php foreach( $teams AS $i => $team ) : $class = ( 'alternate' == $class ) ? '' : 'alternate'; ?>
    4040        <tr class="<?php echo $class ?>" id="team_<?php echo $team->id ?>">
    4141                <th scope="row" class="check-column"><input type="hidden" name="team_id[<?php echo $team->id ?>]" value="<?php echo $team->id ?>" /><input type="checkbox" value="<?php echo $team->id ?>" name="team[<?php echo $team->id ?>]" /></th>
    … …  
    4545                        <input type="text" name="rank[<?php echo $team->id ?>]" size="2" id="rank_<?php echo $team->id ?>" class="rank-input" value="<?php echo $team->rank ?>" />
    4646                        <?php else : ?>
    47                         <?php echo $team->rank ?>
     47                        <?php echo $i+1;//$team->rank ?>
    4848                        <?php endif; ?>
    4949                </td>
  • leaguemanager/trunk/functions.php

    r1336648 r1361999  
    4242 *
    4343 * @param int $team_id
    44  * @param int $ne number of matches
    45  */
    46 function get_last_matches( $team_id, $n = 1 ) {
     44 * @param int $n number of matches
     45 * @param boolean $logos
     46 * @return $matches
     47 */
     48function get_last_matches( $team_id, $n = 1, $logos = true ) {
    4749        global $leaguemanager;
    48        
    49         $matches = $leaguemanager->getMatches( array( 'time' => 'prev', 'team_id' => intval($team_id), 'limit' => intval($n) ) );
    50         return $matches;
     50        $matches = $leaguemanager->getMatches( array("time" => "prev", "team_id" => $team_id, "limit" => $n, "logos" => $logos) );
     51        if ( empty($matches) )
     52                return false;
     53       
     54        if ( $n == 1 )
     55                return $matches[0];
     56        else
     57                return $matches;
    5158}
    5259
    … …  
    5663 *
    5764 * @param int $team_id
    58  * @param int $ne number of matches
    59  */
    60 function get_next_matches( $team_id, $n = 1 ) {
     65 * @param int $n number of matches
     66 * @param boolean $logos
     67 * @return $matches
     68 */
     69function get_next_matches( $team_id, $n = 1, $logos = true ) {
    6170        global $leaguemanager;
    62        
    63         $matches = $leaguemanager->getMatches( array( 'time' => 'next', 'team_id' => intval($team_id), 'limit' => intval($n) ) );
    64         return $matches;
     71        $matches = $leaguemanager->getMatches( array("time" => "next", "team_id" => $team_id, "limit" => $n, "logos" => $logos) );
     72        if ( empty($matches) )
     73                return false;
     74       
     75        if ( $n == 1 )
     76                return $matches[0];
     77        else
     78                return $matches;
    6579}
    6680
    … …  
    114128}
    115129
    116 /**
    117  * get next game for Last 5 function
    118  *
    119  * @param int $id_team
    120  * @param int $limit additional argument (optional)
    121  * @return $next_results
    122  */
    123 
     130
     131 /*
    124132function get_next_match($id_team, $limit = 1) {
    125133     global $wpdb;
    … …  
    133141             return $next_results;
    134142}
    135 
     143*/
    136144
    137145/**
  • leaguemanager/trunk/languages/leaguemanager-de_DE.po

    r1344775 r1361999  
    1616"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    1717
     18msgid "Current Table"
     19msgstr "Aktuelle Tabelle"
     20
     21msgid "Hometable"
     22msgstr "Heimtabelle"
     23
     24msgid "Awaytable"
     25msgstr "Auswärtstabelle"
     26
    1827msgid "Final Results"
    1928msgstr "Finalergebnisse"
  • leaguemanager/trunk/languages/leaguemanager-gymnastics-de_DE.po

    r1324769 r1361999  
    1616"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    1717
     18msgid "Current Table"
     19msgstr "Aktuelle Tabelle"
     20
     21msgid "Hometable"
     22msgstr "Heimtabelle"
     23
     24msgid "Awaytable"
     25msgstr "Auswärtstabelle"
     26
    1827#: sports/gymnastics
    1928msgid "Floor"
  • leaguemanager/trunk/leaguemanager.php

    r1348420 r1361999  
    44Plugin URI: http://wordpress.org/extend/plugins/leaguemanager/
    55Description: Manage and present sports league results.
    6 Version: 4.0.8
     6Version: 4.0.9
    77Author: Kolja Schleich, LaMonte Forthun
    88
    … …  
    3939         * @var string
    4040         */
    41         var $version = '4.0.8';
     41        var $version = '4.0.9';
    4242
    4343
  • leaguemanager/trunk/leaguemanager.pot

    r1324769 r1361999  
    1717"Content-Transfer-Encoding: 8bit\n"
    1818"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
     19
     20msgid "Current Table"
     21msgstr ""
     22
     23msgid "Hometable"
     24msgstr ""
     25
     26msgid "Awaytable"
     27msgstr ""
     28
     29msgid "Final Results"
     30msgstr ""
     31
     32msgid "Third Place"
     33msgstr ""
     34
     35msgid "Final Matches"
     36msgstr ""
     37
     38msgid "Preliminary Rounds"
     39msgstr ""
    1940
    2041#: sports/gymnastics
  • leaguemanager/trunk/lib/core.php

    r1348420 r1361999  
    2222         * @var array
    2323         */
    24         var $league = array();
     24        var $league = null;
    2525
    2626
    … …  
    3030         * @var int
    3131         */
    32         var $league_id;
     32        var $league_id = null;
    3333
    3434       
    … …  
    6666       
    6767        /**
     68         * number of matches
     69         *
     70         * @var int
     71         */
     72        var $num_matches = null;
     73       
     74       
     75        /**
    6876         * number of matches per page
    6977         *
    … …  
    8189       
    8290
     91        /**
     92         * match day
     93         *
     94         * @var int
     95         */
     96        var $match_day = null;
     97       
     98       
    8399        /**
    84100         * Initializes plugin
    … …  
    283299                global $wpdb;
    284300               
     301                if ( isset($this->home_only_query[$league_id]) )
     302                        return $this->home_only_query[$league_id];
     303               
    285304                $queries = array();
    286305                $teams = $wpdb->get_results($wpdb->prepare("SELECT `id` FROM {$wpdb->leaguemanager_teams} WHERE `league_id` = '%d' AND `home` = 1", intval($league_id)) );
    … …  
    291310                        $query = " AND (".implode(" OR ", $queries).")";
    292311                       
    293                         return $query;
     312                        $this->home_only_query[$league_id] = $query;
     313                        return $this->home_only_query[$league_id];
    294314                }
    295315               
    … …  
    484504                global $wpdb;
    485505               
     506                $sql = "";
     507               
    486508                $league_id = $this->getCurrentLeagueID();
    487509                $season = isset($this->season['name']) ? $this->season['name'] : '';
    … …  
    490512                } elseif ( isset($_GET['match_day_'.$league_id])) {
    491513                        $match_day = intval($_GET['match_day_'.$league_id]);
    492                 } elseif ( isset($this->match_day) && $this->match_day != -1) {
    493                         $match_day = intval($this->match_day);
    494514                } elseif (isset($_POST['match_day'])) {
    495515                        $match_day = intval($_POST['match_day']);
    496516                } elseif ( $select == "last" ) {
    497                         $sql = "SELECT `match_day`, DATEDIFF(NOW(), `date`) AS datediff FROM {$wpdb->leaguemanager_matches} WHERE `league_id` = '%d' AND `season` = '%s' AND DATEDIFF(NOW(), `date`) > 0 ORDER BY datediff ASC";
    498                         $matches = $wpdb->get_results( $wpdb->prepare($sql, $this->getLeagueID(), $season) );
    499                         if ($matches[0]) $match_day = $matches[0]->match_day;
    500                         else $match_day = -1;
     517                        if ( isset($this->last_match_day) ) {
     518                                $match_day = $this->last_match_day;
     519                        } else {
     520                                $sql = "SELECT `match_day`, DATEDIFF(NOW(), `date`) AS datediff FROM {$wpdb->leaguemanager_matches} WHERE `league_id` = '%d' AND `season` = '%s' AND DATEDIFF(NOW(), `date`) > 0 ORDER BY datediff ASC";
     521                                $matches = $wpdb->get_results( $wpdb->prepare($sql, $this->getLeagueID(), $season) );
     522                                if ($matches) $match_day = $matches[0]->match_day;
     523                                else $match_day = -1;
     524                               
     525                                $this->last_match_day = $match_day;
     526                        }
    501527                } elseif ( $select == "next" ) {
    502                         $sql = "SELECT `match_day`, DATEDIFF(NOW(), `date`) AS datediff FROM {$wpdb->leaguemanager_matches} WHERE `league_id` = '%d' AND `season` = '%s' AND DATEDIFF(NOW(), `date`) < 0 ORDER BY datediff DESC";
    503                         $matches = $wpdb->get_results( $wpdb->prepare($sql, $this->getLeagueID(), $season) );
    504 
    505                         if ($matches[0]) $match_day = $matches[0]->match_day;
    506                         else $match_day = -1;
     528                        if ( isset($this->next_match_day) ) {
     529                                $match_day = $this->next_match_day;
     530                        } else {
     531                                $sql = "SELECT `match_day`, DATEDIFF(NOW(), `date`) AS datediff FROM {$wpdb->leaguemanager_matches} WHERE `league_id` = '%d' AND `season` = '%s' AND DATEDIFF(NOW(), `date`) < 0 ORDER BY datediff DESC";
     532                                $matches = $wpdb->get_results( $wpdb->prepare($sql, $this->getLeagueID(), $season) );
     533                                if ($matches) $match_day = $matches[0]->match_day;
     534                                else $match_day = -1;
     535                               
     536                                $this->next_match_day = $match_day;
     537                        }
    507538                } elseif ( $select == "current" || $select == "latest") {
    508                         $sql = "SELECT `id`, `match_day`, DATEDIFF(NOW(), `date`) AS datediff FROM {$wpdb->leaguemanager_matches} WHERE `league_id` = '%d' AND `season` = '%s' ORDER BY datediff ASC";
    509                         $matches = $wpdb->get_results( $wpdb->prepare($sql, $this->getLeagueID(), $season) );
    510                         if ($matches) {
    511                                 $datediff = array();
    512                                 foreach ($matches AS $key => $match) {
    513                                         $datediff[$key] = abs($match->datediff);
     539                        if ( isset($this->current_match_day) ) {
     540                                $match_day = $this->current_match_day;
     541                        } else {
     542                                $sql = "SELECT `id`, `match_day`, DATEDIFF(NOW(), `date`) AS datediff FROM {$wpdb->leaguemanager_matches} WHERE `league_id` = '%d' AND `season` = '%s' ORDER BY datediff ASC";
     543                                $matches = $wpdb->get_results( $wpdb->prepare($sql, $this->getLeagueID(), $season) );
     544                                if ($matches) {
     545                                        $datediff = array();
     546                                        foreach ($matches AS $key => $match) {
     547                                                $datediff[$key] = abs($match->datediff);
     548                                        }
     549                                        asort($datediff);
     550                                        $keys = array_keys($datediff);
     551                                        $match_day = $matches[$keys[0]]->match_day;
     552                                } else {
     553                                        $match_day = -1;
    514554                                }
    515                                 asort($datediff);
    516                                 $keys = array_keys($datediff);
    517                                 $match_day = $matches[$keys[0]]->match_day;
    518                         } else {
    519                                 $match_day = -1;
     555                               
     556                                $this->current_match_day = $match_day;
    520557                        }
     558                } elseif ( intval($this->match_day) > 0 ) {
     559                        $match_day = $this->match_day;
    521560                } else {
    522561                        $match_day = -1;
    … …  
    604643        {
    605644                global $wpdb;
     645               
     646                // use cached object
     647                if ( !is_null($this->league) )
     648                        return $this->league;
    606649               
    607650                $league = $wpdb->get_results($wpdb->prepare("SELECT `title`, `id`, `seasons`, `settings` FROM {$wpdb->leaguemanager} WHERE `id` = '%d' OR `title` = '%s'", intval($league_id), $league_id) );
    … …  
    674717                global $wpdb;
    675718               
    676                 $defaults = array( 'league_id' => false, 'season' => false, 'group' => false, 'rank' => false, 'orderby' => array("rank" => "ASC", "id" => "ASC") );
     719                $defaults = array( 'league_id' => false, 'season' => false, 'group' => false, 'rank' => false, 'orderby' => array("rank" => "ASC", "id" => "ASC"), "home" => false, "cache" => true );
    677720                $args = array_merge($defaults, $args);
    678721                extract($args, EXTR_SKIP);
    679722               
     723                $cachekey = md5(implode(array_map(function($entry) { if(is_array($entry)) { return implode($entry); } else { return $entry; } }, $args)) . $output);
     724               
     725                // use cached object
     726                if ( isset($this->teams[$cachekey]) && $cache )
     727                        return $this->teams[$cachekey];
     728               
    680729                $search_terms = array();
    681                 if ($league_id) {
     730                if ( $league_id ) {
    682731                        if ($league_id == "any")
    683732                                $search_terms[] = "`league_id` != ''";
    … …  
    685734                                $search_terms[] = $wpdb->prepare("`league_id` = '%d'", intval($league_id));
    686735                }
    687                 if ($season) {
     736                if ( $season ) {
    688737                        if ($season == "any")
    689738                                $search_terms[] = "`season` != ''";
    … …  
    691740                                $search_terms[] = $wpdb->prepare("`season` = '%s'", htmlspecialchars($season));
    692741                }
    693                 if ($group && $this->groupExists($league_id, htmlspecialchars($group))) $search_terms[] = $wpdb->prepare("`group` = '%s'", htmlspecialchars($group));
    694                 if ($rank) $search_terms[] = $wpdb->prepare("`rank` = '%s'", $rank);
     742                if ($group && $this->groupExists($league_id, htmlspecialchars($group)))
     743                        $search_terms[] = $wpdb->prepare("`group` = '%s'", htmlspecialchars($group));
     744                if ( $rank )
     745                        $search_terms[] = $wpdb->prepare("`rank` = '%s'", $rank);
     746               
     747                if ( $home )
     748                        $search_terms[] = "`home` = 1";
    695749               
    696750                $search = "";
    … …  
    715769                $teamlist = $wpdb->get_results( $sql );
    716770                $teams = array(); $i = 0; $class = '';
     771                $logo_sizes = array( 'tiny', 'thumb', 'large' );
    717772                foreach ( $teamlist AS $team ) {
    718773                        $class = ( 'alternate' == $class ) ? '' : 'alternate';
    … …  
    727782                                $teams[$team->id]['stadium'] = stripslashes($team->stadium);
    728783                                $teams[$team->id]['logo'] = ( !empty($team->logo) ) ? $this->getImageUrl(basename($team->logo)) : false;
     784                                if ( $team->logo ) {
     785                                        foreach ( $logo_sizes AS $logo_size ) {
     786                                                $teams[$team->id]['logos'][$logo_size] = $this->getImageUrl( basename($team->logo), false, $logo_size );
     787                                                $teams[$team->id]['logos'][$logo_size] = $this->getImageUrl( basename($team->logo), false, $logo_size );
     788                                        }
     789                                }
    729790                                $teams[$team->id]['home'] = $team->home;
    730791                                $teams[$team->id]['group'] = $team->group;
    … …  
    739800                                $teams[$team->id]['points2'] = array( 'plus' => $team->points2_plus, 'minus' => $team->points2_minus );
    740801                                $teams[$team->id]['add_points'] = $team->add_points;
     802                                $teams[$team->id]['diff'] = ( $team->diff > 0 ) ? '+'.intval($team->diff) : $team->diff;
    741803                                foreach ( (array)$team->custom AS $key => $value )
    742804                                        $teams[$team->id][$key] = stripslashes_deep($value);
    743805                        } else {
    744806                                $teamlist[$i]->logo = ( !empty($team->logo) ) ? $this->getImageUrl(basename($team->logo)) : false;
     807                                if ( $team->logo ) {
     808                                        foreach ( $logo_sizes AS $logo_size ) {
     809                                                $teamlist[$i]->logos[$logo_size] = $this->getImageUrl( basename($team->logo), false, $logo_size );
     810                                                $teamlist[$i]->logos[$logo_size] = $this->getImageUrl( basename($team->logo), false, $logo_size );
     811                                        }
     812                                }
    745813                                $teamlist[$i]->roster = maybe_unserialize($team->roster);
    746814                                if ( $this->hasBridge() ) {
    … …  
    754822                                $teamlist[$i]->stadium = stripslashes($team->stadium);
    755823                                $teamlist[$i]->class = $class;
     824                                $teamlist[$i]->diff = ( $team->diff > 0 ) ? '+'.intval($team->diff) : $team->diff;
    756825                                $teamlist[$i] = (object)array_merge((array)$team, (array)$team->custom);
    757826                        }
    758827
    759                         unset($teamlist[$i]->custom, $team->custom);
     828                        //unset($teamlist[$i]->custom, $team->custom);
    760829                        $i++;
    761830                }
    762831
    763                 if ( 'ARRAY' == $output )
    764                         return $teams;
    765 
    766                 return $teamlist;
     832                if ( 'ARRAY' == $output ) {
     833                        $this->teams[$cachekey] = $teams;
     834                } else {
     835                        $this->teams[$cachekey] = $teamlist;
     836                }
     837               
     838                return $this->teams[$cachekey];
    767839        }
    768840       
    … …  
    778850                global $wpdb;
    779851
     852                // use cached object
     853                if ( isset($this->team[$team_id]) )
     854                        return $this->team[$team_id];
     855               
    780856                $team = $wpdb->get_results( $wpdb->prepare("SELECT `title`, `website`, `coach`, `stadium`, `logo`, `home`, `group`, `roster`, `profile`, `points_plus`, `points_minus`, `points2_plus`, `points2_minus`, `add_points`, `done_matches`, `won_matches`, `draw_matches`, `lost_matches`, `diff`, `league_id`, `id`, `season`, `rank`, `status`, `custom` FROM {$wpdb->leaguemanager_teams} WHERE `id` = '%d' ORDER BY `rank` ASC, `id` ASC", intval($team_id)) );
    781857               
    … …  
    791867                $team->roster = maybe_unserialize($team->roster);
    792868                $team->logo = ( !empty($team->logo) ) ? $this->getImageUrl(basename($team->logo)) : false;
     869                if ( $team->logo ) {
     870                        $logo_sizes = array( 'tiny', 'thumb', 'large' );
     871                        foreach ( $logo_sizes AS $logo_size ) {
     872                                $team->logos[$logo_size] = $this->getImageUrl( basename($team->logo), false, $logo_size );
     873                                $team->logos[$logo_size] = $this->getImageUrl( basename($team->logo), false, $logo_size );
     874                        }
     875                }
     876                $team->diff = ( $team->diff > 0 ) ? '+'.$team->diff : $team->diff;
     877               
    793878                if ( $this->hasBridge() ) {
    794879                        global $lmBridge;
    … …  
    798883
    799884                $team = (object)array_merge((array)$team,(array)$team->custom);
    800                 unset($team->custom);
    801                
    802                 return $team;
     885                //unset($team->custom);
     886               
     887                $this->team[$team_id] = $team;
     888                return $this->team[$team_id];
    803889        }
    804890       
    … …  
    829915        {
    830916                global $wpdb;
     917               
     918                $key = md5($league_id . $group);
     919               
     920                // use cached number
     921                if ( isset($this->num_teams[$key]) )
     922                        return $this->num_teams[$key];
     923               
    831924                $league_id = intval($league_id);
    832925                if ($group == ''){
    833                         $num_teams = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->leaguemanager_teams} WHERE `league_id` = '%d'", $league_id) );
     926                        $this->num_teams[$key] = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->leaguemanager_teams} WHERE `league_id` = '%d'", $league_id) );
    834927                } else {
    835                         $num_teams = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->leaguemanager_teams} WHERE `league_id` = '%d' AND `group` = '%s'", $league_id, $group) );
    836                 }
    837                 return $num_teams;
     928                        $this->num_teams[$key] = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->leaguemanager_teams} WHERE `league_id` = '%d' AND `group` = '%s'", $league_id, $group) );
     929                }
     930                return $this->num_teams[$key];
    838931        }
    839932       
    … …  
    864957                global $wpdb;
    865958       
    866                 $num_matches = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->leaguemanager_matches} WHERE `league_id` = '%d'", $league_id) );
    867                 return $num_matches;
     959                if ( !is_null($this->num_matches) )
     960                        return $this->num_matches;
     961               
     962                $this->num_matches = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) FROM {$wpdb->leaguemanager_matches} WHERE `league_id` = '%d'", $league_id) );
     963                return $this->num_matches;
    868964        }
    869965       
    … …  
    9301026                        $teams = $teamsTmp = array();
    9311027                        foreach ( $this->getTeams( $team_args ) AS $team ) {
    932                                 $team->diff = ( $team->diff > 0 ) ? '+'.$team->diff : $team->diff;
     1028                                //$team->diff = ( $team->diff > 0 ) ? '+'.$team->diff : $team->diff;
    9331029                                $team->points = array( 'plus' => $team->points_plus, 'minus' => $team->points_minus );
    9341030                                $team->points2 = array( 'plus' => $team->points2_plus, 'minus' => $team->points2_minus );
    … …  
    9591055
    9601056        /**
     1057         * get standings table
     1058         *
     1059         * @param array $teams
     1060         * @param int $match_day
     1061         * @param string $mode
     1062         * @param string $group
     1063         */
     1064        function getStandings( $teams = false, $match_day = false, $mode = 'all', $group = false )
     1065        {
     1066                global $wpdb;
     1067               
     1068                $league = $this->getCurrentLeague( );
     1069                $season = $this->getSeason($league);
     1070                if ( !$teams ) $teams = $this->getTeams( array("league_id" => $league->id, "season" => $season['name']), 'OBJECT' );
     1071               
     1072                $rule = $this->getPointRule( $league->point_rule );
     1073                extract( (array)$rule );
     1074               
     1075                foreach ( $teams AS $i => $team ) {
     1076                        $match_args = array( "league_id" => $league->id, "season" => $season['name'], "final" => "", "standingstable" => true, 'limit' => false );
     1077                        // get matches of specific group
     1078                        if ( $group )
     1079                                $match_args["group"] = $group;
     1080               
     1081                        // get only home matches
     1082                        if ( $mode == "home" )
     1083                                $match_args['home_team'] = $team->id;
     1084                        // get only away matches
     1085                        if ( $mode == "away" )
     1086                                $match_args['away_team'] = $team->id;
     1087                        // get all matches for given team
     1088                        if ( $mode == "all" )
     1089                                $match_args['team_id'] = $team->id;
     1090                       
     1091                        // get matches up to given match day
     1092                        if ( $match_day )
     1093                                $match_args['match_day'] = $match_day;
     1094                       
     1095                        // initialize team standings data
     1096                        $team->done_matches = 0;
     1097                        $team->won_matches = 0;
     1098                        $team->draw_matches = 0;
     1099                        $team->lost_matches = 0;
     1100                        $team->points_plus = 0;
     1101                        $team->points_minus = 0;
     1102                        $team->points2_plus = 0;
     1103                        $team->points2_minus = 0;
     1104                       
     1105                        $points = array( 'plus' => 0, 'minus' => 0 );
     1106                        $points2 = array( 'plus' => 0, 'minus' => 0 );
     1107                        $team_points = 0;
     1108                       
     1109                        // get matches
     1110                        $matches = $this->getMatches( $match_args );
     1111                        foreach ( $matches AS $match ) {
     1112                                if ( $match->home_points != "" && $match->away_points != "" )
     1113                                        $team->done_matches += 1;
     1114                               
     1115                                if ( $match->winner_id == $team->id )
     1116                                        $team->won_matches += 1;
     1117                               
     1118                                if ( $match->loser_id == $team->id )
     1119                                        $team->lost_matches += 1;
     1120                               
     1121                                if ( $match->winner_id == -1 && $match->loser_id == -1 )
     1122                                        $team->draw_matches += 1;
     1123                               
     1124                                // Home Match
     1125                                if ( $match->home_team == $team->id ) {
     1126                                        if ( 'score' == $rule ) {
     1127                                                $points['plus'] += $match->home_points;
     1128                                                $points['minus'] += $match->away_points;
     1129                                        } else {
     1130                                                $team_points += $match->home_points;
     1131                                        }
     1132                                }
     1133                               
     1134                                // Away Match
     1135                                if ( $match->away_team == $team->id ) {
     1136                                        if ( 'score' == $rule ) {
     1137                                                $points['plus'] += $match->away_points;
     1138                                                $points['minus'] += $match->home_points;
     1139                                        } else {
     1140                                                $team_points += $match->away_points;
     1141                                        }
     1142                                }
     1143                        }
     1144                       
     1145                        if ( $rule != "score" ) {
     1146                                $points['plus'] = $team->won_matches * $forwin + $team->draw_matches * $fordraw + $team->lost_matches * $forloss + ($team_points * (isset($forscoring) ? $forscoring : 0));
     1147                                $points['minus'] = $team->draw_matches * $fordraw + $team->lost_matches * $forwin + $team->won_matches * $forloss;
     1148                        }
     1149                       
     1150                        //$points = apply_filters( 'team_points_'.$league->sport, $points, $team->id, $rule );
     1151                        $team->points_plus = $points['plus'];
     1152                        $team->points_minus = $points['minus'];
     1153                       
     1154                        //$points2 = apply_filters( 'team_points2_'.$league->sport, $team->id );
     1155                        $team->points2_plus = $points2['plus'];
     1156                        $team->points2_minus = $points2['minus'];
     1157                       
     1158                        $team = apply_filters( "leaguemanager_get_standings_".$league->sport, $team, $matches, $rule );
     1159                        $team->diff = $team->points2_plus - $team->points2_minus;
     1160                        $team->points = array( 'plus' => $team->points_plus, 'minus' => $team->points_minus );
     1161                        $team->points2 = array( 'plus' => $team->points2_plus, 'minus' => $team->points2_minus );
     1162                       
     1163                        $teams[$i] = $team;
     1164                }
     1165               
     1166                /*
     1167                 * rank teams
     1168                 */
     1169                if ( has_filter( 'rank_teams_'.$league->sport ) ) {
     1170                        $teams = apply_filters( 'rank_teams_'.$league->sport, $teams );
     1171                } else {
     1172                        foreach ( $teams AS $key => $row ) {
     1173                                $points[$key] = $row->points['plus'] + $row->add_points;
     1174                                $done[$key] = $row->done_matches;
     1175                        }
     1176                       
     1177                        array_multisort($points, SORT_DESC, $done, SORT_ASC, $teams);
     1178                }
     1179                               
     1180                return $teams;
     1181        }
     1182       
     1183       
     1184        /**
     1185         * get standings selection
     1186         *
     1187         * @param objet $league
     1188         */
     1189        function getStandingsSelection( $league )
     1190        {
     1191                $selected = isset($_GET['standingstable']) ? htmlspecialchars($_GET['standingstable']) : '';
     1192               
     1193                $season = $this->getSeason( $league );
     1194                $options = array( 'all' => __( 'Current Table', 'leaguemanager' ), 'home' => __( 'Hometable', 'leaguemanager' ), 'away' => __( 'Awaytable', 'leaguemanager' ) );
     1195                $action = is_admin() ? menu_page_url('leaguemanager', 0)."&amp;subpage=show-league&amp;league_id=".$league->id : get_permalink();
     1196                $out = "<select size='1' name='standingstable'>";
     1197                foreach ( $options AS $value => $label ) {
     1198                        $out .= "<option value='".$value."'".selected($value, $selected, false).">".$label."</option>";
     1199                }
     1200                for ( $day = 1; $day <= $season['num_match_days']; $day++ ) {
     1201                        $out .= "<option value='match_day-".$day."'".selected("match_day-".$day, $selected, false).">".sprintf(__("%d. Match Day", 'leaguemanager'), $day)."</option>";
     1202                }
     1203                $out .= "</select>";
     1204               
     1205                return $out;
     1206        }
     1207       
     1208       
     1209        /**
     1210         * get point rule depending on selection.
     1211         * For details on point rules see http://de.wikipedia.org/wiki/Drei-Punkte-Regel (German)
     1212         *
     1213         * @param int $rule
     1214         * @return array of points
     1215         */
     1216        function getPointRule( $rule )
     1217        {
     1218                $rule = maybe_unserialize($rule);
     1219
     1220                // Manual point rule
     1221                if ( is_array($rule) ) {
     1222                        return $rule;
     1223                } else {
     1224                        $point_rules = array();
     1225                        // One point rule
     1226                        $point_rules['one'] = array( 'forwin' => 1, 'fordraw' => 0, 'forloss' => 0 );
     1227                        // Two point rule
     1228                        $point_rules['two'] = array( 'forwin' => 2, 'fordraw' => 1, 'forloss' => 0 );
     1229                        // Three-point rule
     1230                        $point_rules['three'] = array( 'forwin' => 3, 'fordraw' => 1, 'forloss' => 0 );
     1231                        // Score. One point for each scored goal
     1232                        $point_rules['score'] = 'score';
     1233
     1234                        $point_rules = apply_filters( 'leaguemanager_point_rules', $point_rules );
     1235
     1236                        return $point_rules[$rule];
     1237                }
     1238        }
     1239       
     1240       
     1241        /**
    9611242         * determine if two teams are tied
    9621243         *
    … …  
    9861267                global $wpdb;
    9871268       
    988                 $defaults = array( 'league_id' => false, 'count' => false, 'season' => false, 'group' => false, 'final' => false, 'match_day' => false, 'time' => false, 'home_only' => false, 'winner_id' => false, 'loser_id' => false, 'team_id' => false, 'home_team' => false, 'away_team' => false, 'home_points' => false, 'away_points' => false, 'limit' => true, 'orderby' => array("date" => "ASC", "id" => "ASC"));
     1269                $defaults = array( 'league_id' => false, 'count' => false, 'season' => false, 'group' => false, 'final' => false, 'match_day' => false, 'time' => false, 'home_only' => false, 'winner_id' => false, 'loser_id' => false, 'team_id' => false, 'home_team' => false, 'away_team' => false, 'home_points' => false, 'away_points' => false, 'limit' => true, 'orderby' => array("date" => "ASC", "id" => "ASC"), 'standingstable' => false, 'cache' => true, 'logos' => true);
    9891270                $args = array_merge($defaults, (array)$args);
    9901271                extract($args, EXTR_SKIP);
     1272               
     1273                $cachekey = md5(implode(array_map(function($entry) { if(is_array($entry)) { return implode($entry); } else { return $entry; } }, $args)) . $output);
     1274               
     1275                // use cached objects
     1276                if ( isset($this->matches[$cachekey]) && $cache && !$count )
     1277                        return $this->matches[$cachekey];
     1278               
     1279                if ( isset($this->num_matches2[$cachekey]) && $cache && $count )
     1280                        return intval($this->num_matches2[$cachekey]);
    9911281               
    9921282                $league = $this->getCurrentLeague();
    … …  
    10241314                        if ($away_team) $search_terms[] = $wpdb->prepare("`away_team` = '%s'", $away_team);
    10251315                }
    1026                 if ($match_day) $search_terms[] = $wpdb->prepare("`match_day` = '%d'", $match_day);
     1316               
     1317                if ( $match_day && intval($match_day) > 0 ) {
     1318                        if ( $standingstable )
     1319                                $search_terms[] = $wpdb->prepare("`match_day` <='%d'", $match_day);
     1320                        else
     1321                                $search_terms[] = $wpdb->prepare("`match_day` = '%d'", $match_day);
     1322                }
     1323               
     1324                // get only finished matches with score for time 'latest'
     1325                if ( $time == 'latest' ) {
     1326                        $home_points = $away_points = false;
     1327                        $search_terms[] = "(`home_points` != '' OR `away_points` != '')";
     1328                }
     1329               
    10271330                if ($home_points) {
    10281331                        if ($home_points == "null")
    … …  
    10521355                elseif ( $time == 'day' )
    10531356                        $search_terms[] = "DATEDIFF('". htmlspecialchars(strip_tags($match_date))."', `date`) = 0";
    1054                
     1357       
    10551358                $search = "";
    10561359                if (count($search_terms) > 0) {
    … …  
    10941397                        $sql .= " ORDER BY $order";
    10951398                        //if ( $limit ) $sql .= " LIMIT ".intval($offset).",".intval($limit)."";
    1096                         return $wpdb->get_var($sql);
     1399                        $this->num_matches2[$cachekey] = $wpdb->get_var($sql);
     1400                        return $this->num_matches2[$cachekey];
    10971401                } else {
    10981402                        $sql = "SELECT `group`, `home_team`, `away_team`, DATE_FORMAT(`date`, '%Y-%m-%d %H:%i') AS date, DATE_FORMAT(`date`, '%e') AS day, DATE_FORMAT(`date`, '%c') AS month, DATE_FORMAT(`date`, '%Y') AS year, DATE_FORMAT(`date`, '%H') AS `hour`, DATE_FORMAT(`date`, '%i') AS `minutes`, `match_day`, `location`, `league_id`, `home_points`, `away_points`, `winner_id`, `loser_id`, `post_id`, `season`, `id`, `custom` FROM {$wpdb->leaguemanager_matches}";
    … …  
    11051409
    11061410                $i = 0;
     1411                $class = '';
    11071412                foreach ( $matches AS $match ) {
     1413                        $class = ( 'alternate' == $class ) ? '' : 'alternate';
     1414                        $matches[$i]->class = $class;
     1415                       
     1416                        $matches[$i]->title = $this->getMatchTitle($match->id, $logos, $match);
     1417                       
    11081418                        $matches[$i]->location = stripslashes($match->location);
    11091419                        $matches[$i]->custom = $match->custom = stripslashes_deep(maybe_unserialize($match->custom));
    … …  
    11141424                        $matches[$i]->hadPenalty = ( isset($match->penalty) && $match->penalty['home'] != '' && $match->penalty['away'] != '' ) ? true : false;
    11151425
    1116                         $matches[$i]->time = ( '00:00' == $match->hour.":".$match->minutes ) ? '' : mysql2date(get_option('time_format'), $match->date);
     1426                        $matches[$i]->start_time = ( '00:00' == $match->hour.":".$match->minutes ) ? '' : mysql2date(get_option('time_format'), $match->date);
     1427                        $matches[$i]->match_date = ( substr($match->date, 0, 10) == '0000-00-00' ) ? 'N/A' : mysql2date(get_option('date_format'), $match->date);
     1428                       
     1429                        if ( $matches[$i]->hadPenalty ) {
     1430                                $matches[$i]->homeScore = $match->penalty['home']+$match->overtime['home'];
     1431                                $matches[$i]->awayScore = $match->penalty['away']+$match->overtime['away'];
     1432                                $matches[$i]->score = sprintf("%s - %s", $matches[$i]->homeScore, $matches[$i]->awayScore)." ".__( '(o.P.)', 'leaguemanager' );
     1433                        } elseif ( $matches[$i]->hadOvertime ) {
     1434                                $matches[$i]->homeScore = $match->overtime['home'];
     1435                                $matches[$i]->awayScore = $match->overtime['away'];
     1436                                $matches[$i]->score = sprintf("%s - %s", $matches[$i]->homeScore, $matches[$i]->awayScore)." ".__( '(AET)', 'leaguemanager' );
     1437                                //$matches[$i]->score = sprintf("%s - %s", $matches[$i]->home_points, $matches[$i]->away_points);
     1438                        } elseif ( $matches[$i]->home_points != NULL && $match->away_points != NULL ) {
     1439                                $matches[$i]->homeScore = $match->home_points;
     1440                                $matches[$i]->awayScore = $match->away_points;
     1441                                $matches[$i]->score = sprintf("%s - %s", $matches[$i]->homeScore, $matches[$i]->awayScore);
     1442                        } else {
     1443                                $matches[$i]->homeScore = "-";
     1444                                $matches[$i]->awayScore = "-";
     1445                                $matches[$i]->score = sprintf("%s:%s", $matches[$i]->homeScore, $matches[$i]->awayScore);
     1446                        }
     1447
     1448                        $matches[$i]->homeTeam = $this->getTeam($match->home_team);
     1449                        $matches[$i]->awayTeam = $this->getTeam($match->away_team);
     1450                       
     1451                        $matches[$i]->report = ( $match->post_id != 0 ) ? '(<a href="'.get_permalink($match->post_id).'">'.__('Report', 'leaguemanager').'</a>)' : '';
    11171452                       
    11181453                        $i++;
    11191454                }
    1120                 return $matches;
     1455               
     1456                $this->matches[$cachekey] = $matches;
     1457                return $this->matches[$cachekey];
    11211458        }
    11221459       
    … …  
    11281465         * @return object
    11291466         */
    1130         function getMatch( $match_id )
     1467        function getMatch( $match_id, $cache = true )
    11311468        {
    11321469                global $wpdb;
    11331470
     1471                // use cached object
     1472                if ( isset($this->match[$match_id]) && $cache )
     1473                        return $this->match[$match_id];
     1474               
    11341475                $match = $wpdb->get_results("SELECT `group`, `home_team`, `away_team`, DATE_FORMAT(`date`, '%Y-%m-%d %H:%i') AS date, DATE_FORMAT(`date`, '%e') AS day, DATE_FORMAT(`date`, '%c') AS month, DATE_FORMAT(`date`, '%Y') AS year, DATE_FORMAT(`date`, '%H') AS `hour`, DATE_FORMAT(`date`, '%i') AS `minutes`, `match_day`, `location`, `league_id`, `home_points`, `away_points`, `winner_id`, `loser_id`, `post_id`, `season`, `id`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `id` = '".intval($match_id)."'");
    11351476               
    … …  
    11441485                //unset($match->custom);
    11451486
    1146                 return $match;
     1487                $this->match[$match_id] = $match;
     1488                return $this->match[$match_id];
    11471489        }
    11481490       
    … …  
    11671509                                $title = "";
    11681510                } else {
    1169                         $home_logo_img = ($teams[$match->home_team]['logo'] != "" && $show_logo) ? "<img class='home-logo logo' src='".$this->getThumbnailUrl($teams[$match->home_team]['logo'])."' alt='' />" : "";
    1170                         $away_logo_img = ($teams[$match->away_team]['logo'] != "" && $show_logo) ? "<img class='away-logo logo' src='".$this->getThumbnailUrl($teams[$match->away_team]['logo'])."' alt='' />" : "";
     1511                        $home_logo_img = ($teams[$match->home_team]['logo'] != "" && $show_logo) ? "<img class='match-title home-logo logo' src='".$this->getThumbnailUrl($teams[$match->home_team]['logo'])."' alt='' />" : "";
     1512                        $away_logo_img = ($teams[$match->away_team]['logo'] != "" && $show_logo) ? "<img class='match-title away-logo logo' src='".$this->getThumbnailUrl($teams[$match->away_team]['logo'])."' alt='' />" : "";
    11711513                        $home_team_name = ($this->isHomeTeamMatch($match->home_team, $match->away_team, $teams)) ? "<strong>".$teams[$match->home_team]['title']."</strong>" : $teams[$match->home_team]['title'];
    11721514                        $away_team_name = ($this->isHomeTeamMatch($match->home_team, $match->away_team, $teams)) ? "<strong>".$teams[$match->away_team]['title']."</strong>" : $teams[$match->away_team]['title'];
    … …  
    12161558                        $query_args['match_day'] = htmlspecialchars(strip_tags($_POST['match_day']));
    12171559                }
    1218                
     1560
    12191561                $page_links = paginate_links( array(
    12201562                        'base' => add_query_arg( $base, '%#%' ),
    … …  
    12551597                        $this->current_page = 1;
    12561598
     1599                if ( $this->current_page > $this->getNumPages() )
     1600                        $this->current_page = $this->getNumPages();
     1601               
    12571602                return intval($this->current_page);
    12581603        }
    … …  
    12921637        function getNumPages()
    12931638        {
    1294                 $this->num_max_pages = ( 0 == $this->getNumMatchesPerPage() ) ? 1 : ceil( $this->getNumMatchesQuery()/$this->getNumMatchesPerPage() );
     1639                $this->num_max_pages = ( 0 == $this->getNumMatchesPerPage() ) ? 1 : ceil( $this->getNumMatches($this->getLeagueID())/$this->getNumMatchesPerPage() );
    12951640                return $this->num_max_pages;
    12961641        }
    … …  
    14561801                        return false;
    14571802               
     1803                if ( isset($this->database_column_exists[$table][$column]) )
     1804                        return $this->database_column_exists[$table][$column];
     1805               
    14581806                $num = $wpdb->query( $wpdb->prepare("SHOW COLUMNS FROM {$table} LIKE %s", $column) );
    14591807                if ($num == 1)
    1460                         return true;
     1808                        $this->database_column_exists[$table][$column] = true;
    14611809                else
    1462                         return false;
     1810                        $this->database_column_exists[$table][$column] = false;
     1811               
     1812                return $this->database_column_exists[$table][$column];
    14631813        }
    14641814       
  • leaguemanager/trunk/lib/shortcodes.php

    r1348420 r1361999  
    263263                                $league->isCurrMatchDay = '';
    264264                        }
    265                                                
     265                       
    266266                        if ( $match_day == -1 || !empty($league->isCurrMatchDay) ) {
    267267                                if (isset($_GET['match_day']))
    … …  
    271271                                elseif ($league->isCurrMatchDay != "")
    272272                                        $match_day = $leaguemanager->getMatchDay($league->isCurrMatchDay);
    273                                 elseif ( $template != "by_matchday" )
     273                                else
    274274                                        $match_day = 1;
    275275                        }
    … …  
    327327                       
    328328                        //$leaguemanager->getMatchDay();
    329                         if ( $limit === 'false' || $template == 'by_matchday' )  {
     329                        if ( $limit === 'false' || in_array($template, array('by_matchday', 'by_matchday-tabs', 'by_matchday-accordion')) )  {
    330330                                $match_args['limit'] = false;
    331331                        } elseif ( $limit && is_numeric($limit) ) {
    … …  
    336336                        $match_args['match_date'] = $match_date;
    337337                        $match_args['home_only'] = ( $home_only == 1 || $home_only == 'true' ) ? true : false;
    338                        
    339                         // get matches
    340                         $matches = $leaguemanager->getMatches( $match_args );
    341338
    342339                        /*
    … …  
    346343                        $league->current_page = $leaguemanager->getCurrentPage($league->id);
    347344                        $league->pagination = ( $limit == 'true' ) ? $leaguemanager->getPageLinks($league->current_page, "match_paged_".$league->id) : '';
     345                        $league->num_matches = $leaguemanager->getNumMatches($leaguemanager->getLeagueID());
     346
     347                        // get matches
     348                        $matches = $leaguemanager->getMatches( $match_args );
    348349                       
    349350                        /*
    … …  
    656657                                        $next_match->match = $opponent->title  . " &#8211; " . $team->title;
    657658                                }
     659                                $next_match->match = $leaguemanager->getMatchTitle($next_match->id);
    658660                        }
    659661
    … …  
    669671                                        $prev_match->match = $opponent->title  . " &#8211; " . $team->title;
    670672                                }
     673                                $prev_match->match = $leaguemanager->getMatchTitle($prev_match->id);
    671674
    672675                                $prev_match->hadOvertime = ( isset($prev_match->overtime) && $prev_match->overtime['home'] != '' && $prev_match->overtime['away'] != '' ) ? true : false;
  • leaguemanager/trunk/readme.txt

    r1348420 r1361999  
    55Requires at least: 2.7
    66Tested up to: 4.4.2
    7 Stable tag: 4.0.8
     7Stable tag: 4.0.9
    88License: LGPLv2.1 or later
    99
    … …  
    4141* Italian
    4242* Arabian
     43* Hebrew by Bar Shai
    4344
    4445== Installation ==
    … …  
    8384* TO-DO - Updating the translation code to remove the deprecated code has broken some translations due to a change in how WordPress handles multiple options. The translations files need some attention, so do the sport files...
    8485* Coming soon - Players, pagination for leagues, teams, matches, and players. New admin dashboard. New sport files.
     86
     87= 4.0.9 =
     88* NEW: show standingstable for home/away matches and after each match day
     89* NEW: functions get_next_matches() and get_last_matches() (functions.php) to get next or last matches for specific team
     90* NEW: added hebrew translation by Bar Shai
     91* BUGFIX: fixed match_day option in [matches] shortcode when using multiple shortcodes on same page
     92* BUGFIX: fixed calculation of apparatus points for gymnastics
     93* BUGFIX: improved page loading times by caching MySQL query results and prevent unneccessary queries
     94* BUGFIX: fix in matches pagination
     95* BUGFIX: several small fixes
    8596
    8697= 4.0.8 =
  • leaguemanager/trunk/sports/baseball.php

    r1324769 r1361999  
    4343
    4444                add_action( 'leaguemanager_save_standings_'.$this->key, array(&$this, 'saveStandings') );
     45                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    4546
    4647        }
    … …  
    107108
    108109        /**
     110         * get standings table data
     111         *
     112         * @param object $team
     113         * @param array $matches
     114         */
     115        function getStandingsFilter( $team, $matches, $point_rule )
     116        {
     117                /*
     118                 * analogue to leaguemanager_save_standings_$sport filter
     119                 */
     120                $team->runs = $this->getRuns($team->id);
     121                $team->gb = $this->getGamesBehind($team->id);
     122                $team->shutouts = $this->getShutouts($team->id);
     123               
     124                return $team;
     125        }
     126       
     127       
     128        /**
    109129         * get number of runs for team
    110130         *
    … …  
    118138                $runs = array( 'for' => 0, 'against' => 0 );
    119139
    120                 $home = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
    121                 foreach ( $home AS $match ) {
    122                         $runs['for'] += $match->runs['for'];
    123                         $runs['against'] += $match->runs['against'];
     140                $matches =  $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
     141                foreach ( $matches AS $match ) {
     142                        if ( $match->home_team == $team_id ) {
     143                                $runs['for'] += $match->runs['for'];
     144                                $runs['against'] += $match->runs['against'];
     145                        }
     146                        if ( $match->away_team == $team_id ) {
     147                                $runs['for'] += $match->runs['against'];
     148                                $runs['against'] += $match->runs['for'];
     149                        }
    124150                }
    125151
    126                 $away = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    127                 foreach ( $away AS $match ) {
    128                         $runs['for'] += $match->runs['against'];
    129                         $runs['against'] += $match->runs['for'];
    130                 }
    131                
    132152                return $runs;
    133153        }
    … …  
    167187                $shutouts = 0;
    168188
    169                 $home = $leaguemanager->getMatches( array("home_team" => $team_id) );
    170                 foreach ( $home AS $match ) {
    171                         $shutouts += $match->shutouts['home'];
    172                 }
    173 
    174                 $away = $leaguemanager->getMatches( array("away_team" => $team_id) );
    175                 foreach ( $away AS $match ) {
    176                         $shutouts += $match->shutouts['away'];
     189                $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
     190                foreach ( $matches AS $match ) {
     191                        if ( $match->home_team == $team_id ) {
     192                                $shutouts += $match->shutouts['home'];
     193                        } else {
     194                                $shutouts += $match->shutouts['away'];
     195                        }
    177196                }
    178197               
  • leaguemanager/trunk/sports/basketball.php

    r1345280 r1361999  
    3838               
    3939                add_action( 'leaguemanager_update_results_'.$this->key, array(&$this, 'updateResults') );
     40                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    4041        }
    4142        function LeagueManagerBasketball()
    … …  
    8081
    8182        /**
     83         * get standings table data
     84         *
     85         * @param object $team
     86         * @param array $matches
     87         */
     88        function getStandingsFilter( $team, $matches, $point_rule )
     89        {
     90                /*
     91                 * analogue to team_points2_$sport filter
     92                 */
     93                $baskets = $this->calculateBasketStatistics( $team->id, $matches );
     94                $team->points2_plus = $baskets['plus'];
     95                $team->points2_minus = $baskets['minus'];
     96               
     97                return $team;
     98        }
     99       
     100       
     101        /**
    82102         * calculate baskets. Penalty is not counted in statistics
    83103         *
    … …  
    86106         * @return int
    87107         */
    88         function calculateBasketStatistics( $team_id )
     108        function calculateBasketStatistics( $team_id, $matches = false )
    89109        {
    90110                global $wpdb, $leaguemanager;
    … …  
    93113
    94114                $team_id = intval($team_id);
    95                 //$matches = $wpdb->get_results( $wpdb->prepare("SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `home_team` = '%d'", $team_id) );
    96                 $matches = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
     115                if ( !$matches ) $matches =  $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    97116                if ( $matches ) {
    98117                        foreach ( $matches AS $match ) {
    … …  
    100119                                $home_goals = $match->home_points;
    101120                                $away_goals = $match->away_points;
    102 
    103                                 $goals['plus'] += $home_goals;
    104                                 $goals['minus'] += $away_goals;
    105 
    106                         }
    107                 }
    108 
    109                 //$matches = $wpdb->get_results( $wpdb->prepare("SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `away_team` = '%d'", $team_id) );
    110                 $matches = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    111                 if ( $matches ) {
    112                         foreach ( $matches AS $match ) {
    113                                 $custom = maybe_unserialize($match->custom);
    114                                 $home_goals = $match->home_points;
    115                                 $away_goals = $match->away_points;
    116 
    117                                 $goals['plus'] += $away_goals;
    118                                 $goals['minus'] += $home_goals;
    119 
     121                                       
     122                                // home match
     123                                if ( $match->home_team == $team_id ) {
     124                                        $goals['plus'] += $home_goals;
     125                                        $goals['minus'] += $away_goals;
     126                                }
     127                               
     128                                // away match
     129                                if ( $match->away_team == $team_id ) {
     130                                        $goals['plus'] += $away_goals;
     131                                        $goals['minus'] += $home_goals;
     132                                }
    120133                        }
    121134                }
    … …  
    272285                global $wpdb, $leaguemanager;
    273286               
    274                 $match = $leaguemanager->getMatch( $match_id );
     287                $match = $leaguemanager->getMatch( $match_id, false );
    275288               
    276289                if ( $match->home_points == "" && $match->away_points == "" ) {
  • leaguemanager/trunk/sports/cornhole.php

    r1266075 r1361999  
    5858                global $leaguemanager;
    5959
    60                 $home = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
     60                $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    6161                foreach ( $home AS $match ) {
    62                         $points['plus'] += $match->home_points;
    63                         $points['minus'] += $match->away_points;
    64                 }
    65 
    66                 $away = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    67                 foreach ( $away AS $match ) {
    68                         $points['plus'] += $match->away_points;
    69                         $points['minus'] += $match->home_points;
     62                        if ( $match->home_team == $team_id ) {
     63                                $points['plus'] += $match->home_points;
     64                                $points['minus'] += $match->away_points;
     65                        } else {
     66                                $points['plus'] += $match->away_points;
     67                                $points['minus'] += $match->home_points;
     68                        }
    7069                }
    7170
  • leaguemanager/trunk/sports/gymnastics.php

    r1335884 r1361999  
    4343               
    4444                add_action( 'leaguemanager_save_standings_'.$this->key, array(&$this, 'saveStandings') );
     45                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    4546                add_action( 'leaguemanager_update_results_'.$this->key, array(&$this, 'updateResults') );
    4647        }
    … …  
    8485       
    8586        /**
     87         * get standings table data
     88         *
     89         * @param object $team
     90         * @param array $matches
     91         */
     92        function getStandingsFilter( $team, $matches, $point_rule )
     93        {
     94                /*
     95                 * analogue to team_points2_$sport filter
     96                 */
     97                $apparatus_points = $this->calculateApparatusPoints( $team->id, $matches );
     98                $team->points2_plus = $apparatus_points['plus'];
     99                $team->points2_minus = $apparatus_points['minus'];
     100               
     101                /*
     102                 * analogue to leaguemanager_save_standings_$sport filter
     103                 */
     104                $data = $this->getStandingsData( $team->id, maybe_unserialize($team->custom), $matches );
     105                $team->apparatus = $data['apparatus'];
     106               
     107                return $team;
     108        }
     109       
     110       
     111        /**
    86112         * get standings data for given team
    87113         *
    … …  
    90116         * @return array number of runs for and against as assoziative array
    91117         */
    92         function getStandingsData( $team_id, $data = array() )
     118        function getStandingsData( $team_id, $data = array(), $matches = false )
    93119        {
    94120                global $leaguemanager;
    … …  
    97123                $points = array( 'win' => 2, 'lost' => 0);
    98124               
    99                 $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false) );
     125                if ( !$matches ) $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    100126                foreach ( $matches AS $match ) {
    101127                        if ( isset($match->floor) ) {
    … …  
    135161                        $points2[$key] = $row->points2['plus'];
    136162                        $done[$key] = $row->done_matches;
    137                 }
    138 
    139                 array_multisort( $points, SORT_DESC, $points2, SORT_DESC, $done, SORT_ASC, $teams );
     163                        $diff[$key] = $row->diff;
     164                }
     165
     166                array_multisort( $points, SORT_DESC, $diff, SORT_DESC, $done, SORT_ASC, $teams );
    140167                return $teams;
    141168        }
    … …  
    366393         * @return array of points
    367394         */
    368         function calculateApparatusPoints( $team_id )
     395        function calculateApparatusPoints( $team_id, $matches = false )
    369396        {
    370397                global $wpdb, $leaguemanager;
    371398
    372                 $home = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
    373                 $away = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    374 
    375399                $points = array( 'plus' => 0, 'minus' => 0);
    376                 if ( count($home) > 0 ) {
    377                         foreach ( $home AS $match ) {
     400               
     401                if ( !$matches ) $matches =  $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
     402                if ( $matches ) {
     403                        foreach ( $matches AS $match ) {
    378404                                $custom = (array)maybe_unserialize($match->custom);
    379                                
     405                                       
    380406                                if (!isset($custom['apparatus_points'])) $custom['apparatus_points'] = array('plus' => '', 'minus' => '');
    381                                 $points['plus'] += intval($custom['apparatus_points']['plus']);
    382                                 $points['minus'] += intval($custom['apparatus_points']['minus']);
     407                                if ( $match->home_team == $team_id ) {
     408                                        $points['plus'] += intval($custom['apparatus_points']['plus']);
     409                                        $points['minus'] += intval($custom['apparatus_points']['minus']);
     410                                }
     411                                if ( $match->away_team == $team_id ) {
     412                                        $points['plus'] += intval($custom['apparatus_points']['minus']);
     413                                        $points['minus'] += intval($custom['apparatus_points']['plus']);
     414                                }
    383415                        }
    384416                }
    385 
    386                 if ( count($away) > 0 ) {
    387                         foreach ( $away AS $match ) {
    388                                 $custom = (array)maybe_unserialize($match->custom);
    389                                
    390                                 if (!isset($custom['apparatus_points'])) $custom['apparatus_points'] = array('plus' => '', 'minus' => '');
    391                                 $points['plus'] += intval($custom['apparatus_points']['minus']);
    392                                 $points['minus'] += intval($custom['apparatus_points']['plus']);
    393                         }
    394                 }
    395 
     417               
    396418                return $points;
    397419        }
    … …  
    408430                global $wpdb, $leaguemanager;
    409431               
    410                 $match = $leaguemanager->getMatch( $match_id );
     432                $match = $leaguemanager->getMatch( $match_id, false );
    411433               
    412434                if ( $match->home_points == "" && $match->away_points == "" ) {
    … …  
    420442                        foreach ( $apparatus AS $key ) {
    421443                                if ( $match->{$key}['home'] != '' && $match->{$key}['guest'] != '' ) {
    422                                         if ( $match->{$key}['home'] > $match->{$key}['guest'] )
     444                                        if ( $match->{$key}['home'] > $match->{$key}['guest'] ) {
    423445                                                $ap['plus'] += 2;
    424                                         else
     446                                        } elseif ( $match->{$key}['home'] < $match->{$key}['guest'] ) {
    425447                                                $ap['minus'] += 2;
     448                                        } else {
     449                                                $ap['plus'] += 1;
     450                                                $ap['minus'] += 1;
     451                                        }
    426452                                }
    427453                        }
  • leaguemanager/trunk/sports/handball.php

    r1324769 r1361999  
    3838                add_action( 'leaguemanager_standings_header_'.$this->key, array(&$this, 'displayStandingsHeader') );
    3939                add_action( 'leaguemanager_standings_columns_'.$this->key, array(&$this, 'displayStandingsColumns'), 10, 2 );
     40               
     41                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    4042
    4143        }
    … …  
    7880
    7981
     82        /**
     83         * get standings table data
     84         *
     85         * @param object $team
     86         * @param array $matches
     87         */
     88        function getStandingsFilter( $team, $matches, $point_rule )
     89        {
     90                /*
     91                 * analogue to team_points2_$sport filter
     92                 */
     93                $goals = $this->calculateGoalStatistics( $team->id, $matches );
     94                $team->points2_plus = $goals['plus'];
     95                $team->points2_minus = $goals['minus'];
     96               
     97                return $team;
     98        }
     99       
     100       
    80101        /**
    81102         * extend header for Standings Table in Backend
    … …  
    207228         * @return int
    208229         */
    209         function calculateGoalStatistics( $team_id )
     230        function calculateGoalStatistics( $team_id, $matches = false )
    210231        {
    211232                global $wpdb, $leaguemanager;
    … …  
    213234                $goals = array( 'plus' => 0, 'minus' => 0 );
    214235
    215                 $matches = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
     236                if ( !$matches ) $matches =  $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    216237                if ( $matches ) {
    217238                        foreach ( $matches AS $match ) {
    … …  
    225246                                }
    226247
    227                                 $goals['plus'] += $home_goals;
    228                                 $goals['minus'] += $away_goals;
     248                                if ( $match->home_team == $team_id ) {
     249                                        $goals['plus'] += $home_goals;
     250                                        $goals['minus'] += $away_goals;
     251                                } else {
     252                                        $goals['plus'] += $away_goals;
     253                                        $goals['minus'] += $home_goals;
     254                                }
    229255                        }
    230256                }
    231257
    232                 $matches = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    233                 if ( $matches ) {
    234                         foreach ( $matches AS $match ) {
    235                                 $custom = maybe_unserialize($match->custom);
    236                                 if ( !empty($custom['overtime']['home']) && !empty($custom['overtime']['away']) ) {
    237                                         $home_goals = $custom['overtime']['home'];
    238                                         $away_goals = $custom['overtime']['away'];
    239                                 } else {
    240                                         $home_goals = $match->home_points;
    241                                         $away_goals = $match->away_points;
    242                                 }
    243 
    244                                 $goals['plus'] += $away_goals;
    245                                 $goals['minus'] += $home_goals;
    246                         }
    247                 }
    248 
    249258                return $goals;
    250259        }
  • leaguemanager/trunk/sports/hockey.php

    r1345280 r1361999  
    4545                       
    4646                        add_action( 'leaguemanager_update_results_'.$key, array(&$this, 'updateResults') );
     47                        add_action( 'leaguemanager_get_standings_'.$key, array(&$this, 'getStandingsFilter'), 10, 3 );
    4748                }
    4849        }
    … …  
    121122
    122123        /**
     124         * get standings table data
     125         *
     126         * @param object $team
     127         * @param array $matches
     128         */
     129        function getStandingsFilter( $team, $matches, $point_rule )
     130        {
     131                /*
     132                 * analogue to team_points2_$sport filter
     133                 */
     134                $goals = $this->calculateGoalStatistics( $team->id, $matches );
     135                $team->points2_plus = $goals['plus'];
     136                $team->points2_minus = $goals['minus'];
     137               
     138                return $team;
     139        }
     140       
     141       
     142        /**
    123143         * calculate goals. Penalty is not counted in statistics
    124144         *
    … …  
    127147         * @return int
    128148         */
    129         function calculateGoalStatistics( $team_id )
     149        function calculateGoalStatistics( $team_id, $matches = false )
    130150        {
    131151                global $wpdb, $leaguemanager;
    … …  
    133153                $goals = array( 'plus' => 0, 'minus' => 0 );
    134154
    135                 //$matches = $wpdb->get_results( "SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `home_team` = '".$team_id."'" );
    136                 $matches = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
     155                if ( !$matches ) $matches =  $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    137156                if ( $matches ) {
    138157                        foreach ( $matches AS $match ) {
    … …  
    144163                                        $home_goals = $match->home_points;
    145164                                        $away_goals = $match->away_points;
     165                                }
     166                               
     167                                if ( $match->home_team == $team_id ) {
     168                                        $goals['plus'] += $home_goals;
     169                                        $goals['minus'] += $away_goals;
     170                                } else {
     171                                        $goals['plus'] += $away_goals;
     172                                        $goals['minus'] += $home_goals;
    146173                                }
    147 
    148                                 $goals['plus'] += $home_goals;
    149                                 $goals['minus'] += $away_goals;
    150                         }
    151                 }
    152 
    153                 //$matches = $wpdb->get_results( "SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `away_team` = '".$team_id."'" );
    154                 $matches = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    155                 if ( $matches ) {
    156                         foreach ( $matches AS $match ) {
    157                                 $custom = maybe_unserialize($match->custom);
    158                                 if ( !empty($custom['overtime']['home']) && !empty($custom['overtime']['away']) ) {
    159                                         $home_goals = $custom['overtime']['home'];
    160                                         $away_goals = $custom['overtime']['away'];
    161                                 } else {
    162                                         $home_goals = $match->home_points;
    163                                         $away_goals = $match->away_points;
    164                                 }
    165 
    166                                 $goals['plus'] += $away_goals;
    167                                 $goals['minus'] += $home_goals;
    168174                        }
    169175                }
    … …  
    400406                global $wpdb, $leaguemanager;
    401407               
    402                 $match = $leaguemanager->getMatch( $match_id );
     408                $match = $leaguemanager->getMatch( $match_id, false );
    403409               
    404410                if ( $match->home_points == "" && $match->away_points == "" ) {
  • leaguemanager/trunk/sports/other-two-scores.php

    r1266075 r1361999  
    3333                add_action( 'leaguemanager_standings_columns_'.$this->key, array(&$this, 'displayStandingsColumns'), 10, 2 );
    3434
     35                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    3536        }
    3637        function LeagueManagerTwoScores()
    … …  
    7273
    7374
     75        /**
     76         * get standings table data
     77         *
     78         * @param object $team
     79         * @param array $matches
     80         */
     81        function getStandingsFilter( $team, $matches, $point_rule )
     82        {
     83                /*
     84                 * analogue to team_points2_$sport filter
     85                 */
     86                $goals = $this->calculateGoalStatistics( $team->id, $matches );
     87                $team->points2_plus = $goals['plus'];
     88                $team->points2_minus = $goals['minus'];
     89               
     90                return $team;
     91        }
     92       
     93       
    7494        /**
    7595         * extend header for Standings Table in Backend
    … …  
    115135         * @return int
    116136         */
    117         function calculateGoalStatistics( $team_id )
     137        function calculateGoalStatistics( $team_id, $matches = false )
    118138        {
    119139                global $wpdb, $leaguemanager;
    … …  
    121141                $goals = array( 'plus' => 0, 'minus' => 0 );
    122142                               
    123                 //$matches = $wpdb->get_results( "SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `home_team` = '".$team_id."'" );
    124                 $matches = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
     143                if ( !$matches ) $matches =  $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    125144                if ( $matches ) {
    126145                        foreach ( $matches AS $match ) {
    … …  
    134153                                }
    135154                               
    136                                 $goals['plus'] += $home_goals;
    137                                 $goals['minus'] += $away_goals;
    138                         }
    139                 }
    140                
    141                 //$matches = $wpdb->get_results( "SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `away_team` = '".$team_id."'" );
    142                 $matches = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    143                 if ( $matches ) {
    144                         foreach ( $matches AS $match ) {
    145                                 $custom = maybe_unserialize($match->custom);
    146                                 if ( !empty($custom['overtime']['home']) && !empty($custom['overtime']['away']) ) {
    147                                         $home_goals = $custom['overtime']['home'];
    148                                         $away_goals = $custom['overtime']['away'];
     155                                if ( $match->home_team == $team_id ) {
     156                                        $goals['plus'] += $home_goals;
     157                                        $goals['minus'] += $away_goals;
    149158                                } else {
    150                                         $home_goals = $match->home_points;
    151                                         $away_goals = $match->away_points;
     159                                        $goals['plus'] += $away_goals;
     160                                        $goals['minus'] += $home_goals;
    152161                                }
    153                                
    154                                 $goals['plus'] += $away_goals;
    155                                 $goals['minus'] += $home_goals;
    156162                        }
    157163                }
  • leaguemanager/trunk/sports/pool.php

    r1348420 r1361999  
    4343
    4444                add_action( 'leaguemanager_save_standings_'.$this->key, array(&$this, 'saveStandings') );
     45                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    4546        }
    4647        function LeagueManagerSoccer()
    … …  
    8586
    8687        /**
     88         * get standings table data
     89         *
     90         * @param object $team
     91         * @param array $matches
     92         */
     93        function getStandingsFilter( $team, $matches, $point_rule )
     94        {
     95                /*
     96                 * analogue to leaguemanager_save_standings_$sport filter
     97                 */
     98                $team->forScore = $this->getPoolScore($team->id, 'for', $matches);
     99                $team->againstScore = $this->getPoolScore($team->id, 'against', $matches);
     100               
     101                return $team;
     102        }
     103       
     104       
     105        /**
    87106         * save custom standings
    88107         *
    … …  
    111130         * @return array number of runs for and against as assoziative array
    112131         */
    113         function getPoolScore( $team_id, $index )
     132        function getPoolScore( $team_id, $index, $matches = false )
    114133        {
    115134                global $leaguemanager;
    116135
    117136                $score = array( 'for' => 0, 'against' => 0 );
    118                 $home = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
     137                if ( !$matches ) $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    119138                foreach ( $home AS $match ) {
    120                         $score['for'] += $match->forScore;
    121                         $score['against'] += $match->againstScore;
    122                 }
    123 
    124                 $away = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    125                 foreach ( $away AS $match ) {
    126                         $score['for'] += $match->againstScore;
    127                         $score['against'] += $match->forScore;
     139                        if ( $team_id == $match->home_team ) {
     140                                $score['for'] += $match->forScore;
     141                                $score['against'] += $match->againstScore;
     142                        } else {
     143                                $score['for'] += $match->againstScore;
     144                                $score['against'] += $match->forScore;
     145                        }
    128146                }
    129147
  • leaguemanager/trunk/sports/rugby.php

    r1324769 r1361999  
    4848                add_action( 'leaguemanager_update_results_'.$this->key, array(&$this, 'updateResults') );
    4949                add_action( 'leaguemanager_save_standings_'.$this->key, array(&$this, 'saveStandings') );
     50                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    5051        }
    5152        function LeagueManagerSoccer()
    … …  
    127128                extract($rule);
    128129
    129                 $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false) );
     130                $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    130131                foreach ( $matches AS $match ) {
    131132                        $index = ( $match->home_team == $team_id ) ? 'home' : 'away';
    … …  
    198199
    199200        /**
     201         * get standings table data
     202         *
     203         * @param object $team
     204         * @param array $matches
     205         */
     206        function getStandingsFilter( $team, $matches, $point_rule )
     207        {
     208                /*
     209                 * analogue to leaguemanager_save_standings_$sport filter
     210                 */
     211                $data = $this->getStandingsData( $team->id, maybe_unserialize($team->custom), $matches );
     212                $team->gamepoints = $data['gamepoints'];
     213               
     214                return $team;
     215        }
     216       
     217       
     218        /**
    200219         * get standings data for given team
    201220         *
    … …  
    204223         * @return array number of runs for and against as assoziative array
    205224         */
    206         function getStandingsData( $team_id, $data = array() )
     225        function getStandingsData( $team_id, $data = array(), $matches = false )
    207226        {
    208227                global $leaguemanager;
    … …  
    210229                $data['gamepoints'] = array( 'plus' => 0, 'minus' => 0 );
    211230
    212                 $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false) );
     231                if ( !$matches ) $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    213232                foreach ( $matches AS $match ) {
    214233                        // Home Match
  • leaguemanager/trunk/sports/soccer.php

    r1348420 r1361999  
    3838                add_action( 'leaguemanager_standings_columns_'.$this->key, array(&$this, 'displayStandingsColumns'), 10, 2 );
    3939
     40                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    4041        }
    4142        function LeagueManagerSoccer()
    … …  
    7778
    7879
     80        /**
     81         * get standings table data
     82         *
     83         * @param object $team
     84         * @param array $matches
     85         */
     86        function getStandingsFilter( $team, $matches, $point_rule )
     87        {
     88                /*
     89                 * analogue to team_points2_$sport filter
     90                 */
     91                $goals = $this->calculateGoalStatistics( $team->id, $matches );
     92                $team->points2_plus = $goals['plus'];
     93                $team->points2_minus = $goals['minus'];
     94               
     95                return $team;
     96        }
     97       
     98       
    7999        /**
    80100         * extend header for Standings Table
    … …  
    209229         * @return int
    210230         */
    211         function calculateGoalStatistics( $team_id )
     231        function calculateGoalStatistics( $team_id, $matches = false )
    212232        {
    213233                global $wpdb, $leaguemanager;
    … …  
    215235                $goals = array( 'plus' => 0, 'minus' => 0 );
    216236
    217                 //$matches = $wpdb->get_results( "SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `home_team` = '".$team_id."'" );
    218                 $matches = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
     237                if ( !$matches ) $matches =  $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    219238                if ( $matches ) {
    220239                        foreach ( $matches AS $match ) {
    … …  
    228247                                }
    229248
    230                                 $goals['plus'] += $home_goals;
    231                                 $goals['minus'] += $away_goals;
    232                         }
    233                 }
    234 
    235                 //$matches = $wpdb->get_results( "SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `away_team` = '".$team_id."'" );
    236                 $matches = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    237                 if ( $matches ) {
    238                         foreach ( $matches AS $match ) {
    239                                 $custom = maybe_unserialize($match->custom);
    240                                 if ( !empty($custom['overtime']['home']) && !empty($custom['overtime']['away']) ) {
    241                                         $home_goals = $custom['overtime']['home'];
    242                                         $away_goals = $custom['overtime']['away'];
     249                                if ( $match->home_team == $team_id ) {
     250                                        $goals['plus'] += $home_goals;
     251                                        $goals['minus'] += $away_goals;
    243252                                } else {
    244                                         $home_goals = $match->home_points;
    245                                         $away_goals = $match->away_points;
     253                                        $goals['plus'] += $away_goals;
     254                                        $goals['minus'] += $home_goals;
    246255                                }
    247 
    248                                 $goals['plus'] += $away_goals;
    249                                 $goals['minus'] += $home_goals;
    250256                        }
    251257                }
  • leaguemanager/trunk/sports/tabletennis.php

    r1266075 r1361999  
    8989
    9090                $points = array( 'plus' => 0, 'minus' => 0 );
    91                 $home = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
    92                 foreach ( $home AS $match ) {
    93                         $points['plus'] += $match->home_points;
    94                         $points['minus'] += $match->away_points;
    95                 }
    96 
    97                 $away = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    98                 foreach ( $away AS $match ) {
    99                         $points['plus'] += $match->away_points;
    100                         $points['minus'] += $match->home_points;
     91                $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
     92                foreach ( $matches AS $match ) {
     93                        if ( $team_id == $match->home_team ) {
     94                                $points['plus'] += $match->home_points;
     95                                $points['minus'] += $match->away_points;
     96                        } else {
     97                                $points['plus'] += $match->away_points;
     98                                $points['minus'] += $match->home_points;
     99                        }
    101100                }
    102101
  • leaguemanager/trunk/sports/tennis.php

    r1345280 r1361999  
    5656                add_filter( 'leaguemanager_lost_matches_'.$this->key, array(&$this, 'getNumLostMatches'), 10, 2 );
    5757                add_action( 'leaguemanager_save_standings_'.$this->key, array(&$this, 'saveStandings') );
     58                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    5859
    5960                add_action( 'league_settings_'.$this->key, array(&$this, 'leagueSettings') );
    … …  
    286287
    287288        /**
     289         * get standings table data
     290         *
     291         * @param object $team
     292         * @param array $matches
     293         */
     294        function getStandingsFilter( $team, $matches, $point_rule )
     295        {
     296                /*
     297                 * analogue to leaguemanager_save_standings_$sport filter
     298                 */
     299                $data = $this->getStandingsData( $team->id, maybe_unserialize($team->custom), $matches );
     300                $team->straight_set = $data['straight_set'];
     301                $team->split_set = $data['split_set'];
     302                $team->games_allowed = $data['games_allowed'];
     303               
     304                return $team;
     305        }
     306       
     307       
     308        /**
    288309         * get standings data for given team
    289310         *
    … …  
    292313         * @return array number of runs for and against as assoziative array
    293314         */
    294         function getStandingsData( $team_id, $data = array() )
     315        function getStandingsData( $team_id, $data = array(), $matches = false )
    295316        {
    296317                global $leaguemanager;
    … …  
    302323                $season = $leaguemanager->getSeason($league);
    303324
    304                 $matches = $leaguemanager->getMatches( array("league_id" => $league->id, "season" => $season['name'], "final" => '', "limit" => false) );
     325                if ( !$matches ) $matches = $leaguemanager->getMatches( array("league_id" => $league->id, "season" => $season['name'], "final" => '', "limit" => false, "cache" => false) );
    305326                foreach ( $matches AS $match ) {
    306327                        if ( $match->home_team == $team_id || $match->away_team == $team_id || ( isset($match->home_partner) && $match->home_partner == $team_id ) || ( isset($match->guest_partner) && $match->guest_partner == $team_id ) ) {
    … …  
    598619                global $wpdb, $leaguemanager;
    599620               
    600                 $match = $leaguemanager->getMatch( $match_id );
     621                $match = $leaguemanager->getMatch( $match_id, false );
    601622                if ( $match->home_points == "" && $match->away_points == "" ) {
    602623                        $score = array( 'home' => '', 'guest' => '' );
  • leaguemanager/trunk/sports/us-football.php

    r1324769 r1361999  
    3737                        add_action( 'leaguemanager_standings_header_'.$key, array(&$this, 'displayStandingsHeader') );
    3838                        add_action( 'leaguemanager_standings_columns_'.$key, array(&$this, 'displayStandingsColumns'), 10, 2 );
     39                       
     40                        add_action( 'leaguemanager_get_standings_'.$key, array(&$this, 'getStandingsFilter'), 10, 3 );
    3941                }
    4042        }
    … …  
    117119
    118120        /**
     121         * get standings table data
     122         *
     123         * @param object $team
     124         * @param array $matches
     125         */
     126        function getStandingsFilter( $team, $matches, $point_rule )
     127        {
     128                /*
     129                 * analogue to team_points2_$sport filter
     130                 */
     131                $goals = $this->calculateGoalStatistics( $team->id, $matches );
     132                $team->points2_plus = $goals['plus'];
     133                $team->points2_minus = $goals['minus'];
     134
     135                return $team;
     136        }
     137       
     138       
     139        /**
    119140         * extend header for Standings Table in Backend
    120141         *
    … …  
    179200         * @return int
    180201         */
    181         function calculateGoalStatistics( $team_id )
     202        function calculateGoalStatistics( $team_id, $matches = false )
    182203        {
    183204                global $wpdb, $leaguemanager;
    … …  
    185206                $goals = array( 'plus' => 0, 'minus' => 0 );
    186207                               
    187                 //$matches = $wpdb->get_results( "SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `home_team` = '".$team_id."'" );
    188                 $matches = $leaguemanager->getMatches( array("home_team" => $team_id, "limit" => false) );
     208                if ( !$matches ) $matches =  $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    189209                if ( $matches ) {
    190210                        foreach ( $matches AS $match ) {
    … …  
    193213                                $away_goals = $match->away_points;
    194214                               
    195                                 $goals['plus'] += $home_goals;
    196                                 $goals['minus'] += $away_goals;
     215                                if ( $match->home_team == $team_id ) {
     216                                        $goals['plus'] += $home_goals;
     217                                        $goals['minus'] += $away_goals;
     218                                } else {
     219                                        $goals['plus'] += $away_goals;
     220                                        $goals['minus'] += $home_goals;
     221                                }
    197222                        }
    198223                }
    199224               
    200                 //$matches = $wpdb->get_results( "SELECT `home_points`, `away_points`, `custom` FROM {$wpdb->leaguemanager_matches} WHERE `away_team` = '".$team_id."'" );
    201                 $matches = $leaguemanager->getMatches( array("away_team" => $team_id, "limit" => false) );
    202                 if ( $matches ) {
    203                         foreach ( $matches AS $match ) {
    204                                 $custom = maybe_unserialize($match->custom);
    205                                 $home_goals = $match->home_points;
    206                                 $away_goals = $match->away_points;
    207                                
    208                                 $goals['plus'] += $away_goals;
    209                                 $goals['minus'] += $home_goals;
    210                         }
    211                 }
    212                
    213225                return $goals;
    214226        }
  • leaguemanager/trunk/sports/volleyball.php

    r1345280 r1361999  
    5454
    5555                add_action( 'leaguemanager_save_standings_'.$this->key, array(&$this, 'saveStandings') );
    56                
     56                add_action( 'leaguemanager_get_standings_'.$this->key, array(&$this, 'getStandingsFilter'), 10, 3 );
    5757                add_action( 'leaguemanager_update_results_'.$this->key, array(&$this, 'updateResults') );
    5858        }
    … …  
    215215
    216216        /**
     217         * get standings table data
     218         *
     219         * @param object $team
     220         * @param array $matches
     221         */
     222        function getStandingsFilter( $team, $matches, $point_rule )
     223        {
     224                /*
     225                 * analogue to leaguemanager_save_standings_$sport filter
     226                 */
     227                $data = $this->getStandingsData( $team->id, maybe_unserialize($team->custom), $matches );
     228                $team->sets = $data['sets'];
     229                $team->ballpoints = $data['ballpoints'];
     230               
     231                return $team;
     232        }
     233       
     234       
     235        /**
    217236         * get standings data for given team
    218237         *
    … …  
    221240         * @return array number of runs for and against as assoziative array
    222241         */
    223         function getStandingsData( $team_id, $data = array() )
     242        function getStandingsData( $team_id, $data = array(), $matches = false )
    224243        {
    225244                global $leaguemanager;
    … …  
    228247                $data['ballpoints'] = array( 'plus' => 0, 'minus' => 0 );
    229248
    230                 $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false) );
     249                if ( !$matches ) $matches = $leaguemanager->getMatches( array("team_id" => $team_id, "limit" => false, "cache" => false) );
    231250                foreach ( $matches AS $match ) {
    232251                        // Home Match
    … …  
    449468                global $wpdb, $leaguemanager;
    450469               
    451                 $match = $leaguemanager->getMatch( $match_id );
     470                $match = $leaguemanager->getMatch( $match_id, false );
    452471                if ( $match->home_points == "" && $match->away_points == "" ) {
    453472                        $score = array( 'home' => '', 'guest' => '' );
  • leaguemanager/trunk/style.css

    r1348420 r1361999  
    260260        width: 130px;
    261261        }
    262 table.leaguemanager .logo {
     262table.leaguemanager .logo,
     263table .leaguemanager .match-title.logo {
    263264        width: 20px;
    264265        }
     266.match-title.logo {
     267        max-width: 50px;
     268}
    265269table.leaguemanager .logo img {
    266270        display: block;
  • leaguemanager/trunk/templates/matches-by_matchday-accordion.php

    r1344775 r1361999  
    4141                        <?php $class = ( $class == 'alternate' ) ? '' : 'alternate'; ?>
    4242                        <tr class='<?php echo $class ?>'>
    43                                 <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
     43                                <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
    4444                                <td class='score' valign='bottom'><?php echo $match->score ?></td>
    4545                        </tr>
  • leaguemanager/trunk/templates/matches-by_matchday-gymnastics.php

    r1344775 r1361999  
    4242                        <?php $class = ( $class == 'alternate' ) ? '' : 'alternate'; ?>
    4343                        <tr class='<?php echo $class ?>'>
    44                                 <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
     44                                <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
    4545                                <td class='score' valign='bottom'><?php echo $match->score ?></td>
    4646                                <td class='ap' valign='bottom'>
  • leaguemanager/trunk/templates/matches-by_matchday-tabs.php

    r1344775 r1361999  
    4747                        <?php $class = ( $class == 'alternate' ) ? '' : 'alternate'; ?>
    4848                        <tr class='<?php echo $class ?>'>
    49                                 <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
     49                                <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
    5050                                <td class='score' valign='bottom'><?php echo $match->score ?></td>
    5151                        </tr>
  • leaguemanager/trunk/templates/matches-by_matchday.php

    r1344775 r1361999  
    4141                        <?php $class = ( $class == 'alternate' ) ? '' : 'alternate'; ?>
    4242                        <tr class='<?php echo $class ?>'>
    43                                 <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
     43                                <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
    4444                                <td class='score' valign='bottom'><?php echo $match->score ?></td>
    4545                        </tr>
  • leaguemanager/trunk/templates/matches-gymnastics.php

    r1336648 r1361999  
    3030
    3131<tr class='<?php echo $match->class ?>'>
    32         <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
     32        <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
    3333        <td class='score' valign='bottom'><?php echo $match->score ?></td>
    3434        <td class='ap' valign='bottom'>
    … …  
    4040</table>
    4141
     42<p class='page-numbers'><?php echo $league->pagination ?></p>
     43
    4244<?php endif; ?>
    4345
  • leaguemanager/trunk/templates/matches-irish-gaelic-football.php

    r1336648 r1361999  
    3434?>
    3535<tr class='<?php echo $match->class ?>'>
    36         <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
     36        <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
    3737        <td class='score' valign='bottom'><?php echo $match->score ?></td>
    3838</tr>
  • leaguemanager/trunk/templates/matches-racing.php

    r1336648 r1361999  
    7979<?php $class = ( 'alternate' == $class ) ? '' : 'alternate'; ?>
    8080<tr class='<?php echo $class ?>'>
    81         <td><?php echo $match->date ?></td>
     81        <td><?php echo $match->match_date ?></td>
    8282        <?php if (!$roster) : ?>
    8383        <td><?php echo $racer['name'] ?></td>
  • leaguemanager/trunk/templates/matches-tennis.php

    r1336648 r1361999  
    3131
    3232<tr class='<?php echo $match->class ?>'>
    33         <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
     33        <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
    3434        <td class='score' valign='bottom'>
    3535                <?php
  • leaguemanager/trunk/templates/matches-volleyball.php

    r1336648 r1361999  
    3535?>
    3636<tr class='<?php echo $match->class ?>'>
    37         <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
     37        <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $match->title ?></a> <?php echo $match->report ?></td>
    3838        <td class='score' valign='bottom'>
    3939                <?php echo $match->score . " (".implode(", ", $sets).")" ?>
  • leaguemanager/trunk/templates/matches.php

    r1336648 r1361999  
    2828
    2929<tr class='<?php echo $match->class ?>'>
    30         <td class='match'><?php echo $match->date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $leaguemanager->getMatchTitle($match->id) ?></a> <?php echo $match->report ?></td>
     30        <td class='match'><?php echo $match->match_date." ".$match->start_time." ".$match->location ?><br /><a href="<?php echo $match->pageURL ?>"><?php echo $leaguemanager->getMatchTitle($match->id) ?></a> <?php echo $match->report ?></td>
    3131        <td class='score' valign='bottom'><?php echo $match->score ?></td>
    3232</tr>
  • leaguemanager/trunk/templates/standings-last5.php

    r1348420 r1361999  
    7979
    8080// Get Next Match
    81     $next_results = get_next_match($team->id, 1);
     81    //$next_results = get_next_match($team->id, 1);
     82        $next_results = $leaguemanager->getMatches( array("time" => "next", "team_id" => $team->id, "limit" => 1) );
    8283    $last5 = '<td style="text-align: right;" class="last5Icon last5">';
    8384    if ( $next_results ) {
    … …  
    9899    // Get the latest results
    99100    //$results = get_last_matches($team->id, 5);
    100         $results = get_latest_results($team->id, 5);
     101        //$results = get_latest_results($team->id, 5);
     102        $results = $leaguemanager->getMatches( array("time" => "latest", "team_id" => $team->id, "limit" => 5) );
    101103    foreach ($results as $result)
    102104    {
  • leaguemanager/trunk/templates/team.php

    r1348420 r1361999  
    4747                                        <p class="match"><?php echo $team->next_match->match ?></p>
    4848                                        <p class='match_day'><?php printf(__("<strong>%d.</strong> Match Day", 'leaguemanager'), $team->next_match->match_day); ?></p>
    49                                         <p class='match_date'><?php echo mysql2date("j. F Y", $team->next_match->date) ?>&#160;<span class='time'><?php echo $team->next_match->time ?></span> <span class='location'><?php echo $team->next_match->location ?></span></p>
     49                                        <p class='match_date'><?php echo mysql2date("j. F Y", $team->next_match->match_date) ?>&#160;<span class='time'><?php echo $team->next_match->start_time ?></span> <span class='location'><?php echo $team->next_match->location ?></span></p>
    5050                                        <p class="score">&#160;</p>
    5151                                </div>
    … …  
    6161                                        <p class="match"><?php echo $team->prev_match->match ?></p>
    6262                                        <p class='match_day'><?php printf(__("<strong>%d.</strong> Match Day", 'leaguemanager'), $team->prev_match->match_day); ?></p>
    63                                         <p class='match_date'><?php echo mysql2date("j. F Y", $team->prev_match->date) ?>&#160;<span class='time'><?php echo $team->prev_match->time ?></span> <span class='location'><?php echo $team->prev_match->location ?></span></p>
     63                                        <p class='match_date'><?php echo mysql2date("j. F Y", $team->prev_match->match_date) ?>&#160;<span class='time'><?php echo $team->prev_match->start_time ?></span> <span class='location'><?php echo $team->prev_match->location ?></span></p>
    6464                                        <p class="score"><?php echo $team->prev_match->score ?></p>
    6565                                </div>
Note: See TracChangeset for help on using the changeset viewer.