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