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