<?php
include_once H.'/sys/plugins/smarty/Smarty.class.php';
class design extends Smarty{
var $theme_obj;
function __construct(){
parent::__construct();
global $dcms,$user;
$theme=$user->theme?$user->theme:$dcms->theme;

$this->theme_obj = new theme($theme);


$this->template_dir = H.'/sys/themes/'.$theme.'/tpl/';
$this->compile_dir = H.'/sys/themes/'.$theme.'/tpl_c/';
$this->config_dir = H.'/sys/themes/'.$theme.'/tpl_conf/';
$this->cache_dir = H.'/sys/themes/'.$theme.'/tpl_cache/';

$this -> setCaching(Smarty::CACHING_OFF);
$this -> setCompileCheck(true);
$this -> allow_php_tag = true;
$this -> error_reporting = false;


$this->assign('URL',URL);
$this->assignByRef('theme',$this->theme_obj);
$this->assignByRef('dcms',$dcms);
$this->assignByRef('user',$user);
$this->assign('SESSION_NAME',SESSION_NAME);
$this->assign('SESS',SESS);
$this->assign('path','/sys/themes/'.$theme);
}




// получение массива с темами
function themes_array($type=false)
{
static $themes_cache;

switch ($type) {
case 'web':$type='web';break;
case 'pda':$type='pda';break;
case 'wap':$type='wap';break;
default:$type='all';break;
}

$themes=&$themes_cache[$type];
if (!isset($themes))
{
$themes = array();
$od=opendir(H.'/sys/themes');

while ($rd=readdir($od)) {
if ($rd{0}=='.')continue;
if (!$conf=@parse_ini_file(H.'/sys/themes/'.$rd.'/config.ini'))continue;

if ($type!=='all' && !empty($conf['browser']) && $conf['browser']!==$type)continue;

$themes[]=array('type'=>$type,'name'=>$rd,'runame'=>$conf['runame'],'dir' => H.'/sys/themes/'.$rd);
}
closedir($od);
}

return $themes;
}

function img_max_width()
{
global $dcms;
return min($this->theme_obj->img_width_max,$dcms->img_max_width);
}

}
?>