1 | <?php |
---|
2 | /* |
---|
3 | This php file will insert the names of the copyrights into the images description, |
---|
4 | so you can see below the image what copyright it has. |
---|
5 | */ |
---|
6 | |
---|
7 | // Add a prefilter |
---|
8 | add_event_handler('loc_begin_picture', 'copyrights_set_prefilter_add_to_pic_info', 55 ); |
---|
9 | |
---|
10 | // Change the variables used by the function that changes the template |
---|
11 | add_event_handler('loc_begin_picture', 'copyrights_add_image_vars_to_template'); |
---|
12 | |
---|
13 | function copyrights_set_prefilter_add_to_pic_info() |
---|
14 | { |
---|
15 | global $template; |
---|
16 | $template->set_prefilter('picture', 'copyrights_add_to_pic_info'); |
---|
17 | } |
---|
18 | |
---|
19 | function copyrights_add_to_pic_info($content, &$smarty) |
---|
20 | { |
---|
21 | // Add the information after the author - so before the createdate |
---|
22 | $search = '#<tr id="datecreate">#'; |
---|
23 | |
---|
24 | $replacement = ' |
---|
25 | <tr id="Copyrights_name"> |
---|
26 | <td class="label">{\'Copyright\'|@translate}</td> |
---|
27 | <td class="value"> |
---|
28 | {if $CR_INFO_NAME} |
---|
29 | <a target="_blanc" href="{$CR_INFO_URL}" title="{$CR_INFO_NAME}: {$CR_INFO_DESCR}">{$CR_INFO_NAME}</a> |
---|
30 | {else}{\'N/A\'|@translate}{/if} |
---|
31 | </td> |
---|
32 | </tr> |
---|
33 | <tr id="datecreate">'; |
---|
34 | |
---|
35 | return preg_replace($search, $replacement, $content); |
---|
36 | } |
---|
37 | |
---|
38 | function copyrights_add_image_vars_to_template() |
---|
39 | { |
---|
40 | // For as far as i know i only need the $prefixtable, $page and $template |
---|
41 | //global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable; |
---|
42 | global $page, $template, $prefixeTable; |
---|
43 | //load_language('plugin.lang', ADDINFO_PATH); |
---|
44 | //load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); |
---|
45 | |
---|
46 | // Show block only on the photo page |
---|
47 | if ( !empty($page['image_id']) ) |
---|
48 | { |
---|
49 | // Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media) |
---|
50 | $query = ' |
---|
51 | select name, url, descr |
---|
52 | FROM '.COPYRIGHTS_ADMIN.' NATURAL JOIN '.COPYRIGHTS_MEDIA.' |
---|
53 | WHERE media_id = '.$page['image_id'].' |
---|
54 | AND visible = 1 |
---|
55 | ;'; |
---|
56 | $result = pwg_query($query); |
---|
57 | $row = pwg_db_fetch_row($result); |
---|
58 | $name = ''; |
---|
59 | $url = ''; |
---|
60 | $descr = ''; |
---|
61 | if(count($row) > 0) { |
---|
62 | $name = $row[0]; |
---|
63 | $url = $row[1]; |
---|
64 | $descr = $row[2]; |
---|
65 | } |
---|
66 | |
---|
67 | // Sending data to the template |
---|
68 | $template->assign( |
---|
69 | array ( |
---|
70 | 'CR_INFO_NAME' => $name, |
---|
71 | 'CR_INFO_URL' => $url, |
---|
72 | 'CR_INFO_DESCR' => $descr |
---|
73 | )); |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | ?> |
---|