uff
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
class tpl {
|
||||
static $blocks = array();
|
||||
static $views_path = '/home/users/flumm/www/dev.fwtrash.de/views/';
|
||||
static $cache_path = '/home/users/flumm/tmp/';
|
||||
|
||||
static function view($file, $data = array()) {
|
||||
$cached_file = self::cache($file);
|
||||
@ -12,9 +10,10 @@ class tpl {
|
||||
}
|
||||
|
||||
static function cache($file) {
|
||||
if(!file_exists(self::$cache_path))
|
||||
mkdir(self::$cache_path, 0744);
|
||||
$cached_file = self::$cache_path . str_replace(array('/', '.html'), array('_', ''), $file . '.php');
|
||||
global $config;
|
||||
if(!file_exists($config->env->cache))
|
||||
mkdir($config->env->cache, 0744);
|
||||
$cached_file = $config->env->cache . str_replace(array('/', '.html'), array('_', ''), $file . '.php');
|
||||
if(!file_exists($cached_file) || filemtime($cached_file) < filemtime($file)) {
|
||||
$code = self::includeFiles($file);
|
||||
$code = self::compileCode($code);
|
||||
@ -33,7 +32,8 @@ class tpl {
|
||||
}
|
||||
|
||||
static function includeFiles($file) {
|
||||
$code = file_get_contents(self::$views_path . $file);
|
||||
global $config;
|
||||
$code = file_get_contents($config->env->views . $file);
|
||||
preg_match_all('/{% ?(extends|include) ?\'?(.*?)\'? ?%}/i', $code, $matches, PREG_SET_ORDER);
|
||||
foreach($matches as $value)
|
||||
$code = str_replace($value[0], self::includeFiles($value[2]), $code);
|
||||
@ -72,4 +72,3 @@ class tpl {
|
||||
return preg_replace('/{% ?yield ?(.*?) ?%}/i', '', $code);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user