[6768] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // Liste des concours |
---|
| 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | $query = "SELECT id, name, visible, date_begin, date_end, status, logo, summary FROM " . CR_TABLE_1 . " ORDER BY date_begin DESC;"; |
---|
| 8 | $contests = pwg_query($query); |
---|
| 9 | |
---|
| 10 | while($contest = pwg_db_fetch_assoc($contests)){ |
---|
| 11 | if($contest['visible'] OR is_admin()){ |
---|
| 12 | // infos sur le concours |
---|
| 13 | $item = array( |
---|
| 14 | 'ID' => $contest['id'], |
---|
| 15 | 'NAME' => trigger_event('render_CR_content', $contest['name']), |
---|
| 16 | 'VISIBLE' => $contest['visible'], |
---|
| 17 | 'STATUS' => $contest['status'], |
---|
| 18 | 'DATE_END' => format_date($contest['date_end']), |
---|
| 19 | 'DATE_BEGIN' => format_date($contest['date_begin']), |
---|
| 20 | 'LOGO' => $contest['logo'], |
---|
| 21 | 'SUMMARY' => trigger_event('render_CR_content', $contest['summary']), |
---|
| 22 | 'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_CR_content', $contest['name'])), |
---|
| 23 | ); |
---|
| 24 | |
---|
| 25 | // podium si terminé |
---|
| 26 | if($contest['status'] == 'finished'){ |
---|
| 27 | $query = "SELECT |
---|
| 28 | i.id, |
---|
| 29 | i.name, |
---|
| 30 | i.file, |
---|
| 31 | i.path, |
---|
| 32 | i.tn_ext, |
---|
| 33 | c.rank, |
---|
| 34 | c.author |
---|
| 35 | FROM " . IMAGES_TABLE . " AS i |
---|
| 36 | INNER JOIN " . CR_TABLE_2 . " AS c |
---|
| 37 | ON c.image_id = i.id |
---|
| 38 | WHERE c.contest_id = " . $contest['id'] . " |
---|
| 39 | ORDER BY c.rank ASC |
---|
| 40 | LIMIT 3 OFFSET 0;"; |
---|
| 41 | $results = pwg_query($query); |
---|
| 42 | |
---|
| 43 | while($result = pwg_db_fetch_assoc($results)){ |
---|
| 44 | $item['RESULTS'][$result['rank']] = array( |
---|
| 45 | 'RANK' => $result['rank'], |
---|
| 46 | 'AUTHOR' => $result['author'], |
---|
| 47 | 'TN_SRC' => get_thumbnail_url($result) |
---|
| 48 | ); |
---|
| 49 | } |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | $template->append('contests_'.$contest['status'], $item); |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | $template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_main.tpl')); |
---|
| 57 | |
---|
| 58 | // +-----------------------------------------------------------------------+ |
---|
| 59 | // Template |
---|
| 60 | // +-----------------------------------------------------------------------+ |
---|
| 61 | $template->assign('CR_PATH', CR_PATH); |
---|
| 62 | $template->assign('SEPARATOR', $conf['level_separator']); |
---|
| 63 | ?> |
---|