@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | * @return boolean |
56 | 56 | */ |
57 | 57 | public static function createDir($path) { |
58 | - if (file_exists($path)) |
|
59 | - return true; |
|
58 | + if (file_exists($path)) { |
|
59 | + return true; |
|
60 | + } |
|
60 | 61 | |
61 | 62 | $path = explode('/', $path); |
62 | 63 | $cur = ''; |
@@ -100,10 +101,11 @@ discard block |
||
100 | 101 | return false; |
101 | 102 | } |
102 | 103 | |
103 | - if ($img_width / $max_width > $img_height / $max_height) |
|
104 | - $separator = $img_width / $max_width; |
|
105 | - else |
|
106 | - $separator = $img_height / $max_height; |
|
104 | + if ($img_width / $max_width > $img_height / $max_height) { |
|
105 | + $separator = $img_width / $max_width; |
|
106 | + } else { |
|
107 | + $separator = $img_height / $max_height; |
|
108 | + } |
|
107 | 109 | |
108 | 110 | if ($crop === true || $crop == 'q') { |
109 | 111 | if ($img_width > $img_height) { |
@@ -22,16 +22,19 @@ discard block |
||
22 | 22 | |
23 | 23 | $sitePath = App::$primary->path; |
24 | 24 | |
25 | - if (!is_uploaded_file($file['tmp_name'])) |
|
26 | - return 0; |
|
25 | + if (!is_uploaded_file($file['tmp_name'])) { |
|
26 | + return 0; |
|
27 | + } |
|
27 | 28 | |
28 | 29 | $fileinfo = pathinfo($file['name']); |
29 | - if (empty($fileinfo['extension'])) |
|
30 | - return 0; |
|
30 | + if (empty($fileinfo['extension'])) { |
|
31 | + return 0; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $type = Files\Type::get($fileinfo['extension'], 'ext'); |
33 | - if (!$type) |
|
34 | - return 0; |
|
35 | + if (!$type) { |
|
36 | + return 0; |
|
37 | + } |
|
35 | 38 | |
36 | 39 | if (!empty($options['accept_group']) && $options['accept_group'] != $type->group) { |
37 | 40 | return 0; |
@@ -47,8 +50,9 @@ discard block |
||
47 | 50 | } |
48 | 51 | $fileObject->name = $fileinfo['filename']; |
49 | 52 | $fileObject->path = $type->type_dir . date('Y-m-d') . '/' . microtime(true) . '.' . $fileinfo['extension']; |
50 | - if ($fileObject->id && file_exists($sitePath . $fileObject->path)) |
|
51 | - unlink($sitePath . $fileObject->path); |
|
53 | + if ($fileObject->id && file_exists($sitePath . $fileObject->path)) { |
|
54 | + unlink($sitePath . $fileObject->path); |
|
55 | + } |
|
52 | 56 | |
53 | 57 | Tools::createDir($sitePath . $type->type_dir . date('Y-m-d') . '/'); |
54 | 58 | |
@@ -84,12 +88,14 @@ discard block |
||
84 | 88 | $sitePath = App::$primary->path; |
85 | 89 | |
86 | 90 | $fileinfo = pathinfo($url); |
87 | - if (empty($fileinfo['extension'])) |
|
88 | - return 0; |
|
91 | + if (empty($fileinfo['extension'])) { |
|
92 | + return 0; |
|
93 | + } |
|
89 | 94 | |
90 | 95 | $type = Files\Type::get($fileinfo['extension'], 'ext'); |
91 | - if (!$type) |
|
92 | - return 0; |
|
96 | + if (!$type) { |
|
97 | + return 0; |
|
98 | + } |
|
93 | 99 | |
94 | 100 | if (!empty($options['accept_group']) && $options['accept_group'] != $type->group) { |
95 | 101 | return 0; |
@@ -105,8 +111,9 @@ discard block |
||
105 | 111 | } |
106 | 112 | $fileObject->name = $fileinfo['filename']; |
107 | 113 | $fileObject->path = $type->type_dir . date('Y-m-d') . '/' . microtime(true) . '.' . $fileinfo['extension']; |
108 | - if ($fileObject->id && file_exists($sitePath . $fileObject->path)) |
|
109 | - unlink($sitePath . $fileObject->path); |
|
114 | + if ($fileObject->id && file_exists($sitePath . $fileObject->path)) { |
|
115 | + unlink($sitePath . $fileObject->path); |
|
116 | + } |
|
110 | 117 | |
111 | 118 | Tools::createDir($sitePath . $type->type_dir . date('Y-m-d') . '/'); |
112 | 119 |