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/admin/new.php

    r9419 r9572  
    11<?php
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    3 
    4 // Les quatre zones de texte principales
    5 $textareas = array('presentation','rules','prices','final');
    63
    74// +-----------------------------------------------------------------------+
     
    107if (isset($_POST['new_submit'])) {
    118        if ($_POST['name'] != null) {
     9                // Mise en forme des descriptions
     10                if (isset($_POST['description'])) {
     11                        $new_description = array();
     12                        foreach ($_POST['description'] as $data) {
     13                                $new_description[] = array(
     14                                        'name' => $data['name'],
     15                                        'content' => $data['content']
     16                                );
     17                        }
     18                        // encoder le tableau sérialisé est le seul moyen que j'ai trouvé pour pas perdre les caractères spéciaux et planter unserialize
     19                        $_POST['description'] = base64_encode(serialize($new_description));
     20                }
     21                       
    1222                // Modification d'un concours
    13                 if (isset($_GET['contest_id'])) {
     23                if (isset($_GET['contest_id'])) {       
    1424                        pwg_query("UPDATE " . CR_TABLE_1 . " SET
    1525                                `name` = '" . $_POST['name'] ."',
    16                                 `status` = '" . $_POST['status'] ."',
    1726                                `visible` = '" . $_POST['visible'] ."',
    1827                                `date_begin` = '" . $_POST['date_begin'] ."',
     
    2130                                `banner` = '" . $_POST['banner'] ."',
    2231                                `summary` = '" . $_POST['summary'] ."',
    23                                 `presentation` = '" . $_POST['presentation'] ."',
    24                                 `rules` = '" . $_POST['rules'] ."',
    25                                 `prices` = '" . $_POST['prices'] ."',
    26                                 `final` = '" . $_POST['final'] ."'
     32                                `description` = '" . $_POST['description'] ."'
    2733                        WHERE `id` = " . $_GET['contest_id'] .";");
    2834                       
     
    4147                                        date_begin,
    4248                                        date_end,
    43                                         status,
    4449                                        visible,
    4550                                        logo,
    4651                                        banner,
    4752                                        summary,
    48                                         presentation,
    49                                         rules,
    50                                         prices,
    51                                         final
     53                                        description
    5254                                )
    5355                                VALUES(
     
    5557                                        '" . $_POST['date_begin'] ."',
    5658                                        '" . $_POST['date_end'] ."',
    57                                         '" . $_POST['status'] ."',
    5859                                        '" . $_POST['visible'] ."',
    5960                                        '" . $_POST['logo'] ."',
    6061                                        '" . $_POST['banner'] ."',
    6162                                        '" . $_POST['summary'] ."',
    62                                         '" . $_POST['presentation'] ."',
    63                                         '" . $_POST['rules'] ."',
    64                                         '" . $_POST['prices'] ."',
    65                                         '" . $_POST['final'] ."'
     63                                        '" . $_POST['description'] ."'
    6664                                );");
    6765                        redirect(CR_ADMIN .'&amp;tab=manage&amp;msg=added');
     
    7775//                              Définition des variables template
    7876// +-----------------------------------------------------------------------+   
    79 // Formulaire incomplet
     77// Formulaire incomplet ##############################################################################################################################################################
    8078if ($page['errors']) {
    8179        $template->assign(array(
    8280                'NAME' => $_POST['name'],
    83                 'STATUS' => $_POST['status'],
    8481                'VISIBLE' => $_POST['visible'],
    8582                'DATE_BEGIN' => $_POST['date_begin'],
     
    9087        ));
    9188       
    92         foreach ($textareas AS $key) {
    93                 $template->assign(strtoupper($key), $_POST[$key]);
     89        if (isset($_POST['description'])) {
     90                $i=0;
     91                foreach ($_POST['description'] as $data) {
     92                        $template->append('description', array(
     93                                        'NAME' => $data['name'],
     94                                        'CONTENT' => $data['content'],
     95                                        'RANK' => $i,
     96                        ));
     97                        $i++;
     98                }
    9499        }
    95100
     
    102107                'ID' => $contest['id'],
    103108                'NAME' => $contest['name'],
    104                 'STATUS' => $contest['status'],
    105109                'VISIBLE' => $contest['visible'],
    106110                'DATE_BEGIN' => $contest['date_begin'],
     
    111115        ));
    112116       
    113         foreach ($textareas AS $key) {
    114                 $template->assign(strtoupper($key), $contest[$key]);
     117        if ($contest['description'] != null) {
     118                $contest['description'] = unserialize(base64_decode($contest['description']));
     119                $i=0;
     120                foreach ($contest['description'] AS $desc) {
     121                        $template->append('description', array(
     122                                'NAME' => stripslashes($desc['name']),
     123                                'CONTENT' => stripslashes($desc['content']),
     124                                'RANK' => $i,
     125                        ));
     126                        $i++;
     127                }
    115128        }
    116129
     
    119132        $template->assign(array(
    120133                'NAME' => null,
    121                 'STATUS' => 'pending',
    122134                'VISIBLE' => 1,
    123135                'DATE_BEGIN' => date('Y-m-d'),
     
    127139                'SUMMARY' => null,
    128140        ));
    129        
    130         foreach ($textareas AS $key) {
    131                 $template->assign(strtoupper($key), null);
    132         }
    133141}
    134142
Note: See TracChangeset for help on using the changeset viewer.