@@ -32,10 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | $phrases = array_merge(static::PHRASES, array_keys(Extend\Addons::items() ?? [])); |
34 | 34 | |
35 | - foreach (array_unique($languages) as $path) foreach ($phrases as $name) { |
|
35 | + foreach (array_unique($languages) as $path) { |
|
36 | + foreach ($phrases as $name) { |
|
36 | 37 | |
37 | 38 | Language::load($path . 'Phrases/' . $name . '.php'); |
38 | 39 | } |
40 | + } |
|
39 | 41 | } |
40 | 42 | |
41 | 43 | /** |
@@ -86,7 +88,9 @@ discard block |
||
86 | 88 | |
87 | 89 | # Set timezone |
88 | 90 | |
89 | - if (Auth::isLogged() && ('' !== ($timezone = Auth::get('timezone')))) date_default_timezone_set($timezone); |
|
91 | + if (Auth::isLogged() && ('' !== ($timezone = Auth::get('timezone')))) { |
|
92 | + date_default_timezone_set($timezone); |
|
93 | + } |
|
90 | 94 | |
91 | 95 | # Init utils |
92 | 96 |
@@ -21,7 +21,9 @@ |
||
21 | 21 | |
22 | 22 | protected function handle(bool $ajax = false) { |
23 | 23 | |
24 | - if (!$ajax) return false; |
|
24 | + if (!$ajax) { |
|
25 | + return false; |
|
26 | + } |
|
25 | 27 | |
26 | 28 | # Create response |
27 | 29 |
@@ -44,19 +44,27 @@ |
||
44 | 44 | |
45 | 45 | # Validate name |
46 | 46 | |
47 | - if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
47 | + if (false === ($name = Validate::fileName($name))) { |
|
48 | + return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
49 | + } |
|
48 | 50 | |
49 | - if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
|
51 | + if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) { |
|
52 | + return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | # Check if name is used |
52 | 56 | |
53 | - if (!$this->entity->check($name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
57 | + if (!$this->entity->check($name)) { |
|
58 | + return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
59 | + } |
|
54 | 60 | |
55 | 61 | # Rename entity |
56 | 62 | |
57 | - if (!$this->entity->rename($name)) return (($this->entity->getType() === 'dir') ? |
|
63 | + if (!$this->entity->rename($name)) { |
|
64 | + return (($this->entity->getType() === 'dir') ? |
|
58 | 65 | |
59 | 66 | 'FILEMANAGER_ERROR_DIR_RENAME' : 'FILEMANAGER_ERROR_FILE_RENAME'); |
67 | + } |
|
60 | 68 | |
61 | 69 | # ------------------------ |
62 | 70 |
@@ -44,7 +44,9 @@ |
||
44 | 44 | |
45 | 45 | # Rename item |
46 | 46 | |
47 | - if (false === $this->entity->putContents($contents)) return 'FILEMANAGER_ERROR_FILE_EDIT'; |
|
47 | + if (false === $this->entity->putContents($contents)) { |
|
48 | + return 'FILEMANAGER_ERROR_FILE_EDIT'; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | # ------------------------ |
50 | 52 |
@@ -44,9 +44,13 @@ discard block |
||
44 | 44 | |
45 | 45 | # Validate name |
46 | 46 | |
47 | - if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
47 | + if (false === ($name = Validate::fileName($name))) { |
|
48 | + return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
49 | + } |
|
48 | 50 | |
49 | - if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
|
51 | + if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) { |
|
52 | + return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | # Get entity |
52 | 56 | |
@@ -54,11 +58,15 @@ discard block |
||
54 | 58 | |
55 | 59 | # Check if name is used |
56 | 60 | |
57 | - if (!$entity->check($name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
61 | + if (!$entity->check($name)) { |
|
62 | + return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
63 | + } |
|
58 | 64 | |
59 | 65 | # Create entity |
60 | 66 | |
61 | - if (!$entity->create($name, 'dir')) return 'FILEMANAGER_ERROR_DIR_CREATE'; |
|
67 | + if (!$entity->create($name, 'dir')) { |
|
68 | + return 'FILEMANAGER_ERROR_DIR_CREATE'; |
|
69 | + } |
|
62 | 70 | |
63 | 71 | # ------------------------ |
64 | 72 |
@@ -64,7 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | # Set parent |
66 | 66 | |
67 | - if (!$ajax) $contents->parent = $this->parent->getPath(); |
|
67 | + if (!$ajax) { |
|
68 | + $contents->parent = $this->parent->getPath(); |
|
69 | + } |
|
68 | 70 | |
69 | 71 | # Set origin and title |
70 | 72 | |
@@ -76,7 +78,9 @@ discard block |
||
76 | 78 | |
77 | 79 | # Process bar |
78 | 80 | |
79 | - if (!$ajax) $this->processBar($contents->getBlock('bar')); |
|
81 | + if (!$ajax) { |
|
82 | + $this->processBar($contents->getBlock('bar')); |
|
83 | + } |
|
80 | 84 | |
81 | 85 | # Set items |
82 | 86 | |
@@ -84,14 +88,18 @@ discard block |
||
84 | 88 | |
85 | 89 | foreach ($this->loader->getItems() as $entity) { |
86 | 90 | |
87 | - if ($entity->isDir()) $items->addItem(Lister\Dir::getBlock($entity, $ajax)); |
|
88 | - |
|
89 | - else $items->addItem(Lister\File::getBlock($entity, $ajax)); |
|
91 | + if ($entity->isDir()) { |
|
92 | + $items->addItem(Lister\Dir::getBlock($entity, $ajax)); |
|
93 | + } else { |
|
94 | + $items->addItem(Lister\File::getBlock($entity, $ajax)); |
|
95 | + } |
|
90 | 96 | } |
91 | 97 | |
92 | 98 | # Set pagination |
93 | 99 | |
94 | - if (!$ajax) $contents->pagination = $this->getPaginationBlock(); |
|
100 | + if (!$ajax) { |
|
101 | + $contents->pagination = $this->getPaginationBlock(); |
|
102 | + } |
|
95 | 103 | |
96 | 104 | # ------------------------ |
97 | 105 | |
@@ -127,7 +135,9 @@ discard block |
||
127 | 135 | |
128 | 136 | protected function handle(bool $ajax = false) { |
129 | 137 | |
130 | - if ($ajax) return $this->handleAjax(); |
|
138 | + if ($ajax) { |
|
139 | + return $this->handleAjax(); |
|
140 | + } |
|
131 | 141 | |
132 | 142 | # Create parent |
133 | 143 | |
@@ -141,9 +151,11 @@ discard block |
||
141 | 151 | |
142 | 152 | if (static::$permissions['manage']) { |
143 | 153 | |
144 | - if (Uploader::submit('upload', $this->parent->getPathFull())) $submitted = 'upload'; |
|
145 | - |
|
146 | - else if ($this->form->handle(new Filemanager\Controller\Create($this->parent), true)) $submitted = 'create'; |
|
154 | + if (Uploader::submit('upload', $this->parent->getPathFull())) { |
|
155 | + $submitted = 'upload'; |
|
156 | + } else if ($this->form->handle(new Filemanager\Controller\Create($this->parent), true)) { |
|
157 | + $submitted = 'create'; |
|
158 | + } |
|
147 | 159 | } |
148 | 160 | |
149 | 161 | if (isset($submitted)) { |
@@ -155,9 +167,11 @@ discard block |
||
155 | 167 | |
156 | 168 | # Display success message |
157 | 169 | |
158 | - if (Request::get('submitted') === 'upload') Popup::set('positive', Language::get('FILEMANAGER_SUCCESS_UPLOAD')); |
|
159 | - |
|
160 | - else if (Request::get('submitted') === 'create') Popup::set('positive', Language::get('FILEMANAGER_SUCCESS_DIR_CREATE')); |
|
170 | + if (Request::get('submitted') === 'upload') { |
|
171 | + Popup::set('positive', Language::get('FILEMANAGER_SUCCESS_UPLOAD')); |
|
172 | + } else if (Request::get('submitted') === 'create') { |
|
173 | + Popup::set('positive', Language::get('FILEMANAGER_SUCCESS_DIR_CREATE')); |
|
174 | + } |
|
161 | 175 | |
162 | 176 | # Load items |
163 | 177 |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | |
36 | 36 | public function load(int $index = 0, int $display = 0) : Loader { |
37 | 37 | |
38 | - if (!(($index >= 0) && ($display >= 0))) return $this; |
|
38 | + if (!(($index >= 0) && ($display >= 0))) { |
|
39 | + return $this; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $dirs = []; $files = []; |
41 | 43 | |
@@ -43,9 +45,15 @@ discard block |
||
43 | 45 | |
44 | 46 | foreach (Explorer::iterate($this->parent->getPathFull()) as $name) { |
45 | 47 | |
46 | - if (!($entity = new Entity($this->parent, $name))->isInited()) continue; |
|
48 | + if (!($entity = new Entity($this->parent, $name))->isInited()) { |
|
49 | + continue; |
|
50 | + } |
|
47 | 51 | |
48 | - if ($entity->isDir()) $dirs[] = $entity; else $files[] = $entity; |
|
52 | + if ($entity->isDir()) { |
|
53 | + $dirs[] = $entity; |
|
54 | + } else { |
|
55 | + $files[] = $entity; |
|
56 | + } |
|
49 | 57 | } |
50 | 58 | |
51 | 59 | # Sort arrays |
@@ -61,7 +69,9 @@ discard block |
||
61 | 69 | |
62 | 70 | $items = array_merge($dirs, $files); $total = count($items); |
63 | 71 | |
64 | - if (($index > 0) && ($display > 0)) $items = array_splice($items, (($index - 1) * $display), $display); |
|
72 | + if (($index > 0) && ($display > 0)) { |
|
73 | + $items = array_splice($items, (($index - 1) * $display), $display); |
|
74 | + } |
|
65 | 75 | |
66 | 76 | # Set properties |
67 | 77 |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | # Implement forms |
47 | 47 | |
48 | - foreach ($this->forms as $form) $form->implement($contents); |
|
48 | + foreach ($this->forms as $form) { |
|
49 | + $form->implement($contents); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | # Process info block |
51 | 53 | |
@@ -104,7 +106,9 @@ discard block |
||
104 | 106 | |
105 | 107 | # Handle ajax request |
106 | 108 | |
107 | - if ($ajax) return $this->handleAjax(); |
|
109 | + if ($ajax) { |
|
110 | + return $this->handleAjax(); |
|
111 | + } |
|
108 | 112 | |
109 | 113 | # Create parent |
110 | 114 | |
@@ -140,18 +144,22 @@ discard block |
||
140 | 144 | |
141 | 145 | # Handle form |
142 | 146 | |
143 | - foreach ($this->forms as $name => $form) if ($form->handle($this->controllers[$name], true)) { |
|
147 | + foreach ($this->forms as $name => $form) { |
|
148 | + if ($form->handle($this->controllers[$name], true)) { |
|
144 | 149 | |
145 | 150 | Request::redirect(INSTALL_PATH . '/admin/content/filemanager/' . static::$origin . '/' . static::$type . |
146 | 151 | |
147 | 152 | '?parent=' . $this->parent->getPath() . '&name=' . $this->entity->getName() . '&submitted=' . $name); |
148 | 153 | } |
154 | + } |
|
149 | 155 | |
150 | 156 | # Display success message |
151 | 157 | |
152 | - if (Request::get('submitted') === 'rename') Popup::set('positive', Language::get(static::$message_success_rename)); |
|
153 | - |
|
154 | - else if (Request::get('submitted') === 'edit') Popup::set('positive', Language::get(static::$message_success_edit)); |
|
158 | + if (Request::get('submitted') === 'rename') { |
|
159 | + Popup::set('positive', Language::get(static::$message_success_rename)); |
|
160 | + } else if (Request::get('submitted') === 'edit') { |
|
161 | + Popup::set('positive', Language::get(static::$message_success_edit)); |
|
162 | + } |
|
155 | 163 | |
156 | 164 | # ------------------------ |
157 | 165 |
@@ -23,9 +23,13 @@ discard block |
||
23 | 23 | |
24 | 24 | private function getPrototype(string $name) { |
25 | 25 | |
26 | - if (('' === $name) || preg_match('/[\/\\\\]/', $name)) return false; |
|
26 | + if (('' === $name) || preg_match('/[\/\\\\]/', $name)) { |
|
27 | + return false; |
|
28 | + } |
|
27 | 29 | |
28 | - if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) return false; |
|
30 | + if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) { |
|
31 | + return false; |
|
32 | + } |
|
29 | 33 | |
30 | 34 | $path = (($this->parent->getPath() ? ($this->parent->getPath() . '/') : '') . $name); |
31 | 35 | |
@@ -53,17 +57,23 @@ discard block |
||
53 | 57 | |
54 | 58 | public function init(string $name) : bool { |
55 | 59 | |
56 | - if (false === ($prototype = $this->getPrototype($name))) return false; |
|
60 | + if (false === ($prototype = $this->getPrototype($name))) { |
|
61 | + return false; |
|
62 | + } |
|
57 | 63 | |
58 | 64 | # Check type |
59 | 65 | |
60 | 66 | $type = Explorer::getType($prototype['path_full']); |
61 | 67 | |
62 | - if (!in_array($type, ['dir', 'file'], true)) return false; |
|
68 | + if (!in_array($type, ['dir', 'file'], true)) { |
|
69 | + return false; |
|
70 | + } |
|
63 | 71 | |
64 | 72 | # Set data |
65 | 73 | |
66 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
74 | + foreach ($prototype as $var => $value) { |
|
75 | + $this->$var = $value; |
|
76 | + } |
|
67 | 77 | |
68 | 78 | $this->type = $type; |
69 | 79 | |
@@ -81,9 +91,13 @@ discard block |
||
81 | 91 | |
82 | 92 | public function check(string $name) : bool { |
83 | 93 | |
84 | - if (false === ($prototype = $this->getPrototype($name))) return false; |
|
94 | + if (false === ($prototype = $this->getPrototype($name))) { |
|
95 | + return false; |
|
96 | + } |
|
85 | 97 | |
86 | - if (($name !== $this->name) && Explorer::exists($prototype['path_full'])) return false; |
|
98 | + if (($name !== $this->name) && Explorer::exists($prototype['path_full'])) { |
|
99 | + return false; |
|
100 | + } |
|
87 | 101 | |
88 | 102 | # ------------------------ |
89 | 103 | |
@@ -98,19 +112,27 @@ discard block |
||
98 | 112 | |
99 | 113 | public function create(string $name, string $type) : bool { |
100 | 114 | |
101 | - if (('' !== $this->name) || (false === ($prototype = $this->getPrototype($name)))) return false; |
|
115 | + if (('' !== $this->name) || (false === ($prototype = $this->getPrototype($name)))) { |
|
116 | + return false; |
|
117 | + } |
|
102 | 118 | |
103 | - if (!in_array($type, ['dir', 'file'], true)) return false; |
|
119 | + if (!in_array($type, ['dir', 'file'], true)) { |
|
120 | + return false; |
|
121 | + } |
|
104 | 122 | |
105 | 123 | # Create entity |
106 | 124 | |
107 | 125 | $create = (($type === 'dir') ? 'createDir' : 'createFile'); |
108 | 126 | |
109 | - if (!Explorer::$create($prototype['path_full'])) return false; |
|
127 | + if (!Explorer::$create($prototype['path_full'])) { |
|
128 | + return false; |
|
129 | + } |
|
110 | 130 | |
111 | 131 | # Set data |
112 | 132 | |
113 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
133 | + foreach ($prototype as $var => $value) { |
|
134 | + $this->$var = $value; |
|
135 | + } |
|
114 | 136 | |
115 | 137 | $this->type = $type; |
116 | 138 | |
@@ -127,15 +149,21 @@ discard block |
||
127 | 149 | |
128 | 150 | public function rename(string $name) : bool { |
129 | 151 | |
130 | - if (('' === $this->name) || (false === ($prototype = $this->getPrototype($name)))) return false; |
|
152 | + if (('' === $this->name) || (false === ($prototype = $this->getPrototype($name)))) { |
|
153 | + return false; |
|
154 | + } |
|
131 | 155 | |
132 | 156 | # Rename entity |
133 | 157 | |
134 | - if (!Explorer::rename($this->path_full, $prototype['path_full'])) return false; |
|
158 | + if (!Explorer::rename($this->path_full, $prototype['path_full'])) { |
|
159 | + return false; |
|
160 | + } |
|
135 | 161 | |
136 | 162 | # Set data |
137 | 163 | |
138 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
164 | + foreach ($prototype as $var => $value) { |
|
165 | + $this->$var = $value; |
|
166 | + } |
|
139 | 167 | |
140 | 168 | # ------------------------ |
141 | 169 | |
@@ -150,13 +178,17 @@ discard block |
||
150 | 178 | |
151 | 179 | public function remove() : bool { |
152 | 180 | |
153 | - if ('' === $this->name) return false; |
|
181 | + if ('' === $this->name) { |
|
182 | + return false; |
|
183 | + } |
|
154 | 184 | |
155 | 185 | # Remove entity |
156 | 186 | |
157 | 187 | $remove = (($this->type === 'dir') ? 'removeDir' : 'removeFile'); |
158 | 188 | |
159 | - if (!Explorer::$remove($this->path_full, true)) return false; |
|
189 | + if (!Explorer::$remove($this->path_full, true)) { |
|
190 | + return false; |
|
191 | + } |
|
160 | 192 | |
161 | 193 | # Reset data |
162 | 194 | |
@@ -175,7 +207,9 @@ discard block |
||
175 | 207 | |
176 | 208 | public function getExtension() { |
177 | 209 | |
178 | - if ('' === $this->name) return false; |
|
210 | + if ('' === $this->name) { |
|
211 | + return false; |
|
212 | + } |
|
179 | 213 | |
180 | 214 | return strtolower(Explorer::getExtension($this->name, false)); |
181 | 215 | } |
@@ -188,7 +222,9 @@ discard block |
||
188 | 222 | |
189 | 223 | public function getCreated() { |
190 | 224 | |
191 | - if ('' === $this->name) return false; |
|
225 | + if ('' === $this->name) { |
|
226 | + return false; |
|
227 | + } |
|
192 | 228 | |
193 | 229 | return Explorer::getCreated($this->path_full); |
194 | 230 | } |
@@ -201,7 +237,9 @@ discard block |
||
201 | 237 | |
202 | 238 | public function getAccessed() { |
203 | 239 | |
204 | - if ('' === $this->name) return false; |
|
240 | + if ('' === $this->name) { |
|
241 | + return false; |
|
242 | + } |
|
205 | 243 | |
206 | 244 | return Explorer::getAccessed($this->path_full); |
207 | 245 | } |
@@ -214,7 +252,9 @@ discard block |
||
214 | 252 | |
215 | 253 | public function getModified() { |
216 | 254 | |
217 | - if ('' === $this->name) return false; |
|
255 | + if ('' === $this->name) { |
|
256 | + return false; |
|
257 | + } |
|
218 | 258 | |
219 | 259 | return Explorer::getModified($this->path_full); |
220 | 260 | } |
@@ -227,7 +267,9 @@ discard block |
||
227 | 267 | |
228 | 268 | public function getPermissions() { |
229 | 269 | |
230 | - if ('' === $this->name) return false; |
|
270 | + if ('' === $this->name) { |
|
271 | + return false; |
|
272 | + } |
|
231 | 273 | |
232 | 274 | return Explorer::getPermissions($this->path_full); |
233 | 275 | } |
@@ -240,7 +282,9 @@ discard block |
||
240 | 282 | |
241 | 283 | public function getSize() { |
242 | 284 | |
243 | - if ('' === $this->name) return false; |
|
285 | + if ('' === $this->name) { |
|
286 | + return false; |
|
287 | + } |
|
244 | 288 | |
245 | 289 | return Explorer::getSize($this->path_full); |
246 | 290 | } |
@@ -253,7 +297,9 @@ discard block |
||
253 | 297 | |
254 | 298 | public function getContents() { |
255 | 299 | |
256 | - if ('' === $this->name) return false; |
|
300 | + if ('' === $this->name) { |
|
301 | + return false; |
|
302 | + } |
|
257 | 303 | |
258 | 304 | return Explorer::getContents($this->path_full); |
259 | 305 | } |
@@ -266,7 +312,9 @@ discard block |
||
266 | 312 | |
267 | 313 | public function putContents(string $contents) { |
268 | 314 | |
269 | - if ('' === $this->name) return false; |
|
315 | + if ('' === $this->name) { |
|
316 | + return false; |
|
317 | + } |
|
270 | 318 | |
271 | 319 | return Explorer::putContents($this->path_full, $contents); |
272 | 320 | } |