Allow to disable functions via config

master
Vitaliy Filippov 2018-01-08 15:57:37 +03:00
parent f32d481341
commit 5f582e684b
2 changed files with 18 additions and 12 deletions

View File

@ -3,8 +3,8 @@
/** /**
* Homepage: http://yourcmc.ru/wiki/VMX::Template * Homepage: http://yourcmc.ru/wiki/VMX::Template
* License: GNU GPLv3 or later * License: GNU GPLv3 or later
* Author: Vitaliy Filippov, 2006-2016 * Author: Vitaliy Filippov, 2006-2018
* Version: V3 (LALR), 2017-02-24 * Version: V3 (LALR), 2018-01-08
* *
* This file contains the implementation of VMX::Template compiler. * This file contains the implementation of VMX::Template compiler.
* It is only used when a template is compiled in runtime. * It is only used when a template is compiled in runtime.
@ -259,15 +259,21 @@ static \$smap = $smap;
{ {
$argv[] = $a[0]; $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 if (!empty($this->options->compiletime_functions[$fn]))
$r = call_user_func_array(array($this, "function_$fn"), $argv); {
} // Custom compile-time function call
elseif (isset($this->options->compiletime_functions[$fn])) $r = call_user_func($this->options->compiletime_functions[$fn], $this, $argv);
{ }
// Custom compile-time function call else
$r = call_user_func($this->options->compiletime_functions[$fn], $this, $argv); {
// Builtin function call using name
$r = call_user_func_array(array($this, "function_$fn"), $argv);
}
} }
else else
{ {

View File

@ -7,8 +7,8 @@
* *
* Homepage: http://yourcmc.ru/wiki/VMX::Template * Homepage: http://yourcmc.ru/wiki/VMX::Template
* License: GNU GPLv3 or later * License: GNU GPLv3 or later
* Author: Vitaliy Filippov, 2006-2016 * Author: Vitaliy Filippov, 2006-2018
* Version: V3 (LALR), 2017-02-24 * Version: V3 (LALR), 2018-01-08
* *
* The template engine is split into two parts: * The template engine is split into two parts:
* (1) This file - always used when running templates * (1) This file - always used when running templates