source: extensions/Copyrights/image.php @ 11292

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

Added @translate tags in a couple of files
Added index.php to the main copyrights folder
Updated english and dutch language files

File size: 2.3 KB
Line 
1<?php
2/*
3This php file will insert the names of the copyrights into the images description,
4so you can see below the image what copyright it has.
5
6Mattias
7
8thanks to the AddInfo plugin by ddtddt!
9*/
10
11
12
13// Add a prefilter - whatever a prefilter may be
14add_event_handler('loc_begin_picture', 'set_prefilter_add_to_pic_info', 55 );
15
16function set_prefilter_add_to_pic_info()
17{
18        global $template;
19        $template->set_prefilter('picture', 'add_to_pic_info');
20}
21 
22
23 // This function is called by the set_prefilter_add_to_pic_info function. It has something to do with the prefilter stuff, whatever it may be :p
24function add_to_pic_info($content, &$smarty)
25{
26        // Voeg de informatie toe na de auteur - dus voor de datum dat ie gemaakt is...
27        $search = '#<tr id="datecreate">#';
28       
29        $replacement = '
30        <tr id="Copyrights_name">
31                <td class="label">{\'Copyright\'|@translate}</td>
32                <td class="value">
33                        {if $CR_INFO_NAME}
34                        <a target="_blanc" href="{$CR_INFO_URL}" title="{$CR_INFO_NAME}">{$CR_INFO_NAME}</a>
35                        {else}{\'N/A\'|@translate}{/if}
36                </td>
37        </tr>
38        <tr id="datecreate">';
39        // "Copyright" label is nog hardcoded - moet een @translate achter van de smarty, maar dat laat ik maar aan Johan over =P
40
41        return preg_replace($search, $replacement, $content);
42}
43
44// Another function of which i cant see the use ;-)
45add_event_handler('loc_begin_picture', 'add_vars_to_template');
46
47function add_vars_to_template()
48{
49// For as far as i know i only need the $prefixtable, $page and $template
50global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
51//load_language('plugin.lang', ADDINFO_PATH);
52//load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
53
54        // Show block only on the photo page
55        if ( !empty($page['image_id']) )   
56        {
57                // Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media)
58                $query = '
59                  select name, url
60                  FROM '.COPYRIGHTS_ADMIN.' NATURAL JOIN '.COPYRIGHTS_MEDIA.'
61                  WHERE media_id = '.$page['image_id'].'
62                  AND visible = 1
63                  ;';
64                $result = pwg_query($query);
65                $row = mysql_fetch_array($result);
66                //if(count($row) > 0)
67                //{
68                        $name = $row['name'];
69                        $url = $row['url'];
70                //}
71                       
72                // Sending data to the template
73                $template->assign(
74                array   (
75                'CR_INFO_NAME' => $name,
76                'CR_INFO_URL' => $url
77                                ));
78        }
79}
80
81?>
Note: See TracBrowser for help on using the repository browser.