|
@@ -30,6 +30,10 @@
|
|
|
'literal-attributes'=>true
|
|
|
];
|
|
|
private static $regex = [
|
|
|
+ 'getmatch'=>'/\{!([^#\/?_][^}\n]*?)\}/i',
|
|
|
+ 'getparentmatch'=>'/\{!\.\.\/([^#\/?_][^}\n]*?)\}/i',
|
|
|
+ 'getrawmatch'=>'/\{!@([^#\/?_][^}\n]*?)\}/i',
|
|
|
+ 'getrawparentmatch'=>'/\{!@\.\.\/([^#\/?_][^}\n]*?)\}/i',
|
|
|
'match'=>'/\{([^#\/?_][^}\n]*?)\}/i',
|
|
|
'parentmatch'=>'/\{\.\.\/([^#\/?_][^}\n]*?)\}/i',
|
|
|
'rawmatch'=>'/\{@([^#\/?_][^}\n]*?)\}/i',
|
|
@@ -45,7 +49,7 @@
|
|
|
'eval'=>'/\{\?([\W\w\S\s]+)\?\}/i',
|
|
|
'include'=>'/{#include ([^}]+)}/i',
|
|
|
'define'=>'/\{#define ([^}]*)\}([\S\s]*)\{\/define \1\}/i',
|
|
|
- 'widget'=>'/{#widget ([^ }]+)(:? ([^=]+=[^}&]+)*)?}/i'
|
|
|
+ 'widget'=>'/{#widget ([^ }]+)(?: ((?:[^=}]+=[^}&]+)*))?}/i'
|
|
|
];
|
|
|
protected static $parsers;
|
|
|
private $template;
|
|
@@ -102,7 +106,7 @@
|
|
|
$args[urldecode($param[0])] = urldecode($param[1]);
|
|
|
}
|
|
|
}
|
|
|
- $widget = "<?php \$widget_parent[] = \$data; \$data = array_merge(\$data, unserialize(".json_encode(serialize($args)).")); ?>";
|
|
|
+ $widget = "<?php \$widget_parent[] = \$data; \$data = array_merge(json_decode(json_encode(\$data), true), json_decode(base64_decode(".var_export(base64_encode(json_encode($args)), true)."), true)); ?>";
|
|
|
$widget .= static::compile($widgets[$name]);
|
|
|
$widget .= "<?php \$data = array_pop(\$widget_parent); ?>";
|
|
|
}else{
|
|
@@ -168,6 +172,26 @@
|
|
|
return "<?php {$matches[1]}; ?>";
|
|
|
}, $output);
|
|
|
},
|
|
|
+ 'getrawmatch'=>function(&$output){
|
|
|
+ $output = preg_replace_callback(static::$regex['getrawmatch'], function($matches){
|
|
|
+ return "<?=(\$data[\$data[".var_export($matches[1], true)."] ?? ''] ?? '');?>";
|
|
|
+ }, $output);
|
|
|
+ },
|
|
|
+ 'getrawparentmatch'=>function(&$output){
|
|
|
+ $output = preg_replace_callback(static::$regex['getrawparentmatch'], function($matches){
|
|
|
+ return "<?=(\$parent[count(\$parent)-1][\$data[".var_export($matches[1], true)."] ?? ''] ?? '');?>";
|
|
|
+ }, $output);
|
|
|
+ },
|
|
|
+ 'getmatch'=>function(&$output){
|
|
|
+ $output = preg_replace_callback(static::$regex['getmatch'], function($matches){
|
|
|
+ return "<?=htmlentities(\$data[\$data[".var_export($matches[1], true)."] ?? ''] ?? '');?>";
|
|
|
+ }, $output);
|
|
|
+ },
|
|
|
+ 'getparentmatch'=>function(&$output){
|
|
|
+ $output = preg_replace_callback(static::$regex['getparentmatch'], function($matches){
|
|
|
+ return "<?=htmlentities(\$parent[count(\$parent)-1][\$data[".var_export($matches[1], true)."] ?? ''] ?? '');?>";
|
|
|
+ }, $output);
|
|
|
+ },
|
|
|
'rawmatch'=>function(&$output){
|
|
|
$output = preg_replace_callback(static::$regex['rawmatch'], function($matches){
|
|
|
return "<?=(\$data[".var_export($matches[1], true)."] ?? '');?>";
|
|
@@ -285,6 +309,14 @@
|
|
|
static::$parsers['echo']($output);
|
|
|
// Handle {? expression ?}
|
|
|
static::$parsers['eval']($output);
|
|
|
+ // Handle {!@../name}
|
|
|
+ static::$parsers['getrawparentmatch']($output);
|
|
|
+ // Handle {!@name}
|
|
|
+ static::$parsers['getrawmatch']($output);
|
|
|
+ // Handle {!../name}
|
|
|
+ static::$parsers['getparentmatch']($output);
|
|
|
+ // Handle {!name}
|
|
|
+ static::$parsers['getmatch']($output);
|
|
|
// Handle {@../name}
|
|
|
static::$parsers['rawparentmatch']($output);
|
|
|
// Handle {@name}
|