source: extensions/Copyrights/image.php @ 11439

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

Small changes in comment's, removed unnescessary code

File size: 2.6 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// What do these prefilters do?
12// First they use loc_begin_picture to set some template variables
13// Then they use the same event to set a prefilter, who on his turn will change the content
14
15// Add a prefilter - whatever a prefilter may be
16add_event_handler('loc_begin_picture', 'copyrights_set_prefilter_add_to_pic_info', 55 );
17
18// Change the variables used by the function that changes the template
19add_event_handler('loc_begin_picture', 'copyrights_add_vars_to_template');
20
21// The big question is - WHY THIS WAY!!!
22
23function copyrights_set_prefilter_add_to_pic_info()
24{
25        global $template;
26        $template->set_prefilter('picture', 'copyrights_add_to_pic_info');
27}
28 
29
30 // 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
31function copyrights_add_to_pic_info($content, &$smarty)
32{
33        // Voeg de informatie toe na de auteur - dus voor de datum dat ie gemaakt is...
34        $search = '#<tr id="datecreate">#';
35       
36        $replacement = '
37        <tr id="Copyrights_name">
38                <td class="label">{\'Copyright\'|@translate}</td>
39                <td class="value">
40                        {if $CR_INFO_NAME}
41                        <a target="_blanc" href="{$CR_INFO_URL}" title="{$CR_INFO_NAME}">{$CR_INFO_NAME}</a>
42                        {else}{\'N/A\'|@translate}{/if}
43                </td>
44        </tr>
45        <tr id="datecreate">';
46
47        return preg_replace($search, $replacement, $content);
48}
49
50function copyrights_add_vars_to_template()
51{
52        // For as far as i know i only need the $prefixtable, $page and $template
53        //global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
54        global $page, $template, $prefixeTable;
55        //load_language('plugin.lang', ADDINFO_PATH);
56        //load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
57
58        // Show block only on the photo page
59        if ( !empty($page['image_id']) )
60        {
61                // Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media)
62                $query = '
63                  select name, url
64                  FROM '.COPYRIGHTS_ADMIN.' NATURAL JOIN '.COPYRIGHTS_MEDIA.'
65                  WHERE media_id = '.$page['image_id'].'
66                  AND visible = 1
67                  ;';
68                $result = pwg_query($query);
69                $row = mysql_fetch_array($result);
70                //if(count($row) > 0)
71                //{
72                        $name = $row['name'];
73                        $url = $row['url'];
74                //}
75                       
76                // Sending data to the template
77                $template->assign(
78                array   (
79                'CR_INFO_NAME' => $name,
80                'CR_INFO_URL' => $url
81                                ));
82        }
83}
84
85?>
Note: See TracBrowser for help on using the repository browser.