Plugin Directory

Changeset 583439


Ignore:
Timestamp:
08/09/2012 08:47:39 AM (14 years ago)
Author:
belinde
Message:

Label personalizzate nelle partite di finale
classifiche intergirone

Location:
volleytnt/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • volleytnt/trunk/admin/volleytnt_finali.php

    r575704 r583439  
    4242                                            `squadra_1` = %d,
    4343                                            `squadra_2` = %d,
    44                                             `visibile` = %d
     44                                            `visibile` = %d,
     45                                            `testo_1` = %s,
     46                                            `testo_2` = %s
    4547                                        WHERE `categoria` = %s
    4648                                            AND `finale` = %s
     
    4951                                        $_POST['set2_sq1'],
    5052                                        $_POST['set3_sq1'],
    51                                         $_POST['set4_sq1'],
    52                                         $_POST['set5_sq1'],
     53                                        isset( $_POST['set4_sq1'] ) ? $_POST['set4_sq1'] : 0,
     54                                        isset( $_POST['set5_sq1'] ) ? $_POST['set5_sq1'] : 0,
    5355                                        $_POST['set1_sq2'],
    5456                                        $_POST['set2_sq2'],
    5557                                        $_POST['set3_sq2'],
    56                                         $_POST['set4_sq2'],
    57                                         $_POST['set5_sq2'],
     58                                        isset( $_POST['set4_sq2'] ) ? $_POST['set4_sq2'] : 0,
     59                                        isset( $_POST['set5_sq2'] ) ? $_POST['set5_sq2'] : 0,
    5860                                        $_POST['squadra_1'],
    5961                                        $_POST['squadra_2'],
    6062                                        $_POST['visibile'],
     63                                        $_POST['testo_1'],
     64                                        $_POST['testo_2'],
    6165                                        $_POST['categoria'],
    6266                                        $_POST['id_partita'],
     
    7781                                                $_POST['id_partita'],
    7882                                                $this->opts->corrente ) );
     83       
     84        if ( !$row->label_1 ) $row->label_1 = $row->testo_1;
     85        if ( !$row->label_2 ) $row->label_2 = $row->testo_2;
    7986       
    8087        $row->set1 = $row->set2 = 0;
     
    155162</tbody>
    156163</table>
    157 <p><input type="checkbox" id="partita_visibile" tabindex="13"><label for="partita_visibile"><?php _e('Partita giocata', 'volleytnt'); ?></label></p>
    158 <p><input type="submit" class="button-primary" value="<?php echo esc_attr( __('Salva partita', 'volleytnt' ) ); ?>" tabindex="14"></p>
     164<p>
     165    <input type="checkbox" id="partita_visibile" tabindex="13">&nbsp;<label for="partita_visibile"><?php _e('Partita giocata', 'volleytnt'); ?></label>
     166    <input type="text" id="testo_1" tabindex="14">&nbsp;<label for="testo_1"><?php _e('Testo 1', 'volleytnt'); ?></label>
     167    <input type="text" id="testo_2" tabindex="15">&nbsp;<label for="testo_2"><?php _e('Testo 2', 'volleytnt'); ?></label>
     168     
     169</p>
     170<p><input type="submit" class="button-primary" value="<?php echo esc_attr( __('Salva partita', 'volleytnt' ) ); ?>" tabindex="16"></p>
    159171</form>
    160172        <?php
  • volleytnt/trunk/admin/volleytnt_partite.php

    r576316 r583439  
    1414        $this->add_case( 'firstpage' );
    1515       
    16         $this->trigger( 'rigenerapartitegironi', array( $this, 'rigenera_partite_gironi' ), '?page=VolleyTNT_Partite' );
     16        $this->trigger( 'rigenerapartitegironi', array( $this, 'rigenera_partite_gironi' ), '?page=volleytnt_partite' );
    1717       
    1818        add_action( 'wp_ajax_volleytnt_partite_orari',      array( $this, 'ajax_partite_orari' ) );
  • volleytnt/trunk/core/the_plugin.php

    r579121 r583439  
    5858               
    5959        add_shortcode( 'volleytnt_classifiche_gironi', array( $this, 'sc_classifiche_gironi' ) );
     60        add_shortcode( 'volleytnt_classifiche_intergironi', array( $this, 'sc_classifiche_intergironi' ) );
    6061        add_shortcode( 'volleytnt_risultati', array( $this, 'sc_risultati' ) );
    6162        add_shortcode( 'volleytnt_calendario', array( $this, 'sc_calendario' ) );
     
    219220                                                                    'corrente'      => 0 ) );
    220221        $this->torneo = $wpdb->get_row("SELECT * FROM `{$this->prefix}tornei` WHERE `id`={$this->opts->corrente}");
    221         $this->torneo->categorie = explode( ',', $this->torneo->categorie );
    222         $this->torneo->set_partita = absint( $this->torneo->set_partita );
    223         $this->torneo->campi = absint( $this->torneo->campi );
    224         $this->torneo->durata_turno = absint( $this->torneo->durata_turno );
    225         $this->torneo->finali_M = absint( $this->torneo->finali_M );
    226         $this->torneo->finali_F = absint( $this->torneo->finali_F );
    227         $this->torneo->finali_X = absint( $this->torneo->finali_X );
    228        
     222        if ( $this->torneo ) {
     223            $this->torneo->categorie = explode( ',', $this->torneo->categorie );
     224            $this->torneo->set_partita = absint( $this->torneo->set_partita );
     225            $this->torneo->campi = absint( $this->torneo->campi );
     226            $this->torneo->durata_turno = absint( $this->torneo->durata_turno );
     227            $this->torneo->finali_M = absint( $this->torneo->finali_M );
     228            $this->torneo->finali_F = absint( $this->torneo->finali_F );
     229            $this->torneo->finali_X = absint( $this->torneo->finali_X );
     230        } else {
     231            $this->torneo = new stdClass();
     232            $this->torneo->categorie = array();
     233            $this->torneo->set_partita = 3;
     234            $this->torneo->campi = 2;
     235            $this->torneo->durata_turno = 30;
     236            $this->torneo->finali_M = 8;
     237            $this->torneo->finali_F = 8;
     238            $this->torneo->finali_X = 8;
     239        }
    229240        VolleyTNT_Form::manage_cbs_save();
    230241        foreach ( $this->pages as $page ) $page->do_triggers();
     
    359370                    `{$this->prefix}squadre`.`id`
    360371                ORDER BY
     372                    `{$this->prefix}squadre`.`categoria` ASC,
     373                    `{$this->prefix}gironi`.`girone` ASC,
    361374                    `{$this->prefix}squadre`.`label` ASC,
    362375                    `{$this->prefix}atleti`.`cognome` ASC,
     
    393406                if ( !isset( $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ] ) )
    394407                    $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ] = array(    'giocate'       => 0,
     408                                                                                            'punti_class'   => 0,
    395409                                                                                            'vinti'         => 0,
    396410                                                                                            'persi'         => 0,
     
    401415                if ( !isset( $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ] ) )
    402416                    $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ] = array(    'giocate'       => 0,
     417                                                                                            'punti_class'   => 0,
    403418                                                                                            'vinti'         => 0,
    404419                                                                                            'persi'         => 0,
     
    438453                   
    439454                    if ( $set1_sq1 > $set1_sq2 ) {
     455                        $vinti1++;
    440456                        $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['vinti']++;
    441457                        $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['persi']++;
    442458                    } else {
     459                        $vinti2++;
    443460                        $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['vinti']++;
    444461                        $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['persi']++;
    445462                    }
    446463                    if ( $set2_sq1 > $set2_sq2 ) {
     464                        $vinti1++;
    447465                        $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['vinti']++;
    448466                        $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['persi']++;
    449467                    } else {
     468                        $vinti2++;
    450469                        $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['vinti']++;
    451470                        $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['persi']++;
     
    453472                    if ( $this->torneo->set_partita == 5 ) {
    454473                        if ( $set3_sq1 > $set3_sq2 ) {
     474                            $vinti1++;
    455475                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['vinti']++;
    456476                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['persi']++;
    457477                        } else {
     478                            $vinti2++;
    458479                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['vinti']++;
    459480                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['persi']++;
    460481                        }
    461482                        if ( $set4_sq1 or $set4_sq2 ) if ( $set4_sq1 > $set4_sq2 ) {
     483                            $vinti1++;
    462484                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['vinti']++;
    463485                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['persi']++;
    464486                        } else {
     487                            $vinti2++;
    465488                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['vinti']++;
    466489                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['persi']++;
    467490                        }
    468491                        if ( $set5_sq1 or $set5_sq2 ) if ( $set5_sq1 > $set5_sq2 ) {
     492                            $vinti1++;
    469493                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['vinti']++;
    470494                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['persi']++;
    471495                        } else {
     496                            $vinti2++;
    472497                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['vinti']++;
    473498                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['persi']++;
     
    475500                    } else {
    476501                        if ( $set3_sq1 or $set3_sq2 ) if ( $set3_sq1 > $set3_sq2 ) {
     502                            $vinti1++;
    477503                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['vinti']++;
    478504                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['persi']++;
    479505                        } else {
     506                            $vinti2++;
    480507                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['vinti']++;
    481508                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['persi']++;
    482509                        }
    483510                    }
     511                    if ( $this->torneo->set_partita == 5 ) {
     512                        if ( $vinti1 > $vinti2 ) {
     513                            if ( $vinti2 == 2 ) {
     514                                $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['punti_class'] += 2;
     515                                $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['punti_class'] += 1;                               
     516                            } else {
     517                                $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['punti_class'] += 3;
     518                            }
     519                        } else {
     520                            if ( $vinti1 == 2 ) {
     521                                $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['punti_class'] += 1;
     522                                $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['punti_class'] += 2;                               
     523                            } else {
     524                                $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['punti_class'] += 3;
     525                            }                       
     526                        }
     527                    } else {
     528                        if ( $vinti1 > $vinti2 ) {
     529                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_1 ]['punti_class'] += 3;
     530                        } else {
     531                            $work[ $row->categoria ][ $row->girone ][ $row->squadra_2 ]['punti_class'] += 3;                       
     532                        }
     533                    }
    484534                }
    485535            }
     
    488538                foreach ( $i_gironi as $girone => $squadre ) {
    489539                    foreach ( $squadre as $id_squadra => $dati ) {
     540                        $dati['q_punti_class'] = $dati['giocate'] ? round( $dati['punti_class'] / $dati['giocate'], 2 ) : 0;
    490541                        $dati['q_vinti'] = $dati['giocate'] ? round( $dati['vinti'] / $dati['giocate'], 2 ) : 0;
    491542                        $dati['d_set'] = $dati['vinti'] - $dati['persi'];
     
    506557   
    507558    private function sort_classifica( $a, $b ) {
    508         if ( $a['vinti'] == $b['vinti'] ) {
    509             if ( $a['qd_set'] == $b['qd_set'] ) {
    510                 if ( $a['qd_punti'] == $b['qd_punti'] ) {
    511                     if ( $a['giocate'] == $b['giocate'] ) {
    512                         return 0;
    513                     } else return $a['giocate'] > $b['giocate'] ? 1 : -1;
    514                 } else return $a['qd_punti'] < $b['qd_punti'] ? 1 : -1;
    515             } else return $a['qd_set'] < $b['qd_set'] ? 1 : -1;
    516         } else return $a['vinti'] < $b['vinti'] ? 1 : -1;
     559        if ( $a['punti_class'] == $b['punti_class'] ) {
     560            if ( $a['vinti'] == $b['vinti'] ) {
     561                if ( $a['d_set'] == $b['d_set'] ) {
     562                    if ( $a['d_punti'] == $b['d_punti'] ) {
     563                        if ( $a['giocate'] == $b['giocate'] ) {
     564                            return strcmp( $a['label'], $b['label'] );
     565                        } else return $a['giocate'] > $b['giocate'] ? 1 : -1;
     566                    } else return $a['d_punti'] < $b['d_punti'] ? 1 : -1;
     567                } else return $a['d_set'] < $b['d_set'] ? 1 : -1;   
     568            } else return $a['vinti'] < $b['vinti'] ? 1 : -1;   
     569        } else return $a['punti_class'] < $b['punti_class'] ? 1 : -1;
     570    }
     571   
     572    private function sort_classifica_intergironi( $a, $b ) {
     573        if ( $a['q_punti_class'] == $b['q_punti_class'] ) {
     574            if ( $a['q_vinti'] == $b['q_vinti'] ) {
     575                if ( $a['qd_set'] == $b['qd_set'] ) {
     576                    if ( $a['qd_punti'] == $b['qd_punti'] ) {
     577                        return strcmp( $a['label'], $b['label'] );
     578                    } else return $a['qd_punti'] < $b['qd_punti'] ? 1 : -1;
     579                } else return $a['qd_set'] < $b['qd_set'] ? 1 : -1;
     580            } else return $a['q_vinti'] < $b['q_vinti'] ? 1 : -1;   
     581        } else return $a['q_punti_class'] < $b['q_punti_class'] ? 1 : -1;
    517582    }
    518583
     
    663728    }
    664729
     730    public function sc_classifiche_intergironi( $atts, $content = '' ) {
     731        extract( shortcode_atts( array(
     732            'torneo' => $this->opts->corrente
     733        ), $atts ) );
     734        if ( !$torneo ) return '';
     735        $_ = '<div class="tornei_classifiche_intergironi">';
     736        $classifiche = $this->get_classifiche( $torneo );
     737        foreach ( $classifiche as $categoria => $gironi ) {
     738            $_ .= '<h3>' . $this->l_categorie[ $categoria ] . '</h3>';
     739            $work = array();
     740            foreach ( $gironi as $girone => $squadre ) {
     741                foreach ( $squadre as $pos => $value ) {
     742                    $work[ $pos + 1 ][] = $value;
     743                }
     744            }
     745            foreach ( $work as $pos => $squadre ) {
     746               
     747                $_ .= '<h4>' . sprintf( __('%d<sup>e</sup> classificate', 'volleytnt'), $pos ) . '</h4>';
     748                $_ .= '<table><thead><tr>';
     749                $_ .= '<th class="posizione">' . __('Pos.', 'volleytnt') . '</th>';
     750                $_ .= '<th class="squadra">' . __('Squadra', 'volleytnt') . '</th>';
     751                $_ .= '<th class="partite">' . __('Partite', 'volleytnt') . '</th>';
     752                $_ .= '<th class="pticlass">' . __('Q. p.ti class.', 'volleytnt') . '</th>';
     753                $_ .= '<th class="setvinti">' . __('Q. set vinti', 'volleytnt') . '</th>';
     754                $_ .= '<th class="diffset">' . __('Q. diff. set', 'volleytnt') . '</th>';
     755                $_ .= '<th class="diffpti">' . __('Q. diff. p.ti', 'volleytnt') . '</th>';
     756                $_ .= '</tr></thead><tbody>';
     757                $subpos = 1;
     758                usort( $squadre, array( $this, 'sort_classifica_intergironi') );
     759                foreach ( $squadre as $s ) {
     760                    $_ .= '<tr>';
     761                    $_ .= '<td class="posizione">' . $subpos . '&ordm;</td>';
     762                    $_ .= '<td class="squadra">' . $s['label'] . '</td>';
     763                    $_ .= '<td class="partite">' . $s['giocate'] . '</td>';
     764                    $_ .= '<td class="pticlass">' . $s['q_punti_class'] . '</td>';
     765                    $_ .= '<td class="setvinti">' . $s['q_vinti'] . '</td>';
     766                    $_ .= '<td class="diffset">' . $s['qd_set'] . '</td>';
     767                    $_ .= '<td class="diffpti">' . $s['qd_punti'] . '</td>';
     768                    $_ .= '</tr>';
     769                    $subpos++;
     770                }
     771                $_ .= '</tbody></table>';
     772            }
     773        }
     774       
     775        return $_ . '</div>';
     776    }
     777           
     778
    665779   
    666780    public function sc_classifiche_gironi( $atts, $content = '' ) {
     
    675789            $_ .= '<h3>' . sprintf( __('Girone %s', 'volleytnt'), $categoria . $girone ) . '</h3>';
    676790            $_ .= '<table><thead><tr>';
    677             $_ .= '<th class="posizione">' . __('Pos.', 'volleytnt') . '</th>';
     791            $_ .= '<th class="posizione" colspan="2">' . __('Pos.', 'volleytnt') . '</th>';
    678792            $_ .= '<th class="squadra">' . __('Squadra', 'volleytnt') . '</th>';
    679793            $_ .= '<th class="partite">' . __('Partite', 'volleytnt') . '</th>';
     
    684798                $_ .= '<tr>';
    685799                $_ .= '<td class="posizione">' . $pos . '&ordm;</td>';
     800                $_ .= '<td class="punticlass">' . $s['punti_class'] . '</td>';
    686801                $_ .= '<td class="squadra">' . $s['label'] . '</td>';
    687802                $_ .= '<td class="partite">' . $s['giocate'] . '</td>';
    688                 $_ .= '<td class="set">' . $s['vinti'] . 'v, ' . $s['persi'] . 'p <em>(' . $s['qd_set'] . ')</em></td>';
    689                 $_ .= '<td class="punti">' . $s['fatti'] . 'f, ' . $s['subiti'] . 's <em>(' . $s['qd_punti'] . ')</em></td>';
     803                $_ .= '<td class="set">' . $s['vinti'] . 'v, ' . $s['persi'] . 'p <em>(' . $s['d_set'] . ')</em></td>';
     804                $_ .= '<td class="punti">' . $s['fatti'] . 'f, ' . $s['subiti'] . 's <em>(' . $s['d_punti'] . ')</em></td>';
    690805                $_ .= '</tr>';
    691806                $pos++;
     
    878993            $p->set5_sq1 = '';
    879994            $p->set5_sq2 = '';
     995            $p->testo_1 = '';
     996            $p->testo_2 = '';
    880997            $class = 'partita nongiocata';
    881998        }
     
    8931010        ?>
    8941011        <div class="<?php echo $class; ?>" squadra_1="<?php echo $p->squadra_1; ?>" squadra_2="<?php echo $p->squadra_2; ?>" categoria="<?php echo $p->categoria; ?>" id_partita="<?php echo $id; ?>">
    895             <div class="squadra squadra1"><?php echo isset( $this->squadre[ $p->categoria ][ $p->squadra_1 ] ) ? $this->squadre[ $p->categoria ][ $p->squadra_1 ] : ''; ?></div>
     1012            <div class="squadra squadra1"><?php echo ( $p->squadra_1 and isset( $this->squadre[ $p->categoria ][ $p->squadra_1 ] ) ) ? $this->squadre[ $p->categoria ][ $p->squadra_1 ] : $p->testo_1; ?></div>
    8961013            <div class="separatore">
    8971014                <div class="punti punti1">
     
    9171034                </div>
    9181035            </div>
    919             <div class="squadra squadra2"><?php echo isset( $this->squadre[ $p->categoria ][ $p->squadra_2 ] ) ? $this->squadre[ $p->categoria ][ $p->squadra_2 ] : ''; ?></div>
     1036            <div class="squadra squadra2"><?php echo ( $p->squadra_2 and isset( $this->squadre[ $p->categoria ][ $p->squadra_2 ] ) ) ? $this->squadre[ $p->categoria ][ $p->squadra_2 ] : $p->testo_2; ?></div>
    9201037        </div>
    9211038        <?php
  • volleytnt/trunk/js/admin_finali.js

    r575704 r583439  
    2323                        set4_sq2: $('#formfinale .set4_sq2').val(),
    2424                        set5_sq2: $('#formfinale .set5_sq2').val(),
    25                         visibile: $('#partita_visibile').prop('checked') ? 1 : 0 };
     25                        visibile: $('#partita_visibile').prop('checked') ? 1 : 0,
     26                        testo_1: $('#formfinale #testo_1').val(),
     27                        testo_2: $('#formfinale #testo_2').val(), };
    2628        $('body').addClass('loading');
    2729        $.post( ajaxurl,
     
    8486        $('#formfinale').attr('id_partita', partita.attr('id_partita') );
    8587        $('#partita_visibile').prop('checked', !partita.hasClass('nongiocata') );
     88       
     89        $('#formfinale #testo_1').val( partita.attr('squadra_1') == '0' ? partita.find('.squadra.squadra1').text() : '' );
     90        $('#formfinale #testo_2').val( partita.attr('squadra_2') == '0' ? partita.find('.squadra.squadra2').text() : '' );
    8691        $('#formfinale').dialog('open');
    8792    } );
  • volleytnt/trunk/readme.txt

    r579127 r583439  
    3636* **[volleytnt_risultati]** the results of the first phases
    3737* **[volleytnt_classifiche_gironi]** the standings of the round
     38* **[volleytnt_classifiche_intergironi]** the standings between all rounds, merged by position
    3839* **[volleytnt_finali]** the final knock-out tree
    3940
     
    4849* Added dashboard widget to calculate the number of matches needed.
    4950* Added RSS, RSS2 and Atom feed for matches results
     51* Added standings between all rounds
     52* Added custom labels in finals matches
    5053* Bug fixes:
    5154    * Team deletion now run properly
  • volleytnt/trunk/style/admin.css

    r578816 r583439  
    169169}
    170170
     171#formfinale #testo_1,
     172#formfinale #testo_2 {
     173    width:160px;
     174    margin-left:50px;
     175}
     176
    171177#formfinale select {
    172178    width:100%;
  • volleytnt/trunk/volleytnt.php

    r578816 r583439  
    7272  `tornei_id` BIGINT(20) UNSIGNED NOT NULL,
    7373  `visibile` TINYINT(1) NOT NULL DEFAULT '1',
     74  `testo_1` VARCHAR(100) DEFAULT NULL,
     75  `testo_2` VARCHAR(100) DEFAULT NULL,
    7476  PRIMARY KEY (`id`)
    7577) DEFAULT CHARSET=utf8",
Note: See TracChangeset for help on using the changeset viewer.