source: extensions/ContestResults/include/cr_comment_picture.php @ 9975

Last change on this file since 9975 was 9975, checked in by mistic100, 13 years ago
  • many corrections
File size: 2.4 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4// +-----------------------------------------------------------------------+
5//              Affichage du commentaire sur la page d'une image participante
6// +-----------------------------------------------------------------------+
7
8// Requète simple pour savoir si l'image a participé à des concours
9$participation = pwg_query("SELECT image_id FROM " . CR_TABLE_2 . " WHERE image_id = " . $page['image_id'] . ";");
10
11if(pwg_db_num_rows($participation)){
12        // requète complète
13        $results = pwg_query("SELECT
14                        i.rank,
15                        i.comment,
16                        c.name AS contest_name,
17                        c.id AS contest_id
18                FROM " . CR_TABLE_2 . " AS i
19                INNER JOIN " . CR_TABLE_1 . " AS c
20                ON i.contest_id = c.id
21                WHERE i.image_id = " . $page['image_id'] . "
22                ORDER BY c.date_begin DESC;");
23       
24        // Gère plusieurs participations
25        $comment = null;
26        while( $result = pwg_db_fetch_assoc($results)) {
27                // Rang amélioré
28                $result['rank'] = ($result['rank'] <= 3) ? l10n('CR_order_'.$result['rank']) : $result['rank'] . l10n('CR_order_sup');
29               
30                // Lien vers le concours
31                $result['contest_name'] = trigger_event('render_category_name', $result['contest_name']);
32                $result['contest_link'] = CR_PUBLIC . $result['contest_id'] . '-' . str2url($result['contest_name']);
33               
34                // Ajoute le commentaire après la description
35                $comment .= '<div class="CR_comment">
36                        <b><a href="' . $result['contest_link'] .'">' . $result['contest_name'] . '</a></b> :: <u>' . $result['rank'] . ' ' . l10n('CR_place') . '</u>
37                        <p>' . trigger_event('render_category_name', $result['comment']) . '</p>
38                </div>';
39               
40                // Ajoute un lien vers le concours dans les albums
41                $template->append('related_categories', '<a href="' . CR_PUBLIC . '">' . l10n('Contests') . '</a>' . $conf['level_separator'] . '<a href="' . $result['contest_link'] . '">' . $result['contest_name'] . '</a>');
42        }
43       
44        // style utilisé pour les blocs des concours
45        $css = '<style type="text/css">
46                .CR_comment {
47                        border:1px solid #404040;
48                        padding:10px;
49                        margin:10px 20%;
50                }
51        </style>';
52
53        // +-----------------------------------------------------------------------+
54        //                              Template
55        // +-----------------------------------------------------------------------+
56        $template->assign('COMMENT_IMG', $template->get_template_vars('COMMENT_IMG') . $comment);
57        $template->append('footer_elements', $css);
58}
59?>
Note: See TracBrowser for help on using the repository browser.