@@ -27,8 +27,8 @@ class DLPViewer
2727 public static function makeComponentDot (Form $ form , string $ column , string $ title , array $ select = [], array $ selected = [],bool $ strict = false )
2828 {
2929 if ($ strict ) {
30- $ select = self ::safeJson ($ select );
31- $ selected = self ::safeJson ($ selected );
30+ $ select = DLPHelper ::safeJson ($ select );
31+ $ selected = DLPHelper ::safeJson ($ selected );
3232 } else {
3333 $ select = json_encode ($ select , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
3434 $ selected = json_encode ($ selected , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
@@ -52,7 +52,7 @@ public static function makeComponentDot(Form $form, string $column, string $titl
5252 public static function makeComponentLine (Form $ form , string $ column , string $ title , array $ settings = [], array $ data = [], bool $ strict = false )
5353 {
5454 if ($ strict ) {
55- $ data = self ::safeJson ($ data );
55+ $ data = DLPHelper ::safeJson ($ data );
5656 }else {
5757 $ data = json_encode ($ data , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
5858 }
@@ -249,28 +249,4 @@ public static function result($success = true, $message = 'OK', $data = [])
249249 ->header ('Content-Type ' , 'application/json;charset=utf-8 ' )
250250 ->header ('Access-Control-Allow-Origin ' , '* ' );
251251 }
252-
253- /**
254- * @param array $data
255- * @return false|string
256- */
257- public static function safeJson (array $ data )
258- {
259- self ::recursiveJsonArray ($ data );
260- return json_encode ($ data , JSON_UNESCAPED_UNICODE );
261- }
262-
263- /**
264- * @param array $data
265- */
266- private static function recursiveJsonArray (array &$ data )
267- {
268- foreach ($ data as &$ d ) {
269- if (is_array ($ d )) {
270- self ::recursiveJsonArray ($ d );
271- } else {
272- $ d = str_replace (['" ' , '\'' , ': ' , '\\' , '{ ' , '} ' , '[ ' , '] ' ,'` ' ], '' , $ d );
273- }
274- }
275- }
276252}
0 commit comments