forked from AnrDaemon/test-001
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmarty-config.php
39 lines (29 loc) · 1.19 KB
/
smarty-config.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
<?php
require_once __DIR__ . '/vendor/autoload.php';
$smarty = new \Smarty();
$_SERVER['DOCUMENT_ROOT'] = __DIR__;
$smarty->setConfigDir($_SERVER['DOCUMENT_ROOT']);
$smarty->setTemplateDir($_SERVER['DOCUMENT_ROOT']);
if(!is_dir($_SERVER['DOCUMENT_ROOT'] . '/cache'))
mkdir($_SERVER['DOCUMENT_ROOT'] . '/cache');
$smarty->setCacheDir($_SERVER['DOCUMENT_ROOT'] . '/cache');
if(!is_dir($_SERVER['DOCUMENT_ROOT'] . '/cache/templates'))
mkdir($_SERVER['DOCUMENT_ROOT'] . '/cache/templates');
$smarty->setCompileDir($_SERVER['DOCUMENT_ROOT'] . '/cache/templates');
// add before current plugins directory:
$pluginsDirs = $smarty->getPluginsDir();
if(!is_dir($_SERVER['DOCUMENT_ROOT'] . '/plugins'))
mkdir($_SERVER['DOCUMENT_ROOT'] . '/plugins');
array_unshift($pluginsDirs, $_SERVER['DOCUMENT_ROOT'] . '/plugins');
$smarty->setPluginsDir($pluginsDirs);
$smarty->setForceCompile(false);
$smarty->setCaching(\Smarty::CACHING_LIFETIME_SAVED);
$smarty->setCacheLifetime(5);
$smarty->registerFilter('pre',
function($tpl_source, \Smarty_Internal_Template $template)
{
$stack = stristr($tpl_source, '__HALT_COMPILER');
$tpl = substr($stack, strpos($stack, '?>') + 2);
return $tpl ?: $tpl_source;
}
);