source: extensions/ContestResults/admin/results.php @ 9200

Last change on this file since 9200 was 9200, checked in by mistic100, 13 years ago

ContestResults :

  • Code revision
  • Add Letton (lv_LV) language, thanks to Aivars Baldone
  • Delete display options
  • Fix languages bugs
  • Improve public appearence
File size: 2.6 KB
Line 
1<?php
2if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4// +-----------------------------------------------------------------------+
5//                              Modification des résultats
6// +-----------------------------------------------------------------------+
7if (isset($_POST['results_modify'])) {
8        pwg_query("DELETE FROM " . CR_TABLE_2 . " WHERE `contest_id` = " . $_GET['contest_id'] .";");
9       
10        foreach ($_POST['results'] AS $i => $data) {
11                pwg_query("INSERT INTO " . CR_TABLE_2 . "
12                        (
13                                image_id,
14                                contest_id,
15                                rank,
16                                comment,
17                                author
18                        )
19                        VALUES(
20                                '" . $data['image_id'] ."',
21                                '" . $_GET['contest_id'] ."',
22                                '" . $data['rank'] ."',
23                                '" . $data['comment'] ."',
24                                '" . $data['author'] . "'
25                        );");
26        }
27       
28        redirect(CR_ADMIN . '&amp;tab=results&amp;contest_id=' . $_GET['contest_id']);
29}
30
31// +-----------------------------------------------------------------------+
32//                              Affichage des résultats
33// +-----------------------------------------------------------------------+
34// Nom du concours
35$query = "SELECT name FROM " . CR_TABLE_1 . " WHERE id = " . $_GET['contest_id'] . ";";
36$contest = pwg_db_fetch_assoc(pwg_query($query));
37
38$template->assign(array(
39        'NAME' => trigger_event('render_CR_content', $contest['name']),
40        'CONTEST_ID' => $_GET['contest_id']
41));
42
43// Résultats
44$results = pwg_query("SELECT * FROM " . CR_TABLE_2 . " WHERE contest_id = " . $_GET['contest_id'] . " ORDER BY rank;");
45
46while ($result = pwg_db_fetch_assoc($results)) {
47        $data = array(
48                'RANK' => $result['rank'],
49                'IMAGE_ID' => $result['image_id'],
50                'AUTHOR' => $result['author'],
51                'COMMENT' => $result['comment'],
52        );
53       
54        // Infos de l'image
55        $image = pwg_query("SELECT id, name, file, path, tn_ext
56                FROM " . IMAGES_TABLE . "
57                WHERE id = " . $result['image_id'] . ";");
58       
59        if (!pwg_db_num_rows($image)) {
60                $themeconf = $template->get_template_vars('themeconf');
61                $data['TN_SRC'] = $themeconf['admin_icon_dir'] . '/errors.png';
62                $data['IMAGE_NAME'] = 'N/A';
63                $page['errors'][] = l10n_dec('CR_id_unknown %d', 'CR_id_unknown %d', $result['image_id']);
64               
65        } else {
66                $image = pwg_db_fetch_assoc($image);
67                $data['TN_SRC'] = get_thumbnail_url($image);
68                $data['IMAGE_NAME'] = (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'];
69        }
70       
71        $template->append('results', $data);
72}
73
74// +-----------------------------------------------------------------------+
75//                              Template
76// +-----------------------------------------------------------------------+
77$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/results.tpl'));
78$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
79?>
Note: See TracBrowser for help on using the repository browser.