source: extensions/Copyrights/image.php @ 11084

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

Serveral bug fixes in main.inc.php, maintain.inc.php, admin.php
Added link to the CR_name (image.php)

File size: 2.2 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">
33                        <a target="_blanc" href="{$CR_INFO_URL}" title="{$CR_INFO_NAME}">{$CR_INFO_NAME}</a>
34                </td>
35        </tr>
36        <tr id="datecreate">';
37        // "Copyright" label is nog hardcoded - moet een @translate achter van de smarty, maar dat laat ik maar aan Johan over =P
38
39        return preg_replace($search, $replacement, $content);
40}
41
42// Another function of which i cant see the use ;-)
43add_event_handler('loc_begin_picture', 'add_vars_to_template');
44
45function add_vars_to_template()
46{
47// For as far as i know i only need the $prefixtable, $page and $template
48global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
49//load_language('plugin.lang', ADDINFO_PATH);
50//load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
51
52        // Show block only on the photo page
53        if ( !empty($page['image_id']) )   
54        {
55                // Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media)
56                $query = '
57                  select name, url
58                  FROM '.$prefixeTable.'copyrights_admin NATURAL JOIN '.$prefixeTable.'copyrights_media
59                  WHERE media_id = '.$page['image_id'].'
60                  ;';
61                $result = pwg_query($query);
62                $row = mysql_fetch_array($result);
63                $name = $row['name'];
64                $url = $row['url'];
65                       
66                // Sending data to the template
67                $template->assign(
68                array   (
69                'CR_INFO_NAME' => $name,
70                'CR_INFO_URL' => $url
71                                ));
72        }
73}
74
75?>
Note: See TracBrowser for help on using the repository browser.