set_prefilter('picture', 'copyrights_add_to_pic_info');
}
function copyrights_add_to_pic_info($content, &$smarty)
{
// Add the information after the author - so before the createdate
$search = '#
#';
$replacement = '
{\'Copyright\'|@translate} |
{if $CR_INFO_NAME}
{$CR_INFO_NAME}
{else}{\'N/A\'|@translate}{/if}
|
';
return preg_replace($search, $replacement, $content);
}
function copyrights_add_image_vars_to_template()
{
// For as far as i know i only need the $prefixtable, $page and $template
//global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
global $page, $template, $prefixeTable;
//load_language('plugin.lang', ADDINFO_PATH);
//load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
// Show block only on the photo page
if ( !empty($page['image_id']) )
{
// Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media)
$query = '
select name, url, descr
FROM '.COPYRIGHTS_ADMIN.' NATURAL JOIN '.COPYRIGHTS_MEDIA.'
WHERE media_id = '.$page['image_id'].'
AND visible = 1
;';
$result = pwg_query($query);
$row = pwg_db_fetch_row($result);
$name = '';
$url = '';
$descr = '';
if(count($row) > 0) {
$name = $row[0];
$url = $row[1];
$descr = $row[2];
}
// Sending data to the template
$template->assign(
array (
'CR_INFO_NAME' => $name,
'CR_INFO_URL' => $url,
'CR_INFO_DESCR' => $descr
));
}
}
?>