[11076] | 1 | <?php |
---|
| 2 | |
---|
[11656] | 3 | // Add a prefilter |
---|
[11423] | 4 | add_event_handler('loc_begin_picture', 'copyrights_set_prefilter_add_to_pic_info', 55 ); |
---|
[11076] | 5 | |
---|
[11439] | 6 | // Change the variables used by the function that changes the template |
---|
[11621] | 7 | add_event_handler('loc_begin_picture', 'copyrights_add_image_vars_to_template'); |
---|
[11423] | 8 | |
---|
| 9 | function copyrights_set_prefilter_add_to_pic_info() |
---|
[11076] | 10 | { |
---|
| 11 | global $template; |
---|
[11423] | 12 | $template->set_prefilter('picture', 'copyrights_add_to_pic_info'); |
---|
[11076] | 13 | } |
---|
| 14 | |
---|
[11423] | 15 | function copyrights_add_to_pic_info($content, &$smarty) |
---|
[11076] | 16 | { |
---|
[11621] | 17 | // Add the information after the author - so before the createdate |
---|
[11076] | 18 | $search = '#<tr id="datecreate">#'; |
---|
| 19 | |
---|
| 20 | $replacement = ' |
---|
| 21 | <tr id="Copyrights_name"> |
---|
[11292] | 22 | <td class="label">{\'Copyright\'|@translate}</td> |
---|
[11084] | 23 | <td class="value"> |
---|
[11143] | 24 | {if $CR_INFO_NAME} |
---|
[11635] | 25 | <a target="_blanc" href="{$CR_INFO_URL}" title="{$CR_INFO_NAME}: {$CR_INFO_DESCR}">{$CR_INFO_NAME}</a> |
---|
[11292] | 26 | {else}{\'N/A\'|@translate}{/if} |
---|
[11084] | 27 | </td> |
---|
[11076] | 28 | </tr> |
---|
| 29 | <tr id="datecreate">'; |
---|
| 30 | |
---|
| 31 | return preg_replace($search, $replacement, $content); |
---|
| 32 | } |
---|
| 33 | |
---|
[11621] | 34 | function copyrights_add_image_vars_to_template() |
---|
[11076] | 35 | { |
---|
[11439] | 36 | global $page, $template, $prefixeTable; |
---|
[11076] | 37 | |
---|
| 38 | // Show block only on the photo page |
---|
[11439] | 39 | if ( !empty($page['image_id']) ) |
---|
[11076] | 40 | { |
---|
[11675] | 41 | // Get the copyright name, url and description that belongs to the current media_item |
---|
[11076] | 42 | $query = ' |
---|
[11635] | 43 | select name, url, descr |
---|
[11143] | 44 | FROM '.COPYRIGHTS_ADMIN.' NATURAL JOIN '.COPYRIGHTS_MEDIA.' |
---|
[11076] | 45 | WHERE media_id = '.$page['image_id'].' |
---|
[11143] | 46 | AND visible = 1 |
---|
[11076] | 47 | ;'; |
---|
| 48 | $result = pwg_query($query); |
---|
[11505] | 49 | $row = pwg_db_fetch_row($result); |
---|
[11635] | 50 | $name = ''; |
---|
| 51 | $url = ''; |
---|
| 52 | $descr = ''; |
---|
[11505] | 53 | if(count($row) > 0) { |
---|
| 54 | $name = $row[0]; |
---|
| 55 | $url = $row[1]; |
---|
[11635] | 56 | $descr = $row[2]; |
---|
[11505] | 57 | } |
---|
[11076] | 58 | |
---|
| 59 | // Sending data to the template |
---|
| 60 | $template->assign( |
---|
| 61 | array ( |
---|
| 62 | 'CR_INFO_NAME' => $name, |
---|
[11635] | 63 | 'CR_INFO_URL' => $url, |
---|
| 64 | 'CR_INFO_DESCR' => $descr |
---|
[11076] | 65 | )); |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
[11675] | 69 | ?> |
---|