-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsSmarty.php
85 lines (72 loc) · 1.82 KB
/
dsSmarty.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* @description:
*
* @author: Monk
* @create: 8.12.2009
* @update: $Id: dsSmarty.php 49 2014-01-07 21:14:32Z Monk $
*/
require('Smarty.class.php');
class dsSmarty extends Smarty
{
public function __construct()
{
global $cfg;
parent::__construct();
$this->template_dir = 'template/'.$cfg['style'].'/templates/';
$this->compile_dir = 'template/'.$cfg['style'].'/templates_c/';
$this->config_dir = 'template/'.$cfg['style'].'/configs/';
$this->cache_dir = 'template/'.$cfg['style'].'/cache/';
$this->register_block('dynamic', 'smarty_block_dynamic', false);
$this->setDebug($cfg['debug']);
// èñïîëüçîâàíèå ïîääèðåêòîðèé äëÿ õðàíåíèÿ ôàéëîâ ñìàðòè
//$this->use_sub_dirs = true;
}
/**
* dsSmarty::setCacheTime() - çàäàíèå âðåìåíè êåøèðîâàíèÿ
*
* @param integer $time - âðåìÿ êåøèðîâàíèÿ â ñåêóíäàõ
* @return void
*/
public function setCacheTime($time = 600)
{
$time = abs(intval($time));
if ($time == 0)
{
$this->setCache(false);
$this->cache_lifetime = 0;
return;
}
$this->caching = 2;
$this->cache_lifetime = $time;
}
/**
* dsSmarty::setCache() - âêëþ÷åíèå/âûêëþ÷åíèÿ êåøèðîâàíèÿ
*
* @param bool $is_cache
* @return void
*/
public function setCache($is_cache)
{
$is_cache = abs(intval($is_cache));
if ($is_cache > 2) $is_cache = 2;
$this->caching = $is_cache;
}
/**
* dsSmarty::getCache() - âêëþ÷åíî ëè êåøèðîâàíèå â øàáëîíå
* @return int
*/
public function getCache()
{
return $this->caching;
}
public function setDebug($debug = false)
{
if (!$debug)
{
// ïðè ñìåíå tpl íóæíî âðó÷íóþ óäàëÿòü ñêîìïèëèðîâàííóþ êîïèþ
$this->compile_check = false;
}
}
}
function smarty_block_dynamic($param, $content, &$smarty) { return $content; }