<?php

/**
 *
 * @copyright  2010-2016 izend.org
 * @version    39
 * @link       http://www.izend.org
 */
?>
<?php if (!empty($lang)): ?>
<meta http-equiv="content-type" content="text/html; charset=utf-8" lang="<?php echo $lang; ?>" />
<?php else: ?>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php endif; ?>
<?php if (true): ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<?php endif; ?>
<?php if (!empty($description)): ?>
<meta name="description" content="<?php echo htmlspecialchars($description, ENT_NOQUOTES, 'UTF-8', false); ?>" />
<?php endif; ?>
<?php if (!empty($keywords)): ?>
<meta name="keywords" content="<?php echo htmlspecialchars($keywords, ENT_NOQUOTES, 'UTF-8', false); ?>" />
<?php endif; ?>
<meta name="generator" content="iZend" />
<?php if (!empty($author)): ?>
<meta name="author" content="<?php echo htmlspecialchars($author, ENT_NOQUOTES, 'UTF-8', false); ?>" />
<?php endif; ?>
<?php if (!empty($date)): ?>
<meta name="date" content="<?php echo date('Y-m-d', $date); ?>" />
<?php endif; ?>
<?php if (!empty($robots)): ?>
<meta name="robots" content="<?php echo $robots; ?>" />
<?php else: ?>
<meta name="robots" content="index, follow" />
<?php endif; ?>
<?php require_once 'isagent.php'; ?>
<?php if (is_opengraph()): ?>
<?php if (!empty($lang)): ?>
<?php switch($lang): ?>
<?php case 'en': ?>
<meta property="og:locale" content="en_US" />
<?php break; ?>
<?php case 'fr': ?>
<meta property="og:locale" content="fr_FR" />
<?php break; ?>
<?php endswitch; ?>
<?php endif; ?>
<meta property="og:title" content="<?php echo htmlspecialchars(!empty($title) ? $title : $sitename, ENT_NOQUOTES, 'UTF-8', false); ?>" />
<meta property="og:type" content="article" />
<?php if (true): ?>
<meta property="og:url" content="<?php echo preg_replace('#^https://#', 'http://', $base_url, 1); ?>/<?php echo $request_path; ?>" />
<?php else: ?>
<meta property="og:url" content="<?php echo $base_url; ?>/<?php echo $request_path; ?>" />
<?php endif; ?>
<meta property="og:image" content="<?php echo $base_url; ?><?php echo !empty($image) ? $image : '/logos/sitefb.png'; ?>" />
<?php if (!empty($description)): ?>
<meta property="og:description" content="<?php echo htmlspecialchars($description, ENT_NOQUOTES, 'UTF-8', false); ?>" />
<?php endif; ?>
<meta property="og:site_name" content="<?php echo $sitename; ?>" />
<?php endif; ?>
<?php global $facebookid; ?>
<?php if (!empty($facebookid) and is_facebook()): ?>
<meta property="fb:app_id" content="<?php echo $facebookid; ?>" />
<?php endif; ?>
<?php if (!empty($canonical)): ?>
<link rel="canonical" href="<?php echo $canonical; ?>" />
<?php else: ?>
<?php if (true): ?>
<link rel="canonical" href="<?php echo preg_replace('#^https://#', 'http://', $base_url, 1); ?>/<?php echo $request_path; ?>" />
<?php else: ?>
<link rel="canonical" href="<?php echo $base_url; ?>/<?php echo $request_path; ?>" />
<?php endif; ?>
<?php endif; ?>
<?php if (!empty($hreflang)): ?>
<?php foreach ($hreflang as $lg => $url) : ?>
<link rel="alternate" href="<?php echo $base_url;?>/<?php echo $url; ?>" hreflang="<?php echo $lg; ?>" />
<?php endforeach; ?>
<?php endif; ?>
<?php if (!empty($lang)): ?>
<link rel="alternate" href="<?php echo $base_url; ?>/<?php echo $lang; ?>/rss" type="application/rss+xml" title="<?php echo $sitename; ?> RSS" />
<?php else: ?>
<link rel="alternate" href="<?php echo $base_url; ?>/rss" type="application/rss+xml" title="<?php echo $sitename; ?> RSS" />
<?php endif; ?>
<?php if (!empty($favicon)): ?>
<link rel="shortcut icon" href="<?php echo $base_path; ?>/<?php echo $favicon; ?>.ico" type="image/x-icon" />
<?php endif; ?>
<?php if (!empty($fonts)): ?>
<?php require_once 'ishttps.php'; ?>
<link rel="stylesheet" type="text/css" href="http<?php if (is_https()): ?>s<?php endif; ?>://fonts.googleapis.com/css?family=<?php echo urlencode(implode('|', $fonts)); ?>" />
<?php endif; ?>
<?php if (false): ?>
<?php require_once 'ishttps.php'; ?>
<link rel="stylesheet" type="text/css" href="http<?php if (is_https()): ?>s<?php endif; ?>://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" media="screen" >
<?php endif; ?>
<?php if (true): ?>
<link rel="stylesheet" type="text/css" href="<?php echo $base_path; ?>/css/zero.css" media="screen" />
<?php endif; ?>
<link rel="stylesheet" type="text/css" href="<?php echo $base_path; ?>/css/screen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="<?php echo $base_path; ?>/css/theme.css" media="screen" />
<?php if (!empty($lang)): ?>
<link rel="stylesheet" type="text/css" href="<?php echo $base_path; ?>/css/<?php echo $lang; ?>.css" media="screen" />
<?php endif; ?>
<?php if (!empty($stylesheets)): ?>
<?php foreach ($stylesheets as $css) : ?>
<?php
$name=$css['name'];
$media=isset($css['media']) ? $css['media'] : 'all';
if ($name[0] == '/' or substr($name, 0, 7) == 'http://' or substr($name, 0, 8) == 'https://') {
	$url=$name;
}
else if (substr($name, -4, 4) == '.css') {
	$url=$base_path . '/css/' . $name;
}
else {
	$url=$base_path . '/css/' . $name . '.css';
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo htmlspecialchars($url, ENT_NOQUOTES, 'UTF-8', false); ?>" media="<?php echo $media; ?>" />
<?php endforeach; ?>
<?php endif; ?>
<?php if (!empty($theme)): ?>
<link rel="stylesheet" type="text/css" href="<?php echo $base_path; ?>/css/themes/<?php echo $theme; ?>.css" media="screen" />
<?php endif; ?>
<link rel="stylesheet" type="text/css" href="<?php echo $base_path; ?>/css/print.css" media="print" />
<?php if (true): ?>
<link rel="stylesheet" type="text/css" href="<?php echo $base_path; ?>/css/media.css" />
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1" />
<?php endif; ?>
<?php require_once 'ismobile.php'; ?>
<?php if (is_mobile()): ?>
<meta name="format-detection" content="telephone=no" />
<?php endif; ?>
<?php if (!empty($javascripts)): ?>
<?php foreach ($javascripts as $js) : ?>
<?php
$name=$js['name'];
$param=isset($js['param']) ? $js['param'] : '';
if ($name[0] == '/' or substr($name, 0, 7) == 'http://' or substr($name, 0, 8) == 'https://') {
	$url=$name;
}
else if (substr($name, -3, 3) == '.js') {
	$url=$base_path . '/js/' . $name;
}
else {
	$url=$base_path . '/js/' . $name . '.js';
}
?>
<script type="text/javascript" src="<?php echo htmlspecialchars($url, ENT_NOQUOTES, 'UTF-8', false); ?>"><?php echo htmlspecialchars($param, ENT_NOQUOTES, 'UTF-8', false); ?></script>
<?php endforeach; ?>
<?php endif; ?>
<script type="text/javascript" src="<?php echo $base_path; ?>/js/tools.js"></script>
<title><?php echo htmlspecialchars(!empty($title) ? $title : $sitename, ENT_NOQUOTES, 'UTF-8', false); ?></title>
<?php if (!empty($style)): ?>
<?php foreach ($style as $media => $css) : ?>
<style type="text/css" media="<?php echo $media; ?>">
<?php echo $css, PHP_EOL; ?>
</style>
<?php endforeach; ?>
<?php endif; ?>
<?php if (!empty($script)): ?>
<script type="text/javascript">
//<![CDATA[
<?php echo $script, PHP_EOL; ?>
//]]>
</script>
<?php endif; ?>
