Skip to content

Commit e88a085

Browse files
author
fuze
committed
мелкие правки + возможность получать записи
типов контента по списку id
1 parent d451795 commit e88a085

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

manifest.en.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[info]
22
title = "InstantCMS JSON API"
33
image = "icon.png"
4+
addon_id = "600"
45

56
[version]
67
major = "2"
78
minor = "0"
89
build = "0"
9-
date = "20170505"
10+
date = "20170905"
1011

1112
[depends]
1213
core = "2.5.0"

manifest.ru.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[info]
22
title = "InstantCMS JSON API"
33
image = "icon.png"
4+
addon_id = "600"
45

56
[version]
67
major = "2"
78
minor = "0"
89
build = "0"
9-
date = "20170505"
10+
date = "20170905"
1011

1112
[depends]
1213
core = "2.5.0"

package/system/controllers/api/actions/method.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private function validateMethodParams() {
252252

253253
$errors = array();
254254

255-
// фалидация аналогична валидации форм
255+
// валидация аналогична валидации форм
256256
foreach ($this->method_action->request_params as $param_name => $rules) {
257257

258258
$value = $this->request->get($param_name, null);

package/system/controllers/api/api_actions/api_content_get.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ class actionContentApiContentGet extends cmsAction {
6464
'rules' => array(
6565
array('digits')
6666
)
67+
),
68+
'ids' => array(
69+
'default' => 0,
70+
'rules' => array(
71+
array('regexp', '/^([0-9,]+)$/i')
72+
)
6773
)
6874
);
6975

@@ -109,7 +115,7 @@ public function validateApiRequest($ctype_name=null) {
109115
$user_id = $this->request->get('user_id');
110116
if($user_id){
111117

112-
$this->user = $this->model->$this->getItemById('{users}', $user_id);
118+
$this->user = $this->model->getItemById('{users}', $user_id);
113119
if (!$this->user){
114120
return array('error_msg' => LANG_API_ERROR100);
115121
}
@@ -131,7 +137,7 @@ public function validateApiRequest($ctype_name=null) {
131137
$group_id = $this->request->get('group_id');
132138
if($group_id){
133139

134-
$this->group = $this->model->$this->getItemById('content_folders', $group_id);
140+
$this->group = $this->model->getItemById('groups', $group_id);
135141
if (!$this->group){
136142
return array('error_msg' => LANG_API_ERROR100);
137143
}
@@ -166,6 +172,19 @@ public function run($ctype_name){
166172
// категории выключены, а передали категорию
167173
if (empty($this->ctype['is_cats']) && $this->cat['id'] > 1) { return; }
168174

175+
// если нужен список по id
176+
$ids = $this->request->get('ids');
177+
if($ids){
178+
179+
$ids = explode(',', $ids);
180+
$ids = array_filter($ids);
181+
182+
if($ids){
183+
$this->model->filterIn('id', $ids);
184+
}
185+
186+
}
187+
169188
// если передан набор, фильтруем по нему
170189
if($this->dataset){
171190
$this->model->applyDatasetFilters($this->dataset);

package/system/controllers/api/api_actions/api_content_get_categories.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,21 @@ public function run($ctype_name){
7878
return;
7979
}
8080

81+
$categories = array();
82+
8183
$cat_ids = $this->request->get('cat_ids');
8284
if($cat_ids){
8385

8486
$cat_ids = explode(',', $cat_ids);
8587
$cat_ids = array_filter($cat_ids);
8688

87-
$this->model->filterIn('id', $cat_ids);
89+
if($cat_ids){
90+
91+
$this->model->filterIn('id', $cat_ids);
8892

89-
$categories = $this->model->get($this->model->table_prefix.$ctype_name.'_cats');
93+
$categories = $this->model->get($this->model->table_prefix.$ctype_name.'_cats');
94+
95+
}
9096

9197
} else {
9298

0 commit comments

Comments
 (0)