Ignore:
Timestamp:
Mar 8, 2011, 1:19:06 PM (13 years ago)
Author:
mistic100
Message:

[extensions] ContestResults 1.3

  • Add error and success messages on admin page
  • Add Spain (es_ES) thanks to jpr928
  • Contest status is automatic and shows remaining days
  • More flexibility for description fields
  • Compatibility with Piwigo 2.2.0
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ContestResults/maintain.inc.php

    r9333 r9572  
    33
    44// Configuration par défaut
    5 define('default_config' , serialize(array(
     5define('default_config', serialize(array(
    66        'menubar_mode' => array(
    77                'link' => 0,
     
    2626                `date_begin` DATE NOT NULL ,
    2727                `date_end` DATE NOT NULL ,
    28                 `status` VARCHAR( 255 ) NOT NULL ,
    2928                `visible` TINYINT(1) NOT NULL ,
    3029                `logo` VARCHAR( 255 ) NULL ,
    3130                `banner` VARCHAR( 255 ) NULL ,
    32                 `summary` TEXT NULL ,
    33                 `presentation` TEXT NULL ,
    34                 `rules` TEXT NULL ,
    35                 `prices` TEXT NULL ,
    36                 `final` TEXT NULL ,
     31                `description` TEXT NULL ,
    3732                PRIMARY KEY ( `id` )
    3833        );");
     
    6257        $field = pwg_query("SHOW COLUMNS FROM `" . $prefixeTable . "contests` LIKE 'presentation_display'");
    6358        if (pwg_db_num_rows($field)) {
    64                 pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `presentation_display`");
    65                 pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `rules_display`");
    66                 pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `prices_display`");
    67                 pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `final_display`");
     59                pwg_query("ALTER TABLE `" . $prefixeTable . "contests`
     60                        DROP `presentation_display`,
     61                        DROP `rules_display`,
     62                        DROP `prices_display`,
     63                        DROP `final_display`;"
     64                );
    6865        }
     66       
     67        // compatibilité avec les versions < 1.3 (suppression option status, regroupement des champs de description)
     68        $field = pwg_query("SHOW COLUMNS FROM `" . $prefixeTable . "contests` LIKE 'status'");
     69        if (pwg_db_num_rows($field)) {
     70                pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `status`");
     71                pwg_query("ALTER TABLE `" . $prefixeTable . "contests` ADD `description` TEXT NULL");
     72               
     73                $contests = pwg_query("SELECT * FROM `" . $prefixeTable . "contests`");
     74                while ($contest = pwg_db_fetch_assoc($contests)) {
     75                        $new_description = array();
     76                        if (!empty($contest['presentation'])) {
     77                                $new_description[] = array(
     78                                        'name' => 'Presentation[lang=fr]Présentation[/lang][lang=es]Presentación[/lang][lang=lv]Prezentacija[/lang]',
     79                                        'content' => $contest['presentation'],
     80                                );
     81                        }
     82                        if (!empty($contest['rules'])) {
     83                                $new_description[] = array(
     84                                        'name' => 'Rules[lang=fr]Règles[/lang][lang=es]Restricciones[/lang][lang=lv]Noteikumi[/lang]',
     85                                        'content' => $contest['rules'],
     86                                );
     87                        }
     88                        if (!empty($contest['prices'])) {
     89                                $new_description[] = array(
     90                                        'name' => 'Prices[lang=fr]Prix[/lang][lang=es]Precios[/lang][lang=lv]Cenas[/lang]',
     91                                        'content' => $contest['prices'],
     92                                );
     93                        }
     94                        if (!empty($contest['final'])) {
     95                                $new_description[] = array(
     96                                        'name' => 'Conclusion[lang=fr]Conclusion[/lang][lang=es]Conclusión[/lang][lang=lv]Beigsana[/lang]',
     97                                        'content' => $contest['final'],
     98                                );
     99                        }
     100               
     101                        $new_description = base64_encode(serialize($new_description));
     102                        pwg_query("UPDATE `" . $prefixeTable . "contests`
     103                                SET description = '". $new_description ."'
     104                                WHERE id = ". $contest['id'] .";"
     105                        );
     106                }
     107               
     108                pwg_query("ALTER TABLE `" . $prefixeTable . "contests`
     109                        DROP `presentation`,
     110                        DROP `rules`,
     111                        DROP `prices`,
     112                        DROP `final`;"
     113                );
     114        }
     115       
    69116}
    70117
Note: See TracChangeset for help on using the changeset viewer.