source: extensions/ContestResults/include/cr_main.php @ 9200

Last change on this file since 9200 was 9200, checked in by mistic100, 13 years ago

ContestResults :

  • Code revision
  • Add Letton (lv_LV) language, thanks to Aivars Baldone
  • Delete display options
  • Fix languages bugs
  • Improve public appearence
File size: 2.0 KB
Line 
1<?php 
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4// +-----------------------------------------------------------------------+
5//                              Liste des concours
6// +-----------------------------------------------------------------------+
7$contests = pwg_query("SELECT
8                id,
9                name,
10                visible,
11                date_begin,
12                date_end,
13                status,
14                logo,
15                summary
16        FROM " . CR_TABLE_1 . "
17        ORDER BY date_begin DESC;");
18
19while ($contest = pwg_db_fetch_assoc($contests)) {
20        if ($contest['visible'] OR is_admin()) {
21                // infos sur le concours
22                $item =  array(
23                        'ID' => $contest['id'],
24                        'NAME' => trigger_event('render_CR_content', $contest['name']),
25                        'VISIBLE' => $contest['visible'],
26                        'STATUS' => $contest['status'],
27                        'DATE_END' => format_date($contest['date_end']),
28                        'DATE_BEGIN' => format_date($contest['date_begin']),
29                        'LOGO' => $contest['logo'],
30                        'SUMMARY' => CR_cut_string(trigger_event('render_CR_content', $contest['summary']), 350),
31                        'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_CR_content', $contest['name'])),
32                );
33               
34                // podium si terminé
35                if ($contest['status'] == 'finished') {
36                        $results = pwg_query("SELECT
37                                        i.id,
38                                        i.name,
39                                        i.file,
40                                        i.path,
41                                        i.tn_ext,
42                                        c.rank,
43                                        c.author
44                                FROM " . IMAGES_TABLE . " AS i
45                                INNER JOIN " . CR_TABLE_2 . " AS c
46                                ON c.image_id = i.id
47                                WHERE c.contest_id = " . $contest['id'] . "
48                                ORDER BY c.rank ASC
49                                LIMIT 3 OFFSET 0;");
50                       
51                        while ($result = pwg_db_fetch_assoc($results)) {
52                                $item['RESULTS'][$result['rank']] = array(
53                                        'RANK' => $result['rank'],
54                                        'AUTHOR' => $result['author'],
55                                        'TN_SRC' => get_thumbnail_url($result)
56                                );
57                        }
58                }
59
60                $template->append('contests', $item);
61        }
62}
63
64$template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_main.tpl'));
65
66// +-----------------------------------------------------------------------+
67//                              Template
68// +-----------------------------------------------------------------------+
69$template->assign('CR_PATH', CR_PATH);
70$template->assign('SEPARATOR', $conf['level_separator']);
71?>
Note: See TracBrowser for help on using the repository browser.