Skip to content

Commit 5ff6301

Browse files
committed
мелкие улучшения для более удобной разработки
1 parent 213ad80 commit 5ff6301

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

manifest.en.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ addon_id = "600"
66
[version]
77
major = "2"
88
minor = "0"
9-
build = "0"
10-
date = "20170905"
9+
build = "1"
10+
date = "20180105"
1111

1212
[depends]
1313
core = "2.5.0"

manifest.ru.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ addon_id = "600"
66
[version]
77
major = "2"
88
minor = "0"
9-
build = "0"
10-
date = "20170905"
9+
build = "1"
10+
date = "20180105"
1111

1212
[depends]
1313
core = "2.5.0"

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
class actionApiMethod extends cmsAction {
1111

12-
private $method_name = null;
13-
private $method_params = array();
12+
private $method_params = array();
1413
private $method_controller_name = null;
1514
private $method_action_name = null;
1615

@@ -183,6 +182,7 @@ public function run($method_name = null){
183182

184183
// ставим ключ API в свойство
185184
$this->method_action->key = $this->key;
185+
$this->method_action->method_name = $this->method_name;
186186

187187
// валидация параметров запроса
188188
$params_error = $this->validateMethodParams();
@@ -288,6 +288,8 @@ private function validateMethodParams() {
288288

289289
$this->request->set($param_name, $value);
290290

291+
} elseif(!is_null($value) && isset($rules['default'])){
292+
$value = $this->request->get($param_name, $rules['default']);
291293
}
292294

293295
foreach ($rules['rules'] as $rule) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class actionUsersApiUsersGetSig extends cmsAction {
99
public function run(){
1010

1111
$this->result = array(
12-
'sig' => get_sig()
12+
'sig' => get_sig(),
13+
'csrf_token' => cmsForm::generateCSRFToken()
1314
);
1415

1516
}

package/system/controllers/api/frontend.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class api extends cmsFrontend {
1515
private $output_error = array();
1616

1717
public $key = null;
18+
public $method_name = null;
1819

1920
public function __construct($request){
2021

@@ -125,7 +126,7 @@ public function actionExecute() {
125126

126127
if(!$method_result){ return $this->error(13); }
127128

128-
$response[$method_param['method']] = $this->output_success['response'];
129+
$response[!empty($method_param['key']) ? $method_param['key'] : $method_param['method']] = $this->output_success['response'];
129130

130131
}
131132

@@ -268,7 +269,7 @@ function api_image_src($images, $size_preset = false){
268269
}
269270
function form_to_params($form) {
270271

271-
$params = array(array(
272+
$params = array('csrf_token' => array(
272273
'title' => 'csrf_token',
273274
'fields' => array(
274275
array(
@@ -293,7 +294,7 @@ function form_to_params($form) {
293294

294295
$structure = $form->getStructure();
295296

296-
foreach($structure as $fieldset){
297+
foreach($structure as $key => $fieldset){
297298

298299
if (empty($fieldset['childs'])) { continue; }
299300

@@ -304,20 +305,21 @@ function form_to_params($form) {
304305

305306
foreach($fieldset['childs'] as $field){
306307

307-
$param['fields'][] = array(
308+
$param['fields'][$field->getName()] = array(
308309
'title' => $field->title,
309310
'type' => $field->class,
310311
'name' => $field->getName(),
311312
'rules' => $field->getRules(),
312313
'var_type' => $field->var_type,
313314
'items' => (method_exists($field, 'getListItems') ? $field->getListItems() : null),
314315
'hint' => (!empty($field->hint) ? $field->hint : null),
316+
'units' => (!empty($field->units) ? $field->units : null),
315317
'default' => (isset($field->default) ? $field->default : null)
316318
);
317319

318320
}
319321

320-
$params[] = $param;
322+
$params[$key] = $param;
321323

322324
}
323325

0 commit comments

Comments
 (0)