From 36fa3366538e1699743122bbfe273040d83c371c Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Tue, 5 Jul 2016 02:33:31 +0200 Subject: [PATCH] Limited autoescaping feature in views --- src/View.php | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/View.php b/src/View.php index b54b51f..28d9cb4 100644 --- a/src/View.php +++ b/src/View.php @@ -189,7 +189,7 @@ class View { { $view_real_path=View::$root_path.'/'.$base_path.'/'.$template.'.php'; - /* + $view_path=View::$root_path.'/'.View::$cache_directory.'/'.$base_path.'/'.$template.'.php'; $all_path[]=$view_real_path; @@ -198,10 +198,37 @@ class View { if(is_file($view_real_path)) { + if(View::$escape==true && $escape==true) + { + + if(!is_file($view_path)) + { + + $directory_cache=View::$root_path.'/'.View::$cache_directory.'/'.$base_path.'/'.dirname($template); + + if(!is_dir($directory_cache)) + { + + if(!mkdir($directory_cache, 0755, true)) + { + + throw new \Exception('Error: directory cache cant be created: '.$directory_cache); + + die; + + } + + } + + + + } + } + } //If escape then get - if(View::$escape==true && $escape==true) + /*if(View::$escape==true && $escape==true) { if(!is_file($view_path)) @@ -311,7 +338,7 @@ class View { #/', '', $file); @@ -319,7 +346,9 @@ class View { $file=preg_replace('/<\?=(.*?)\?>/', '', $file); - $file=preg_replace('/<\?php echo\s+(.*?);/', '