1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | // display only on home |
---|
6 | $display_options = & $template->get_template_vars('display_options'); |
---|
7 | $display_options['on_root'] = false; |
---|
8 | $display_options['on_cats'] = false; |
---|
9 | $display_options['on_picture'] = false; |
---|
10 | |
---|
11 | |
---|
12 | // Configuration par défaut |
---|
13 | if (!isset($datas)) { |
---|
14 | $datas = array( |
---|
15 | 'contest_id' => array(0), |
---|
16 | 'nb_per_line' => 1, |
---|
17 | ); |
---|
18 | } |
---|
19 | |
---|
20 | // Enregistrement de la configuration |
---|
21 | if (isset($_POST['submit']) ) { |
---|
22 | |
---|
23 | $datas = array( |
---|
24 | // 'contest_id' => implode(',', $_POST['contest_id']), |
---|
25 | 'contest_id' => intval($_POST['contest_id']), |
---|
26 | 'nb_per_line' => $_POST['nb_per_line'], |
---|
27 | ); |
---|
28 | } |
---|
29 | |
---|
30 | // list of closed contests |
---|
31 | $query = 'SELECT DISTINCT(id_concours),CONC.name' |
---|
32 | .' FROM ' .CONCOURS_RESULT_TABLE |
---|
33 | .' INNER JOIN ' . CONCOURS_TABLE.' AS CONC on CONC.id = id_concours' |
---|
34 | .' AND time_to_sec(TIMEDIFF(now(), end_date)) > 0' |
---|
35 | .' ORDER BY id_concours;'; |
---|
36 | |
---|
37 | // selected contests |
---|
38 | $selected_ids = explode(',', $datas['contest_id']); |
---|
39 | |
---|
40 | $result = pwg_query($query); |
---|
41 | |
---|
42 | $visible = false; |
---|
43 | // Contest list |
---|
44 | while ($contest = pwg_db_fetch_assoc($result)) |
---|
45 | { |
---|
46 | $visible = true; |
---|
47 | |
---|
48 | $template->append('contests', array( |
---|
49 | 'ID' => $contest['id_concours'], |
---|
50 | 'NAME' => $contest['name'], |
---|
51 | 'SELECTED' => in_array($contest['id_concours'], $selected_ids) ? true : false, |
---|
52 | )); |
---|
53 | } |
---|
54 | if (!$visible) |
---|
55 | { |
---|
56 | $template->append('contests', array( |
---|
57 | 'ID' => 0, |
---|
58 | 'NAME' => l10n('NO_concours'), |
---|
59 | 'SELECTED' => true , |
---|
60 | )); |
---|
61 | $template->assign('VISILBLE',false); |
---|
62 | } |
---|
63 | |
---|
64 | // Nombre de cadres |
---|
65 | $template->assign('NB_PER_LINE', array( |
---|
66 | 'OPTIONS' => array(1 => 1, 2 => 2, 3 => 3), |
---|
67 | 'SELECTED' => $datas['nb_per_line'], |
---|
68 | )); |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | // +-----------------------------------------------------------------------+ |
---|
73 | // Template |
---|
74 | // +-----------------------------------------------------------------------+ |
---|
75 | $template->set_filenames(array('module_options' => dirname(__FILE__) . '/config.tpl')); |
---|
76 | $template->assign_var_from_handle('MODULE_OPTIONS', 'module_options'); |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | ?> |
---|