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

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

[extensions] ContestResults 1.3

  • Add error and success messages on admin page
  • Add Spain (es_ES) thanks to jpr928
  • Contest status is automatic and shows remaining days
  • More flexibility for description fields
  • Compatibility with Piwigo 2.2.0
File size: 2.2 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                logo,
14                summary
15        FROM " . CR_TABLE_1 . "
16        ORDER BY date_begin DESC;");
17
18while ($contest = pwg_db_fetch_assoc($contests)) {
19        if ($contest['visible'] OR is_admin()) {
20                $contest['finished'] = is_date_passed($contest['date_end']);
21               
22                // infos sur le concours
23                $item =  array(
24                        'ID' => $contest['id'],
25                        'NAME' => trigger_event('render_CR_content', $contest['name']),
26                        'VISIBLE' => $contest['visible'],
27                        'FINISHED' => $contest['finished'],
28                        'DATE_END' => format_date($contest['date_end']),
29                        'DATE_BEGIN' => format_date($contest['date_begin']),
30                        'LOGO' => $contest['logo'],
31                        'SUMMARY' => CR_cut_string(trigger_event('render_CR_content', $contest['summary']), 350),
32                        'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_CR_content', $contest['name'])),
33                        'DAYS' => DateDiff($contest['date_end'], date('Y-m-d')),
34                );
35               
36                // podium si terminé
37                if ($contest['finished'] == true) {
38                        $results = pwg_query("SELECT
39                                        i.id,
40                                        i.name,
41                                        i.file,
42                                        i.path,
43                                        i.tn_ext,
44                                        c.rank,
45                                        c.author
46                                FROM " . IMAGES_TABLE . " AS i
47                                INNER JOIN " . CR_TABLE_2 . " AS c
48                                ON c.image_id = i.id
49                                WHERE c.contest_id = " . $contest['id'] . "
50                                ORDER BY c.rank ASC
51                                LIMIT 3 OFFSET 0;");
52                       
53                        while ($result = pwg_db_fetch_assoc($results)) {
54                                $item['RESULTS'][$result['rank']] = array(
55                                        'RANK' => $result['rank'],
56                                        'AUTHOR' => $result['author'],
57                                        'TN_SRC' => get_thumbnail_url($result)
58                                );
59                        }
60                }
61
62                $template->append('contests', $item);
63        }
64}
65
66$template->set_filenames(array('index'=> dirname(__FILE__).'/../template/cr_main.tpl'));
67
68// +-----------------------------------------------------------------------+
69//                              Template
70// +-----------------------------------------------------------------------+
71if (is_admin()) {
72        $template->assign('U_EDIT', CR_ADMIN);
73}
74$template->assign('CR_PATH', CR_PATH);
75$template->assign('SEPARATOR', $conf['level_separator']);
76?>
Note: See TracBrowser for help on using the repository browser.