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 = pwg_db_fetch_assoc($result))
{
$meta[$row['metaname']] = $row['metaval'];
$metaED[$row['metaname']]=trigger_change('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', '');
}
//Metaperso
if (script_basename() !== 'admin')
{
$metapersos = pwg_query("SELECT * FROM `". METAPERSO_TABLE .";");
if (pwg_db_num_rows($metapersos)) {
while ($metaperso = pwg_db_fetch_assoc($metapersos))
{
$items = array(
'METANAME' => $metaperso['metaname'],
'METAVAL' => $metaperso['metaval'],
'METATYPE' => $metaperso['metatype']
);
$template->append('metapersos', $items);
}
}
$template->set_filename('PERSO_META', realpath(meta_PATH.'persometa.tpl'));
$template->append('head_elements', $template->parse('PERSO_META', true));
}
$MPC = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';"));
if($MPC['state'] == 'active')
{
global $conf;
if (isset($page['section']) and $page['section'] == 'contact' and isset($conf['contactmeta']) and strpos($conf['contactmeta'], ',') !== false)
{
$metacontact = explode(',', $conf['contactmeta']);
$metakeyED=trigger_change('AP_render_content', $metacontact[0]);
$metadesED=trigger_change('AP_render_content', $metacontact[1]);
if (!empty($metakeyED))
{
$template->append('related_tags', array('name' => $metakeyED));
}
if (!empty($metadesED))
{
$template->assign('PLUG_META', $metadesED);
}
}
}
$MAP = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'AdditionalPages';"));
if($MAP['state'] == 'active')
{
if ( !empty($page['additional_page']['id']) )
{
$lire=$page['additional_page']['id'];
$query = '
select id, metaKeyap, metadesap
FROM ' . META_AP_TABLE . '
WHERE id = \''.$lire.'\'
;';
$result = pwg_query($query);
$row = pwg_db_fetch_assoc($result);
$metaKeyapap=$row['metaKeyap'];
$metadesapap=$row['metadesap'];
$metaKeyapapED=trigger_change('AP_render_content', $metaKeyapap);
$metadesapED=trigger_change('AP_render_content', $metadesapap);
}
if (isset($page['section']) and $page['section'] == 'additional_page')
{
if (!empty($metaKeyapapED))
{
$template->append('related_tags', array('name' => $metaKeyapapED));
}
if (!empty($metadesapED))
{
$template->assign('PLUG_META', $metadesapED);
}
}
}
}
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 = pwg_db_fetch_assoc($result);
$albumKeyED=trigger_change('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 = pwg_db_fetch_assoc($result);
$albumDesED=trigger_change('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 = pwg_db_fetch_assoc($result);
$photoKeyED=trigger_change('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 = pwg_db_fetch_assoc($result);
$photoDesED=trigger_change('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'],
)
);
}
?>