source: extensions/ContestResults/include/cr_main.php @ 9975

Last change on this file since 9975 was 9975, checked in by mistic100, 13 years ago
  • many corrections
File size: 2.3 KB
RevLine 
[6768]1<?php 
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4// +-----------------------------------------------------------------------+
[9200]5//                              Liste des concours
[6768]6// +-----------------------------------------------------------------------+
[9200]7$contests = pwg_query("SELECT
8                id,
9                name,
10                visible,
11                date_begin,
12                date_end,
13                logo,
14                summary
15        FROM " . CR_TABLE_1 . "
16        ORDER BY date_begin DESC;");
[6768]17
[9200]18while ($contest = pwg_db_fetch_assoc($contests)) {
[9745]19        $contest = array_merge($contest, get_contest_status($contest['date_begin'],$contest['date_end']));
20               
[9200]21        if ($contest['visible'] OR is_admin()) {
[6768]22                // infos sur le concours
23                $item =  array(
24                        'ID' => $contest['id'],
[9975]25                        'NAME' => trigger_event('render_element_name', $contest['name']),
[6768]26                        'VISIBLE' => $contest['visible'],
[9745]27                        'STATUS' => $contest['status'],
[6768]28                        'DATE_END' => format_date($contest['date_end']),
29                        'DATE_BEGIN' => format_date($contest['date_begin']),
30                        'LOGO' => $contest['logo'],
[9975]31                        'SUMMARY' => CR_cut_string(trigger_event('render_category_name', $contest['summary']), $conf['ContestResults']['truncate_summary']),
32                        'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_category_name', $contest['name'])),
[9745]33                        'DAYS' => $contest['days'],
[6768]34                );
35               
[9975]36                // podium si terminé
[9745]37                if ($contest['status'] == 'finished') {
[9200]38                        $results = pwg_query("SELECT
[6768]39                                        i.id,
40                                        i.name,
41                                        i.file,
42                                        i.path,
43                                        i.tn_ext,
44                                        c.rank,
45                                        c.author
46                                FROM " . IMAGES_TABLE . " AS i
47                                INNER JOIN " . CR_TABLE_2 . " AS c
48                                ON c.image_id = i.id
49                                WHERE c.contest_id = " . $contest['id'] . "
50                                ORDER BY c.rank ASC
[9200]51                                LIMIT 3 OFFSET 0;");
[6768]52                       
[9200]53                        while ($result = pwg_db_fetch_assoc($results)) {
[6768]54                                $item['RESULTS'][$result['rank']] = array(
55                                        'RANK' => $result['rank'],
56                                        'AUTHOR' => $result['author'],
57                                        'TN_SRC' => get_thumbnail_url($result)
58                                );
59                        }
60                }
61
[9200]62                $template->append('contests', $item);
[6768]63        }
64}
65
66$template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_main.tpl'));
67
68// +-----------------------------------------------------------------------+
69//                              Template
70// +-----------------------------------------------------------------------+
[9572]71if (is_admin()) {
72        $template->assign('U_EDIT', CR_ADMIN);
73}
[6768]74$template->assign('CR_PATH', CR_PATH);
75$template->assign('SEPARATOR', $conf['level_separator']);
76?>
Note: See TracBrowser for help on using the repository browser.