1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // Requète simple pour savoir si l'image a participé à des concours |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | $query = "SELECT image_id FROM " . CR_TABLE_2 . " WHERE image_id = " . $page['image_id'] . ";"; |
---|
8 | $results = pwg_query($query); |
---|
9 | |
---|
10 | if(pwg_db_num_rows($results)){ |
---|
11 | $query = "SELECT |
---|
12 | i.rank, |
---|
13 | i.comment, |
---|
14 | c.name AS contest_name, |
---|
15 | c.id AS contest_id |
---|
16 | FROM " . CR_TABLE_2 . " AS i |
---|
17 | INNER JOIN " . CR_TABLE_1 . " AS c |
---|
18 | ON i.contest_id = c.id |
---|
19 | WHERE i.image_id = " . $page['image_id'] . " |
---|
20 | ORDER BY c.date_begin DESC;"; |
---|
21 | $results = pwg_query($query); |
---|
22 | |
---|
23 | // Gère plusieurs participations |
---|
24 | $comment = null; |
---|
25 | while($result = pwg_db_fetch_assoc($results)){ |
---|
26 | // rang amélioré |
---|
27 | if($result['rank'] <= 3) $result['rank'] = l10n('CR_order_'.$result['rank']); |
---|
28 | else $result['rank'] .= l10n('CR_order_sup'); |
---|
29 | |
---|
30 | // Lien vers le concours |
---|
31 | $result['contest_name'] = trigger_event('render_CR_content', $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 style="border:1px solid #404040;padding:10px;margin:10px 25%"> |
---|
36 | <b><a href="' . $result['contest_link'] .'">' . $result['contest_name'] . '</a></b> |
---|
37 | :: <u>' . $result['rank'] . '</u> |
---|
38 | <p>' . trigger_event('render_CR_content', $result['comment']) . '</p> |
---|
39 | </div>'; |
---|
40 | |
---|
41 | // Ajoute un lien vers le concours dans les albums |
---|
42 | $template->append('related_categories', '<a href="' . CR_PUBLIC . '">' . l10n('Contests') . '</a>' . $conf['level_separator'] . '<a href="' . $result['contest_link'] . '">' . $result['contest_name'] . '</a>'); |
---|
43 | } |
---|
44 | |
---|
45 | $template->assign('COMMENT_IMG', $template->get_template_vars('COMMENT_IMG') . $comment); |
---|
46 | } |
---|
47 | |
---|
48 | ?> |
---|