source: extensions/Copyrights/image.php @ 11423

Last change on this file since 11423 was 11423, checked in by Mattias, 13 years ago
  • batch renamed to batch_global and moved to a distinct file
  • created batch_single.php
  • some comments here and there
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// Another function of which i cant see the use ;-)
19add_event_handler('loc_begin_picture', 'copyrights_add_vars_to_template');
20
21function copyrights_set_prefilter_add_to_pic_info()
22{
23        global $template;
24        $template->set_prefilter('picture', 'copyrights_add_to_pic_info');
25}
26 
27
28 // 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
29function copyrights_add_to_pic_info($content, &$smarty)
30{
31        // Voeg de informatie toe na de auteur - dus voor de datum dat ie gemaakt is...
32        $search = '#<tr id="datecreate">#';
33       
34        $replacement = '
35        <tr id="Copyrights_name">
36                <td class="label">{\'Copyright\'|@translate}</td>
37                <td class="value">
38                        {if $CR_INFO_NAME}
39                        <a target="_blanc" href="{$CR_INFO_URL}" title="{$CR_INFO_NAME}">{$CR_INFO_NAME}</a>
40                        {else}{\'N/A\'|@translate}{/if}
41                </td>
42        </tr>
43        <tr id="datecreate">';
44        // "Copyright" label is nog hardcoded - moet een @translate achter van de smarty, maar dat laat ik maar aan Johan over =P
45
46        return preg_replace($search, $replacement, $content);
47}
48
49function copyrights_add_vars_to_template()
50{
51// For as far as i know i only need the $prefixtable, $page and $template
52//global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
53global $page, $template, $prefixeTable;
54//load_language('plugin.lang', ADDINFO_PATH);
55//load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
56
57        // Show block only on the photo page
58        if ( !empty($page['image_id']) )   
59        {
60                // Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media)
61                $query = '
62                  select name, url
63                  FROM '.COPYRIGHTS_ADMIN.' NATURAL JOIN '.COPYRIGHTS_MEDIA.'
64                  WHERE media_id = '.$page['image_id'].'
65                  AND visible = 1
66                  ;';
67                $result = pwg_query($query);
68                $row = mysql_fetch_array($result);
69                //if(count($row) > 0)
70                //{
71                        $name = $row['name'];
72                        $url = $row['url'];
73                //}
74                       
75                // Sending data to the template
76                $template->assign(
77                array   (
78                'CR_INFO_NAME' => $name,
79                'CR_INFO_URL' => $url
80                                ));
81        }
82}
83
84?>
Note: See TracBrowser for help on using the repository browser.