<?php
require_once($smartyroot.'Smarty.class.php');
class Website extends Smarty {
var $settings;
var $scripts;
var $scripts_bottom;
var $styles;
var $styles_media;
function Website($settings = null) {
parent::Smarty();
$this->scripts = array();
$this->scripts_bottom = array();
$this->styles = array();
$this->styles_media = array();
$this->onloadscripts = array();
if (!empty($settings)) {
if (isset($settings["smarty"]["template_dir"]))
$this->template_dir = $settings["smarty"]["template_dir"];
if (isset($settings["smarty"]["compile_dir"]))
$this->compile_dir = $settings["smarty"]["compile_dir"];
if (isset($settings["smarty"]["config_dir"]))
$this->config_dir = $settings["smarty"]["config_dir"];
if (isset($settings["smarty"]["cache_dir"]))
$this->cache_dir = $settings["smarty"]["cache_dir"];
if (isset($settings["smarty"]["caching"]))
$this->caching = $settings["smarty"]["caching"];
}
}
function addScript($src) {
if (!in_array($src, $this->scripts)) $this->scripts[] = $src;
}
function addScript_bottom($src) {
if (!in_array($src, $this->scripts_bottom)) $this->scripts_bottom[] = $src;
}
function addStyle($src) {
if (!in_array($src, $this->styles)) $this->styles[] = $src;
}
function addStyle_media($src) {
if (!in_array($src, $this->styles_media)) $this->styles_media[] = $src;
}
function onload($param) {
$this->assign("onload", $param);
}
function display($src) {
$this->assign("js_top", $this->scripts);
$this->assign("js_bottom", $this->scripts_bottom);
$this->assign("css_top", $this->styles);
$this->assign("css_media", $this->styles_media);
$this->assign("oljs", $this->onloadscripts);
$html = parent::display($src);
}
function generateSrc($src) {
$this->assign("js_top", $this->scripts);
$this->assign("js_bottom", $this->scripts_bottom);
$this->assign("css_top", $this->styles);
$this->assign("css_media", $this->styles_media);
$this->assign("oljs", $this->onloadscripts);
$html = parent::fetch($src);
return $html;
}
/**
* Overwrite the default error trigger of Smarty. Give some more information.
*
* @param $error_msg
* @param $error_type
*/
function trigger_error($error_msg, $error_type = E_USER_WARNING) {
global $settings;
$error_msg = preg_replace("/\"/", "'", $error_msg);
$email = $settings["adminmail"];
echo <<<EOT
<style>
html, body {
background-color: gray;
border: 0px;
margin: 0px;
padding: 0px;
font-family: Verdana, Arial;
font-size: 12px;
}
#root {
position: relative;
background-color: white;
width: 760px;
left: 50%;
border: 1px solid black;
margin: 0px;
margin-left: -380px;
padding: 0px;
}
#main {
margin-top: 20px;
padding: 10px;
}
</style>
<div id="root">
<div id="main">
<h1>Template error</h1>
<p>The website cannot be displayed correctly because there was a problem with the template engine.
Please check the template parameters in the config file.
</p>
<p><i>Smarty error: $error_msg</i></p>
</div>
</div>
EOT;
}
}
?>