set_prefilter('header', 'upmata');
$PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
if($PAED['state'] == 'active') add_event_handler('AP_render_content', 'get_user_language_desc');
}
function upmata ($content, &$smarty)
{
$search = '##';
$replacement = '';
return preg_replace($search, $replacement, $content);
}
function add_meta()
{
global $template, $page, $meta_infos;
$meta_infos = array();
$meta_infos['author'] = $template->get_template_vars('INFO_AUTHOR');
$meta_infos['related_tags'] = $template->get_template_vars('related_tags');
$meta_infos['info'] = $template->get_template_vars('INFO_FILE');
$meta_infos['title'] = $template->get_template_vars('PAGE_TITLE');
$query = '
select id,metaname,metaval
FROM ' . meta_TABLE . '
WHERE metaname IN (\'author\', \'keywords\', \'Description\', \'robots\')
;';
$result = pwg_query($query);
$meta = array();
while ($row = mysql_fetch_assoc($result))
{
$meta[$row['metaname']] = $row['metaval'];
$metaED[$row['metaname']]=trigger_event('AP_render_content', $meta[$row['metaname']]);
}
// Authors
if (!empty($meta_infos['author']) and !empty($metaED['author']))
{
$template->assign('INFO_AUTHOR', $meta_infos['author'] . ' - ' . $metaED['author']);
}
elseif (!empty($metaED['author']))
{
$template->assign('INFO_AUTHOR', $metaED['author']);
}
// Keywords
if (!empty($metaED['keywords']))
{
$template->append('related_tags', array('name' => $metaED['keywords']));
}
// Description
if (!empty($meta_infos['title']) and !empty($meta_infos['info']) and !empty($metaED['Description']))
{
$template->assign('PLUG_META', $meta_infos['title']. ' - ' .$meta_infos['info'] . ', ' . $metaED['Description']);
}
elseif (!empty($meta_infos['title']) and !empty($metaED['Description']))
{
$template->assign('PLUG_META', $meta_infos['title']. ' - ' .$metaED['Description']);
}
elseif (!empty($metaED['Description']))
{
$template->assign('PLUG_META', $metaED['Description']);
}
// Robots
if (!empty($meta['robots']))
{
$template->append('head_elements', '');
}
}
function add_metacat()
{
global $template, $page, $meta_infos;
//meta categories
if ( !empty($page['category']['id']) )
{
$query = '
select id,metaKeycat
FROM ' . meta_cat_TABLE . '
WHERE id = \''.$page['category']['id'].'\'
;';
$result = pwg_query($query);
$row = mysql_fetch_array($result);
$albumKeyED=trigger_event('AP_render_content', $row['metaKeycat']);
if (!empty($row['metaKeycat']))
{
$template->append('related_tags', array('name' => $albumKeyED));
}
$query = '
select id,metadescat
FROM ' . meta_cat_TABLE . '
WHERE id = \''.$page['category']['id'].'\'
;';
$result = pwg_query($query);
$row = mysql_fetch_array($result);
$albumDesED=trigger_event('AP_render_content', $row['metadescat']);
if (!empty($row['metadescat']))
{
$template->assign('PLUG_META', $albumDesED);
}
}
}
function add_metaimg()
{
global $template, $page, $meta_infos;
//meta images
if ( !empty($page['image_id']) )
{
$query = '
select id,metaKeyimg
FROM ' . meta_img_TABLE . '
WHERE id = \''.$page['image_id'].'\'
;';
$result = pwg_query($query);
$row = mysql_fetch_array($result);
$photoKeyED=trigger_event('AP_render_content', $row['metaKeyimg']);
if (!empty($row['metaKeyimg']))
{
$template->append('related_tags', array('name' => $photoKeyED));
}
$query = '
select id,metadesimg
FROM ' . meta_img_TABLE . '
WHERE id = \''.$page['image_id'].'\'
;';
$result = pwg_query($query);
$row = mysql_fetch_array($result);
$photoDesED=trigger_event('AP_render_content', $row['metadesimg']);
if (!empty($row['metadesimg']))
{
$template->assign('PLUG_META', $photoDesED);
}
}
}
function set_meta_back()
{
global $template, $meta_infos;
$template->assign
(array
(
'INFO_AUTHOR' => $meta_infos['author'],
'related_tags' => $meta_infos['related_tags'],
'INFO_FILE' => $meta_infos['info'],
)
);
}
?>