source: extensions/Copyrights/image.php @ 11076

Last change on this file since 11076 was 11076, checked in by Mattias, 13 years ago
File size: 2.1 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</td>
32                <td class="value">{$CR_INFO_NAME}</td>
33        </tr>
34        <tr id="datecreate">';
35        // "Copyright" is nog hardcoded
36
37        return preg_replace($search, $replacement, $content);
38}
39
40// Another function of which i cant see the use ;-)
41add_event_handler('loc_begin_picture', 'add_vars_to_template');
42
43function add_vars_to_template()
44{
45// For as far as i know i only need the $prefixtable, $page and $template
46global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
47//load_language('plugin.lang', ADDINFO_PATH);
48//load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
49
50        // Show block only on the photo page
51        if ( !empty($page['image_id']) )   
52        {
53                // Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media)
54                $query = '
55                  select name, url
56                  FROM '.$prefixeTable.'copyrights_admin NATURAL JOIN '.$prefixeTable.'copyrights_media
57                  WHERE media_id = '.$page['image_id'].'
58                  ;';
59                $result = pwg_query($query);
60                $row = mysql_fetch_array($result);
61                $name = $row['name'];
62                $url = $row['url'];
63                       
64                // Sending data to the template
65                $template->assign(
66                array   (
67                'CR_INFO_NAME' => $name,
68                'CR_INFO_URL' => $url
69                                ));
70        }
71}
72
73?>
Note: See TracBrowser for help on using the repository browser.