1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | global $template; |
---|
5 | |
---|
6 | // Publish the result on a global page. |
---|
7 | // Mode global ==> simply display global result |
---|
8 | // Mode full ==> display global result and user notations |
---|
9 | |
---|
10 | $ap_id = explode('concours/' , $_SERVER['REQUEST_URI']); |
---|
11 | $id_concours = $ap_id[1]; |
---|
12 | |
---|
13 | $concours = new Concours($id_concours); |
---|
14 | |
---|
15 | $template->assign( 'CONCOURS', array( |
---|
16 | 'ID' => $concours->concours_infos['id'], |
---|
17 | 'NAME' => $concours->concours_infos['name'], |
---|
18 | 'DESCR' => $concours->concours_infos['descr'], |
---|
19 | 'BEGIN_DATE' => $concours->concours_infos['begin_date'], |
---|
20 | 'END_DATE' => $concours->concours_infos['end_date'], |
---|
21 | 'METHOD' => l10n("concours_method".$concours->concours_infos['method']) |
---|
22 | )); |
---|
23 | |
---|
24 | |
---|
25 | $category = $concours->concours_infos['category']; |
---|
26 | |
---|
27 | if (!(isset($concours->concours_infos['method']))) |
---|
28 | $concours->concours_infos['method'] = 1; |
---|
29 | |
---|
30 | $query = 'SELECT DISTINCT(img.id), img.name, img.file, img.path, img.tn_ext,img.author, |
---|
31 | ic.category_id, cat.name AS catname, conc.note, conc.moyenne, conc.nbvotant' |
---|
32 | .' FROM ' . IMAGES_TABLE.' AS img' |
---|
33 | .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' |
---|
34 | .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' |
---|
35 | .' INNER JOIN '.CONCOURS_RESULT_TABLE.' AS conc ON conc.img_id = img.id' |
---|
36 | .' WHERE ic.category_id = '.$concours->concours_infos['category']; |
---|
37 | |
---|
38 | if ($concours->concours_infos['method'] == 1) // total |
---|
39 | $query .= ' ORDER BY note DESC'; |
---|
40 | elseif ($concours->concours_infos['method'] == 2) // moyenne |
---|
41 | $query .= ' ORDER BY moyenne DESC'; |
---|
42 | |
---|
43 | $query .=';'; |
---|
44 | // .' ORDER by note DESC;'; |
---|
45 | $result = pwg_query($query); |
---|
46 | $rang = 1; |
---|
47 | while ($row = mysql_fetch_assoc($result)) |
---|
48 | { |
---|
49 | // link on picture.php page |
---|
50 | set_make_full_url(); |
---|
51 | if ( isset($row['category_id']) & isset($row['catname']) ) |
---|
52 | { |
---|
53 | $url = duplicate_picture_url( |
---|
54 | array( |
---|
55 | 'image_id' => $row['id'], |
---|
56 | 'image_file' => $row['file'], |
---|
57 | 'category' => array( |
---|
58 | 'id' => $row['category_id'], |
---|
59 | 'name' => $row['catname'], |
---|
60 | 'permalink' => '' |
---|
61 | ) |
---|
62 | ), |
---|
63 | array('start') |
---|
64 | ); |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | $url = duplicate_picture_url( |
---|
69 | array( |
---|
70 | 'image_id' => $row['id'], |
---|
71 | 'image_file' => $row['file'] |
---|
72 | ), |
---|
73 | array('start') |
---|
74 | ); |
---|
75 | } |
---|
76 | unset_make_full_url(); |
---|
77 | |
---|
78 | $template->append( 'concours_note', array( |
---|
79 | 'img_id' => $row['id'], |
---|
80 | 'name' => $row['name'], |
---|
81 | 'file' => $row['file'], |
---|
82 | 'author' => $row['author'], |
---|
83 | 'rang' => $rang, |
---|
84 | 'thumb' => get_thumbnail_url($row), |
---|
85 | 'url' => $url, |
---|
86 | 'note' => ($row['note'] == 0 ? 'N/A' :$row['note']), |
---|
87 | 'moyenne' => ($row['moyenne'] == 0 ? 'N/A' :$row['moyenne']), |
---|
88 | 'nbvotant' => $row['nbvotant'], |
---|
89 | 'usernote' => $concours->get_img_globalnote_user($row['id']) |
---|
90 | |
---|
91 | )); |
---|
92 | $rang ++; |
---|
93 | |
---|
94 | } |
---|
95 | // Envoi de la page |
---|
96 | $template->assign(array( |
---|
97 | 'TITLE' => "Concours : ".$concours->concours_infos['name'])); |
---|
98 | |
---|
99 | $template->assign('IMG_URL', CONCOURS_IMG_PATH); |
---|
100 | |
---|
101 | $template->set_filenames(array('concours_result' => CONCOURS_ROOT.'/template/result.tpl')); |
---|
102 | $template->concat('PLUGIN_INDEX_CONTENT_BEGIN', $template->parse('concours_result', true)); |
---|
103 | |
---|
104 | |
---|
105 | $template->assign('PLUGIN_INDEX_ACTIONS' , ' |
---|
106 | <li><a href="' . make_index_url() . '" title="' . l10n('return to homepage') . '"> |
---|
107 | <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a> |
---|
108 | </li>'); |
---|
109 | |
---|
110 | if (is_admin()) |
---|
111 | { |
---|
112 | $template->assign('U_EDIT', PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&concours=' . $id_concours.'&action=edit'); |
---|
113 | } |
---|
114 | |
---|
115 | $template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED')); |
---|
116 | |
---|
117 | ?> |
---|