source: extensions/Copyrights/image.php @ 11675

Last change on this file since 11675 was 11675, checked in by Mattias, 13 years ago

Fixed bugs in modify.php, it works now, though it still looks awfull :-/
Added language for the error message in admin.php

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