From 5f582e684bfa9c3c4f85ce3890164735f563615c Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 8 Jan 2018 15:57:37 +0300 Subject: [PATCH] Allow to disable functions via config --- template.parser.php | 26 ++++++++++++++++---------- template.php | 4 ++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/template.parser.php b/template.parser.php index dfdf30f..95c7932 100644 --- a/template.parser.php +++ b/template.parser.php @@ -3,8 +3,8 @@ /** * Homepage: http://yourcmc.ru/wiki/VMX::Template * License: GNU GPLv3 or later - * Author: Vitaliy Filippov, 2006-2016 - * Version: V3 (LALR), 2017-02-24 + * Author: Vitaliy Filippov, 2006-2018 + * Version: V3 (LALR), 2018-01-08 * * This file contains the implementation of VMX::Template compiler. * It is only used when a template is compiled in runtime. @@ -259,15 +259,21 @@ static \$smap = $smap; { $argv[] = $a[0]; } - if (method_exists($this, "function_$fn")) + // Check if function is not disabled + if (!empty($this->options->compiletime_functions[$fn]) || + !isset($this->options->compiletime_functions[$fn]) && + method_exists($this, "function_$fn")) { - // Builtin function call using name - $r = call_user_func_array(array($this, "function_$fn"), $argv); - } - elseif (isset($this->options->compiletime_functions[$fn])) - { - // Custom compile-time function call - $r = call_user_func($this->options->compiletime_functions[$fn], $this, $argv); + if (!empty($this->options->compiletime_functions[$fn])) + { + // Custom compile-time function call + $r = call_user_func($this->options->compiletime_functions[$fn], $this, $argv); + } + else + { + // Builtin function call using name + $r = call_user_func_array(array($this, "function_$fn"), $argv); + } } else { diff --git a/template.php b/template.php index 1172c2e..7ab5e56 100644 --- a/template.php +++ b/template.php @@ -7,8 +7,8 @@ * * Homepage: http://yourcmc.ru/wiki/VMX::Template * License: GNU GPLv3 or later - * Author: Vitaliy Filippov, 2006-2016 - * Version: V3 (LALR), 2017-02-24 + * Author: Vitaliy Filippov, 2006-2018 + * Version: V3 (LALR), 2018-01-08 * * The template engine is split into two parts: * (1) This file - always used when running templates