From: Nicolas Boisselier Date: Mon, 20 Nov 2017 02:47:02 +0000 (+0000) Subject: lib/php/nb.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=29679a0be08d85ddaa9224b1237b756ba8e5d48c;p=nb.git lib/php/nb.php --- diff --git a/lib/php/nb.php b/lib/php/nb.php index 4d2e1201..6f2bd03b 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -432,10 +432,15 @@ class NB { private static function yaml_init() { static $Spyc; - if (empty($Spyc) and !function_exists('yaml_emit')) { - require_once(NB_ROOT.'/lib/php/Spyc.php'); - function yaml_emit($data) { return Spyc::YAMLDump($data, false, false, true); } - function yaml_parse_file($file) { return Spyc::YAMLLoad($file); } + if (!isset($Spyc)) { + + if (!function_exists('yaml_emit')) { + require_once(NB_ROOT.'/lib/php/Spyc.php'); + function yaml_emit($data) { return Spyc::YAMLDump($data, false, false, true); } + function yaml_parse_file($file) { return Spyc::YAMLLoad($file); } + function yaml_parse($str) { return Spyc::YAMLLoadString($str); } + } + $Spyc = true; } } @@ -458,6 +463,10 @@ class NB { return "$yaml\n"; } + public static function yaml_decode($str) { + return yaml_parse($str); + } + /* * Function: debug_backtrace_msg * @copyright 13.07.11