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