1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // Liste des concours |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
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;"); |
---|
17 | |
---|
18 | while ($contest = pwg_db_fetch_assoc($contests)) { |
---|
19 | $contest = array_merge($contest, get_contest_status($contest['date_begin'],$contest['date_end'])); |
---|
20 | |
---|
21 | if ($contest['visible'] OR is_admin()) { |
---|
22 | // infos sur le concours |
---|
23 | $item = array( |
---|
24 | 'ID' => $contest['id'], |
---|
25 | 'NAME' => trigger_event('render_element_name', $contest['name']), |
---|
26 | 'VISIBLE' => $contest['visible'], |
---|
27 | 'STATUS' => $contest['status'], |
---|
28 | 'DATE_END' => format_date($contest['date_end']), |
---|
29 | 'DATE_BEGIN' => format_date($contest['date_begin']), |
---|
30 | 'LOGO' => $contest['logo'], |
---|
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'])), |
---|
33 | 'DAYS' => $contest['days'], |
---|
34 | ); |
---|
35 | |
---|
36 | // podium si terminé |
---|
37 | if ($contest['status'] == 'finished') { |
---|
38 | $results = pwg_query("SELECT |
---|
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 |
---|
51 | LIMIT 3 OFFSET 0;"); |
---|
52 | |
---|
53 | while ($result = pwg_db_fetch_assoc($results)) { |
---|
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 | |
---|
62 | $template->append('contests', $item); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | $template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_main.tpl')); |
---|
67 | |
---|
68 | // +-----------------------------------------------------------------------+ |
---|
69 | // Template |
---|
70 | // +-----------------------------------------------------------------------+ |
---|
71 | if (is_admin()) { |
---|
72 | $template->assign('U_EDIT', CR_ADMIN); |
---|
73 | } |
---|
74 | $template->assign('CR_PATH', CR_PATH); |
---|
75 | $template->assign('SEPARATOR', $conf['level_separator']); |
---|
76 | ?> |
---|