@@ -20,21 +20,21 @@ |
||
20 | 20 | $file = new \Exchange1c\Exchange\File(); |
21 | 21 | $file->name = $_GET['filename']; |
22 | 22 | $file->exchange_id = $this->exchange->id; |
23 | - $file->size = ceil(filesize($dir . '/' . $_GET['filename'])); |
|
23 | + $file->size = ceil(filesize($dir.'/'.$_GET['filename'])); |
|
24 | 24 | $file->save(); |
25 | 25 | |
26 | 26 | if (strpos($_GET['filename'], '/') !== false) { |
27 | 27 | $subDir = substr($_GET['filename'], 0, strrpos($_GET['filename'], "/") + 1); |
28 | - \Tools::createDir($dir . '/' . $subDir); |
|
28 | + \Tools::createDir($dir.'/'.$subDir); |
|
29 | 29 | } |
30 | 30 | $status = 'success'; |
31 | 31 | $text = ''; |
32 | - if (false === file_put_contents($dir . '/' . $_GET['filename'], file_get_contents("php://input"))) { |
|
32 | + if (false === file_put_contents($dir.'/'.$_GET['filename'], file_get_contents("php://input"))) { |
|
33 | 33 | $status = 'failure'; |
34 | - $text = 'Fail on save file: ' . $_GET['filename']; |
|
34 | + $text = 'Fail on save file: '.$_GET['filename']; |
|
35 | 35 | } |
36 | 36 | if (strpos($_GET['filename'], '1cbitrix') !== false) { |
37 | - $data = new \SimpleXMLElement(file_get_contents($dir . '/' . $_GET['filename'])); |
|
37 | + $data = new \SimpleXMLElement(file_get_contents($dir.'/'.$_GET['filename'])); |
|
38 | 38 | $orders = new \Exchange1c\Parser\Orders($data); |
39 | 39 | $orders->process(); |
40 | 40 | } |
@@ -13,85 +13,85 @@ |
||
13 | 13 | |
14 | 14 | class Value extends \Migrations\Parser { |
15 | 15 | |
16 | - public function parse() { |
|
16 | + public function parse() { |
|
17 | 17 | $options = $this->param->options ? json_decode($this->param->options, true) : []; |
18 | 18 | $modelName = get_class($this->model); |
19 | 19 | $cols = $modelName::$cols; |
20 | 20 | $value = $this->data; |
21 | 21 | if (is_array($value)) { |
22 | - $value = ''; |
|
22 | + $value = ''; |
|
23 | 23 | } |
24 | 24 | if (!empty($cols[$this->param->value])) { |
25 | - $col = $cols[$this->param->value]; |
|
26 | - if ($col['type'] == 'dynamicType') { |
|
25 | + $col = $cols[$this->param->value]; |
|
26 | + if ($col['type'] == 'dynamicType') { |
|
27 | 27 | switch ($col['typeSource']) { |
28 | - case'selfMethod': |
|
28 | + case'selfMethod': |
|
29 | 29 | $type = $this->model->{$col['selfMethod']}(); |
30 | 30 | if (is_array($type)) { |
31 | - if (strpos($type['relation'], ':')) { |
|
31 | + if (strpos($type['relation'], ':')) { |
|
32 | 32 | $relationPath = explode(':', $type['relation']); |
33 | 33 | $relationName = array_pop($relationPath); |
34 | 34 | $item = $this->model; |
35 | 35 | foreach ($relationPath as $path) { |
36 | - $item = $item->$path; |
|
36 | + $item = $item->$path; |
|
37 | 37 | } |
38 | 38 | $itemModel = get_class($item); |
39 | 39 | $relation = $itemModel::getRelation($relationName); |
40 | 40 | $sourceModel = $relation['model']; |
41 | - } else { |
|
41 | + } else { |
|
42 | 42 | $relation = $modelName::getRelation($type['relation']); |
43 | 43 | $sourceModel = $relation['model']; |
44 | - } |
|
45 | - $objectId = \App::$cur->migrations->findObject((string) $value, $sourceModel); |
|
46 | - if ($objectId) { |
|
44 | + } |
|
45 | + $objectId = \App::$cur->migrations->findObject((string) $value, $sourceModel); |
|
46 | + if ($objectId) { |
|
47 | 47 | $value = $objectId->object_id; |
48 | - } |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | break; |
51 | 51 | } |
52 | - } else { |
|
52 | + } else { |
|
53 | 53 | $type = $col['type']; |
54 | - } |
|
54 | + } |
|
55 | 55 | } else { |
56 | - $type = 'text'; |
|
56 | + $type = 'text'; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | if (!empty($options['valueReplace'])) { |
60 | - $values = $this->param->values(['key' => 'original']); |
|
61 | - if (empty($values[$value])) { |
|
60 | + $values = $this->param->values(['key' => 'original']); |
|
61 | + if (empty($values[$value])) { |
|
62 | 62 | $valueObject = new \Migrations\Migration\Object\Param\Value(); |
63 | 63 | $valueObject->param_id = $this->param->id; |
64 | 64 | $valueObject->original = $value; |
65 | 65 | $valueObject->save(); |
66 | - } else { |
|
66 | + } else { |
|
67 | 67 | $valueObject = $values[$value]; |
68 | - } |
|
69 | - $value = $valueObject->replace; |
|
68 | + } |
|
69 | + $value = $valueObject->replace; |
|
70 | 70 | } |
71 | 71 | switch ($type) { |
72 | - case 'image': |
|
72 | + case 'image': |
|
73 | 73 | $notEq = true; |
74 | 74 | $dir = pathinfo($this->object->walker->migtarionLog->source, PATHINFO_DIRNAME); |
75 | 75 | if ($this->model->{$this->param->value}) { |
76 | - $file = \Files\File::get($this->model->{$this->param->value}); |
|
77 | - if ($file && $value && file_exists($dir . '/' . $value) && file_exists(\App::$primary->path . $file->path) && md5_file($dir . '/' . $value) == md5_file(\App::$primary->path . $file->path)) { |
|
76 | + $file = \Files\File::get($this->model->{$this->param->value}); |
|
77 | + if ($file && $value && file_exists($dir . '/' . $value) && file_exists(\App::$primary->path . $file->path) && md5_file($dir . '/' . $value) == md5_file(\App::$primary->path . $file->path)) { |
|
78 | 78 | $notEq = false; |
79 | - } |
|
80 | - if ($file && $notEq) { |
|
79 | + } |
|
80 | + if ($file && $notEq) { |
|
81 | 81 | $file->delete(); |
82 | 82 | $this->model->{$this->param->value} = 0; |
83 | - } |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | if ($notEq) { |
86 | - $this->model->{$this->param->value} = \App::$primary->files->uploadFromUrl($dir . '/' . $value, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']); |
|
86 | + $this->model->{$this->param->value} = \App::$primary->files->uploadFromUrl($dir . '/' . $value, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']); |
|
87 | 87 | } |
88 | 88 | break; |
89 | - default: |
|
89 | + default: |
|
90 | 90 | if (is_array($value)) { |
91 | - $value = implode(' ', $value); |
|
91 | + $value = implode(' ', $value); |
|
92 | 92 | } |
93 | 93 | $this->model->{$this->param->value} = $value; |
94 | 94 | } |
95 | - } |
|
95 | + } |
|
96 | 96 | |
97 | 97 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $dir = pathinfo($this->object->walker->migtarionLog->source, PATHINFO_DIRNAME); |
75 | 75 | if ($this->model->{$this->param->value}) { |
76 | 76 | $file = \Files\File::get($this->model->{$this->param->value}); |
77 | - if ($file && $value && file_exists($dir . '/' . $value) && file_exists(\App::$primary->path . $file->path) && md5_file($dir . '/' . $value) == md5_file(\App::$primary->path . $file->path)) { |
|
77 | + if ($file && $value && file_exists($dir.'/'.$value) && file_exists(\App::$primary->path.$file->path) && md5_file($dir.'/'.$value) == md5_file(\App::$primary->path.$file->path)) { |
|
78 | 78 | $notEq = false; |
79 | 79 | } |
80 | 80 | if ($file && $notEq) { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | if ($notEq) { |
86 | - $this->model->{$this->param->value} = \App::$primary->files->uploadFromUrl($dir . '/' . $value, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']); |
|
86 | + $this->model->{$this->param->value} = \App::$primary->files->uploadFromUrl($dir.'/'.$value, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']); |
|
87 | 87 | } |
88 | 88 | break; |
89 | 89 | default: |