add missing jsencode
[Pman.Core] / JsonOutputTrait.php
index 0c1e7a4..92a313f 100644 (file)
@@ -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