24 if($this->numericCheck) array_walk_recursive($data,
function(&$value){
25 if(\
Rsi\Str::numeric($value) && (strpos(
'.',$value) || (abs($value) < $this->maxInt))) $value += 0;
27 return json_encode($data,$this->_fred->debug ? JSON_PRETTY_PRINT : 0);
42 public function menu($menu,$type =
null){
43 extract($this->
components(
'front',
'router',
'trans',
'user'));
44 if($type ===
true) $type = $router->viewtype;
46 if($menu)
foreach($menu as $item){
47 if($controller = $item[
'controller'] ??
null) $controller = $front->controllerFactory($controller);
48 $right = $item[
'right'] ??
null;
49 if((!$controller || $front->controllerAuthorized($controller->name)) && (!$right || $user->authorized($right))){
50 $link = ($item[
'link'] ??
null) ?: ($controller ? $router->reverse($controller->name,$type) :
null);
51 $items = $this->
menu($item[
'items'] ??
null);
52 if($link || $items) $result[$item[
'caption'] ?? $trans->id(str_replace(
'*',$controller->name,$this->menuCaptionId))] =
53 compact(
'link',
'items');
60 if(!headers_sent()) header(
'Content-type: application/json; charset=utf-8');
62 if($error = json_last_error())
63 $this->
component(
'log')->error(
'JSON encoding error: ' . json_last_error_msg(),__FILE__,__LINE__,compact(
'data',
'error'));
69 'data' => $request->data,
70 'result' => $request->result,
72 if(!$request->action) $data[
'config'] = array_merge(
73 $this->_fred->clientConfig(),
74 [
'controller' => $this->_controller->clientConfig()]
76 if($request->errors) $data[
'errors'] = $request->errors;
77 if($request->redir) $data[
'redir'] = $request->redir;
78 elseif($messages = $this->
component(
'message')->retrieve()) $data[
'messages'] = $messages;