source: extensions/ConcoursPhoto/publish.php @ 4372

Last change on this file since 4372 was 4368, checked in by tiico, 14 years ago

[ConcoursPhoto] Correct some bug, update database and add audit page (Need to be completed)

File size: 3.2 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4global $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$query = 'SELECT DISTINCT(img.id), img.name, img.file, img.path, img.tn_ext,img.author,
28                  ic.category_id, cat.name AS catname, conc.note, conc.moyenne, conc.nbvotant'
29                .' FROM ' . IMAGES_TABLE.' AS img'
30                .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
31                .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
32                .' INNER JOIN '.CONCOURS_RESULT_TABLE.' AS conc ON conc.img_id = img.id'
33                .' WHERE ic.category_id = '.$concours->concours_infos['category']
34                .' ORDER by note DESC;';
35$result = pwg_query($query);
36$rang = 1;
37while ($row = mysql_fetch_assoc($result))
38{
39        // link on picture.php page
40        set_make_full_url();
41        if ( isset($row['category_id']) & isset($row['catname']) ) 
42        {
43                $url = duplicate_picture_url(
44                array(
45                'image_id' => $row['id'],
46                'image_file' => $row['file'],
47                'category' => array(
48                                                'id' => $row['category_id'],
49                                                'name' => $row['catname'],
50                                                'permalink' => ''
51                                          )
52                ),
53                array('start')
54                );
55        }
56        else
57        {
58                $url = duplicate_picture_url(
59                  array(
60                        'image_id' => $row['id'],
61                        'image_file' => $row['file']
62                  ),
63                  array('start')
64                );
65        }       
66        unset_make_full_url();
67
68        $template->append( 'concours_note', array(
69                        'img_id' => $row['id'],
70                        'name'  => $row['name'],
71                        'file'  => $row['file'],
72                        'author'        => $row['author'],
73                        'rang'  => $rang,
74                        'thumb' => get_thumbnail_url($row),
75                        'url'   => $url,
76                        'note'  => ($row['note'] == 0 ? 'N/A' :$row['note']),
77                        'moyenne'       => ($row['moyenne'] == 0 ? 'N/A' :$row['moyenne']),
78                        'nbvotant'      => $row['nbvotant'],
79                        'usernote'      => $concours->get_img_globalnote_user($row['id'])
80                       
81                ));
82        $rang ++;
83
84}
85// Envoi de la page
86$template->assign(array(
87  'TITLE' => "Concours : ".$concours->concours_infos['name']));
88
89$template->assign('IMG_URL', CONCOURS_IMG_PATH);
90
91$template->set_filenames(array('concours_result' =>  CONCOURS_ROOT.'/template/result.tpl'));
92$template->concat('PLUGIN_INDEX_CONTENT_BEGIN', $template->parse('concours_result', true));
93 
94 
95  $template->assign('PLUGIN_INDEX_ACTIONS' , '
96    <li><a href="' . make_index_url() . '" title="' . l10n('return to homepage') . '">
97      <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
98    </li>');
99
100if (is_admin())
101{
102  $template->assign('U_EDIT', PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $id_concours.'&amp;action=edit');
103}
104
105$template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED'));
106
107?>
Note: See TracBrowser for help on using the repository browser.