[6768] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[9200] | 5 | // Page d'un concours |
---|
[6768] | 6 | // +-----------------------------------------------------------------------+ |
---|
[9200] | 7 | if (is_admin()) { |
---|
[9745] | 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'); |
---|
[6768] | 10 | } |
---|
| 11 | |
---|
| 12 | // Infos du concours |
---|
[9745] | 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'])); |
---|
[6768] | 15 | |
---|
[9745] | 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'], |
---|
[9975] | 24 | 'NAME' => trigger_event('render_category_name', $contest['name']), |
---|
[9745] | 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'], |
---|
[9975] | 31 | 'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_category_name', $contest['name'])), |
---|
[9745] | 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( |
---|
[9975] | 40 | 'NAME' => trigger_event('render_category_name', stripslashes($desc['name'])), |
---|
| 41 | 'CONTENT' => trigger_event('render_category_name', stripslashes($desc['content'])), |
---|
[9745] | 42 | )); |
---|
[9200] | 43 | } |
---|
[9745] | 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 | )); |
---|
[6768] | 83 | |
---|
[9745] | 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'], |
---|
[9975] | 92 | 'COMMENT' => CR_cut_string(trigger_event('render_category_name', $result['comment']), 450), |
---|
[9745] | 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 | ); |
---|
[6768] | 102 | } |
---|
[9745] | 103 | $template->append('RESULTS', $data); |
---|
[6768] | 104 | } |
---|
[9745] | 105 | $template->assign('NB_RESULTS', $i); |
---|
[6768] | 106 | } |
---|
| 107 | |
---|
[9745] | 108 | $template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_page.tpl')); |
---|
| 109 | |
---|
[6768] | 110 | |
---|
| 111 | // +-----------------------------------------------------------------------+ |
---|
| 112 | // Template |
---|
| 113 | // +-----------------------------------------------------------------------+ |
---|
| 114 | $template->assign('CR_PATH', CR_PATH); |
---|
| 115 | $template->assign('SEPARATOR', $conf['level_separator']); |
---|
| 116 | ?> |
---|