From 1dddb4e8e56a07f8523583608f979b4772eec0fd Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 29 Feb 2024 13:23:49 +0800 Subject: [PATCH] add missing jsencode --- JsonOutputTrait.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/JsonOutputTrait.php b/JsonOutputTrait.php index 0c1e7a4b..92a313f9 100644 --- a/JsonOutputTrait.php +++ b/JsonOutputTrait.php @@ -278,4 +278,23 @@ trait Pman_Core_JsonOutputTrait { } + function jsencode($v, $header = false) + { + if ($header) { + header("Content-type: text/javascript"); + } + if (function_exists("json_encode")) { + $ret= json_encode($v); + if ($ret !== false) { + return $ret; + } + } + require_once 'Services/JSON.php'; + $js = new Services_JSON(); + return $js->encodeUnsafe($v); + + + + } + } \ No newline at end of file -- 2.39.2