X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JsonOutputTrait.php;h=92a313f98b651f186c70d799352dfe4f40037451;hb=1dddb4e8e56a07f8523583608f979b4772eec0fd;hp=0c1e7a4bf63744e4db99eeaf43393813a1126bdd;hpb=90ef5a22ee8210198820a422282a33fb64249975;p=Pman.Core 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