[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()) { |
---|
| 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']); |
---|
[6768] | 10 | } |
---|
| 11 | |
---|
| 12 | // Infos du concours |
---|
[9200] | 13 | $contest = pwg_query("SELECT * FROM " . CR_TABLE_1 . " WHERE id=" . $page['contest'] . ";"); |
---|
[6768] | 14 | |
---|
[9200] | 15 | if (pwg_db_num_rows($contest)) { |
---|
| 16 | $contest = pwg_db_fetch_assoc($contest); |
---|
[9572] | 17 | $contest['finished'] = is_date_passed($contest['date_end']); |
---|
[9200] | 18 | |
---|
| 19 | // Concours non-publique |
---|
| 20 | if (!$contest['visible']) { |
---|
| 21 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 22 | } |
---|
| 23 | |
---|
[6768] | 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'], |
---|
[9572] | 29 | 'FINISHED' => $contest['finished'], |
---|
[6768] | 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'])), |
---|
[9572] | 35 | 'DAYS' => DateDiff($contest['date_end'], date('Y-m-d')), |
---|
[6768] | 36 | )); |
---|
| 37 | |
---|
[9200] | 38 | // Les quatre zones texte |
---|
[9572] | 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 | } |
---|
[6768] | 47 | } |
---|
| 48 | |
---|
| 49 | // Affichage des résultats |
---|
[9572] | 50 | if ($contest['finished'] == true) { |
---|
[6768] | 51 | // Infos des résultats |
---|
[9200] | 52 | $results = pwg_query("SELECT * FROM " . CR_TABLE_2 . " WHERE contest_id=" . $contest['id'] . " ORDER BY rank ASC;"); |
---|
[6768] | 53 | |
---|
[9200] | 54 | while ($result = pwg_db_fetch_assoc($results)) { |
---|
[6768] | 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 |
---|
[9200] | 70 | $query = "SELECT |
---|
| 71 | id, |
---|
| 72 | name, |
---|
| 73 | permalink, |
---|
| 74 | uppercats |
---|
[6768] | 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 |
---|
[9200] | 87 | if (in_array($result['rank'], array(1,2,3))) { |
---|
[6782] | 88 | $data = array( |
---|
[6768] | 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'], |
---|
[6782] | 93 | 'IMAGE_NAME' => (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'], |
---|
[6768] | 94 | 'COMMENT' => CR_cut_string(trigger_event('render_CR_content', $result['comment']), 450), |
---|
[9200] | 95 | ); |
---|
[6768] | 96 | }else{ |
---|
[6782] | 97 | $data = array( |
---|
[6768] | 98 | 'RANK' => $result ['rank'], |
---|
| 99 | 'AUTHOR' => $result['author'], |
---|
| 100 | 'TN_SRC' => get_thumbnail_url($image), |
---|
| 101 | 'IMAGE_URL' => $image['url'], |
---|
[6782] | 102 | 'IMAGE_NAME' => (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'], |
---|
[6768] | 103 | ); |
---|
| 104 | } |
---|
[6782] | 105 | $template->append('RESULTS', $data); |
---|
[6768] | 106 | } |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | $template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_page.tpl')); |
---|
| 110 | |
---|
[9200] | 111 | } else { |
---|
[6768] | 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 | ?> |
---|