Changeset 9745 for extensions/ContestResults/include/cr_page.php
- Timestamp:
- Mar 17, 2011, 8:25:13 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/ContestResults/include/cr_page.php
r9572 r9745 6 6 // +-----------------------------------------------------------------------+ 7 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']);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'); 10 10 } 11 11 12 12 // Infos du concours 13 $contest = pwg_query("SELECT * FROM " . CR_TABLE_1 . " WHERE id=" . $page['contest'] . ";"); 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'])); 14 15 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')); 16 // Concours non-publique 17 if (!$contest['visible']) { 18 check_status(ACCESS_ADMINISTRATOR); 113 19 } 114 20 21 // Paramètres généraux 22 $template->assign(array( 23 'ID' => $contest['id'], 24 'NAME' => trigger_event('render_CR_content', $contest['name']), 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'], 31 'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_CR_content', $contest['name'])), 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( 40 'NAME' => trigger_event('render_CR_content', stripslashes($desc['name'])), 41 'CONTENT' => trigger_event('render_CR_content', stripslashes($desc['content'])), 42 )); 43 } 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 )); 83 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'], 92 'COMMENT' => CR_cut_string(trigger_event('render_CR_content', $result['comment']), 450), 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 ); 102 } 103 $template->append('RESULTS', $data); 104 } 105 $template->assign('NB_RESULTS', $i); 106 } 107 108 $template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_page.tpl')); 109 115 110 116 111 // +-----------------------------------------------------------------------+
Note: See TracChangeset
for help on using the changeset viewer.