Plugin Directory

Changeset 575704


Ignore:
Timestamp:
07/22/2012 12:31:20 PM (14 years ago)
Author:
belinde
Message:

Prima versione pienamente funzionante

Location:
volleytnt/trunk
Files:
1 added
8 edited

Legend:

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

    r575201 r575704  
    55        $this->set_title( __("Finali", 'volleytnt') );
    66       
    7 //      $this->add_help_tab( __("Inserimento risultati", 'volleytnt'), array( $this, 'help_risultati' ) );
     7        $this->add_help_tab( __("Inserimento risultati", 'volleytnt'), array( $this, 'help_risultati' ) );
    88       
    9         $this->load_js( 'admin_finali.js', 'jquery-ui-tabs' );
     9        $this->load_js( 'admin_finali.js', 'jquery-ui-tabs', 'jquery-ui-dialog' );
    1010       
    11 //      $this->localize_js_string( 'modifica', __( "Modifica", 'volleytnt' ) );
     11        $this->localize_js_string( 'impossibile_salvare', __( "Impossibile effettuare il salvataggio!", 'volleytnt' ) );
    1212
    1313        $this->add_case( 'firstpage' );
     14   
     15        add_action( 'wp_ajax_volleytnt_finali',         array( $this, 'ajax_finali' ) );
     16    }
     17   
     18    public function help_risultati() {
     19        echo '<p>';
     20        _e("In questa pagina si possono impostare le partite giocate, le squadre e i risultati. Le partite non giocate permettono di creare alberi di eliminatorie da forme differenti (per esempio con i secondi e i terzi classificati che giocano gli ottavi di finale e i primi che entrano ai quarti). I risultati si inseriscono anche qua mettendo soltanto i punti per ogni set, ma occorre segnare a mano chi passa al turno successivo.", 'volleytnt');
     21        echo '</p>';
     22    }
     23   
     24    public function ajax_finali() {
     25        global $wpdb;
     26        header('Content-Type: application/json');
     27        if ( !isset( $_POST['id_partita'], $_POST['categoria'] ) ) die( json_encode( false ) );
     28        if ( !in_array( $_POST['categoria'], array( 'M', 'F', 'X' ) ) ) die( json_encode( false ) );
     29        if ( !preg_match( '|\d+_\d+|', $_POST['id_partita'] ) ) die( json_encode( false ) );
     30        $_POST = stripslashes_deep( $_POST );
     31        $wpdb->query( $wpdb->prepare("  UPDATE `{$this->prefix}partite`
     32                                        SET `set1_sq1` = %d,
     33                                            `set2_sq1` = %d,
     34                                            `set3_sq1` = %d,
     35                                            `set4_sq1` = %d,
     36                                            `set5_sq1` = %d,
     37                                            `set1_sq2` = %d,
     38                                            `set2_sq2` = %d,
     39                                            `set3_sq2` = %d,
     40                                            `set4_sq2` = %d,
     41                                            `set5_sq2` = %d,
     42                                            `squadra_1` = %d,
     43                                            `squadra_2` = %d,
     44                                            `visibile` = %d
     45                                        WHERE `categoria` = %s
     46                                            AND `finale` = %s
     47                                            AND `tornei_id` = %d",
     48                                        $_POST['set1_sq1'],
     49                                        $_POST['set2_sq1'],
     50                                        $_POST['set3_sq1'],
     51                                        $_POST['set4_sq1'],
     52                                        $_POST['set5_sq1'],
     53                                        $_POST['set1_sq2'],
     54                                        $_POST['set2_sq2'],
     55                                        $_POST['set3_sq2'],
     56                                        $_POST['set4_sq2'],
     57                                        $_POST['set5_sq2'],
     58                                        $_POST['squadra_1'],
     59                                        $_POST['squadra_2'],
     60                                        $_POST['visibile'],
     61                                        $_POST['categoria'],
     62                                        $_POST['id_partita'],
     63                                        $this->opts->corrente   ) );
     64
     65        $row = $wpdb->get_row( $wpdb->prepare(" SELECT `{$this->prefix}partite`.*,
     66                                                        `sq1`.`label` AS `label_1`,
     67                                                        `sq2`.`label` AS `label_2`
     68                                                FROM `{$this->prefix}partite`
     69                                                LEFT JOIN `{$this->prefix}squadre` AS `sq1`
     70                                                    ON `{$this->prefix}partite`.`squadra_1`=`sq1`.`id`
     71                                                LEFT JOIN `{$this->prefix}squadre` AS `sq2`
     72                                                    ON `{$this->prefix}partite`.`squadra_2`=`sq2`.`id`
     73                                                WHERE `{$this->prefix}partite`.`categoria` = %s
     74                                                    AND `{$this->prefix}partite`.`finale` = %s
     75                                                    AND `{$this->prefix}partite`.`tornei_id` = %d",
     76                                                $_POST['categoria'],
     77                                                $_POST['id_partita'],
     78                                                $this->opts->corrente ) );
    1479       
    15 //      $this->trigger( 'rigenerapartitegironi', array( $this, 'rigenera_partite_gironi' ), '?page=VolleyTNT_Partite' );
    16        
    17 //      add_action( 'wp_ajax_volleytnt_salvapartita',       array( $this, 'ajax_salvapartita' ) );
     80        $row->set1 = $row->set2 = 0;
     81        if ( !$row->set1_sq1 and !$row->set1_sq2 ) {
     82            $row->set1_sq1 = $row->set1_sq2 = '';
     83        } else if ( $row->set1_sq1 > $row->set1_sq2 ) $row->set1++; else $row->set2++;
     84        if ( !$row->set2_sq1 and !$row->set2_sq2 ) {
     85            $row->set2_sq1 = $row->set2_sq2 = '';
     86        } else if ( $row->set2_sq1 > $row->set2_sq2 ) $row->set1++; else $row->set2++;
     87        if ( !$row->set3_sq1 and !$row->set3_sq2 ) {
     88            $row->set3_sq1 = $row->set3_sq2 = '';
     89        } else if ( $row->set3_sq1 > $row->set3_sq2 ) $row->set1++; else $row->set2++;
     90        if ( $this->torneo->set_partita == 5 ) {
     91            if ( !$row->set4_sq1 and !$row->set4_sq2 ) {
     92                $row->set4_sq1 = $row->set4_sq2 = '';
     93            } else if ( $row->set4_sq1 > $row->set4_sq2 ) $row->set1++; else $row->set2++;
     94            if ( !$row->set5_sq1 and !$row->set5_sq2 ) {
     95                $row->set5_sq1 = $row->set5_sq2 = '';
     96            } else if ( $row->set5_sq1 > $row->set5_sq2 ) $row->set1++; else $row->set2++;
     97        }
     98               
     99        if ( !$row->set1 and !$row->set2 ) $row->set1 = $row->set2 = '';
     100        die( json_encode( $row ) );
    18101    }
    19102   
    20103    public function firstpage() {
    21104        $tree = new VolleyTNT_Tree();
    22         $tree->show( 'M' );
     105       
     106        echo '<div class="tabbor"><ul>';
     107        foreach ( $this->torneo->categorie as $categoria ) {
     108            echo '<li><a href="#tab' . $categoria . '">' . $this->l_categorie[ $categoria ] . '</a></li>';
     109        }
     110        echo '</ul>';
     111        foreach ( $this->torneo->categorie as $categoria ) {
     112            echo '<div id="tab' . $categoria . '">';
     113            $tree->show( $categoria );
     114            echo '</div>'; 
     115        }
     116        echo '</div>';
     117       
     118        ?>
     119<script type="text/javascript">var squadre = <?php echo json_encode( $tree->squadre ); ?>;</script>
     120<form id="formfinale" title="<?php echo esc_attr( __('Modifica partita', 'volleytnt' ) ); ?>" categoria="" id_partita="">
     121<table class="widefat">
     122<thead>
     123<tr>
     124<th><?php echo __('Squadra', 'volleytnt'); ?></th>
     125<th class="punti"><?php printf( __('%d&ordm; set', 'volleytnt'), 1 ); ?></th>
     126<th class="punti"><?php printf( __('%d&ordm; set', 'volleytnt'), 2 ); ?></th>
     127<th class="punti"><?php printf( __('%d&ordm; set', 'volleytnt'), 3 ); ?></th>
     128<?php if ( $this->torneo->set_partita == 5 ) { ?>
     129    <th class="punti"><?php printf( __('%d&ordm; set', 'volleytnt'), 4 ); ?></th>
     130    <th class="punti"><?php printf( __('%d&ordm; set', 'volleytnt'), 5 ); ?></th>
     131<?php } ?>
     132</tr>
     133</thead>
     134<tbody>
     135<tr>
     136<td><select class="squadra_1" tabindex="1"></select></td>
     137<td><input type="text" class="punti set1_sq1" tabindex="3"></td>
     138<td><input type="text" class="punti set2_sq1" tabindex="5"></td>
     139<td><input type="text" class="punti set3_sq1" tabindex="7"></td>
     140<?php if ( $this->torneo->set_partita == 5 ) { ?>
     141    <td><input type="text" class="punti set4_sq1" tabindex="9"></td>
     142    <td><input type="text" class="punti set5_sq1" tabindex="11"></td>
     143<?php } ?>
     144</tr>
     145<tr>
     146<td><select class="squadra_2" tabindex="2"></select></td>
     147<td><input type="text" class="punti set1_sq2" tabindex="4"></td>
     148<td><input type="text" class="punti set2_sq2" tabindex="6"></td>
     149<td><input type="text" class="punti set3_sq2" tabindex="8"></td>
     150<?php if ( $this->torneo->set_partita == 5 ) { ?>
     151    <td><input type="text" class="punti set4_sq2" tabindex="10"></td>
     152    <td><input type="text" class="punti set5_sq2" tabindex="12"></td>
     153<?php } ?>
     154</tr>
     155</tbody>
     156</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>
     159</form>
     160        <?php
    23161    }
    24162}
  • volleytnt/trunk/admin/volleytnt_opzioni.php

    r574270 r575704  
    5858        echo '<dd>' . __("La durata media di un incontro in minuti, valore di riferimento usato per la pianificazione del calendario partite.", 'volleytnt') . '</dd>';
    5959        echo '<dt>' . __("Finali", 'volleytnt') . '<dt>';
    60         echo '<dd>' . __("La prima fase giocata delle finali a eliminazione diretta.", 'volleytnt') . '</dd>';
     60        echo '<dd>' . __("La prima fase giocata delle finali a eliminazione diretta. Sono possibili valori differenti per ogni categoria.", 'volleytnt') . '</dd>';
    6161        echo '</dl>';
    6262    }
    6363
    6464    public function translate_finali( $num ) {
    65         return $this->l_finali[ $num ];
     65        return ( $num and isset( $this->l_finali[ $num ] ) ) ? $this->l_finali[ $num ] : '';
    6666    }
    6767
     
    7878    public function salva_slots( $slots ) {
    7979        global $wpdb;
     80        $slots['id'] = absint( $slots['id'] );
    8081        $torneo = $wpdb->get_row("SELECT * FROM `{$this->prefix}tornei` WHERE `id`={$slots['id']}");
    8182        if ( $torneo ) {
     
    233234                        'campi'         => __("Campi", 'volleytnt' ),
    234235                        'durata_turno'  => __("Durata turno", 'volleytnt'),
    235                         'finali'        => __("Finali", 'volleytnt' ) );
     236                        'finali_M'      => __("Finali maschile", 'volleytnt' ),
     237                        'finali_F'      => __("Finali femminile", 'volleytnt' ),
     238                        'finali_X'      => __("Finali misto", 'volleytnt' ) );
    236239        $table = new VolleyTNT_Table( 'vtnt_opts', $cols, "SELECT * FROM `{$this->prefix}tornei` ORDER BY `id` ASC" );
    237240        $table->add_action( $this->url( 'edit', '%id%' ), __("Modifica", 'volleytnt') );
    238241        $table->add_action( $this->url( 'timespan', '%id%' ), __("Giorni e ore", 'volleytnt') );
    239242        $table->add_action( $this->url( 'delete', '%id%' ), __("Elimina", 'volleytnt'), 'delete', 'conferma_elimina_torneo' );
    240         $table->add_filter( 'finali', array( $this, 'translate_finali' ) );
     243        $table->add_filter( 'finali_M', array( $this, 'translate_finali' ) );
     244        $table->add_filter( 'finali_F', array( $this, 'translate_finali' ) );
     245        $table->add_filter( 'finali_X', array( $this, 'translate_finali' ) );
    241246        $table->add_filter( 'set_partita', array( $this, 'translate_set_partita' ) );
    242247        $table->add_filter( 'categorie', array( $this, 'translate_categorie' ) );
     
    270275        $form->add_element( 'string', 'campi', __("Numero di campi", 'volleytnt'), __("Su quanti campi si svolge il torneo.", 'volleytnt') );
    271276        $form->add_element( 'string', 'durata_turno', __("Durata del turno in minuti", 'volleytnt'), __("Durata indicativa della partita media, usata per il calcolo degli orari.", 'volleytnt') );
    272         $form->add_element( 'select', 'finali', __("Prima fase delle finali", 'volleytnt'), __("Determina quante squadre passano alle finali a eliminazione diretta. ", 'volleytnt'), $this->l_finali );
     277        $form->add_element( 'select', 'finali_M', __("Prima fase delle finali maschili", 'volleytnt'), __("Determina quante squadre passano alle finali a eliminazione diretta. ", 'volleytnt'), $this->l_finali );
     278        $form->add_element( 'select', 'finali_F', __("Prima fase delle finali femminili", 'volleytnt'), __("Determina quante squadre passano alle finali a eliminazione diretta. ", 'volleytnt'), $this->l_finali );
     279        $form->add_element( 'select', 'finali_X', __("Prima fase delle finali misto", 'volleytnt'), __("Determina quante squadre passano alle finali a eliminazione diretta. ", 'volleytnt'), $this->l_finali );
    273280        $form->show();
    274281    }
     
    299306    public function salva_torneo( $data, $id ) {
    300307        global $wpdb;
     308        if ( !in_array( 'M', $data['categorie'] ) ) $data['finali_M'] = 0;
     309        if ( !in_array( 'F', $data['categorie'] ) ) $data['finali_F'] = 0;
     310        if ( !in_array( 'X', $data['categorie'] ) ) $data['finali_X'] = 0;
    301311        $data['categorie'] = implode( ',', $data['categorie'] );
    302312        $id = intval( $data['id'] );
  • volleytnt/trunk/admin/volleytnt_partite.php

    r574270 r575704  
    6464       
    6565        $tokens = array();
    66         if ( $categorie ) foreach ( $categorie as $categoria ) {
    67             if ( $this->torneo->finali >= 32 ) for ( $i = 1; $i <= 32; $i++ ) $tokens[] = "('$categoria', '32_{$i}', {$this->opts->corrente})";
    68             if ( $this->torneo->finali >= 16 ) for ( $i = 1; $i <= 16; $i++ ) $tokens[] = "('$categoria', '16_{$i}', {$this->opts->corrente})";
    69             if ( $this->torneo->finali >= 8 ) for ( $i = 1; $i <= 8; $i++ ) $tokens[] = "('$categoria', '8_{$i}', {$this->opts->corrente})";
    70             if ( $this->torneo->finali >= 4 ) for ( $i = 1; $i <= 4; $i++ ) $tokens[] = "('$categoria', '4_{$i}', {$this->opts->corrente})";
    71             if ( $this->torneo->finali >= 2 ) for ( $i = 1; $i <= 2; $i++ ) $tokens[] = "('$categoria', '2_{$i}', {$this->opts->corrente})";
    72             $tokens[] = "('$categoria', '1_1', {$this->opts->corrente})";
     66        if ( $categorie ) foreach ( $categorie as $categoria ) if ( in_array( $categoria, $this->torneo->categorie ) ) {
     67            $attr = 'finali_' . $categoria;
     68            if ( $this->torneo->$attr >= 32 ) for ( $i = 1; $i <= 32; $i++ ) $tokens[] = "('$categoria', '32_{$i}', {$this->opts->corrente})";
     69            if ( $this->torneo->$attr >= 16 ) for ( $i = 1; $i <= 16; $i++ ) $tokens[] = "('$categoria', '16_{$i}', {$this->opts->corrente})";
     70            if ( $this->torneo->$attr >= 8 ) for ( $i = 1; $i <= 8; $i++ ) $tokens[] = "('$categoria', '8_{$i}', {$this->opts->corrente})";
     71            if ( $this->torneo->$attr >= 4 ) for ( $i = 1; $i <= 4; $i++ ) $tokens[] = "('$categoria', '4_{$i}', {$this->opts->corrente})";
     72            if ( $this->torneo->$attr >= 2 ) for ( $i = 1; $i <= 2; $i++ ) $tokens[] = "('$categoria', '2_{$i}', {$this->opts->corrente})";
     73            if ( $this->torneo->$attr >= 2 ) $tokens[] = "('$categoria', '1_1', {$this->opts->corrente})";
    7374            $tokens[] = "('$categoria', '0_1', {$this->opts->corrente})";
    7475        }
     
    130131        $slots = $wpdb->get_results("   SELECT
    131132                                            `id`,
     133                                            `giorno` AS `sql`,
    132134                                            DATE_FORMAT(`giorno`, '" . volleytnt_date_format('sql') . "') AS giorno,
    133135                                            DATE_FORMAT(`inizio`, '%k:%i') AS inizio,
     
    147149       
    148150        if ( $slots ) {
     151            $settimana = array( 1 => __('Lunedì', 'volleytnt' ),
     152                                2 => __('Martedì', 'volleytnt' ),
     153                                3 => __('Mercoledì', 'volleytnt' ),
     154                                4 => __('Giovedì', 'volleytnt' ),
     155                                5 => __('Venerdì', 'volleytnt' ),
     156                                6 => __('Sabato', 'volleytnt' ),
     157                                7 => __('Domenica', 'volleytnt' ) );
    149158            echo '<div class="accordion" id="accopartite">';
    150159            $inizi = $campi = $giorni = array();
     160            $labelgiorni = array();
    151161            foreach ( $slots as $slot ) {
    152162                $inizi[ $slot->ordo ] = $slot->inizio;
    153163                $campi[] = $slot->campo;
    154164                $giorni[] = $slot->giorno;
     165                if ( !isset( $labelgiorni[ $slot->giorno ] ) ) {
     166                    $d = new DateTime( $slot->sql );
     167                    $labelgiorni[ $slot->giorno ] = $settimana[ $d->format('N') ];
     168                    unset( $d );
     169                }
    155170            }
    156171            ksort( $inizi );
     
    213228
    214229    private function riga_partita( $par ) {
    215         echo '<div class="partita ui-corner-all ui-widget-content" partita_id="' . $par->id . '" impossibilita="' . $par->imps . '">';
     230        $class = $par->imps ? ' ui-state-focus' : '';
     231        echo '<div class="partita ui-corner-all ui-widget-content' . $class . '" partita_id="' . $par->id . '" impossibilita="' . $par->imps . '">';
    216232        echo '<span class="girone">' . $par->categoria;
    217233        if ( $par->girone ) echo $par->girone;
  • volleytnt/trunk/core/the_plugin.php

    r575201 r575704  
    2727        require_once( $this->path . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'adminpage.php' );
    2828
    29         add_action( 'init',                                 array( $this, 'init' ) );
    30         add_action( 'admin_menu',                           array( $this, 'admin_menu' ) );
    31         add_action( 'admin_enqueue_scripts',                array( $this, 'admin_enqueue_scripts' ) );
    32        
    33         add_filter( 'plugin_row_meta',                      array( $this, 'plugin_row_meta' ), 10, 4 );
     29        add_action( 'init',                     array( $this, 'init' ) );
     30        add_action( 'admin_menu',               array( $this, 'admin_menu' ) );
     31        add_action( 'admin_enqueue_scripts',    array( $this, 'admin_enqueue_scripts' ) );
     32        add_action( 'template_redirect',        array( $this, 'template_redirect' ) );
     33       
     34        add_filter( 'plugin_row_meta',          array( $this, 'plugin_row_meta' ), 10, 4 );
    3435
    3536        $this->register_page('VolleyTNT_Home');
     
    5051    }
    5152   
     53    public function template_redirect() {
     54        wp_enqueue_style('volleytnt_common');
     55    }
     56   
    5257    public function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) {
    5358        if ( $plugin_file === plugin_basename( VOLLEYTNT_PATH . '/volleytnt.php' ) ) {
     
    6873        $this->l_set_partita = array(   '3' => __("Alla meglio dei 3", 'volleytnt'),
    6974                                        '5' => __("Alla meglio dei 5", 'volleytnt') );
    70         $this->l_finali = array(        '32'=> __("Trentaduesimi di finale", 'volleytnt'),
    71                                         '16'=> __("Sedicesimi di finale", 'volleytnt'),
    72                                         '8' => __("Ottavi di finale", 'volleytnt'),
    73                                         '4' => __("Quarti di finale", 'volleytnt'),
     75        $this->l_finali = array(        '0' => __("Non giocato", 'volleytnt'),
     76                                        '1' => __("Finale", 'volleytnt'),
    7477                                        '2' => __("Semifinali", 'volleytnt'),
    75                                         '1' => __("Finale", 'volleytnt') );
     78                                        '4' => __("Quarti", 'volleytnt'),
     79                                        '8' => __("Ottavi", 'volleytnt'),
     80                                        '16'=> __("Sedicesimi", 'volleytnt'),
     81                                        '32'=> __("Trentaduesimi", 'volleytnt') );
    7682
    7783        wp_register_style( 'volleytnt_common', $this->url . '/style/common.css' );
     
    8692        $this->torneo->campi = absint( $this->torneo->campi );
    8793        $this->torneo->durata_turno = absint( $this->torneo->durata_turno );
    88         $this->torneo->finali = absint( $this->torneo->finali );
     94        $this->torneo->finali_M = absint( $this->torneo->finali_M );
     95        $this->torneo->finali_F = absint( $this->torneo->finali_F );
     96        $this->torneo->finali_X = absint( $this->torneo->finali_X );
    8997       
    9098        VolleyTNT_Form::manage_cbs_save();
     
    398406        return $_ . '</div>';
    399407    }
    400    
     408
     409
     410    public function sc_finali( $atts, $content = '' ) {
     411        global $wpdb;
     412        extract( shortcode_atts( array(
     413            'torneo' => $this->opts->corrente,
     414            'categoria' => false
     415        ), $atts ) );
     416       
     417        if ( !$torneo ) return '';
     418       
     419        ob_start();
     420        $tree = new VolleyTNT_Tree( $torneo );
     421       
     422        echo '<div class="volleytnt_sc_finali">';
     423        $cats = $categoria ? array( $categoria ) : $tree->torneo->categorie;
     424       
     425        foreach ( $cats as $cat ) {
     426            echo '<div class="albero finali_' . $cat . '">';
     427            echo '<h3>' . $this->l_categorie[ $cat ] . '</h3>';
     428            $tree->show( $cat );
     429            echo '</div>'; 
     430        }
     431       
     432        echo '</div>';
     433        return ob_get_clean();
     434    }
    401435   
    402436    public function sc_risultati( $atts, $content = '' ) {
     
    668702        $torneo = is_null( $torneo ) ?  $this->opts->corrente : absint( $torneo );
    669703        $this->torneo = $wpdb->get_row("SELECT * FROM `{$this->prefix}tornei` WHERE `id`={$torneo}");
     704        $this->torneo->categorie = explode( ',', $this->torneo->categorie );
    670705        if ( $tmp = $wpdb->get_results("SELECT * FROM `{$this->prefix}partite` WHERE `finale`<>'' AND `tornei_id`={$torneo} AND `visibile`=1" ) ) {
    671706            foreach ( $tmp as $row ) $this->finali[ $row->categoria ][ $row->finale ] = $row;
     
    708743            $p->set5_sq1 = '';
    709744            $p->set5_sq2 = '';
    710             $class = 'partita nongiocata____';
    711         }
    712        
    713             $p = new stdClass();
    714             $p->categoria = $categoria;
    715             $p->squadra_1 = 20;
    716             $p->squadra_2 = 22;
    717             $p->set1_sq1 = 21;
    718             $p->set1_sq2 = 12;
    719             $p->set2_sq1 = 12;
    720             $p->set2_sq2 = 21;
    721             $p->set3_sq1 = 21;
    722             $p->set3_sq2 = 12;
    723             $p->set4_sq1 = 12;
    724             $p->set4_sq2 = 21;
    725             $p->set5_sq1 = 21;
    726             $p->set5_sq2 = 12;
    727             $class = 'partita';
     745            $class = 'partita nongiocata';
     746        }
    728747
    729748        $p->set1 = $p->set2 = 0;
     
    731750        if ( $p->set2_sq1 or $p->set2_sq2 ) if ( $p->set2_sq1 > $p->set2_sq2 ) $p->set1++; else $p->set2++;
    732751        if ( $p->set3_sq1 or $p->set3_sq2 ) if ( $p->set3_sq1 > $p->set3_sq2 ) $p->set1++; else $p->set2++;
    733         if ( !$p->set1 and !$p->set2 ) $p->set1 = $p->set2 = $p->set1_sq1 = $p->set1_sq2 = $p->set2_sq1 = $p->set2_sq2 = $p->set3_sq1 = $p->set3_sq2 = '';
     752        if ( $this->torneo->set_partita == 5 ) {
     753            if ( $p->set4_sq1 or $p->set4_sq2 ) if ( $p->set4_sq1 > $p->set4_sq2 ) $p->set1++; else $p->set2++;
     754            if ( $p->set5_sq1 or $p->set5_sq2 ) if ( $p->set5_sq1 > $p->set5_sq2 ) $p->set1++; else $p->set2++;
     755        }
     756        if ( !$p->set1 and !$p->set2 ) $p->set1 = $p->set2 = $p->set1_sq1 = $p->set1_sq2 = $p->set2_sq1 = $p->set2_sq2 = $p->set3_sq1 = $p->set3_sq2 = $p->set4_sq1 = $p->set4_sq2 = $p->set5_sq1 = $p->set5_sq2 = '';
    734757        $class .= ' p' . $id;
    735758        ?>
     
    742765                    <span class="set set2 sq1 set2_sq1"><?php echo $p->set2_sq1; ?></span>
    743766                    <span class="set set3 sq1 set3_sq1"><?php echo $p->set3_sq1; ?></span>
     767                    <?php if ( $this->torneo->set_partita == 5 ) { ?>
     768                        <span class="set set4 sq1 set4_sq1"><?php echo $p->set4_sq1; ?></span>
     769                        <span class="set set5 sq1 set5_sq1"><?php echo $p->set5_sq1; ?></span>
     770                    <?php } ?>
    744771                </div>
    745772                <div class="sottoseparatore"></div>
     
    749776                    <span class="set set2 sq2 set2_sq2"><?php echo $p->set2_sq2; ?></span>
    750777                    <span class="set set3 sq2 set3_sq2"><?php echo $p->set3_sq2; ?></span>
     778                    <?php if ( $this->torneo->set_partita == 5 ) { ?>
     779                        <span class="set set4 sq2 set4_sq2"><?php echo $p->set4_sq2; ?></span>
     780                        <span class="set set5 sq2 set5_sq2"><?php echo $p->set5_sq2; ?></span>
     781                    <?php } ?>
    751782                </div>
    752783            </div>
     
    757788
    758789    public function show( $categoria ) {
    759         $this->torneo->finali = 32;
    760 
    761         echo '<div class="tabellonefinale base' . $this->torneo->finali . '">';
     790        $attr = 'finali_' . $categoria;
     791        echo '<div class="tabellonefinale base' . $this->torneo->$attr . '">';
    762792        echo '<div class="fasi">';
    763         if ( $this->torneo->finali >= 32 ) echo '<h4>' . __('Trentaduesimi', 'volleytnt') . '</h4>';
    764         if ( $this->torneo->finali >= 16 ) echo '<h4>' . __('Sedicesimi', 'volleytnt') . '</h4>';
    765         if ( $this->torneo->finali >= 8 ) echo '<h4>' . __('Ottavi', 'volleytnt') . '</h4>';
    766         if ( $this->torneo->finali >= 4 ) echo '<h4>' . __('Quarti', 'volleytnt') . '</h4>';
    767         if ( $this->torneo->finali >= 2 ) echo '<h4>' . __('Semifinali', 'volleytnt') . '</h4>';
    768         echo '<h4>' . __('Finalina', 'volleytnt') . '</h4>';
    769         echo '<h4>' . __('Finale', 'volleytnt') . '</h4>';
     793        if ( $this->torneo->$attr >= 32 ) echo '<h4 class="trentaduesimi">' . __('Trentaduesimi', 'volleytnt') . '</h4>';
     794        if ( $this->torneo->$attr >= 16 ) echo '<h4 class="sedicesimi">' . __('Sedicesimi', 'volleytnt') . '</h4>';
     795        if ( $this->torneo->$attr >= 8 ) echo '<h4 class="ottavi">' . __('Ottavi', 'volleytnt') . '</h4>';
     796        if ( $this->torneo->$attr >= 4 ) echo '<h4 class="quarti">' . __('Quarti', 'volleytnt') . '</h4>';
     797        if ( $this->torneo->$attr >= 2 ) echo '<h4 class="semifinali">' . __('Semifinali', 'volleytnt') . '</h4><h4 class="finalina">' . __('Finalina', 'volleytnt') . '</h4>';
     798        echo '<h4 class="finale">' . __('Finale', 'volleytnt') . '</h4>';
    770799        echo '<br style="clear:both" />';
    771800        echo '</div>';
    772801       
    773         if ( $this->torneo->finali >= 32 ) {
     802        if ( $this->torneo->$attr >= 32 ) {
    774803            echo '<div class="trentaduesimi colonna">';
    775804            for ( $i = 1; $i <= 32; $i++ ) $this->partita( $categoria, '32_' . $i );
    776805            echo '</div>';
    777806        }
    778         if ( $this->torneo->finali >= 16 ) {
     807        if ( $this->torneo->$attr >= 16 ) {
    779808            echo '<div class="sedicesimi colonna">';
    780809            for ( $i = 1; $i <= 16; $i++ ) $this->partita( $categoria, '16_' . $i );
    781810            echo '</div>';
    782811        }
    783         if ( $this->torneo->finali >= 8 ) {
     812        if ( $this->torneo->$attr >= 8 ) {
    784813            echo '<div class="ottavi colonna">';
    785814            for ( $i = 1; $i <= 8; $i++ ) $this->partita( $categoria, '8_' . $i );
    786815            echo '</div>';
    787816        }
    788         if ( $this->torneo->finali >= 4 ) {
     817        if ( $this->torneo->$attr >= 4 ) {
    789818            echo '<div class="quarti colonna">';
    790819            for ( $i = 1; $i <= 4; $i++ ) $this->partita( $categoria, '4_' . $i );
    791820            echo '</div>';
    792821        }
    793         if ( $this->torneo->finali >= 2 ) {
     822        if ( $this->torneo->$attr >= 2 ) {
    794823            echo '<div class="semifinali colonna">';
    795824            $this->partita( $categoria, '2_1' );
  • volleytnt/trunk/js/admin_partite.js

    r574270 r575704  
    11jQuery( function ( $ ) {
    22
    3     $('div.accordion').accordion( { collapsible: true } );
     3    $('div.accordion').accordion( { collapsible: true, autoHeight: false } );
    44   
    55    $('#rigenerapartitegironi').click( function () {
  • volleytnt/trunk/style/admin.css

    r574270 r575704  
    127127    height:21px;
    128128    width:270px;
     129    display:block;
    129130}
    130131
     
    138139    line-height:30px;
    139140}
     141
     142
     143.tabellonefinale .partita {
     144    cursor:pointer;
     145}
     146
     147.tabellonefinale .partita:hover {
     148    background-color:#ddd;
     149}
     150
     151#formfinale th.punti {
     152    width:60px;
     153}
     154
     155#formfinale input.punti {
     156    width:50px;
     157}
     158
     159#formfinale select {
     160    width:100%;
     161}
  • volleytnt/trunk/style/common.css

    r575201 r575704  
    66}
    77
     8.tabellonefinale .fasi h4 {
     9    text-align:center;
     10}
     11
    812.tabellonefinale .partita {
    913    -moz-border-radius: 8px;
     
    2428    font-weight: bold;
    2529    font-size:16px;
    26     margin-right: 5px;
     30    margin-right: 3px;
    2731}
    2832.tabellonefinale .partita .risultato.risultato1 {
     
    6670
    6771.tabellonefinale .partita .punti span {
    68     padding-right:4px;
     72    display: block;
     73    float: left;
     74    padding-right: 4px;
     75    text-align: right;
     76    width: 15px;
    6977}
    7078
  • volleytnt/trunk/volleytnt.php

    r472014 r575704  
    1414global $wp_version;
    1515
    16 if ( version_compare( $wp_version, '3.3-RC1', '>=' ) ) {
     16if ( version_compare( $wp_version, '3.3', '>=' ) ) {
    1717    require_once( VOLLEYTNT_PATH . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'the_plugin.php' );
    1818} else {
    1919    add_action( 'pre_current_active_plugins', create_function( '', 'echo \'<div class="error fade"><p><strong>Whoa! There is an error!</strong></p><p>VolleyTNT requires at least Wordpress 3.3 RC1. Please disable the plugin and upgrade your installation.</p></div>\';') );
    2020}
     21
     22function volleytnt_activation() {
     23    global $wpdb;
     24    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     25    $prefix = $wpdb->prefix . 'volleytnt_';
     26    $sql = array(
     27   
     28"CREATE TABLE `{$prefix}atleti` (
     29  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
     30  `nome` VARCHAR(100) NOT NULL,
     31  `cognome` VARCHAR(100) NOT NULL,
     32  `telefono` VARCHAR(100) NOT NULL,
     33  `mail` VARCHAR(100) NOT NULL,
     34  PRIMARY KEY (`id`)
     35) DEFAULT CHARSET=utf8",
     36
     37"CREATE TABLE `{$prefix}gironi` (
     38  `girone` TINYINT(3) UNSIGNED NOT NULL,
     39  `categoria` ENUM('M','F','X') NOT NULL DEFAULT 'M',
     40  `squadre_id` BIGINT(20) UNSIGNED NOT NULL,
     41  `tornei_id` BIGINT(20) UNSIGNED NOT NULL,
     42  PRIMARY KEY (`categoria`,`squadre_id`,`tornei_id`)
     43) DEFAULT CHARSET=utf8",
     44
     45"CREATE TABLE `{$prefix}impossibilita` (
     46  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
     47  `squadre_id` BIGINT(20) UNSIGNED NOT NULL,
     48  `giorno` DATE NOT NULL,
     49  `primadopo` ENUM('prima','dopo') NOT NULL DEFAULT 'prima',
     50  `ora` TIME NOT NULL DEFAULT '20:00:00',
     51  PRIMARY KEY (`id`)
     52) DEFAULT CHARSET=utf8",
     53
     54"CREATE TABLE `{$prefix}partite` (
     55  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
     56  `slots_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
     57  `categoria` ENUM('M','F','X') NOT NULL DEFAULT 'M',
     58  `girone` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     59  `finale` CHAR(5) NOT NULL DEFAULT '',
     60  `squadra_1` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
     61  `squadra_2` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
     62  `set1_sq1` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     63  `set1_sq2` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     64  `set2_sq1` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     65  `set2_sq2` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     66  `set3_sq1` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     67  `set3_sq2` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     68  `set4_sq1` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     69  `set4_sq2` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     70  `set5_sq1` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     71  `set5_sq2` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
     72  `tornei_id` BIGINT(20) UNSIGNED NOT NULL,
     73  `visibile` TINYINT(1) NOT NULL DEFAULT '1',
     74  PRIMARY KEY (`id`)
     75) DEFAULT CHARSET=utf8",
     76
     77"CREATE TABLE `{$prefix}slots` (
     78  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
     79  `giorno` DATE NOT NULL,
     80  `inizio` TIME NOT NULL,
     81  `fine` TIME NOT NULL,
     82  `tornei_id` BIGINT(20) UNSIGNED NOT NULL,
     83  `campo` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
     84  PRIMARY KEY (`id`)
     85) DEFAULT CHARSET=utf8",
     86
     87"CREATE TABLE `{$prefix}squadre` (
     88  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
     89  `label` VARCHAR(100) NOT NULL,
     90  `categoria` ENUM('M','F','X') NOT NULL DEFAULT 'M',
     91  `tornei_id` BIGINT(20) UNSIGNED NOT NULL,
     92  PRIMARY KEY (`id`)
     93) DEFAULT CHARSET=utf8",
     94
     95"CREATE TABLE `{$prefix}squadre_atleti` (
     96  `squadre_id` BIGINT(20) UNSIGNED NOT NULL,
     97  `atleti_id` BIGINT(20) UNSIGNED NOT NULL,
     98  `pagato` TINYINT(1) NOT NULL DEFAULT '0',
     99  `manleva` TINYINT(1) NOT NULL DEFAULT '0',
     100  PRIMARY KEY (`squadre_id`,`atleti_id`)
     101) DEFAULT CHARSET=utf8",
     102
     103"CREATE TABLE `{$prefix}tornei` (
     104  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
     105  `label` VARCHAR(100) NOT NULL,
     106  `categorie` SET('M','F','X') NOT NULL DEFAULT 'M,F',
     107  `set_partita` ENUM('3','5') NOT NULL DEFAULT '3',
     108  `campi` TINYINT(3) UNSIGNED NOT NULL DEFAULT '2',
     109  `durata_turno` TINYINT(3) UNSIGNED NOT NULL DEFAULT '30',
     110  `finali_M` ENUM('0','1','2','4','8','16','32') NOT NULL DEFAULT '0',
     111  `finali_F` ENUM('0','1','2','4','8','16','32') NOT NULL DEFAULT '0',
     112  `finali_X` ENUM('0','1','2','4','8','16','32') NOT NULL DEFAULT '0',
     113  PRIMARY KEY (`id`)
     114) DEFAULT CHARSET=utf8"
     115
     116    );
     117   
     118    foreach ( $sql as $s ) dbDelta( $s );
     119}
     120register_activation_hook( __FILE__, 'volleytnt_activation' );
    21121?>
Note: See TracChangeset for help on using the changeset viewer.