2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* MainTemplate.php
|
|
|
|
* Defines the key template MainTemplate.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class MainTemplate extends Template
|
|
|
|
{
|
|
|
|
private $title = '';
|
|
|
|
private $classes = [];
|
|
|
|
private $area;
|
|
|
|
private $css = '';
|
|
|
|
private $header_html = '';
|
|
|
|
private $canonical_url = '';
|
|
|
|
|
|
|
|
public function __construct($title = '')
|
|
|
|
{
|
|
|
|
$this->title = $title;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function html_main()
|
|
|
|
{
|
|
|
|
echo '<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2023-03-11 13:12:12 +01:00
|
|
|
<title>', $this->title, '</title>';
|
|
|
|
|
|
|
|
if (!empty($this->canonical_url))
|
|
|
|
echo '
|
|
|
|
<link rel="canonical" href="', $this->canonical_url, '">';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<link rel="stylesheet" href="', BASEURL, '/vendor/twbs/bootstrap/dist/css/bootstrap.min.css">
|
|
|
|
<link rel="stylesheet" href="', BASEURL, '/vendor/twbs/bootstrap-icons/font/bootstrap-icons.css">
|
2016-09-01 23:13:23 +02:00
|
|
|
<link type="text/css" rel="stylesheet" href="', BASEURL, '/css/default.css">
|
2023-03-11 13:12:12 +01:00
|
|
|
<script type="text/javascript" src="', BASEURL, '/js/main.js"></script>'
|
|
|
|
, $this->header_html, '
|
2016-09-01 23:13:23 +02:00
|
|
|
</head>
|
|
|
|
<body', !empty($this->classes) ? ' class="' . implode(' ', $this->classes) . '"' : '', '>
|
2023-03-11 15:14:05 +01:00
|
|
|
<header>';
|
|
|
|
|
|
|
|
$bar = new MainNavBar();
|
|
|
|
$bar->html_main();
|
|
|
|
|
|
|
|
echo '
|
2016-09-01 23:13:23 +02:00
|
|
|
</header>
|
|
|
|
<div id="wrapper">';
|
|
|
|
|
|
|
|
foreach ($this->_subtemplates as $template)
|
|
|
|
$template->html_main();
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<footer>';
|
|
|
|
|
|
|
|
if (Registry::has('user') && Registry::get('user')->isAdmin())
|
|
|
|
{
|
|
|
|
if (class_exists('Cache'))
|
|
|
|
echo '
|
|
|
|
<span class="cache-info">Cache info: ', Cache::$hits, ' hits, ', Cache::$misses, ' misses, ', Cache::$puts, ' puts, ', Cache::$removals, ' removals</span>';
|
|
|
|
|
|
|
|
if (Registry::has('start'))
|
|
|
|
echo '<br>
|
|
|
|
<span class="creation-time">Page creation time: ', sprintf('%1.4f', microtime(true) - Registry::get('start')), ' seconds</span>';
|
|
|
|
|
|
|
|
if (Registry::has('db'))
|
|
|
|
echo '<br>
|
|
|
|
<span class="query-count">Database interaction: ', Registry::get('db')->getQueryCount(), ' queries</span>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
echo '
|
2016-09-02 11:16:01 +02:00
|
|
|
<span class="vanity">Powered by <a href="https://aaronweb.net/projects/kabuki/">Kabuki CMS</a></span>';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</footer>
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
if (Registry::has('db') && defined("DB_LOG_QUERIES") && DB_LOG_QUERIES)
|
|
|
|
foreach (Registry::get('db')->getLoggedQueries() as $query)
|
|
|
|
echo '<pre>', strtr($query, "\t", " "), '</pre>';
|
|
|
|
|
|
|
|
echo '
|
2023-03-11 15:14:05 +01:00
|
|
|
<script type="text/javascript" src="', BASEURL, '/vendor/twbs/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
2016-09-01 23:13:23 +02:00
|
|
|
</body>
|
|
|
|
</html>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function appendHeaderHtml($html)
|
|
|
|
{
|
|
|
|
$this->header_html .= "\n\t\t" . $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function appendStylesheet($uri)
|
|
|
|
{
|
|
|
|
$this->appendHeaderHtml('<link text="text/css" rel="stylesheet" href="'. $uri . '">');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCanonicalUrl($url)
|
|
|
|
{
|
|
|
|
$this->canonical_url = $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addClass($class)
|
|
|
|
{
|
|
|
|
if (!in_array($class, $this->classes))
|
|
|
|
$this->classes[] = $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function removeClass($class)
|
|
|
|
{
|
|
|
|
if ($key = array_search($class, $this->classes) !== false)
|
|
|
|
unset($this->classes[$key]);
|
|
|
|
}
|
|
|
|
}
|