Skip to content

Commit

Permalink
мелкие правки + возможность получать записи
Browse files Browse the repository at this point in the history
типов контента по списку id
  • Loading branch information
fuze committed Sep 4, 2017
1 parent d451795 commit e88a085
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
3 changes: 2 additions & 1 deletion manifest.en.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[info]
title = "InstantCMS JSON API"
image = "icon.png"
addon_id = "600"

[version]
major = "2"
minor = "0"
build = "0"
date = "20170505"
date = "20170905"

[depends]
core = "2.5.0"
Expand Down
3 changes: 2 additions & 1 deletion manifest.ru.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[info]
title = "InstantCMS JSON API"
image = "icon.png"
addon_id = "600"

[version]
major = "2"
minor = "0"
build = "0"
date = "20170505"
date = "20170905"

[depends]
core = "2.5.0"
Expand Down
2 changes: 1 addition & 1 deletion package/system/controllers/api/actions/method.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private function validateMethodParams() {

$errors = array();

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

$value = $this->request->get($param_name, null);
Expand Down
23 changes: 21 additions & 2 deletions package/system/controllers/api/api_actions/api_content_get.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class actionContentApiContentGet extends cmsAction {
'rules' => array(
array('digits')
)
),
'ids' => array(
'default' => 0,
'rules' => array(
array('regexp', '/^([0-9,]+)$/i')
)
)
);

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

$this->user = $this->model->$this->getItemById('{users}', $user_id);
$this->user = $this->model->getItemById('{users}', $user_id);
if (!$this->user){
return array('error_msg' => LANG_API_ERROR100);
}
Expand All @@ -131,7 +137,7 @@ public function validateApiRequest($ctype_name=null) {
$group_id = $this->request->get('group_id');
if($group_id){

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

// если нужен список по id
$ids = $this->request->get('ids');
if($ids){

$ids = explode(',', $ids);
$ids = array_filter($ids);

if($ids){
$this->model->filterIn('id', $ids);
}

}

// если передан набор, фильтруем по нему
if($this->dataset){
$this->model->applyDatasetFilters($this->dataset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,21 @@ public function run($ctype_name){
return;
}

$categories = array();

$cat_ids = $this->request->get('cat_ids');
if($cat_ids){

$cat_ids = explode(',', $cat_ids);
$cat_ids = array_filter($cat_ids);

$this->model->filterIn('id', $cat_ids);
if($cat_ids){

$this->model->filterIn('id', $cat_ids);

$categories = $this->model->get($this->model->table_prefix.$ctype_name.'_cats');
$categories = $this->model->get($this->model->table_prefix.$ctype_name.'_cats');

}

} else {

Expand Down

0 comments on commit e88a085

Please sign in to comment.