1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Ui controller |
5
|
|
|
* |
6
|
|
|
* @author Alexey Krupskiy <[email protected]> |
7
|
|
|
* @link http://inji.ru/ |
8
|
|
|
* @copyright 2015 Alexey Krupskiy |
9
|
|
|
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
10
|
|
|
*/ |
11
|
|
|
class UiController extends Controller { |
|
|
|
|
12
|
|
|
|
13
|
|
|
public function formPopUpAction() { |
14
|
|
|
if (strpos($_GET['item'], ':')) { |
15
|
|
|
$raw = explode(':', $_GET['item']); |
16
|
|
|
$modelName = $raw[0]; |
17
|
|
|
$id = $raw[1]; |
18
|
|
|
$model = $modelName::get($id, $modelName::index(), !empty($_GET['params']['dataManagerParams']) ? $_GET['params']['dataManagerParams'] : []); |
19
|
|
|
} else { |
20
|
|
|
$modelName = $_GET['item']; |
21
|
|
|
$model = new $modelName(); |
22
|
|
|
} |
23
|
|
|
$params = []; |
24
|
|
|
if (!empty($_GET['params'])) { |
25
|
|
|
$params = $_GET['params']; |
26
|
|
|
if (!empty($params['preset'])) { |
27
|
|
|
$model->setParams($params['preset']); |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
if (!empty($_GET['params']['dataManagerParams']['appType'])) { |
31
|
|
|
$params['appType'] = $_GET['params']['dataManagerParams']['appType']; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$formName = !empty($_GET['formName']) ? $_GET['formName'] : (!empty($_GET['params']['formName']) ? $_GET['params']['formName'] : 'manager'); |
35
|
|
|
$form = new Ui\ActiveForm($model, $formName); |
36
|
|
|
if (!empty($_GET['_']) || !empty($_POST['_'])) { |
37
|
|
|
$return = new Server\Result(); |
38
|
|
|
ob_start(); |
39
|
|
|
$form->checkRequest($params, true); |
40
|
|
|
$_GET['item'] = get_class($form->model) . ($model->pk() ? ':' . $model->pk() : ''); |
41
|
|
|
$get = $_GET; |
42
|
|
|
if (isset($get['notSave'])) { |
43
|
|
|
unset($get['notSave']); |
44
|
|
|
} |
45
|
|
|
$this->view->widget('msgList'); |
46
|
|
|
$form->action = (App::$cur->system ? '/' . App::$cur->name : '') . '/ui/formPopUp/?' . http_build_query($get); |
47
|
|
|
$form->draw($params, true); |
48
|
|
|
$return->content = ob_get_contents(); |
49
|
|
|
ob_end_clean(); |
50
|
|
|
$return->send(); |
51
|
|
|
} else { |
52
|
|
|
$form->checkRequest($params); |
53
|
|
|
$_GET['item'] = get_class($form->model) . ($model->pk() ? ':' . $model->pk() : ''); |
54
|
|
|
$get = $_GET; |
55
|
|
|
if (isset($get['notSave'])) { |
56
|
|
|
unset($get['notSave']); |
57
|
|
|
} |
58
|
|
|
$form->action = (App::$cur->system ? '/' . App::$cur->name : '') . '/ui/formPopUp/?' . http_build_query($get); |
59
|
|
|
$this->view->setTitle(($model && $model->pk() ? 'Изменить ' : 'Создать ') . $form->header); |
60
|
|
|
$this->view->page(['content' => 'form', 'data' => compact('form', 'params')]); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function fastEditAction() { |
65
|
|
|
$model = $_POST['model']::get($_POST['key']); |
66
|
|
|
if ($model && $model->checkAccess()) { |
67
|
|
|
$model->{$_POST['col']} = $_POST['data']; |
68
|
|
|
$model->save(); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function autocompleteAction() { |
73
|
|
|
$snippets = $this->module->getSnippets('autocomplete'); |
74
|
|
|
if (!is_string($_GET['snippet']) || !isset($snippets[$_GET['snippet']])) { |
75
|
|
|
exit(); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
$snippet = $snippets[$_GET['snippet']]; |
78
|
|
|
$result = new \Server\Result(); |
79
|
|
|
$result->content = $snippet['find']($_GET['search'], $_GET['snippetParams']); |
80
|
|
|
$result->send(); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths