@@ -13,52 +13,52 @@ discard block |
||
13 | 13 | |
14 | 14 | class Menu extends \Model { |
15 | 15 | |
16 | - public static $objectName = 'Меню'; |
|
17 | - public static $labels = [ |
|
18 | - 'name' => 'Название', |
|
19 | - 'code' => 'Алиас', |
|
20 | - 'item' => 'Пункты меню', |
|
21 | - 'group_id' => 'Группа пользователей', |
|
22 | - ]; |
|
23 | - public static $storage = ['type' => 'moduleConfig']; |
|
24 | - public static $cols = [ |
|
25 | - 'name' => ['type' => 'text'], |
|
26 | - 'code' => ['type' => 'text'], |
|
27 | - 'item' => ['type' => 'dataManager', 'relation' => 'items'], |
|
28 | - 'group_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'group'] |
|
29 | - ]; |
|
30 | - public static $dataManagers = [ |
|
31 | - 'manager' => [ |
|
32 | - 'options' => [ |
|
33 | - 'access' => [ |
|
34 | - 'groups' => [ |
|
35 | - 3 |
|
36 | - ] |
|
37 | - ] |
|
38 | - ], |
|
39 | - 'cols' => [ |
|
40 | - 'name', 'code', 'item', 'group_id' |
|
41 | - ] |
|
42 | - ] |
|
43 | - ]; |
|
44 | - public static $forms = [ |
|
45 | - 'manager' => [ |
|
46 | - 'options' => [ |
|
47 | - 'access' => [ |
|
48 | - 'groups' => [ |
|
49 | - 3 |
|
50 | - ] |
|
51 | - ] |
|
52 | - ], |
|
53 | - 'map' => [ |
|
54 | - ['name', 'code'], |
|
55 | - ['group_id'], |
|
56 | - ['item'] |
|
57 | - ] |
|
58 | - ] |
|
59 | - ]; |
|
16 | + public static $objectName = 'Меню'; |
|
17 | + public static $labels = [ |
|
18 | + 'name' => 'Название', |
|
19 | + 'code' => 'Алиас', |
|
20 | + 'item' => 'Пункты меню', |
|
21 | + 'group_id' => 'Группа пользователей', |
|
22 | + ]; |
|
23 | + public static $storage = ['type' => 'moduleConfig']; |
|
24 | + public static $cols = [ |
|
25 | + 'name' => ['type' => 'text'], |
|
26 | + 'code' => ['type' => 'text'], |
|
27 | + 'item' => ['type' => 'dataManager', 'relation' => 'items'], |
|
28 | + 'group_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'group'] |
|
29 | + ]; |
|
30 | + public static $dataManagers = [ |
|
31 | + 'manager' => [ |
|
32 | + 'options' => [ |
|
33 | + 'access' => [ |
|
34 | + 'groups' => [ |
|
35 | + 3 |
|
36 | + ] |
|
37 | + ] |
|
38 | + ], |
|
39 | + 'cols' => [ |
|
40 | + 'name', 'code', 'item', 'group_id' |
|
41 | + ] |
|
42 | + ] |
|
43 | + ]; |
|
44 | + public static $forms = [ |
|
45 | + 'manager' => [ |
|
46 | + 'options' => [ |
|
47 | + 'access' => [ |
|
48 | + 'groups' => [ |
|
49 | + 3 |
|
50 | + ] |
|
51 | + ] |
|
52 | + ], |
|
53 | + 'map' => [ |
|
54 | + ['name', 'code'], |
|
55 | + ['group_id'], |
|
56 | + ['item'] |
|
57 | + ] |
|
58 | + ] |
|
59 | + ]; |
|
60 | 60 | |
61 | - public static function relations() { |
|
61 | + public static function relations() { |
|
62 | 62 | return [ |
63 | 63 | 'items' => [ |
64 | 64 | 'type' => 'many', |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | 'model' => 'Users\Group' |
71 | 71 | ] |
72 | 72 | ]; |
73 | - } |
|
73 | + } |
|
74 | 74 | |
75 | - public static function index() { |
|
75 | + public static function index() { |
|
76 | 76 | return 'id'; |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | 79 | } |
@@ -5,33 +5,33 @@ discard block |
||
5 | 5 | $formParams = ['formName' => 'manager']; |
6 | 6 | $aform = new \Ui\ActiveForm($item, $formParams['formName']); |
7 | 7 | if ($aform->checkAccess()) { |
8 | - $table->addButton([ |
|
9 | - 'text' => 'Редактировать', |
|
10 | - 'onclick' => 'inji.Ui.forms.popUp("' . addcslashes($modelName, '\\') . ':' . $item->pk() . '",' . json_encode($formParams) . ');', |
|
11 | - ]); |
|
8 | + $table->addButton([ |
|
9 | + 'text' => 'Редактировать', |
|
10 | + 'onclick' => 'inji.Ui.forms.popUp("' . addcslashes($modelName, '\\') . ':' . $item->pk() . '",' . json_encode($formParams) . ');', |
|
11 | + ]); |
|
12 | 12 | } |
13 | 13 | $row = []; |
14 | 14 | $cols = !empty($modelName::$views['manager']['cols']) ? $modelName::$views['manager']['cols'] : array_keys($modelName::$cols); |
15 | 15 | foreach ($cols as $colName) { |
16 | - $modelName = get_class($item); |
|
17 | - $colInfo = $modelName::getColInfo($colName); |
|
18 | - $type = !empty($colInfo['colParams']['type']) ? $colInfo['colParams']['type'] : 'string'; |
|
19 | - if ($type != 'dataManager') { |
|
16 | + $modelName = get_class($item); |
|
17 | + $colInfo = $modelName::getColInfo($colName); |
|
18 | + $type = !empty($colInfo['colParams']['type']) ? $colInfo['colParams']['type'] : 'string'; |
|
19 | + if ($type != 'dataManager') { |
|
20 | 20 | $table->addRow([ |
21 | 21 | !empty($modelName::$labels[$colName]) ? $modelName::$labels[$colName] : $colName, |
22 | 22 | \Model::resloveTypeValue($item, $colName, true) |
23 | 23 | ]); |
24 | - } |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | $table->draw(); |
27 | 27 | $form = new \Ui\Form(); |
28 | 28 | $relations = $modelName::relations(); |
29 | 29 | foreach ($cols as $colName) { |
30 | - $colInfo = $modelName::getColInfo($colName); |
|
31 | - if ($colInfo['colParams']['type'] == 'dataManager') { |
|
30 | + $colInfo = $modelName::getColInfo($colName); |
|
31 | + if ($colInfo['colParams']['type'] == 'dataManager') { |
|
32 | 32 | $dataManager = new \Ui\DataManager($relations[$colInfo['colParams']['relation']]['model']); |
33 | 33 | $dataManager->draw(['relation' => $colInfo['colParams']['relation']], $item); |
34 | - } |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | ?> |
37 | 37 | <div> |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | ]]); |
43 | 43 | ?>)</h3> |
44 | 44 | <?php |
45 | - foreach (\Dashboard\Comment::getList([ 'where' => [ |
|
46 | - ['item_id', $item->id], |
|
47 | - ['model', $modelName], |
|
48 | - ], 'order' => ['date_create', 'desc']]) as $comment) { |
|
45 | + foreach (\Dashboard\Comment::getList([ 'where' => [ |
|
46 | + ['item_id', $item->id], |
|
47 | + ['model', $modelName], |
|
48 | + ], 'order' => ['date_create', 'desc']]) as $comment) { |
|
49 | 49 | ?> |
50 | 50 | <div class="row"> |
51 | 51 | <div class="col-sm-3" style="max-width: 300px;"> |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | </div> |
58 | 58 | </div> |
59 | 59 | <?php |
60 | - } |
|
61 | - ?> |
|
60 | + } |
|
61 | + ?> |
|
62 | 62 | </div> |
63 | 63 | <div> |
64 | 64 | <?php |
65 | - $form = new \Ui\Form(); |
|
66 | - $form->begin(); |
|
67 | - $form->input('textarea', 'comment', 'Комментарий'); |
|
68 | - $form->end(); |
|
69 | - ?> |
|
65 | + $form = new \Ui\Form(); |
|
66 | + $form->begin(); |
|
67 | + $form->input('textarea', 'comment', 'Комментарий'); |
|
68 | + $form->end(); |
|
69 | + ?> |
|
70 | 70 | </div> |
@@ -10,31 +10,31 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class DataManagerController extends Controller { |
12 | 12 | |
13 | - public function parseRequest() { |
|
13 | + public function parseRequest() { |
|
14 | 14 | $return = []; |
15 | 15 | $return['params'] = UserRequest::get('params', 'array', []); |
16 | 16 | |
17 | 17 | $item = UserRequest::get('modelName', 'string', ''); |
18 | 18 | if (!$item) { |
19 | - $item = UserRequest::get('item', 'string', ''); |
|
19 | + $item = UserRequest::get('item', 'string', ''); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (strpos($item, ':')) { |
23 | - $raw = explode(':', $item); |
|
24 | - $return['modelName'] = $raw[0]; |
|
25 | - $return['model'] = $return['modelName']::get($raw[1], $return['modelName']::index(), $return['params']); |
|
23 | + $raw = explode(':', $item); |
|
24 | + $return['modelName'] = $raw[0]; |
|
25 | + $return['model'] = $return['modelName']::get($raw[1], $return['modelName']::index(), $return['params']); |
|
26 | 26 | } else { |
27 | - $return['modelName'] = $item; |
|
28 | - $return['model'] = null; |
|
27 | + $return['modelName'] = $item; |
|
28 | + $return['model'] = null; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | if (!empty($return['params']['relation'])) { |
32 | - $relation = $return['modelName']::getRelation($return['params']['relation']); |
|
33 | - if (!empty($relation['type']) && $relation['type'] == 'relModel') { |
|
32 | + $relation = $return['modelName']::getRelation($return['params']['relation']); |
|
33 | + if (!empty($relation['type']) && $relation['type'] == 'relModel') { |
|
34 | 34 | $return['modelName'] = $relation['relModel']; |
35 | - } else { |
|
35 | + } else { |
|
36 | 36 | $return['modelName'] = $relation['model']; |
37 | - } |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | $return['params']['filters'] = UserRequest::get('filters', 'array', []); |
40 | 40 | $return['params']['sortered'] = UserRequest::get('sortered', 'array', []); |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | |
55 | 55 | $return['managerName'] = UserRequest::get('managerName', 'string', 'manager'); |
56 | 56 | if (!$return['managerName']) { |
57 | - $return['managerName'] = 'manager'; |
|
57 | + $return['managerName'] = 'manager'; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $return; |
61 | - } |
|
61 | + } |
|
62 | 62 | |
63 | - public function indexAction() { |
|
63 | + public function indexAction() { |
|
64 | 64 | $result = new Server\Result(); |
65 | 65 | |
66 | 66 | ob_start(); |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | ob_end_clean(); |
76 | 76 | |
77 | 77 | $result->send(); |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | - public function loadRowsAction() { |
|
80 | + public function loadRowsAction() { |
|
81 | 81 | $result = new Server\Result(); |
82 | 82 | $result->content = []; |
83 | 83 | |
@@ -88,55 +88,55 @@ discard block |
||
88 | 88 | $dataManager = new Ui\DataManager($request['modelName'], $request['managerName']); |
89 | 89 | if ($request['download']) { |
90 | 90 | |
91 | - ini_set('memory_limit', '2000M'); |
|
92 | - set_time_limit(0); |
|
91 | + ini_set('memory_limit', '2000M'); |
|
92 | + set_time_limit(0); |
|
93 | 93 | |
94 | - $request['params']['all'] = true; |
|
95 | - $request['params']['download'] = true; |
|
96 | - ob_end_clean(); |
|
97 | - header('Content-Encoding: UTF-8'); |
|
98 | - header("Content-Type: text/csv"); |
|
99 | - header("Content-Disposition: attachment; filename=" . $request['modelName']::$objectName . '.csv'); |
|
100 | - echo "\xEF\xBB\xBF"; // UTF-8 BOM |
|
94 | + $request['params']['all'] = true; |
|
95 | + $request['params']['download'] = true; |
|
96 | + ob_end_clean(); |
|
97 | + header('Content-Encoding: UTF-8'); |
|
98 | + header("Content-Type: text/csv"); |
|
99 | + header("Content-Disposition: attachment; filename=" . $request['modelName']::$objectName . '.csv'); |
|
100 | + echo "\xEF\xBB\xBF"; // UTF-8 BOM |
|
101 | 101 | |
102 | 102 | |
103 | - $cols = $dataManager->getCols(); |
|
104 | - $cols = array_slice($cols, 1); |
|
105 | - $endRow = true; |
|
106 | - foreach ($cols as $colName => $options) { |
|
103 | + $cols = $dataManager->getCols(); |
|
104 | + $cols = array_slice($cols, 1); |
|
105 | + $endRow = true; |
|
106 | + foreach ($cols as $colName => $options) { |
|
107 | 107 | if (!$endRow) { |
108 | - echo ";"; |
|
108 | + echo ";"; |
|
109 | 109 | } |
110 | 110 | $endRow = false; |
111 | 111 | echo '"' . $options['label'] . '"'; |
112 | - } |
|
113 | - echo "\n"; |
|
114 | - $endRow = true; |
|
112 | + } |
|
113 | + echo "\n"; |
|
114 | + $endRow = true; |
|
115 | 115 | } |
116 | 116 | if (!$request['params']['all']) { |
117 | - $pages = $dataManager->getPages($request['params'], $request['model']); |
|
118 | - $request['params']['page'] = !empty($pages->params['page']) ? $pages->params['page'] : $dataManager->page; |
|
119 | - $request['params']['limit'] = !empty($pages->params['limit']) ? $pages->params['limit'] : $dataManager->limit; |
|
117 | + $pages = $dataManager->getPages($request['params'], $request['model']); |
|
118 | + $request['params']['page'] = !empty($pages->params['page']) ? $pages->params['page'] : $dataManager->page; |
|
119 | + $request['params']['limit'] = !empty($pages->params['limit']) ? $pages->params['limit'] : $dataManager->limit; |
|
120 | 120 | } |
121 | 121 | $rows = $dataManager->getRows($request['params'], $request['model']); |
122 | 122 | foreach ($rows as $row) { |
123 | - if ($request['download']) { |
|
123 | + if ($request['download']) { |
|
124 | 124 | $row = array_slice($row, 1, -1); |
125 | 125 | foreach ($row as $col) { |
126 | - if (!$endRow) { |
|
126 | + if (!$endRow) { |
|
127 | 127 | echo ";"; |
128 | - } |
|
129 | - $endRow = false; |
|
130 | - echo '"' . str_replace(["\n", '"'], ['“'], $col) . '"'; |
|
128 | + } |
|
129 | + $endRow = false; |
|
130 | + echo '"' . str_replace(["\n", '"'], ['“'], $col) . '"'; |
|
131 | 131 | } |
132 | 132 | echo "\n"; |
133 | 133 | $endRow = true; |
134 | - } else { |
|
134 | + } else { |
|
135 | 135 | Ui\Table::drawRow($row); |
136 | - } |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | if ($request['download']) { |
139 | - exit(); |
|
139 | + exit(); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | $result->content['rows'] = ob_get_contents(); |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | $result->content['pages'] = ''; |
146 | 146 | |
147 | 147 | if (isset($pages) && $pages) { |
148 | - if ($pages) { |
|
148 | + if ($pages) { |
|
149 | 149 | $pages->draw(); |
150 | 150 | echo '<div style="background:#fff;">записей: <b>' . $pages->options['count'] . '</b>. страница <b>' . $pages->params['page'] . '</b> из <b>' . $pages->params['pages'] . '</b></div>'; |
151 | - } |
|
152 | - $result->content['pages'] = ob_get_contents(); |
|
153 | - ob_end_clean(); |
|
151 | + } |
|
152 | + $result->content['pages'] = ob_get_contents(); |
|
153 | + ob_end_clean(); |
|
154 | 154 | } |
155 | 155 | $result->send(); |
156 | - } |
|
156 | + } |
|
157 | 157 | |
158 | - public function loadCategorysAction() { |
|
158 | + public function loadCategorysAction() { |
|
159 | 159 | $result = new Server\Result(); |
160 | 160 | |
161 | 161 | ob_start(); |
@@ -169,88 +169,88 @@ discard block |
||
169 | 169 | ob_end_clean(); |
170 | 170 | |
171 | 171 | $result->send(); |
172 | - } |
|
172 | + } |
|
173 | 173 | |
174 | - public function delRowAction() { |
|
174 | + public function delRowAction() { |
|
175 | 175 | |
176 | 176 | $request = $this->parseRequest(); |
177 | 177 | |
178 | 178 | $dataManager = new Ui\DataManager($request['modelName'], $request['managerName']); |
179 | 179 | |
180 | 180 | if ($dataManager->checkAccess()) { |
181 | - $model = $request['modelName']::get($request['key'], $request['modelName']::index(), $request['params']); |
|
182 | - if ($model) { |
|
181 | + $model = $request['modelName']::get($request['key'], $request['modelName']::index(), $request['params']); |
|
182 | + if ($model) { |
|
183 | 183 | $model->delete($request['params']); |
184 | - } |
|
184 | + } |
|
185 | 185 | } |
186 | 186 | $result = new Server\Result(); |
187 | 187 | $result->successMsg = empty($request['silence']) ? 'Запись удалена' : ''; |
188 | 188 | $result->send(); |
189 | - } |
|
189 | + } |
|
190 | 190 | |
191 | - public function updateRowAction() { |
|
191 | + public function updateRowAction() { |
|
192 | 192 | |
193 | 193 | $request = $this->parseRequest(); |
194 | 194 | |
195 | 195 | $dataManager = new Ui\DataManager($request['modelName'], $request['managerName']); |
196 | 196 | |
197 | 197 | if ($dataManager->checkAccess()) { |
198 | - $model = $request['modelName']::get($request['key'], $request['modelName']::index(), $request['params']); |
|
199 | - if ($model) { |
|
198 | + $model = $request['modelName']::get($request['key'], $request['modelName']::index(), $request['params']); |
|
199 | + if ($model) { |
|
200 | 200 | $model->{$request['col']} = $request['col_value']; |
201 | 201 | $model->save($request['params']); |
202 | - } |
|
202 | + } |
|
203 | 203 | } |
204 | 204 | $result = new Server\Result(); |
205 | 205 | $result->successMsg = empty($request['silence']) ? 'Запись Обновлена' : ''; |
206 | 206 | $result->send(); |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | - public function groupActionAction() { |
|
209 | + public function groupActionAction() { |
|
210 | 210 | $request = $this->parseRequest(); |
211 | 211 | $dataManager = new Ui\DataManager($request['modelName'], $request['managerName']); |
212 | 212 | $result = new Server\Result(); |
213 | 213 | $result->success = false; |
214 | 214 | $result->content = 'Не удалось выполнить операцию'; |
215 | 215 | if ($dataManager->checkAccess()) { |
216 | - $ids = trim($request['ids'], ' ,'); |
|
217 | - if ($request['action'] && $ids) { |
|
216 | + $ids = trim($request['ids'], ' ,'); |
|
217 | + if ($request['action'] && $ids) { |
|
218 | 218 | $actions = $dataManager->getActions(); |
219 | 219 | if (!empty($actions[$request['action']])) { |
220 | - $actionParams = $actions[$request['action']]; |
|
221 | - if (!empty($actionParams['access']['groups']) && !in_array(\Users\User::$cur->group_id, $actionParams['access']['groups'])) { |
|
220 | + $actionParams = $actions[$request['action']]; |
|
221 | + if (!empty($actionParams['access']['groups']) && !in_array(\Users\User::$cur->group_id, $actionParams['access']['groups'])) { |
|
222 | 222 | $result->content = 'У вас нет прав доступа к операции ' . (!isset($actionParams['name']) ? $actionParams['className']::$name : $actionParams['name']); |
223 | - } else { |
|
223 | + } else { |
|
224 | 224 | try { |
225 | - $result->successMsg = $actionParams['className']::groupAction($dataManager, $ids, $actionParams, !empty($_GET['adInfo']) ? $_GET['adInfo'] : []); |
|
226 | - $result->success = true; |
|
225 | + $result->successMsg = $actionParams['className']::groupAction($dataManager, $ids, $actionParams, !empty($_GET['adInfo']) ? $_GET['adInfo'] : []); |
|
226 | + $result->success = true; |
|
227 | 227 | } catch (\Exception $e) { |
228 | - $result->content = $e->getMessage(); |
|
228 | + $result->content = $e->getMessage(); |
|
229 | 229 | } |
230 | - } |
|
230 | + } |
|
231 | + } |
|
231 | 232 | } |
232 | - } |
|
233 | 233 | } else { |
234 | - $result->content = 'У вас нет прав доступа к менеджеру ' . $request['managerName'] . ' модели ' . $request['modelName']; |
|
234 | + $result->content = 'У вас нет прав доступа к менеджеру ' . $request['managerName'] . ' модели ' . $request['modelName']; |
|
235 | 235 | } |
236 | 236 | $result->send(); |
237 | - } |
|
237 | + } |
|
238 | 238 | |
239 | - public function delCategoryAction() { |
|
239 | + public function delCategoryAction() { |
|
240 | 240 | |
241 | 241 | $request = $this->parseRequest(); |
242 | 242 | |
243 | 243 | $dataManager = new Ui\DataManager($request['modelName'], $request['managerName']); |
244 | 244 | |
245 | 245 | if ($dataManager->checkAccess() && !empty($dataManager->managerOptions['categorys'])) { |
246 | - $categoryModel = $dataManager->managerOptions['categorys']['model']; |
|
247 | - $model = $categoryModel::get($request['key'], $categoryModel::index(), $request['params']); |
|
248 | - if ($model) { |
|
246 | + $categoryModel = $dataManager->managerOptions['categorys']['model']; |
|
247 | + $model = $categoryModel::get($request['key'], $categoryModel::index(), $request['params']); |
|
248 | + if ($model) { |
|
249 | 249 | $model->delete($request['params']); |
250 | - } |
|
250 | + } |
|
251 | 251 | } |
252 | 252 | $result = new Server\Result(); |
253 | 253 | $result->send(); |
254 | - } |
|
254 | + } |
|
255 | 255 | |
256 | 256 | } |
@@ -9,16 +9,16 @@ |
||
9 | 9 | 'value' => !empty($options['value']) ? addcslashes($options['value'], "'") : (!empty($form->userDataTree[$name]) ? addcslashes($form->userDataTree[$name], "'") : '') |
10 | 10 | ]; |
11 | 11 | if (!empty($options['disabled'])) { |
12 | - $attributes['disabled'] = 'disabled'; |
|
12 | + $attributes['disabled'] = 'disabled'; |
|
13 | 13 | } |
14 | 14 | if (!empty($options['placeholder'])) { |
15 | - $attributes['placeholder'] = $options['placeholder']; |
|
15 | + $attributes['placeholder'] = $options['placeholder']; |
|
16 | 16 | } |
17 | 17 | if (!empty($options['checked'])) { |
18 | - $attributes['checked'] = 'checked'; |
|
18 | + $attributes['checked'] = 'checked'; |
|
19 | 19 | } |
20 | 20 | if (!empty($options['attributes'])) { |
21 | - $attributes = array_merge($attributes, $options['attributes']); |
|
21 | + $attributes = array_merge($attributes, $options['attributes']); |
|
22 | 22 | } |
23 | 23 | echo Html::el('input', $attributes, '', null); |
24 | 24 | echo!empty($options['helpText']) ? "<div class='help-block'>{$options['helpText']}</div>" : ''; |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | </li> |
8 | 8 | <?php |
9 | 9 | if (class_exists('Users\User')) { |
10 | - App::$cur->ui; |
|
11 | - ?> |
|
10 | + App::$cur->ui; |
|
11 | + ?> |
|
12 | 12 | <hr /> |
13 | 13 | <div class="row userWidget"> |
14 | 14 | <div class="col-xs-4"> |
@@ -29,23 +29,23 @@ discard block |
||
29 | 29 | <a href = "/admin">Панель управления</a> |
30 | 30 | </li> |
31 | 31 | <?php |
32 | - $where[] = ['group_id', Users\User::$cur->group_id]; |
|
33 | - if (Users\User::$cur->group_id == 3) { |
|
32 | + $where[] = ['group_id', Users\User::$cur->group_id]; |
|
33 | + if (Users\User::$cur->group_id == 3) { |
|
34 | 34 | $where[] = ['group_id', 0, '=', 'OR']; |
35 | - } |
|
36 | - $menu = Menu\Menu::get([['code', 'sidebarMenu'], $where]); |
|
37 | - foreach ($menu->items(['where' => ['parent_id', 0], 'order' => ['weight', 'asc']]) as $item) { |
|
35 | + } |
|
36 | + $menu = Menu\Menu::get([['code', 'sidebarMenu'], $where]); |
|
37 | + foreach ($menu->items(['where' => ['parent_id', 0], 'order' => ['weight', 'asc']]) as $item) { |
|
38 | 38 | echo "<li><a href = '{$item->href}'>{$item->name}</a>"; |
39 | 39 | $childItems = Menu\Item::getList(['where' => ['parent_id', $item->id]]); |
40 | 40 | if ($childItems) { |
41 | - echo "<ul>"; |
|
42 | - foreach ($childItems as $item) { |
|
41 | + echo "<ul>"; |
|
42 | + foreach ($childItems as $item) { |
|
43 | 43 | echo "<li><a href = '{$item->href}'>{$item->name}</a>"; |
44 | - } |
|
45 | - echo "</ul>"; |
|
44 | + } |
|
45 | + echo "</ul>"; |
|
46 | 46 | } |
47 | 47 | echo "</li>"; |
48 | - } |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | ?> |
51 | 51 | <li> |
@@ -10,55 +10,55 @@ |
||
10 | 10 | */ |
11 | 11 | class adminController extends Controller { |
12 | 12 | |
13 | - public function indexAction() { |
|
13 | + public function indexAction() { |
|
14 | 14 | $args = func_get_args(); |
15 | 15 | call_user_func_array([$this, 'dataManagerAction'], $args); |
16 | - } |
|
16 | + } |
|
17 | 17 | |
18 | - public function dataManagerAction($model = '', $dataManager = 'manager') { |
|
18 | + public function dataManagerAction($model = '', $dataManager = 'manager') { |
|
19 | 19 | if (!$model) { |
20 | - $modulePath = Module::getModulePath($this->module->moduleName); |
|
21 | - $path = $modulePath . '/models'; |
|
22 | - if (file_exists($path)) { |
|
20 | + $modulePath = Module::getModulePath($this->module->moduleName); |
|
21 | + $path = $modulePath . '/models'; |
|
22 | + if (file_exists($path)) { |
|
23 | 23 | $files = array_slice(scandir($path), 2); |
24 | 24 | foreach ($files as $file) { |
25 | - if (is_dir($path . '/' . $file)) { |
|
25 | + if (is_dir($path . '/' . $file)) { |
|
26 | 26 | continue; |
27 | - } |
|
28 | - $model = pathinfo($file, PATHINFO_FILENAME); |
|
29 | - break; |
|
27 | + } |
|
28 | + $model = pathinfo($file, PATHINFO_FILENAME); |
|
29 | + break; |
|
30 | + } |
|
30 | 31 | } |
31 | - } |
|
32 | 32 | } |
33 | 33 | $fullModelName = $this->module->moduleName . '\\' . ucfirst($model); |
34 | 34 | $dataManager = new Ui\DataManager($fullModelName, $dataManager); |
35 | 35 | $title = !empty($dataManager->managerOptions['name']) ? $dataManager->managerOptions['name'] : $fullModelName::objectName(); |
36 | 36 | $this->view->setTitle($title); |
37 | 37 | $this->view->page(['module' => 'Ui', 'content' => 'dataManager/manager', 'data' => compact('dataManager')]); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - public function viewAction($model, $pk) { |
|
40 | + public function viewAction($model, $pk) { |
|
41 | 41 | $fullModelName = $this->module->moduleName . '\\' . ucfirst($model); |
42 | 42 | if (Users\User::$cur->group_id != 3 && (empty($fullModelName::$views['manager']['access']) || !in_array(Users\User::$cur->group_id, $fullModelName::$views['manager']['access']['groups']))) { |
43 | - Tools::redirect('/admin', 'У вас нет прав доступа для просмотра этого объекта', 'danger'); |
|
43 | + Tools::redirect('/admin', 'У вас нет прав доступа для просмотра этого объекта', 'danger'); |
|
44 | 44 | } |
45 | 45 | $item = $fullModelName::get($pk); |
46 | 46 | $this->view->setTitle(($fullModelName::$objectName ? $fullModelName::$objectName : $fullModelName) . ($item ? ( ' - ' . $item->name()) : '')); |
47 | 47 | if (!empty($_POST['comment'])) { |
48 | - $comment = new Dashboard\Comment(); |
|
49 | - $comment->text = $_POST['comment']; |
|
50 | - $comment->user_id = \Users\User::$cur->id; |
|
51 | - $comment->model = $fullModelName; |
|
52 | - $comment->item_id = $item->pk(); |
|
53 | - $comment->save(); |
|
54 | - Tools::redirect($_SERVER['REQUEST_URI']); |
|
48 | + $comment = new Dashboard\Comment(); |
|
49 | + $comment->text = $_POST['comment']; |
|
50 | + $comment->user_id = \Users\User::$cur->id; |
|
51 | + $comment->model = $fullModelName; |
|
52 | + $comment->item_id = $item->pk(); |
|
53 | + $comment->save(); |
|
54 | + Tools::redirect($_SERVER['REQUEST_URI']); |
|
55 | 55 | } |
56 | 56 | $moduleName = $this->module->moduleName; |
57 | 57 | $pageParam = ['module' => 'Ui', 'content' => 'dataManager/view', 'data' => compact('item', 'moduleName')]; |
58 | 58 | if (isset($_GET['print'])) { |
59 | - $pageParam['page'] = 'print'; |
|
59 | + $pageParam['page'] = 'print'; |
|
60 | 60 | } |
61 | 61 | $this->view->page($pageParam); |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | } |
@@ -13,39 +13,39 @@ discard block |
||
13 | 13 | |
14 | 14 | class File extends \Model { |
15 | 15 | |
16 | - public static $cols = [ |
|
17 | - 'code' => ['type' => 'text'], |
|
18 | - 'type_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'type'], |
|
19 | - 'folder_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'foler'], |
|
20 | - 'upload_code' => ['type' => 'text'], |
|
21 | - 'path' => ['type' => 'textarea'], |
|
22 | - 'name' => ['type' => 'text'], |
|
23 | - 'about' => ['type' => 'html'], |
|
24 | - 'original_name' => ['type' => 'text'], |
|
25 | - 'md5' => ['type' => 'text'], |
|
26 | - 'date_create' => ['type' => 'dateTime'], |
|
27 | - ]; |
|
28 | - |
|
29 | - public function beforeSave() { |
|
16 | + public static $cols = [ |
|
17 | + 'code' => ['type' => 'text'], |
|
18 | + 'type_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'type'], |
|
19 | + 'folder_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'foler'], |
|
20 | + 'upload_code' => ['type' => 'text'], |
|
21 | + 'path' => ['type' => 'textarea'], |
|
22 | + 'name' => ['type' => 'text'], |
|
23 | + 'about' => ['type' => 'html'], |
|
24 | + 'original_name' => ['type' => 'text'], |
|
25 | + 'md5' => ['type' => 'text'], |
|
26 | + 'date_create' => ['type' => 'dateTime'], |
|
27 | + ]; |
|
28 | + |
|
29 | + public function beforeSave() { |
|
30 | 30 | $path = $this->getRealPath(); |
31 | 31 | if (!$this->md5 && $this->path && file_exists($path)) { |
32 | - $this->md5 = md5_file($path); |
|
32 | + $this->md5 = md5_file($path); |
|
33 | + } |
|
33 | 34 | } |
34 | - } |
|
35 | 35 | |
36 | - public function beforeDelete() { |
|
36 | + public function beforeDelete() { |
|
37 | 37 | $path = $this->getRealPath(); |
38 | 38 | if (file_exists($path)) { |
39 | - unlink($path); |
|
39 | + unlink($path); |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | 42 | |
43 | - public function getRealPath() { |
|
43 | + public function getRealPath() { |
|
44 | 44 | $sitePath = \App::$primary->path; |
45 | 45 | return "{$sitePath}{$this->path}"; |
46 | - } |
|
46 | + } |
|
47 | 47 | |
48 | - public static function relations() { |
|
48 | + public static function relations() { |
|
49 | 49 | return [ |
50 | 50 | 'type' => [ |
51 | 51 | 'model' => 'Files\Type', |
@@ -56,6 +56,6 @@ discard block |
||
56 | 56 | 'col' => 'folder_id' |
57 | 57 | ], |
58 | 58 | ]; |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
@@ -1,67 +1,67 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return function($step = NULL, $params = []) { |
4 | - $options = ['max_height' => 1200, 'max_width' => 1200]; |
|
5 | - $types = [ |
|
6 | - [ |
|
7 | - 'dir' => '/static/mediafiles/images/', |
|
8 | - 'ext' => 'png', |
|
9 | - 'group' => 'image', |
|
10 | - 'allow_resize' => 1, |
|
11 | - 'options' => json_encode($options) |
|
12 | - ], |
|
13 | - [ |
|
14 | - 'dir' => '/static/mediafiles/images/', |
|
15 | - 'ext' => 'jpeg', |
|
16 | - 'group' => 'image', |
|
17 | - 'allow_resize' => 1, |
|
18 | - 'options' => json_encode($options) |
|
19 | - ], |
|
20 | - [ |
|
21 | - 'dir' => '/static/mediafiles/images/', |
|
22 | - 'ext' => 'jpg', |
|
23 | - 'group' => 'image', |
|
24 | - 'allow_resize' => 1, |
|
25 | - 'options' => json_encode($options) |
|
26 | - ], |
|
27 | - [ |
|
28 | - 'dir' => '/static/mediafiles/images/', |
|
29 | - 'ext' => 'gif', |
|
30 | - 'group' => 'image', |
|
31 | - 'allow_resize' => 1, |
|
32 | - 'options' => json_encode($options) |
|
33 | - ], |
|
34 | - [ |
|
35 | - 'dir' => '/static/mediafiles/docs/', |
|
36 | - 'ext' => 'xls', |
|
37 | - 'group' => 'doc', |
|
38 | - 'allow_resize' => 0, |
|
39 | - 'options' => '' |
|
40 | - ], |
|
41 | - [ |
|
42 | - 'dir' => '/static/mediafiles/docs/', |
|
43 | - 'ext' => 'pdf', |
|
44 | - 'group' => 'doc', |
|
45 | - 'allow_resize' => 0, |
|
46 | - 'options' => '' |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'dir' => '/static/mediafiles/docs/', |
|
50 | - 'ext' => 'docx', |
|
51 | - 'group' => 'doc', |
|
52 | - 'allow_resize' => 0, |
|
53 | - 'options' => '' |
|
54 | - ], |
|
55 | - [ |
|
56 | - 'dir' => '/static/mediafiles/docs/', |
|
57 | - 'ext' => 'xlsx', |
|
58 | - 'group' => 'doc', |
|
59 | - 'allow_resize' => 0, |
|
60 | - 'options' => '' |
|
61 | - ], |
|
62 | - ]; |
|
63 | - foreach ($types as $type) { |
|
4 | + $options = ['max_height' => 1200, 'max_width' => 1200]; |
|
5 | + $types = [ |
|
6 | + [ |
|
7 | + 'dir' => '/static/mediafiles/images/', |
|
8 | + 'ext' => 'png', |
|
9 | + 'group' => 'image', |
|
10 | + 'allow_resize' => 1, |
|
11 | + 'options' => json_encode($options) |
|
12 | + ], |
|
13 | + [ |
|
14 | + 'dir' => '/static/mediafiles/images/', |
|
15 | + 'ext' => 'jpeg', |
|
16 | + 'group' => 'image', |
|
17 | + 'allow_resize' => 1, |
|
18 | + 'options' => json_encode($options) |
|
19 | + ], |
|
20 | + [ |
|
21 | + 'dir' => '/static/mediafiles/images/', |
|
22 | + 'ext' => 'jpg', |
|
23 | + 'group' => 'image', |
|
24 | + 'allow_resize' => 1, |
|
25 | + 'options' => json_encode($options) |
|
26 | + ], |
|
27 | + [ |
|
28 | + 'dir' => '/static/mediafiles/images/', |
|
29 | + 'ext' => 'gif', |
|
30 | + 'group' => 'image', |
|
31 | + 'allow_resize' => 1, |
|
32 | + 'options' => json_encode($options) |
|
33 | + ], |
|
34 | + [ |
|
35 | + 'dir' => '/static/mediafiles/docs/', |
|
36 | + 'ext' => 'xls', |
|
37 | + 'group' => 'doc', |
|
38 | + 'allow_resize' => 0, |
|
39 | + 'options' => '' |
|
40 | + ], |
|
41 | + [ |
|
42 | + 'dir' => '/static/mediafiles/docs/', |
|
43 | + 'ext' => 'pdf', |
|
44 | + 'group' => 'doc', |
|
45 | + 'allow_resize' => 0, |
|
46 | + 'options' => '' |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'dir' => '/static/mediafiles/docs/', |
|
50 | + 'ext' => 'docx', |
|
51 | + 'group' => 'doc', |
|
52 | + 'allow_resize' => 0, |
|
53 | + 'options' => '' |
|
54 | + ], |
|
55 | + [ |
|
56 | + 'dir' => '/static/mediafiles/docs/', |
|
57 | + 'ext' => 'xlsx', |
|
58 | + 'group' => 'doc', |
|
59 | + 'allow_resize' => 0, |
|
60 | + 'options' => '' |
|
61 | + ], |
|
62 | + ]; |
|
63 | + foreach ($types as $type) { |
|
64 | 64 | $typeObject = new \Files\Type($type); |
65 | 65 | $typeObject->save(); |
66 | - } |
|
66 | + } |
|
67 | 67 | }; |
@@ -13,22 +13,22 @@ |
||
13 | 13 | |
14 | 14 | class File extends \Ui\ActiveForm\Input { |
15 | 15 | |
16 | - public function parseRequest($request) { |
|
16 | + public function parseRequest($request) { |
|
17 | 17 | if (!empty($_FILES[$this->activeForm->requestFormName]['tmp_name'][$this->modelName][$this->colName])) { |
18 | - $file_id = \App::$primary->files->upload([ |
|
19 | - 'tmp_name' => $_FILES[$this->activeForm->requestFormName]['tmp_name'][$this->modelName][$this->colName], |
|
20 | - 'name' => $_FILES[$this->activeForm->requestFormName]['name'][$this->modelName][$this->colName], |
|
21 | - 'type' => $_FILES[$this->activeForm->requestFormName]['type'][$this->modelName][$this->colName], |
|
22 | - 'size' => $_FILES[$this->activeForm->requestFormName]['size'][$this->modelName][$this->colName], |
|
23 | - 'error' => $_FILES[$this->activeForm->requestFormName]['error'][$this->modelName][$this->colName], |
|
24 | - ], [ |
|
25 | - 'upload_code' => 'activeForm:' . $this->activeForm->modelName . ':' . $this->activeForm->model->pk() |
|
26 | - ]); |
|
18 | + $file_id = \App::$primary->files->upload([ |
|
19 | + 'tmp_name' => $_FILES[$this->activeForm->requestFormName]['tmp_name'][$this->modelName][$this->colName], |
|
20 | + 'name' => $_FILES[$this->activeForm->requestFormName]['name'][$this->modelName][$this->colName], |
|
21 | + 'type' => $_FILES[$this->activeForm->requestFormName]['type'][$this->modelName][$this->colName], |
|
22 | + 'size' => $_FILES[$this->activeForm->requestFormName]['size'][$this->modelName][$this->colName], |
|
23 | + 'error' => $_FILES[$this->activeForm->requestFormName]['error'][$this->modelName][$this->colName], |
|
24 | + ], [ |
|
25 | + 'upload_code' => 'activeForm:' . $this->activeForm->modelName . ':' . $this->activeForm->model->pk() |
|
26 | + ]); |
|
27 | 27 | |
28 | - if ($file_id) { |
|
28 | + if ($file_id) { |
|
29 | 29 | $this->activeForm->model->{$this->colName} = $file_id; |
30 | - } |
|
30 | + } |
|
31 | + } |
|
31 | 32 | } |
32 | - } |
|
33 | 33 | |
34 | 34 | } |