Example #1
0
 public function after($controller, $metadata, &$data)
 {
     if ($metadata->or_ajax == 'true') {
         $ismobile = Request::is_ajax();
     } else {
         $ismobile = Dispatcher::RequestType() == 'mobile' && Request::is_ajax();
     }
     if ($ismobile) {
         if ($metadata->key) {
             $data = $data[$metadata->key];
         }
         $data = Model::Flatten($data);
         echo json_encode($data);
         die;
     }
 }
Example #2
0
 public function after($controller, $metadata, &$data)
 {
     $data = Model::Flatten($data);
     $res = json_encode($data);
     if ($metadata->hash) {
         $salt = '';
         if ($metadata->salt) {
             $salt = $metadata->salt;
         } else {
             if ($metadata->app_id) {
                 $app = Config::Get('apps');
                 if ($app->{$metadata->app_id}) {
                     $salt = $app->{$metadata->app_id}->key;
                 }
             }
         }
         header('X-Hash: ' . md5($res . $salt));
     }
     header('Content-Type: text/json');
     echo $res;
     die;
 }
Example #3
0
 static function Flatten(&$data)
 {
     if (is_array($data)) {
         foreach ($data as $key => $value) {
             if ($value instanceof Model) {
                 $data[$key] = $value->to_array();
             } else {
                 if (is_array($value)) {
                     $data[$key] = Model::Flatten($value);
                 }
             }
         }
     }
     return $data;
 }
Example #4
0
 public function after($controller, $metadata, &$data)
 {
     $data = Model::Flatten($data);
     echo json_encode($data);
     die;
 }