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