@@ -329,6 +329,9 @@  | 
                                                    ||
| 329 | 329 | return $rows;  | 
                                                        
| 330 | 330 | }  | 
                                                        
| 331 | 331 | |
| 332 | + /**  | 
                                                        |
| 333 | + * @param DataManager $dataManager  | 
                                                        |
| 334 | + */  | 
                                                        |
| 332 | 335 | public static function drawCol($item, $colName, $params = [], $dataManager = null, $originalCol = '', $originalItem = null)  | 
                                                        
| 333 | 336 |      { | 
                                                        
| 334 | 337 | $modelName = get_class($item);  | 
                                                        
@@ -58,7 +58,7 @@ discard block  | 
                                                    ||
| 58 | 58 | $this->name = $this->managerOptions['name'];  | 
                                                        
| 59 | 59 | }  | 
                                                        
| 60 | 60 | |
| 61 | -        $this->managerId = str_replace('\\', '_', 'dataManager_' . $this->modelName . '_' . $this->managerName . '_' . \Tools::randomString()); | 
                                                        |
| 61 | +        $this->managerId = str_replace('\\', '_', 'dataManager_'.$this->modelName.'_'.$this->managerName.'_'.\Tools::randomString()); | 
                                                        |
| 62 | 62 | }  | 
                                                        
| 63 | 63 | |
| 64 | 64 | /**  | 
                                                        
@@ -102,13 +102,13 @@ discard block  | 
                                                    ||
| 102 | 102 |          if (!empty($this->managerOptions['filters'])) { | 
                                                        
| 103 | 103 | $buttons[] = [  | 
                                                        
| 104 | 104 | 'text' => 'Фильтры',  | 
                                                        
| 105 | -                'onclick' => '  var modal = $("#' . $this->managerId . '_filters"); | 
                                                        |
| 105 | +                'onclick' => '  var modal = $("#'.$this->managerId.'_filters"); | 
                                                        |
| 106 | 106 |                  modal.modal("show");', | 
                                                        
| 107 | 107 | ];  | 
                                                        
| 108 | 108 | }  | 
                                                        
| 109 | 109 | $buttons[] = [  | 
                                                        
| 110 | 110 | 'text' => 'Добавить элемент',  | 
                                                        
| 111 | -            'onclick' => 'inji.Ui.forms.popUp("' . str_replace('\\', '\\\\', $modelName) . '",' . json_encode($formParams) . ')', | 
                                                        |
| 111 | +            'onclick' => 'inji.Ui.forms.popUp("'.str_replace('\\', '\\\\', $modelName).'",'.json_encode($formParams).')', | 
                                                        |
| 112 | 112 | ];  | 
                                                        
| 113 | 113 | |
| 114 | 114 | return $buttons;  | 
                                                        
@@ -138,7 +138,7 @@ discard block  | 
                                                    ||
| 138 | 138 | 'className' => $action  | 
                                                        
| 139 | 139 | ];  | 
                                                        
| 140 | 140 | }  | 
                                                        
| 141 | -            $return[$key]['className'] = strpos($return[$key]['className'], '\\') === false && class_exists('Ui\DataManager\Action\\' . $return[$key]['className']) ? 'Ui\DataManager\Action\\' . $return[$key]['className'] : $return[$key]['className']; | 
                                                        |
| 141 | +            $return[$key]['className'] = strpos($return[$key]['className'], '\\') === false && class_exists('Ui\DataManager\Action\\'.$return[$key]['className']) ? 'Ui\DataManager\Action\\'.$return[$key]['className'] : $return[$key]['className']; | 
                                                        |
| 142 | 142 |              if (!class_exists($return[$key]['className']) || ($onlyGroupActions && !$return[$key]['className']::$groupAction)) { | 
                                                        
| 143 | 143 | unset($return[$key]);  | 
                                                        
| 144 | 144 | }  | 
                                                        
@@ -170,7 +170,7 @@ discard block  | 
                                                    ||
| 170 | 170 | <?php  | 
                                                        
| 171 | 171 |                foreach ($actions as $action => $actionParams) { | 
                                                        
| 172 | 172 |                    if (class_exists($actionParams['className']) && $actionParams['className']::$groupAction) { | 
                                                        
| 173 | -                      echo "<li><a href ='' onclick='inji.Ui.dataManagers.get(this).groupAction(\"" . str_replace('\\', '\\\\', $action) . "\");return false;'>{$actionParams['className']::$name}</a></li>"; | 
                                                        |
| 173 | +                      echo "<li><a href ='' onclick='inji.Ui.dataManagers.get(this).groupAction(\"".str_replace('\\', '\\\\', $action)."\");return false;'>{$actionParams['className']::$name}</a></li>"; | 
                                                        |
| 174 | 174 | }  | 
                                                        
| 175 | 175 | }  | 
                                                        
| 176 | 176 | ?>  | 
                                                        
@@ -221,7 +221,7 @@ discard block  | 
                                                    ||
| 221 | 221 | return [];  | 
                                                        
| 222 | 222 | }  | 
                                                        
| 223 | 223 |          if (!$this->checkAccess()) { | 
                                                        
| 224 | -            $this->drawError('you not have access to "' . $this->modelName . '" manager with name: "' . $this->managerName . '"'); | 
                                                        |
| 224 | +            $this->drawError('you not have access to "'.$this->modelName.'" manager with name: "'.$this->managerName.'"'); | 
                                                        |
| 225 | 225 | return [];  | 
                                                        
| 226 | 226 | }  | 
                                                        
| 227 | 227 | $modelName = $this->modelName;  | 
                                                        
@@ -237,7 +237,7 @@ discard block  | 
                                                    ||
| 237 | 237 | $queryParams['start'] = $this->page * $this->limit - $this->limit;  | 
                                                        
| 238 | 238 | }  | 
                                                        
| 239 | 239 |          if (!empty($params['categoryPath']) && $modelName::$categoryModel) { | 
                                                        
| 240 | - $queryParams['where'][] = ['tree_path', $params['categoryPath'] . '%', 'LIKE'];  | 
                                                        |
| 240 | + $queryParams['where'][] = ['tree_path', $params['categoryPath'].'%', 'LIKE'];  | 
                                                        |
| 241 | 241 | }  | 
                                                        
| 242 | 242 |          if (!empty($params['appType'])) { | 
                                                        
| 243 | 243 | $queryParams['appType'] = $params['appType'];  | 
                                                        
@@ -296,7 +296,7 @@ discard block  | 
                                                    ||
| 296 | 296 |                          if (!empty($params['filters'][$col]['max'])) { | 
                                                        
| 297 | 297 |                              if ($colInfo['colParams']['type'] == 'dateTime' && !strpos($params['filters'][$col]['max'], ' ')) { | 
                                                        
| 298 | 298 | |
| 299 | - $date = $params['filters'][$col]['max'] . ' 23:59:59';  | 
                                                        |
| 299 | + $date = $params['filters'][$col]['max'].' 23:59:59';  | 
                                                        |
| 300 | 300 |                              } else { | 
                                                        
| 301 | 301 | $date = $params['filters'][$col]['max'];  | 
                                                        
| 302 | 302 | }  | 
                                                        
@@ -323,16 +323,16 @@ discard block  | 
                                                    ||
| 323 | 323 | }  | 
                                                        
| 324 | 324 |                          switch ($params['filters'][$col]['compareType']) { | 
                                                        
| 325 | 325 | case 'contains':  | 
                                                        
| 326 | - $queryParams['where'][] = [$col, '%' . $params['filters'][$col]['value'] . '%', 'LIKE'];  | 
                                                        |
| 326 | + $queryParams['where'][] = [$col, '%'.$params['filters'][$col]['value'].'%', 'LIKE'];  | 
                                                        |
| 327 | 327 | break;  | 
                                                        
| 328 | 328 | case 'equals':  | 
                                                        
| 329 | 329 | $queryParams['where'][] = [$col, $params['filters'][$col]['value']];  | 
                                                        
| 330 | 330 | break;  | 
                                                        
| 331 | 331 | case 'starts_with':  | 
                                                        
| 332 | - $queryParams['where'][] = [$col, $params['filters'][$col]['value'] . '%', 'LIKE'];  | 
                                                        |
| 332 | + $queryParams['where'][] = [$col, $params['filters'][$col]['value'].'%', 'LIKE'];  | 
                                                        |
| 333 | 333 | break;  | 
                                                        
| 334 | 334 | case 'ends_with':  | 
                                                        
| 335 | - $queryParams['where'][] = [$col, '%' . $params['filters'][$col]['value'], 'LIKE'];  | 
                                                        |
| 335 | + $queryParams['where'][] = [$col, '%'.$params['filters'][$col]['value'], 'LIKE'];  | 
                                                        |
| 336 | 336 | break;  | 
                                                        
| 337 | 337 | }  | 
                                                        
| 338 | 338 | break;  | 
                                                        
@@ -371,7 +371,7 @@ discard block  | 
                                                    ||
| 371 | 371 | $item = $relation['relModel']::get([[$item->index(), $item->id], [$model->index(), $model->id]]);  | 
                                                        
| 372 | 372 | }  | 
                                                        
| 373 | 373 | $row = [];  | 
                                                        
| 374 | - $row[] = '<input type ="checkbox" name = "pk[]" value =' . $item->pk() . '>';  | 
                                                        |
| 374 | + $row[] = '<input type ="checkbox" name = "pk[]" value ='.$item->pk().'>';  | 
                                                        |
| 375 | 375 | $row[] = $item->pk();  | 
                                                        
| 376 | 376 |              foreach ($this->managerOptions['cols'] as $key => $colName) { | 
                                                        
| 377 | 377 |                  if (!empty($params['download'])) { | 
                                                        
@@ -417,16 +417,16 @@ discard block  | 
                                                    ||
| 417 | 417 | $managerParams = ['relation' => $modelName::$cols[$colName]['relation']];  | 
                                                        
| 418 | 418 |                      $count = $item->{$modelName::$cols[$colName]['relation']}(array_merge($params, ['count' => 1])); | 
                                                        
| 419 | 419 | $count = $count ? $count : 'Нет';  | 
                                                        
| 420 | -                    return "<a class = 'btn btn-xs btn-primary' onclick = 'inji.Ui.dataManagers.popUp(\"" . str_replace('\\', '\\\\', $modelName) . ":" . $item->pk() . "\"," . json_encode(array_merge($params, $managerParams)) . ")'>{$count}</a>"; | 
                                                        |
| 420 | +                    return "<a class = 'btn btn-xs btn-primary' onclick = 'inji.Ui.dataManagers.popUp(\"".str_replace('\\', '\\\\', $modelName).":".$item->pk()."\",".json_encode(array_merge($params, $managerParams)).")'>{$count}</a>"; | 
                                                        |
| 421 | 421 | case 'many':  | 
                                                        
| 422 | 422 | $managerParams = ['relation' => $modelName::$cols[$colName]['relation']];  | 
                                                        
| 423 | 423 |                      $count = $item->{$modelName::$cols[$colName]['relation']}(array_merge($params, ['count' => 1])); | 
                                                        
| 424 | 424 | $count = $count ? $count : 'Нет';  | 
                                                        
| 425 | -                    return "<a class = 'btn btn-xs btn-primary' onclick = 'inji.Ui.dataManagers.popUp(\"" . str_replace('\\', '\\\\', $modelName) . ":" . $item->pk() . "\"," . json_encode(array_merge($params, $managerParams)) . ")'>{$count}</a>"; | 
                                                        |
| 425 | +                    return "<a class = 'btn btn-xs btn-primary' onclick = 'inji.Ui.dataManagers.popUp(\"".str_replace('\\', '\\\\', $modelName).":".$item->pk()."\",".json_encode(array_merge($params, $managerParams)).")'>{$count}</a>"; | 
                                                        |
| 426 | 426 | default :  | 
                                                        
| 427 | 427 |                      if ($item->{$modelName::$cols[$colName]['relation']}) { | 
                                                        
| 428 | 428 |                          if (\App::$cur->name == 'admin') { | 
                                                        
| 429 | -                            $href = "<a href ='/admin/" . str_replace('\\', '/view/', $relations[$modelName::$cols[$colName]['relation']]['model']) . "/" . $item->{$modelName::$cols[$colName]['relation']}->pk() . "'>"; | 
                                                        |
| 429 | +                            $href = "<a href ='/admin/".str_replace('\\', '/view/', $relations[$modelName::$cols[$colName]['relation']]['model'])."/".$item->{$modelName::$cols[$colName]['relation']}->pk()."'>"; | 
                                                        |
| 430 | 430 |                              if (!empty($modelName::$cols[$colName]['showCol'])) { | 
                                                        
| 431 | 431 |                                  $href .= $item->{$modelName::$cols[$colName]['relation']}->{$modelName::$cols[$colName]['showCol']}; | 
                                                        
| 432 | 432 |                              } else { | 
                                                        
@@ -456,18 +456,18 @@ discard block  | 
                                                    ||
| 456 | 456 | case 'many':  | 
                                                        
| 457 | 457 | $managerParams = ['relation' => $modelName::$cols[$colName]['relation']];  | 
                                                        
| 458 | 458 |                          $count = $item->{$modelName::$cols[$colName]['relation']}(array_merge($params, ['count' => 1])); | 
                                                        
| 459 | -                        return "<a class = 'btn btn-xs btn-primary' onclick = 'inji.Ui.dataManagers.popUp(\"" . str_replace('\\', '\\\\', $modelName) . ":" . $item->pk() . "\"," . json_encode(array_merge($params, $managerParams)) . ")'>{$count} " . \Tools::getNumEnding($count, ['Элемент', 'Элемента', 'Элементов']) . "</a>"; | 
                                                        |
| 459 | +                        return "<a class = 'btn btn-xs btn-primary' onclick = 'inji.Ui.dataManagers.popUp(\"".str_replace('\\', '\\\\', $modelName).":".$item->pk()."\",".json_encode(array_merge($params, $managerParams)).")'>{$count} ".\Tools::getNumEnding($count, ['Элемент', 'Элемента', 'Элементов'])."</a>"; | 
                                                        |
| 460 | 460 | default:  | 
                                                        
| 461 | 461 | return $item->$colName;  | 
                                                        
| 462 | 462 | }  | 
                                                        
| 463 | 463 |              } elseif (!empty($modelName::$cols[$colName]['type'])) { | 
                                                        
| 464 | -                if (\App::$cur->name == 'admin' && $originalCol == 'name' || ( $dataManager && !empty($dataManager->managerOptions['colToView']) && $dataManager->managerOptions['colToView'] == $originalCol)) { | 
                                                        |
| 464 | +                if (\App::$cur->name == 'admin' && $originalCol == 'name' || ($dataManager && !empty($dataManager->managerOptions['colToView']) && $dataManager->managerOptions['colToView'] == $originalCol)) { | 
                                                        |
| 465 | 465 | $formName = $dataManager && !empty($dataManager->managerOptions['editForm']) ? $dataManager->managerOptions['editForm'] : 'manager';  | 
                                                        
| 466 | -                    $redirectUrl = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/admin/' . str_replace('\\', '/', get_class($originalItem)); | 
                                                        |
| 467 | -                    return "<a href ='/admin/" . str_replace('\\', '/view/', get_class($originalItem)) . "/{$originalItem->id}?formName={$formName}&redirectUrl={$redirectUrl}'>{$item->$colName}</a>"; | 
                                                        |
| 466 | +                    $redirectUrl = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/admin/'.str_replace('\\', '/', get_class($originalItem)); | 
                                                        |
| 467 | +                    return "<a href ='/admin/".str_replace('\\', '/view/', get_class($originalItem))."/{$originalItem->id}?formName={$formName}&redirectUrl={$redirectUrl}'>{$item->$colName}</a>"; | 
                                                        |
| 468 | 468 |                  } elseif (\App::$cur->name == 'admin' && $colName == 'name') { | 
                                                        
| 469 | -                    $redirectUrl = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/admin/' . str_replace('\\', '/', get_class($originalItem)); | 
                                                        |
| 470 | -                    return "<a href ='/admin/" . str_replace('\\', '/view/', get_class($item)) . "/{$item->id}?redirectUrl={$redirectUrl}'>{$item->$colName}</a>"; | 
                                                        |
| 469 | +                    $redirectUrl = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/admin/'.str_replace('\\', '/', get_class($originalItem)); | 
                                                        |
| 470 | +                    return "<a href ='/admin/".str_replace('\\', '/view/', get_class($item))."/{$item->id}?redirectUrl={$redirectUrl}'>{$item->$colName}</a>"; | 
                                                        |
| 471 | 471 |                  } else { | 
                                                        
| 472 | 472 | return \Model::resloveTypeValue($item, $colName);  | 
                                                        
| 473 | 473 | }  | 
                                                        
@@ -502,7 +502,7 @@ discard block  | 
                                                    ||
| 502 | 502 | return [];  | 
                                                        
| 503 | 503 | }  | 
                                                        
| 504 | 504 |          if (!$this->checkAccess()) { | 
                                                        
| 505 | -            $this->drawError('you not have access to "' . $this->modelName . '" manager with name: "' . $this->managerName . '"'); | 
                                                        |
| 505 | +            $this->drawError('you not have access to "'.$this->modelName.'" manager with name: "'.$this->managerName.'"'); | 
                                                        |
| 506 | 506 | return [];  | 
                                                        
| 507 | 507 | }  | 
                                                        
| 508 | 508 |          if (!empty($params['limit'])) { | 
                                                        
@@ -516,7 +516,7 @@ discard block  | 
                                                    ||
| 516 | 516 | ];  | 
                                                        
| 517 | 517 | $modelName = $this->modelName;  | 
                                                        
| 518 | 518 |          if (!empty($params['categoryPath']) && $modelName::$categoryModel) { | 
                                                        
| 519 | - $queryParams['where'][] = ['tree_path', $params['categoryPath'] . '%', 'LIKE'];  | 
                                                        |
| 519 | + $queryParams['where'][] = ['tree_path', $params['categoryPath'].'%', 'LIKE'];  | 
                                                        |
| 520 | 520 | }  | 
                                                        
| 521 | 521 |          if (!empty($this->managerOptions['userGroupFilter'][\Users\User::$cur->group_id]['getRows'])) { | 
                                                        
| 522 | 522 |              foreach ($this->managerOptions['userGroupFilter'][\Users\User::$cur->group_id]['getRows'] as $colName => $colOptions) { | 
                                                        
@@ -570,7 +570,7 @@ discard block  | 
                                                    ||
| 570 | 570 |                          if (!empty($params['filters'][$col]['max'])) { | 
                                                        
| 571 | 571 |                              if ($colInfo['colParams']['type'] == 'dateTime' && !strpos($params['filters'][$col]['max'], ' ')) { | 
                                                        
| 572 | 572 | |
| 573 | - $date = $params['filters'][$col]['max'] . ' 23:59:59';  | 
                                                        |
| 573 | + $date = $params['filters'][$col]['max'].' 23:59:59';  | 
                                                        |
| 574 | 574 |                              } else { | 
                                                        
| 575 | 575 | $date = $params['filters'][$col]['max'];  | 
                                                        
| 576 | 576 | }  | 
                                                        
@@ -597,16 +597,16 @@ discard block  | 
                                                    ||
| 597 | 597 | }  | 
                                                        
| 598 | 598 |                          switch ($params['filters'][$col]['compareType']) { | 
                                                        
| 599 | 599 | case 'contains':  | 
                                                        
| 600 | - $queryParams['where'][] = [$col, '%' . $params['filters'][$col]['value'] . '%', 'LIKE'];  | 
                                                        |
| 600 | + $queryParams['where'][] = [$col, '%'.$params['filters'][$col]['value'].'%', 'LIKE'];  | 
                                                        |
| 601 | 601 | break;  | 
                                                        
| 602 | 602 | case 'equals':  | 
                                                        
| 603 | 603 | $queryParams['where'][] = [$col, $params['filters'][$col]['value']];  | 
                                                        
| 604 | 604 | break;  | 
                                                        
| 605 | 605 | case 'starts_with':  | 
                                                        
| 606 | - $queryParams['where'][] = [$col, $params['filters'][$col]['value'] . '%', 'LIKE'];  | 
                                                        |
| 606 | + $queryParams['where'][] = [$col, $params['filters'][$col]['value'].'%', 'LIKE'];  | 
                                                        |
| 607 | 607 | break;  | 
                                                        
| 608 | 608 | case 'ends_with':  | 
                                                        
| 609 | - $queryParams['where'][] = [$col, '%' . $params['filters'][$col]['value'], 'LIKE'];  | 
                                                        |
| 609 | + $queryParams['where'][] = [$col, '%'.$params['filters'][$col]['value'], 'LIKE'];  | 
                                                        |
| 610 | 610 | break;  | 
                                                        
| 611 | 611 | }  | 
                                                        
| 612 | 612 | break;  | 
                                                        
@@ -640,7 +640,7 @@ discard block  | 
                                                    ||
| 640 | 640 | $tableCols[] = !empty($colOptions['label']) ? $colOptions['label'] : $colName;  | 
                                                        
| 641 | 641 | }  | 
                                                        
| 642 | 642 | $tableCols[] = '';  | 
                                                        
| 643 | - $this->table->class .=' datamanagertable';  | 
                                                        |
| 643 | + $this->table->class .= ' datamanagertable';  | 
                                                        |
| 644 | 644 | $this->table->setCols($tableCols);  | 
                                                        
| 645 | 645 | }  | 
                                                        
| 646 | 646 | |
@@ -663,12 +663,12 @@ discard block  | 
                                                    ||
| 663 | 663 | return false;  | 
                                                        
| 664 | 664 | }  | 
                                                        
| 665 | 665 |          if (!$this->checkAccess()) { | 
                                                        
| 666 | -            $this->drawError('you not have access to "' . $this->modelName . '" manager with name: "' . $this->managerName . '"'); | 
                                                        |
| 666 | +            $this->drawError('you not have access to "'.$this->modelName.'" manager with name: "'.$this->managerName.'"'); | 
                                                        |
| 667 | 667 | return [];  | 
                                                        
| 668 | 668 | }  | 
                                                        
| 669 | 669 | $tree = new Tree();  | 
                                                        
| 670 | 670 |          $tree->ul($this->managerOptions['categorys']['model'], 0, function($category) { | 
                                                        
| 671 | - $path = $category->tree_path . ($category->pk() ? $category->pk() . "/" : '');  | 
                                                        |
| 671 | + $path = $category->tree_path.($category->pk() ? $category->pk()."/" : '');  | 
                                                        |
| 672 | 672 |              $cleanClassName = str_replace('\\', '\\\\', get_class($category)); | 
                                                        
| 673 | 673 |              return "<a href='#' onclick='inji.Ui.dataManagers.get(this).switchCategory(this);return false;' data-index='{$category->index()}' data-path ='{$path}' data-id='{$category->pk()}'> {$category->name}</a>  | 
                                                        
| 674 | 674 | |
@@ -718,17 +718,21 @@ discard block  | 
                                                    ||
| 718 | 718 |          if (!$query) { | 
                                                        
| 719 | 719 | return [];  | 
                                                        
| 720 | 720 | }  | 
                                                        
| 721 | - if (!empty($options['where']))  | 
                                                        |
| 722 | - $query->where($options['where']);  | 
                                                        |
| 721 | +        if (!empty($options['where'])) { | 
                                                        |
| 722 | + $query->where($options['where']);  | 
                                                        |
| 723 | + }  | 
                                                        |
| 723 | 724 |          if (!empty($options['group'])) { | 
                                                        
| 724 | 725 | $query->group($options['group']);  | 
                                                        
| 725 | 726 | }  | 
                                                        
| 726 | - if (!empty($options['order']))  | 
                                                        |
| 727 | - $query->order($options['order']);  | 
                                                        |
| 728 | - if (!empty($options['join']))  | 
                                                        |
| 729 | - $query->join($options['join']);  | 
                                                        |
| 730 | - if (!empty($options['distinct']))  | 
                                                        |
| 731 | - $query->distinct = $options['distinct'];  | 
                                                        |
| 727 | +        if (!empty($options['order'])) { | 
                                                        |
| 728 | + $query->order($options['order']);  | 
                                                        |
| 729 | + }  | 
                                                        |
| 730 | +        if (!empty($options['join'])) { | 
                                                        |
| 731 | + $query->join($options['join']);  | 
                                                        |
| 732 | + }  | 
                                                        |
| 733 | +        if (!empty($options['distinct'])) { | 
                                                        |
| 734 | + $query->distinct = $options['distinct'];  | 
                                                        |
| 735 | + }  | 
                                                        |
| 732 | 736 | |
| 733 | 737 |          foreach (static::$relJoins as $join) { | 
                                                        
| 734 | 738 | $query->join($join[0], $join[1]);  | 
                                                        
@@ -754,14 +758,14 @@ discard block  | 
                                                    ||
| 754 | 758 | }  | 
                                                        
| 755 | 759 | static::$needJoin = [];  | 
                                                        
| 756 | 760 | |
| 757 | - if (!empty($options['limit']))  | 
                                                        |
| 758 | - $limit = (int) $options['limit'];  | 
                                                        |
| 759 | -        else { | 
                                                        |
| 761 | +        if (!empty($options['limit'])) { | 
                                                        |
| 762 | + $limit = (int) $options['limit'];  | 
                                                        |
| 763 | +        } else { | 
                                                        |
| 760 | 764 | $limit = 0;  | 
                                                        
| 761 | 765 | }  | 
                                                        
| 762 | - if (!empty($options['start']))  | 
                                                        |
| 763 | - $start = (int) $options['start'];  | 
                                                        |
| 764 | -        else { | 
                                                        |
| 766 | +        if (!empty($options['start'])) { | 
                                                        |
| 767 | + $start = (int) $options['start'];  | 
                                                        |
| 768 | +        } else { | 
                                                        |
| 765 | 769 | $start = 0;  | 
                                                        
| 766 | 770 | }  | 
                                                        
| 767 | 771 |          if ($limit || $start) { | 
                                                        
@@ -1020,21 +1024,23 @@ discard block  | 
                                                    ||
| 1020 | 1024 |          if (!empty($options['where'])) { | 
                                                        
| 1021 | 1025 | static::fixPrefix($options['where'], 'first');  | 
                                                        
| 1022 | 1026 | }  | 
                                                        
| 1023 | - if (!empty($options['where']))  | 
                                                        |
| 1024 | - $query->where($options['where']);  | 
                                                        |
| 1025 | - if (!empty($options['join']))  | 
                                                        |
| 1026 | - $query->join($options['join']);  | 
                                                        |
| 1027 | +        if (!empty($options['where'])) { | 
                                                        |
| 1028 | + $query->where($options['where']);  | 
                                                        |
| 1029 | + }  | 
                                                        |
| 1030 | +        if (!empty($options['join'])) { | 
                                                        |
| 1031 | + $query->join($options['join']);  | 
                                                        |
| 1032 | + }  | 
                                                        |
| 1027 | 1033 |          if (!empty($options['order'])) { | 
                                                        
| 1028 | 1034 | $query->order($options['order']);  | 
                                                        
| 1029 | 1035 | }  | 
                                                        
| 1030 | - if (!empty($options['limit']))  | 
                                                        |
| 1031 | - $limit = (int) $options['limit'];  | 
                                                        |
| 1032 | -        else { | 
                                                        |
| 1036 | +        if (!empty($options['limit'])) { | 
                                                        |
| 1037 | + $limit = (int) $options['limit'];  | 
                                                        |
| 1038 | +        } else { | 
                                                        |
| 1033 | 1039 | $limit = 0;  | 
                                                        
| 1034 | 1040 | }  | 
                                                        
| 1035 | - if (!empty($options['start']))  | 
                                                        |
| 1036 | - $start = (int) $options['start'];  | 
                                                        |
| 1037 | -        else { | 
                                                        |
| 1041 | +        if (!empty($options['start'])) { | 
                                                        |
| 1042 | + $start = (int) $options['start'];  | 
                                                        |
| 1043 | +        } else { | 
                                                        |
| 1038 | 1044 | $start = 0;  | 
                                                        
| 1039 | 1045 | }  | 
                                                        
| 1040 | 1046 |          if ($limit || $start) { | 
                                                        
@@ -1112,8 +1118,9 @@ discard block  | 
                                                    ||
| 1112 | 1118 | |
| 1113 | 1119 | $values = [];  | 
                                                        
| 1114 | 1120 |          foreach ($cols as $col => $param) { | 
                                                        
| 1115 | - if (isset($params[$col]))  | 
                                                        |
| 1116 | - $values[$col] = $params[$col];  | 
                                                        |
| 1121 | +            if (isset($params[$col])) { | 
                                                        |
| 1122 | + $values[$col] = $params[$col];  | 
                                                        |
| 1123 | + }  | 
                                                        |
| 1117 | 1124 | }  | 
                                                        
| 1118 | 1125 |          if (empty($values)) { | 
                                                        
| 1119 | 1126 | return false;  | 
                                                        
@@ -1296,8 +1303,9 @@ discard block  | 
                                                    ||
| 1296 | 1303 | $values = [];  | 
                                                        
| 1297 | 1304 | |
| 1298 | 1305 |          foreach ($this->cols() as $col => $param) { | 
                                                        
| 1299 | - if (isset($this->_params[$col]))  | 
                                                        |
| 1300 | - $values[$col] = $this->_params[$col];  | 
                                                        |
| 1306 | +            if (isset($this->_params[$col])) { | 
                                                        |
| 1307 | + $values[$col] = $this->_params[$col];  | 
                                                        |
| 1308 | + }  | 
                                                        |
| 1301 | 1309 | }  | 
                                                        
| 1302 | 1310 |          if (empty($values) && empty($options['empty'])) { | 
                                                        
| 1303 | 1311 | return false;  | 
                                                        
@@ -1457,8 +1465,9 @@ discard block  | 
                                                    ||
| 1457 | 1465 |      { | 
                                                        
| 1458 | 1466 | |
| 1459 | 1467 |          foreach (static::relations() as $relName => $rel) { | 
                                                        
| 1460 | - if ($rel['col'] == $col)  | 
                                                        |
| 1461 | - return $relName;  | 
                                                        |
| 1468 | +            if ($rel['col'] == $col) { | 
                                                        |
| 1469 | + return $relName;  | 
                                                        |
| 1470 | + }  | 
                                                        |
| 1462 | 1471 | }  | 
                                                        
| 1463 | 1472 | return NULL;  | 
                                                        
| 1464 | 1473 | }  | 
                                                        
@@ -72,7 +72,7 @@ discard block  | 
                                                    ||
| 72 | 72 | $this->info = $this->getInfo();  | 
                                                        
| 73 | 73 | $this->config = Config::module($this->moduleName, !empty($this->info['systemConfig']));  | 
                                                        
| 74 | 74 | $that = $this;  | 
                                                        
| 75 | -        Inji::$inst->listen('Config-change-module-' . $this->app->name . '-' . $this->moduleName, $this->app->name . '-' . $this->moduleName . 'config', function($event) use ($that) { | 
                                                        |
| 75 | +        Inji::$inst->listen('Config-change-module-'.$this->app->name.'-'.$this->moduleName, $this->app->name.'-'.$this->moduleName.'config', function($event) use ($that) { | 
                                                        |
| 76 | 76 | $that->config = $event['eventObject'];  | 
                                                        
| 77 | 77 | });  | 
                                                        
| 78 | 78 | }  | 
                                                        
@@ -88,10 +88,10 @@ discard block  | 
                                                    ||
| 88 | 88 | $moduleName = ucfirst($moduleName);  | 
                                                        
| 89 | 89 | $paths = [];  | 
                                                        
| 90 | 90 |          if (App::$cur !== App::$primary) { | 
                                                        
| 91 | - $paths['primaryAppPath'] = App::$primary->path . '/modules/' . $moduleName;  | 
                                                        |
| 91 | + $paths['primaryAppPath'] = App::$primary->path.'/modules/'.$moduleName;  | 
                                                        |
| 92 | 92 | }  | 
                                                        
| 93 | - $paths['curAppPath'] = App::$cur->path . '/modules/' . $moduleName;  | 
                                                        |
| 94 | - $paths['systemPath'] = INJI_SYSTEM_DIR . '/modules/' . $moduleName;  | 
                                                        |
| 93 | + $paths['curAppPath'] = App::$cur->path.'/modules/'.$moduleName;  | 
                                                        |
| 94 | + $paths['systemPath'] = INJI_SYSTEM_DIR.'/modules/'.$moduleName;  | 
                                                        |
| 95 | 95 | return $paths;  | 
                                                        
| 96 | 96 | }  | 
                                                        
| 97 | 97 | |
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | $moduleName = ucfirst($moduleName);  | 
                                                        
| 107 | 107 | $paths = Module::getModulePaths($moduleName);  | 
                                                        
| 108 | 108 |          foreach ($paths as $path) { | 
                                                        
| 109 | -            if (file_exists($path . '/' . $moduleName . '.php')) { | 
                                                        |
| 109 | +            if (file_exists($path.'/'.$moduleName.'.php')) { | 
                                                        |
| 110 | 110 | return $path;  | 
                                                        
| 111 | 111 | }  | 
                                                        
| 112 | 112 | }  | 
                                                        
@@ -159,12 +159,12 @@ discard block  | 
                                                    ||
| 159 | 159 |          foreach ($moduleDirs as $moduleDir) { | 
                                                        
| 160 | 160 |              if (is_dir($moduleDir)) { | 
                                                        
| 161 | 161 |                  foreach (scandir($moduleDir) as $dir) { | 
                                                        
| 162 | -                    if (preg_match('!Controllers$!', $dir) && is_dir($moduleDir . '/' . $dir)) { | 
                                                        |
| 163 | - $path = $moduleDir . '/' . $dir;  | 
                                                        |
| 162 | +                    if (preg_match('!Controllers$!', $dir) && is_dir($moduleDir.'/'.$dir)) { | 
                                                        |
| 163 | + $path = $moduleDir.'/'.$dir;  | 
                                                        |
| 164 | 164 |                          foreach (scandir($path) as $file) { | 
                                                        
| 165 | -                            if (preg_match('!Controller\.php$!', $file) && is_file($path . '/' . $file)) { | 
                                                        |
| 165 | +                            if (preg_match('!Controller\.php$!', $file) && is_file($path.'/'.$file)) { | 
                                                        |
| 166 | 166 |                                  $controllerName = preg_replace('!Controller\.php$!', '', $file); | 
                                                        
| 167 | -                                $controllers[preg_replace('!Controllers$!', '', $dir)][$controllerName] = $path . '/' . $file; | 
                                                        |
| 167 | +                                $controllers[preg_replace('!Controllers$!', '', $dir)][$controllerName] = $path.'/'.$file; | 
                                                        |
| 168 | 168 | }  | 
                                                        
| 169 | 169 | }  | 
                                                        
| 170 | 170 | }  | 
                                                        
@@ -211,31 +211,31 @@ discard block  | 
                                                    ||
| 211 | 211 | $paths = [];  | 
                                                        
| 212 | 212 |          if (App::$cur != App::$primary) { | 
                                                        
| 213 | 213 |              if (!empty($this->params[0]) && strtolower($this->params[0]) != strtolower($this->moduleName)) { | 
                                                        
| 214 | - $paths['primaryAppAppTypePath_slice'] = App::$primary->path . '/modules/' . $this->moduleName . '/' . $this->app->type . 'Controllers/' . ucfirst($this->params[0]) . 'Controller.php';  | 
                                                        |
| 214 | + $paths['primaryAppAppTypePath_slice'] = App::$primary->path.'/modules/'.$this->moduleName.'/'.$this->app->type.'Controllers/'.ucfirst($this->params[0]).'Controller.php';  | 
                                                        |
| 215 | 215 |                  if (App::$primary->{$this->moduleName}) { | 
                                                        
| 216 | -                    $paths['primaryAppAppTypePath_slice'] = App::$primary->{$this->moduleName}->path . '/' . $this->app->type . 'Controllers/' . ucfirst($this->params[0]) . 'Controller.php'; | 
                                                        |
| 216 | +                    $paths['primaryAppAppTypePath_slice'] = App::$primary->{$this->moduleName}->path.'/'.$this->app->type.'Controllers/'.ucfirst($this->params[0]).'Controller.php'; | 
                                                        |
| 217 | 217 | }  | 
                                                        
| 218 | 218 | }  | 
                                                        
| 219 | - $paths['primaryAppAppAppTypePath'] = App::$primary->path . '/modules/' . $this->moduleName . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php';  | 
                                                        |
| 219 | + $paths['primaryAppAppAppTypePath'] = App::$primary->path.'/modules/'.$this->moduleName.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php';  | 
                                                        |
| 220 | 220 |              if (App::$primary->{$this->moduleName}) { | 
                                                        
| 221 | -                $paths['primaryAppAppTypePath'] = App::$primary->{$this->moduleName}->path . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php'; | 
                                                        |
| 221 | +                $paths['primaryAppAppTypePath'] = App::$primary->{$this->moduleName}->path.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php'; | 
                                                        |
| 222 | 222 | }  | 
                                                        
| 223 | -            $paths['curAppAppTypePath'] = $this->app->{$this->moduleName}->path . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php'; | 
                                                        |
| 223 | +            $paths['curAppAppTypePath'] = $this->app->{$this->moduleName}->path.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php'; | 
                                                        |
| 224 | 224 | }  | 
                                                        
| 225 | 225 | |
| 226 | 226 |          if (!empty($this->params[0]) && strtolower($this->params[0]) != strtolower($this->moduleName)) { | 
                                                        
| 227 | - $paths['appAppTypePath_slice'] = $this->app->path . '/modules/' . $this->moduleName . '/' . $this->app->type . 'Controllers/' . ucfirst($this->params[0]) . 'Controller.php';  | 
                                                        |
| 228 | - $paths['appTypePath_slice'] = $this->path . '/' . $this->app->type . 'Controllers/' . ucfirst($this->params[0]) . 'Controller.php';  | 
                                                        |
| 227 | + $paths['appAppTypePath_slice'] = $this->app->path.'/modules/'.$this->moduleName.'/'.$this->app->type.'Controllers/'.ucfirst($this->params[0]).'Controller.php';  | 
                                                        |
| 228 | + $paths['appTypePath_slice'] = $this->path.'/'.$this->app->type.'Controllers/'.ucfirst($this->params[0]).'Controller.php';  | 
                                                        |
| 229 | 229 | }  | 
                                                        
| 230 | - $paths['appAppTypePath'] = $this->app->path . '/modules/' . $this->moduleName . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php';  | 
                                                        |
| 231 | - $paths['appTypePath'] = $this->path . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php';  | 
                                                        |
| 230 | + $paths['appAppTypePath'] = $this->app->path.'/modules/'.$this->moduleName.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php';  | 
                                                        |
| 231 | + $paths['appTypePath'] = $this->path.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php';  | 
                                                        |
| 232 | 232 | |
| 233 | 233 |          if (!empty($this->params[0]) && strtolower($this->params[0]) != strtolower($this->moduleName)) { | 
                                                        
| 234 | - $paths['appUniversalPath_slice'] = $this->app->path . '/modules/' . $this->moduleName . '/Controllers/' . ucfirst($this->params[0]) . 'Controller.php';  | 
                                                        |
| 235 | - $paths['universalPath_slice'] = $this->path . '/Controllers/' . ucfirst($this->params[0]) . 'Controller.php';  | 
                                                        |
| 234 | + $paths['appUniversalPath_slice'] = $this->app->path.'/modules/'.$this->moduleName.'/Controllers/'.ucfirst($this->params[0]).'Controller.php';  | 
                                                        |
| 235 | + $paths['universalPath_slice'] = $this->path.'/Controllers/'.ucfirst($this->params[0]).'Controller.php';  | 
                                                        |
| 236 | 236 | }  | 
                                                        
| 237 | - $paths['appUniversalPath'] = $this->app->path . '/modules/' . $this->moduleName . '/Controllers/' . $this->moduleName . 'Controller.php';  | 
                                                        |
| 238 | - $paths['universalPath'] = $this->path . '/Controllers/' . $this->moduleName . 'Controller.php';  | 
                                                        |
| 237 | + $paths['appUniversalPath'] = $this->app->path.'/modules/'.$this->moduleName.'/Controllers/'.$this->moduleName.'Controller.php';  | 
                                                        |
| 238 | + $paths['universalPath'] = $this->path.'/Controllers/'.$this->moduleName.'Controller.php';  | 
                                                        |
| 239 | 239 | |
| 240 | 240 | return $paths;  | 
                                                        
| 241 | 241 | }  | 
                                                        
@@ -258,7 +258,7 @@ discard block  | 
                                                    ||
| 258 | 258 | $controllerName = $this->moduleName;  | 
                                                        
| 259 | 259 | $params = $this->params;  | 
                                                        
| 260 | 260 | }  | 
                                                        
| 261 | - $fullControllerName = $controllerName . 'Controller';  | 
                                                        |
| 261 | + $fullControllerName = $controllerName.'Controller';  | 
                                                        |
| 262 | 262 | $controller = new $fullControllerName();  | 
                                                        
| 263 | 263 | $controller->params = $params;  | 
                                                        
| 264 | 264 | $controller->module = $this;  | 
                                                        
@@ -284,8 +284,8 @@ discard block  | 
                                                    ||
| 284 | 284 | }  | 
                                                        
| 285 | 285 | $paths = Module::getModulePaths($moduleName);  | 
                                                        
| 286 | 286 |          foreach ($paths as $path) { | 
                                                        
| 287 | -            if (file_exists($path . '/info.php')) { | 
                                                        |
| 288 | - return include $path . '/info.php';  | 
                                                        |
| 287 | +            if (file_exists($path.'/info.php')) { | 
                                                        |
| 288 | + return include $path.'/info.php';  | 
                                                        |
| 289 | 289 | }  | 
                                                        
| 290 | 290 | }  | 
                                                        
| 291 | 291 | return [];  | 
                                                        
@@ -304,16 +304,16 @@ discard block  | 
                                                    ||
| 304 | 304 |      { | 
                                                        
| 305 | 305 | $moduleName = $moduleName ? $moduleName : $this->moduleName;  | 
                                                        
| 306 | 306 | $modulePaths = Module::getModulePaths($moduleName);  | 
                                                        
| 307 | - $modulePaths['templatePath'] = App::$cur->view->template->path . '/modules/' . ucfirst($moduleName);  | 
                                                        |
| 307 | + $modulePaths['templatePath'] = App::$cur->view->template->path.'/modules/'.ucfirst($moduleName);  | 
                                                        |
| 308 | 308 | $snippets = [];  | 
                                                        
| 309 | 309 |          foreach ($modulePaths as $path) { | 
                                                        
| 310 | -            if (file_exists($path . $dir . '/' . $snippetsPath)) { | 
                                                        |
| 311 | - $snippetsPaths = array_slice(scandir($path . $dir . '/' . $snippetsPath), 2);  | 
                                                        |
| 310 | +            if (file_exists($path.$dir.'/'.$snippetsPath)) { | 
                                                        |
| 311 | + $snippetsPaths = array_slice(scandir($path.$dir.'/'.$snippetsPath), 2);  | 
                                                        |
| 312 | 312 |                  foreach ($snippetsPaths as $snippetPath) { | 
                                                        
| 313 | -                    if (is_dir($path . $dir . '/' . $snippetsPath . '/' . $snippetPath)) { | 
                                                        |
| 314 | - $snippets[$snippetPath] = include $path . $dir . '/' . $snippetsPath . '/' . $snippetPath . '/info.php';  | 
                                                        |
| 313 | +                    if (is_dir($path.$dir.'/'.$snippetsPath.'/'.$snippetPath)) { | 
                                                        |
| 314 | + $snippets[$snippetPath] = include $path.$dir.'/'.$snippetsPath.'/'.$snippetPath.'/info.php';  | 
                                                        |
| 315 | 315 |                      } else { | 
                                                        
| 316 | - $snippets[pathinfo($snippetPath, PATHINFO_FILENAME)] = include $path . $dir . '/' . $snippetsPath . '/' . $snippetPath;  | 
                                                        |
| 316 | + $snippets[pathinfo($snippetPath, PATHINFO_FILENAME)] = include $path.$dir.'/'.$snippetsPath.'/'.$snippetPath;  | 
                                                        |
| 317 | 317 | }  | 
                                                        
| 318 | 318 | }  | 
                                                        
| 319 | 319 | }  | 
                                                        
@@ -335,9 +335,9 @@ discard block  | 
                                                    ||
| 335 | 335 |      { | 
                                                        
| 336 | 336 | $extensions = [];  | 
                                                        
| 337 | 337 | $modules = Module::getInstalled(App::$cur);  | 
                                                        
| 338 | - $method = 'get' . ucfirst($extensionType);  | 
                                                        |
| 338 | + $method = 'get'.ucfirst($extensionType);  | 
                                                        |
| 339 | 339 |          foreach ($modules as $module) { | 
                                                        
| 340 | -            $extensions = array_merge($extensions, $this->{$method}($request, false, "/extensions/{$this->moduleName}/" . $extensionType, $module)); | 
                                                        |
| 340 | +            $extensions = array_merge($extensions, $this->{$method}($request, false, "/extensions/{$this->moduleName}/".$extensionType, $module)); | 
                                                        |
| 341 | 341 | }  | 
                                                        
| 342 | 342 | return $extensions;  | 
                                                        
| 343 | 343 | }  | 
                                                        
@@ -9,6 +9,6 @@  | 
                                                    ||
| 9 | 9 | <a href='#' onclick='inji.Ui.dataManagers.get(this).switchCategory(this);return false;' data-index='<?= $model::index(); ?>' data-path ='/' data-id='0'> Корень</a>  | 
                                                        
| 10 | 10 | <div class="categoryTree">  | 
                                                        
| 11 | 11 | <?php  | 
                                                        
| 12 | - $dataManager->drawCategorys();  | 
                                                        |
| 13 | - ?>  | 
                                                        |
| 12 | + $dataManager->drawCategorys();  | 
                                                        |
| 13 | + ?>  | 
                                                        |
| 14 | 14 | </div>  | 
                                                        
| 15 | 15 | \ No newline at end of file  |