diff --git a/system/api.php b/system/api.php index 751c9d12..55c0032b 100644 --- a/system/api.php +++ b/system/api.php @@ -48,7 +48,28 @@ $ui = new class($key) } function getAll() { - return $this->assign; + + $result = []; + foreach ($this->assign as $key => $value) { + if($value instanceof ORM){ + $result[$key] = $value->as_array(); + }else if($value instanceof IdiormResultSet){ + $count = count($value); + for($n=0;$n<$count;$n++){ + foreach ($value[$n] as $k=>$v) { + $result[$key][$n][$k] = $v; + } + } + }else{ + $result[$key] = $value; + } + } + return $result; + } + + function fetch() + { + return ""; } }; diff --git a/system/autoload/Csrf.php b/system/autoload/Csrf.php index 57752a0e..4c8002b7 100644 --- a/system/autoload/Csrf.php +++ b/system/autoload/Csrf.php @@ -22,8 +22,8 @@ class Csrf public static function check($token) { - global $config; - if($config['csrf_enabled'] == 'yes') { + global $config, $isApi; + if($config['csrf_enabled'] == 'yes' && !$isApi) { if (isset($_SESSION['csrf_token'], $_SESSION['csrf_token_time'], $token)) { $storedToken = $_SESSION['csrf_token']; $tokenTime = $_SESSION['csrf_token_time']; diff --git a/system/autoload/Paginator.php b/system/autoload/Paginator.php index 13675e26..f45eeb50 100644 --- a/system/autoload/Paginator.php +++ b/system/autoload/Paginator.php @@ -10,7 +10,7 @@ class Paginator { public static function findMany($query, $search = [], $per_page = '10', $append_url = "", $toArray = false) { - global $routes, $ui; + global $routes, $ui, $isApi; $adjacents = "2"; $page = _get('p', 1); $page = (empty($page) ? 1 : $page); @@ -72,7 +72,7 @@ class Paginator if ($ui) { $ui->assign('paginator', $result); } - if($toArray){ + if($toArray || $isApi){ return $query->offset($startpoint)->limit($per_page)->find_array(); }else{ return $query->offset($startpoint)->limit($per_page)->find_many(); diff --git a/ui/ui/admin/customers/add.tpl b/ui/ui/admin/customers/add.tpl index 003a496f..a8f96bdf 100644 --- a/ui/ui/admin/customers/add.tpl +++ b/ui/ui/admin/customers/add.tpl @@ -90,7 +90,7 @@