1 | <?php |
---|
2 | |
---|
3 | //Ajout du prefiltre |
---|
4 | add_event_handler('loc_begin_picture', 'pabI', 55 ); |
---|
5 | |
---|
6 | function pabI() |
---|
7 | { |
---|
8 | global $template; |
---|
9 | $template->set_prefilter('picture', 'pabIT'); |
---|
10 | } |
---|
11 | |
---|
12 | |
---|
13 | function pabIT($content, &$smarty) |
---|
14 | { |
---|
15 | |
---|
16 | global $conf; |
---|
17 | |
---|
18 | $search = '#<div id="'.$conf['Photo_add_by'].'" class="imageInfo">#'; |
---|
19 | |
---|
20 | $replacement = ' |
---|
21 | {if $PAB} |
---|
22 | <div id="pab1" class="imageInfo"> |
---|
23 | <dt>{\'Photo added by\'|@translate}</dt> |
---|
24 | <dd>{$PAB}</dd> |
---|
25 | </div> |
---|
26 | {/if} |
---|
27 | <div id="'.$conf['Photo_add_by'].'" class="imageInfo">'; |
---|
28 | |
---|
29 | return preg_replace($search, $replacement, $content); |
---|
30 | } |
---|
31 | |
---|
32 | add_event_handler('loc_begin_picture', 'pab'); |
---|
33 | |
---|
34 | function pab() |
---|
35 | { |
---|
36 | global $conf, $page, $template; |
---|
37 | load_language('plugin.lang', PAB_PATH); |
---|
38 | load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) ); |
---|
39 | |
---|
40 | if ( !empty($page['image_id']) ) |
---|
41 | { |
---|
42 | |
---|
43 | $query = ' |
---|
44 | select added_by |
---|
45 | FROM ' . IMAGES_TABLE . ' |
---|
46 | WHERE id = \''.$page['image_id'].'\' |
---|
47 | ;'; |
---|
48 | $result = pwg_query($query); |
---|
49 | $row = pwg_db_fetch_assoc($result); |
---|
50 | $userab=$row['added_by']; |
---|
51 | |
---|
52 | $query = ' |
---|
53 | select username |
---|
54 | FROM ' . USERS_TABLE . ' |
---|
55 | WHERE id = \''.$userab.'\' |
---|
56 | ;'; |
---|
57 | $result = pwg_query($query); |
---|
58 | $row = pwg_db_fetch_assoc($result); |
---|
59 | $pab=$row['username']; |
---|
60 | |
---|
61 | |
---|
62 | // Envoi des données au template |
---|
63 | $template->assign ( |
---|
64 | array ( |
---|
65 | 'PAB' => $pab, |
---|
66 | ) ); |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | ?> |
---|