source: extensions/Photo_add_by/initpicture.php @ 16859

Last change on this file since 16859 was 16859, checked in by ddtddt, 12 years ago

[extensions] - Photo_add_by - firs release

File size: 1.3 KB
Line 
1<?php
2
3//Ajout du prefiltre
4add_event_handler('loc_begin_picture', 'pabI', 55 );
5
6function pabI()
7 {
8        global $template;
9        $template->set_prefilter('picture', 'pabIT');
10 }
11
12function pabIT($content, &$smarty)
13 {
14  $search = '#<div id="datecreate" class="imageInfo">#';
15 
16  $replacement = '
17  {if $PAB}
18  <div id="pab1" class="imageInfo">
19    <dt>{\'Photo add by\'|@translate}</dt>
20    <dd>{$PAB}</dd>
21  </div>
22{/if}
23<div id="datecreate" class="imageInfo">';
24
25  return preg_replace($search, $replacement, $content);
26 }
27
28add_event_handler('loc_begin_picture', 'pab');
29
30function pab()
31{
32global $conf, $page, $template;
33load_language('plugin.lang', PAB_PATH);
34load_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 = '
40select 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 = '
49select 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?>
Note: See TracBrowser for help on using the repository browser.