source: extensions/ConcoursPhoto/publish.php @ 3905

Last change on this file since 3905 was 3905, checked in by tiico, 15 years ago

Initial submit for plugin ConcoursPhoto (Possibility to add a competition on category with selected criterias and generation of the competition's result).
Functionnal version. Admin pages must be checked for informations/errors notifications

File size: 2.6 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$category = $concours->concours_infos['category'];
16
17$query = 'SELECT DISTINCT(img.id), img.name, img.file, img.path, img.tn_ext,
18                  ic.category_id, cat.name AS catname, conc.note'
19                .' FROM ' . IMAGES_TABLE.' AS img'
20                .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
21                .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
22                .' INNER JOIN '.CONCOURS_RESULT_TABLE.' AS conc ON conc.img_id = img.id'
23                .' WHERE ic.category_id = '.$concours->concours_infos['category']
24                .' ORDER by note DESC;';
25$result = pwg_query($query);
26$rang = 1;
27while ($row = mysql_fetch_assoc($result))
28{
29        // link on picture.php page
30        set_make_full_url();
31        if ( isset($row['category_id']) & isset($row['catname']) ) 
32        {
33                $url = duplicate_picture_url(
34                array(
35                'image_id' => $row['id'],
36                'image_file' => $row['file'],
37                'category' => array(
38                                                'id' => $row['category_id'],
39                                                'name' => $row['catname'],
40                                                'permalink' => ''
41                                          )
42                ),
43                array('start')
44                );
45        }
46        else
47        {
48                $url = duplicate_picture_url(
49                  array(
50                        'image_id' => $row['id'],
51                        'image_file' => $row['file']
52                  ),
53                  array('start')
54                );
55        }       
56        unset_make_full_url();
57
58        $template->append( 'concours_note', array(
59                        'img_id' => $row['id'],
60                        'name'  => $row['name'],
61                        'file'  => $row['file'],
62                        'rang'  => $rang,
63                        'thumb' => get_thumbnail_url($row),
64                        'url'   => $url,
65                        'note'  => ($row['note'] == 0 ? 'N/A' :$row['note'])
66                ));
67        $rang ++;
68
69}
70// Envoi de la page
71$template->assign(array(
72  'TITLE' => "Concours : ".$concours->concours_infos['name']));
73
74$template->assign('IMG_URL', CONCOURS_IMG_PATH);
75
76$template->set_filenames(array('concours_result' =>  CONCOURS_ROOT.'/template/result.tpl'));
77$template->concat('PLUGIN_INDEX_CONTENT_BEGIN', $template->parse('concours_result', true));
78 
79 
80  $template->assign('PLUGIN_INDEX_ACTIONS' , '
81    <li><a href="' . make_index_url() . '" title="' . l10n('return to homepage') . '">
82      <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
83    </li>');
84
85if (is_admin())
86{
87  $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');
88}
89
90$template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED'));
91
92?>
Note: See TracBrowser for help on using the repository browser.