1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // Page d'un concours |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | if (is_admin()) { |
---|
8 | $template->assign('U_EDIT', CR_ADMIN . '-edit&contest_id=' . $page['contest'] . '&redirect=page'); |
---|
9 | $template->assign('U_RESULTS', CR_ADMIN . '-results&contest_id=' . $page['contest'] . '&redirect=page'); |
---|
10 | } |
---|
11 | |
---|
12 | // Infos du concours |
---|
13 | $contest = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . CR_TABLE_1 . " WHERE id=" . $page['contest'] . ";")); |
---|
14 | $contest = array_merge($contest, get_contest_status($contest['date_begin'],$contest['date_end'])); |
---|
15 | |
---|
16 | // Concours non-publique |
---|
17 | if (!$contest['visible']) { |
---|
18 | check_status(ACCESS_ADMINISTRATOR); |
---|
19 | } |
---|
20 | |
---|
21 | // Paramètres généraux |
---|
22 | $template->assign(array( |
---|
23 | 'ID' => $contest['id'], |
---|
24 | 'NAME' => trigger_event('render_category_name', $contest['name']), |
---|
25 | 'VISIBLE' => $contest['visible'], |
---|
26 | 'STATUS' => $contest['status'], |
---|
27 | 'DATE_BEGIN' => format_date($contest['date_begin']), |
---|
28 | 'DATE_END' => format_date($contest['date_end']), |
---|
29 | 'LOGO' => $contest['logo'], |
---|
30 | 'BANNER' => $contest['banner'], |
---|
31 | 'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_category_name', $contest['name'])), |
---|
32 | 'DAYS' => $contest['days'], |
---|
33 | )); |
---|
34 | |
---|
35 | // Les quatre zones texte |
---|
36 | if (!empty($contest['description'])) { |
---|
37 | $contest['description'] = unserialize(base64_decode($contest['description'])); |
---|
38 | foreach ($contest['description'] as $desc) { |
---|
39 | $template->append('description', array( |
---|
40 | 'NAME' => trigger_event('render_category_name', stripslashes($desc['name'])), |
---|
41 | 'CONTENT' => trigger_event('render_category_name', stripslashes($desc['content'])), |
---|
42 | )); |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | // Affichage des résultats |
---|
47 | if ($contest['status'] == 'finished') { |
---|
48 | // Infos des résultats |
---|
49 | $results = pwg_query("SELECT * FROM " . CR_TABLE_2 . " WHERE contest_id=" . $contest['id'] . " ORDER BY rank ASC;"); |
---|
50 | $i=0; |
---|
51 | while ($result = pwg_db_fetch_assoc($results)) { |
---|
52 | $i++; |
---|
53 | // Infos de l'image |
---|
54 | $query = "SELECT |
---|
55 | i.id, |
---|
56 | i.name, |
---|
57 | i.file, |
---|
58 | i.path, |
---|
59 | i.tn_ext, |
---|
60 | ic.category_id |
---|
61 | FROM " . IMAGES_TABLE . " AS i |
---|
62 | INNER JOIN " . IMAGE_CATEGORY_TABLE . " AS ic |
---|
63 | ON ic.image_id = i.id |
---|
64 | WHERE i.id = " . $result['image_id'] . ";"; |
---|
65 | $image = pwg_db_fetch_assoc(pwg_query($query)); |
---|
66 | |
---|
67 | // retrieving category informations |
---|
68 | $query = "SELECT |
---|
69 | id, |
---|
70 | name, |
---|
71 | permalink, |
---|
72 | uppercats |
---|
73 | FROM " . CATEGORIES_TABLE." |
---|
74 | WHERE id = " . $image['category_id'] . ";"; |
---|
75 | $image['cat'] = pwg_db_fetch_assoc(pwg_query($query)); |
---|
76 | |
---|
77 | // link to the full size picture |
---|
78 | $image['url'] = make_picture_url(array( |
---|
79 | 'category' => $image['cat'], |
---|
80 | 'image_id' => $image['id'], |
---|
81 | 'image_file' => $image['file'], |
---|
82 | )); |
---|
83 | |
---|
84 | // Template |
---|
85 | if (in_array($result['rank'], array(1,2,3))) { |
---|
86 | $data = array( |
---|
87 | 'RANK' => $result ['rank'], |
---|
88 | 'AUTHOR' => $result['author'], |
---|
89 | 'IMAGE_SRC' => str_replace('thumbnail/'.$conf['prefix_thumbnail'], null, get_thumbnail_url($image)), |
---|
90 | 'IMAGE_URL' => $image['url'], |
---|
91 | 'IMAGE_NAME' => (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'], |
---|
92 | 'COMMENT' => CR_cut_string(trigger_event('render_category_name', $result['comment']), 450), |
---|
93 | ); |
---|
94 | }else{ |
---|
95 | $data = array( |
---|
96 | 'RANK' => $result ['rank'], |
---|
97 | 'AUTHOR' => $result['author'], |
---|
98 | 'TN_SRC' => get_thumbnail_url($image), |
---|
99 | 'IMAGE_URL' => $image['url'], |
---|
100 | 'IMAGE_NAME' => (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'], |
---|
101 | ); |
---|
102 | } |
---|
103 | $template->append('RESULTS', $data); |
---|
104 | } |
---|
105 | $template->assign('NB_RESULTS', $i); |
---|
106 | } |
---|
107 | |
---|
108 | $template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_page.tpl')); |
---|
109 | |
---|
110 | |
---|
111 | // +-----------------------------------------------------------------------+ |
---|
112 | // Template |
---|
113 | // +-----------------------------------------------------------------------+ |
---|
114 | $template->assign('CR_PATH', CR_PATH); |
---|
115 | $template->assign('SEPARATOR', $conf['level_separator']); |
---|
116 | ?> |
---|