Completed
Push — develop ( 8dee05 )
by Dmytro
20:08
created
core/vendor/tracy/tracy/src/Tracy/Helpers.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -60,6 +60,9 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 
63
+	/**
64
+	 * @param string $mask
65
+	 */
63 66
 	public static function formatHtml($mask)
64 67
 	{
65 68
 		$args = func_get_args();
@@ -75,6 +78,9 @@  discard block
 block discarded – undo
75 78
 	}
76 79
 
77 80
 
81
+	/**
82
+	 * @param string $method
83
+	 */
78 84
 	public static function findTrace(array $trace, $method, &$index = null)
79 85
 	{
80 86
 		$m = explode('::', $method);
@@ -277,6 +283,7 @@  discard block
 block discarded – undo
277 283
 
278 284
 	/**
279 285
 	 * Finds the best suggestion.
286
+	 * @param string $value
280 287
 	 * @return string|null
281 288
 	 * @internal
282 289
 	 */
Please login to merge, or discard this patch.
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -14,308 +14,308 @@
 block discarded – undo
14 14
 class Helpers
15 15
 {
16 16
 
17
-	/**
18
-	 * Returns HTML link to editor.
19
-	 * @return string
20
-	 */
21
-	public static function editorLink($file, $line = null)
22
-	{
23
-		$file = strtr($origFile = $file, Debugger::$editorMapping);
24
-		if ($editor = self::editorUri($origFile, $line)) {
25
-			$file = strtr($file, '\\', '/');
26
-			if (preg_match('#(^[a-z]:)?/.{1,50}$#i', $file, $m) && strlen($file) > strlen($m[0])) {
27
-				$file = '...' . $m[0];
28
-			}
29
-			$file = strtr($file, '/', DIRECTORY_SEPARATOR);
30
-			return self::formatHtml('<a href="%" title="%">%<b>%</b>%</a>',
31
-				$editor,
32
-				$file . ($line ? ":$line" : ''),
33
-				rtrim(dirname($file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR,
34
-				basename($file),
35
-				$line ? ":$line" : ''
36
-			);
37
-		} else {
38
-			return self::formatHtml('<span>%</span>', $file . ($line ? ":$line" : ''));
39
-		}
40
-	}
41
-
42
-
43
-	/**
44
-	 * Returns link to editor.
45
-	 * @return string|null
46
-	 */
47
-	public static function editorUri($file, $line = null, $action = 'open', $search = null, $replace = null)
48
-	{
49
-		if (Debugger::$editor && $file && ($action === 'create' || is_file($file))) {
50
-			$file = strtr($file, '/', DIRECTORY_SEPARATOR);
51
-			$file = strtr($file, Debugger::$editorMapping);
52
-			return strtr(Debugger::$editor, [
53
-				'%action' => $action,
54
-				'%file' => rawurlencode($file),
55
-				'%line' => $line ? (int) $line : 1,
56
-				'%search' => rawurlencode($search),
57
-				'%replace' => rawurlencode($replace),
58
-			]);
59
-		}
60
-	}
61
-
62
-
63
-	public static function formatHtml($mask)
64
-	{
65
-		$args = func_get_args();
66
-		return preg_replace_callback('#%#', function () use (&$args, &$count) {
67
-			return self::escapeHtml($args[++$count]);
68
-		}, $mask);
69
-	}
70
-
71
-
72
-	public static function escapeHtml($s)
73
-	{
74
-		return htmlspecialchars((string) $s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
75
-	}
76
-
77
-
78
-	public static function findTrace(array $trace, $method, &$index = null)
79
-	{
80
-		$m = explode('::', $method);
81
-		foreach ($trace as $i => $item) {
82
-			if (
83
-				isset($item['function'])
84
-				&& $item['function'] === end($m)
85
-				&& isset($item['class']) === isset($m[1])
86
-				&& (!isset($item['class']) || $m[0] === '*' || is_a($item['class'], $m[0], true))
87
-			) {
88
-				$index = $i;
89
-				return $item;
90
-			}
91
-		}
92
-	}
93
-
94
-
95
-	/**
96
-	 * @return string
97
-	 */
98
-	public static function getClass($obj)
99
-	{
100
-		return explode("\x00", get_class($obj))[0];
101
-	}
102
-
103
-
104
-	/** @internal */
105
-	public static function fixStack($exception)
106
-	{
107
-		if (function_exists('xdebug_get_function_stack')) {
108
-			$stack = [];
109
-			foreach (array_slice(array_reverse(xdebug_get_function_stack()), 2, -1) as $row) {
110
-				$frame = [
111
-					'file' => $row['file'],
112
-					'line' => $row['line'],
113
-					'function' => isset($row['function']) ? $row['function'] : '*unknown*',
114
-					'args' => [],
115
-				];
116
-				if (!empty($row['class'])) {
117
-					$frame['type'] = isset($row['type']) && $row['type'] === 'dynamic' ? '->' : '::';
118
-					$frame['class'] = $row['class'];
119
-				}
120
-				$stack[] = $frame;
121
-			}
122
-			$ref = new \ReflectionProperty('Exception', 'trace');
123
-			$ref->setAccessible(true);
124
-			$ref->setValue($exception, $stack);
125
-		}
126
-		return $exception;
127
-	}
128
-
129
-
130
-	/** @internal */
131
-	public static function fixEncoding($s)
132
-	{
133
-		return htmlspecialchars_decode(htmlspecialchars($s, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8'), ENT_NOQUOTES);
134
-	}
135
-
136
-
137
-	/** @internal */
138
-	public static function errorTypeToString($type)
139
-	{
140
-		$types = [
141
-			E_ERROR => 'Fatal Error',
142
-			E_USER_ERROR => 'User Error',
143
-			E_RECOVERABLE_ERROR => 'Recoverable Error',
144
-			E_CORE_ERROR => 'Core Error',
145
-			E_COMPILE_ERROR => 'Compile Error',
146
-			E_PARSE => 'Parse Error',
147
-			E_WARNING => 'Warning',
148
-			E_CORE_WARNING => 'Core Warning',
149
-			E_COMPILE_WARNING => 'Compile Warning',
150
-			E_USER_WARNING => 'User Warning',
151
-			E_NOTICE => 'Notice',
152
-			E_USER_NOTICE => 'User Notice',
153
-			E_STRICT => 'Strict standards',
154
-			E_DEPRECATED => 'Deprecated',
155
-			E_USER_DEPRECATED => 'User Deprecated',
156
-		];
157
-		return isset($types[$type]) ? $types[$type] : 'Unknown error';
158
-	}
159
-
160
-
161
-	/** @internal */
162
-	public static function getSource()
163
-	{
164
-		if (isset($_SERVER['REQUEST_URI'])) {
165
-			return (!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://')
166
-				. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '')
167
-				. $_SERVER['REQUEST_URI'];
168
-		} else {
169
-			return 'CLI (PID: ' . getmypid() . ')'
170
-				. (empty($_SERVER['argv']) ? '' : ': ' . implode(' ', $_SERVER['argv']));
171
-		}
172
-	}
173
-
174
-
175
-	/** @internal */
176
-	public static function improveException($e)
177
-	{
178
-		$message = $e->getMessage();
179
-
180
-		if ($e instanceof \Nette\MemberAccessException && ($trace = $e->getTrace()) && isset($trace[1]['file'], $trace[1]['line'])) {
181
-			if (preg_match('# property ([\w\\\\]+)::\$(\w+), did you mean \$(\w+)#', $message, $m)) {
182
-				$replace = ["->$m[2]", "->$m[3]"];
183
-			} elseif (preg_match('# method ([\w\\\\]+)::(\w+)\(\), did you mean (\w+)\(#', $message, $m)) {
184
-				$replace = ["$m[2](", "$m[3]("];
185
-			} else {
186
-				return;
187
-			}
188
-			$e->tracyAction = [
189
-				'link' => self::editorUri($trace[1]['file'], $trace[1]['line'], 'fix', $replace[0], $replace[1]),
190
-				'label' => 'fix it',
191
-			];
192
-
193
-		} elseif (!$e instanceof \Error && !$e instanceof \ErrorException) {
194
-			// do nothing
195
-		} elseif (preg_match('#^Call to undefined function (\S+\\\\)?(\w+)\(#', $message, $m)) {
196
-			$funcs = array_merge(get_defined_functions()['internal'], get_defined_functions()['user']);
197
-			$hint = self::getSuggestion($funcs, $m[1] . $m[2]) ?: self::getSuggestion($funcs, $m[2]);
198
-			$message = "Call to undefined function $m[2](), did you mean $hint()?";
199
-			$replace = ["$m[2](", "$hint("];
200
-
201
-		} elseif (preg_match('#^Call to undefined method ([\w\\\\]+)::(\w+)#', $message, $m)) {
202
-			$hint = self::getSuggestion(get_class_methods($m[1]), $m[2]);
203
-			$message .= ", did you mean $hint()?";
204
-			$replace = ["$m[2](", "$hint("];
205
-
206
-		} elseif (preg_match('#^Undefined variable: (\w+)#', $message, $m) && !empty($e->context)) {
207
-			$hint = self::getSuggestion(array_keys($e->context), $m[1]);
208
-			$message = "Undefined variable $$m[1], did you mean $$hint?";
209
-			$replace = ["$$m[1]", "$$hint"];
210
-
211
-		} elseif (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
212
-			$rc = new \ReflectionClass($m[1]);
213
-			$items = array_diff($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC));
214
-			$hint = self::getSuggestion($items, $m[2]);
215
-			$message .= ", did you mean $$hint?";
216
-			$replace = ["->$m[2]", "->$hint"];
217
-
218
-		} elseif (preg_match('#^Access to undeclared static property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
219
-			$rc = new \ReflectionClass($m[1]);
220
-			$items = array_intersect($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC));
221
-			$hint = self::getSuggestion($items, $m[2]);
222
-			$message .= ", did you mean $$hint?";
223
-			$replace = ["::$$m[2]", "::$$hint"];
224
-		}
225
-
226
-		if (isset($hint)) {
227
-			$ref = new \ReflectionProperty($e, 'message');
228
-			$ref->setAccessible(true);
229
-			$ref->setValue($e, $message);
230
-			$e->tracyAction = [
231
-				'link' => self::editorUri($e->getFile(), $e->getLine(), 'fix', $replace[0], $replace[1]),
232
-				'label' => 'fix it',
233
-			];
234
-		}
235
-	}
236
-
237
-
238
-	/** @internal */
239
-	public static function improveError($message, array $context = [])
240
-	{
241
-		if (preg_match('#^Undefined variable: (\w+)#', $message, $m) && $context) {
242
-			$hint = self::getSuggestion(array_keys($context), $m[1]);
243
-			return $hint ? "Undefined variable $$m[1], did you mean $$hint?" : $message;
244
-
245
-		} elseif (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
246
-			$rc = new \ReflectionClass($m[1]);
247
-			$items = array_diff($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC));
248
-			$hint = self::getSuggestion($items, $m[2]);
249
-			return $hint ? $message . ", did you mean $$hint?" : $message;
250
-		}
251
-		return $message;
252
-	}
253
-
254
-
255
-	/** @internal */
256
-	public static function guessClassFile($class)
257
-	{
258
-		$segments = explode(DIRECTORY_SEPARATOR, $class);
259
-		$res = null;
260
-		$max = 0;
261
-		foreach (get_declared_classes() as $class) {
262
-			$parts = explode(DIRECTORY_SEPARATOR, $class);
263
-			foreach ($parts as $i => $part) {
264
-				if (!isset($segments[$i]) || $part !== $segments[$i]) {
265
-					break;
266
-				}
267
-			}
268
-			if ($i > $max && ($file = (new \ReflectionClass($class))->getFileName())) {
269
-				$max = $i;
270
-				$res = array_merge(array_slice(explode(DIRECTORY_SEPARATOR, $file), 0, $i - count($parts)), array_slice($segments, $i));
271
-				$res = implode(DIRECTORY_SEPARATOR, $res) . '.php';
272
-			}
273
-		}
274
-		return $res;
275
-	}
276
-
277
-
278
-	/**
279
-	 * Finds the best suggestion.
280
-	 * @return string|null
281
-	 * @internal
282
-	 */
283
-	public static function getSuggestion(array $items, $value)
284
-	{
285
-		$best = null;
286
-		$min = (strlen($value) / 4 + 1) * 10 + .1;
287
-		foreach (array_unique($items, SORT_REGULAR) as $item) {
288
-			$item = is_object($item) ? $item->getName() : $item;
289
-			if (($len = levenshtein($item, $value, 10, 11, 10)) > 0 && $len < $min) {
290
-				$min = $len;
291
-				$best = $item;
292
-			}
293
-		}
294
-		return $best;
295
-	}
296
-
297
-
298
-	/** @internal */
299
-	public static function isHtmlMode()
300
-	{
301
-		return empty($_SERVER['HTTP_X_REQUESTED_WITH']) && empty($_SERVER['HTTP_X_TRACY_AJAX'])
302
-			&& PHP_SAPI !== 'cli'
303
-			&& !preg_match('#^Content-Type: (?!text/html)#im', implode("\n", headers_list()));
304
-	}
305
-
306
-
307
-	/** @internal */
308
-	public static function isAjax()
309
-	{
310
-		return isset($_SERVER['HTTP_X_TRACY_AJAX']) && preg_match('#^\w{10}\z#', $_SERVER['HTTP_X_TRACY_AJAX']);
311
-	}
312
-
313
-
314
-	/** @internal */
315
-	public static function getNonce()
316
-	{
317
-		return preg_match('#^Content-Security-Policy(?:-Report-Only)?:.*\sscript-src\s+(?:[^;]+\s)?\'nonce-([\w+/]+=*)\'#mi', implode("\n", headers_list()), $m)
318
-			? $m[1]
319
-			: null;
320
-	}
17
+    /**
18
+     * Returns HTML link to editor.
19
+     * @return string
20
+     */
21
+    public static function editorLink($file, $line = null)
22
+    {
23
+        $file = strtr($origFile = $file, Debugger::$editorMapping);
24
+        if ($editor = self::editorUri($origFile, $line)) {
25
+            $file = strtr($file, '\\', '/');
26
+            if (preg_match('#(^[a-z]:)?/.{1,50}$#i', $file, $m) && strlen($file) > strlen($m[0])) {
27
+                $file = '...' . $m[0];
28
+            }
29
+            $file = strtr($file, '/', DIRECTORY_SEPARATOR);
30
+            return self::formatHtml('<a href="%" title="%">%<b>%</b>%</a>',
31
+                $editor,
32
+                $file . ($line ? ":$line" : ''),
33
+                rtrim(dirname($file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR,
34
+                basename($file),
35
+                $line ? ":$line" : ''
36
+            );
37
+        } else {
38
+            return self::formatHtml('<span>%</span>', $file . ($line ? ":$line" : ''));
39
+        }
40
+    }
41
+
42
+
43
+    /**
44
+     * Returns link to editor.
45
+     * @return string|null
46
+     */
47
+    public static function editorUri($file, $line = null, $action = 'open', $search = null, $replace = null)
48
+    {
49
+        if (Debugger::$editor && $file && ($action === 'create' || is_file($file))) {
50
+            $file = strtr($file, '/', DIRECTORY_SEPARATOR);
51
+            $file = strtr($file, Debugger::$editorMapping);
52
+            return strtr(Debugger::$editor, [
53
+                '%action' => $action,
54
+                '%file' => rawurlencode($file),
55
+                '%line' => $line ? (int) $line : 1,
56
+                '%search' => rawurlencode($search),
57
+                '%replace' => rawurlencode($replace),
58
+            ]);
59
+        }
60
+    }
61
+
62
+
63
+    public static function formatHtml($mask)
64
+    {
65
+        $args = func_get_args();
66
+        return preg_replace_callback('#%#', function () use (&$args, &$count) {
67
+            return self::escapeHtml($args[++$count]);
68
+        }, $mask);
69
+    }
70
+
71
+
72
+    public static function escapeHtml($s)
73
+    {
74
+        return htmlspecialchars((string) $s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
75
+    }
76
+
77
+
78
+    public static function findTrace(array $trace, $method, &$index = null)
79
+    {
80
+        $m = explode('::', $method);
81
+        foreach ($trace as $i => $item) {
82
+            if (
83
+                isset($item['function'])
84
+                && $item['function'] === end($m)
85
+                && isset($item['class']) === isset($m[1])
86
+                && (!isset($item['class']) || $m[0] === '*' || is_a($item['class'], $m[0], true))
87
+            ) {
88
+                $index = $i;
89
+                return $item;
90
+            }
91
+        }
92
+    }
93
+
94
+
95
+    /**
96
+     * @return string
97
+     */
98
+    public static function getClass($obj)
99
+    {
100
+        return explode("\x00", get_class($obj))[0];
101
+    }
102
+
103
+
104
+    /** @internal */
105
+    public static function fixStack($exception)
106
+    {
107
+        if (function_exists('xdebug_get_function_stack')) {
108
+            $stack = [];
109
+            foreach (array_slice(array_reverse(xdebug_get_function_stack()), 2, -1) as $row) {
110
+                $frame = [
111
+                    'file' => $row['file'],
112
+                    'line' => $row['line'],
113
+                    'function' => isset($row['function']) ? $row['function'] : '*unknown*',
114
+                    'args' => [],
115
+                ];
116
+                if (!empty($row['class'])) {
117
+                    $frame['type'] = isset($row['type']) && $row['type'] === 'dynamic' ? '->' : '::';
118
+                    $frame['class'] = $row['class'];
119
+                }
120
+                $stack[] = $frame;
121
+            }
122
+            $ref = new \ReflectionProperty('Exception', 'trace');
123
+            $ref->setAccessible(true);
124
+            $ref->setValue($exception, $stack);
125
+        }
126
+        return $exception;
127
+    }
128
+
129
+
130
+    /** @internal */
131
+    public static function fixEncoding($s)
132
+    {
133
+        return htmlspecialchars_decode(htmlspecialchars($s, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8'), ENT_NOQUOTES);
134
+    }
135
+
136
+
137
+    /** @internal */
138
+    public static function errorTypeToString($type)
139
+    {
140
+        $types = [
141
+            E_ERROR => 'Fatal Error',
142
+            E_USER_ERROR => 'User Error',
143
+            E_RECOVERABLE_ERROR => 'Recoverable Error',
144
+            E_CORE_ERROR => 'Core Error',
145
+            E_COMPILE_ERROR => 'Compile Error',
146
+            E_PARSE => 'Parse Error',
147
+            E_WARNING => 'Warning',
148
+            E_CORE_WARNING => 'Core Warning',
149
+            E_COMPILE_WARNING => 'Compile Warning',
150
+            E_USER_WARNING => 'User Warning',
151
+            E_NOTICE => 'Notice',
152
+            E_USER_NOTICE => 'User Notice',
153
+            E_STRICT => 'Strict standards',
154
+            E_DEPRECATED => 'Deprecated',
155
+            E_USER_DEPRECATED => 'User Deprecated',
156
+        ];
157
+        return isset($types[$type]) ? $types[$type] : 'Unknown error';
158
+    }
159
+
160
+
161
+    /** @internal */
162
+    public static function getSource()
163
+    {
164
+        if (isset($_SERVER['REQUEST_URI'])) {
165
+            return (!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://')
166
+                . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '')
167
+                . $_SERVER['REQUEST_URI'];
168
+        } else {
169
+            return 'CLI (PID: ' . getmypid() . ')'
170
+                . (empty($_SERVER['argv']) ? '' : ': ' . implode(' ', $_SERVER['argv']));
171
+        }
172
+    }
173
+
174
+
175
+    /** @internal */
176
+    public static function improveException($e)
177
+    {
178
+        $message = $e->getMessage();
179
+
180
+        if ($e instanceof \Nette\MemberAccessException && ($trace = $e->getTrace()) && isset($trace[1]['file'], $trace[1]['line'])) {
181
+            if (preg_match('# property ([\w\\\\]+)::\$(\w+), did you mean \$(\w+)#', $message, $m)) {
182
+                $replace = ["->$m[2]", "->$m[3]"];
183
+            } elseif (preg_match('# method ([\w\\\\]+)::(\w+)\(\), did you mean (\w+)\(#', $message, $m)) {
184
+                $replace = ["$m[2](", "$m[3]("];
185
+            } else {
186
+                return;
187
+            }
188
+            $e->tracyAction = [
189
+                'link' => self::editorUri($trace[1]['file'], $trace[1]['line'], 'fix', $replace[0], $replace[1]),
190
+                'label' => 'fix it',
191
+            ];
192
+
193
+        } elseif (!$e instanceof \Error && !$e instanceof \ErrorException) {
194
+            // do nothing
195
+        } elseif (preg_match('#^Call to undefined function (\S+\\\\)?(\w+)\(#', $message, $m)) {
196
+            $funcs = array_merge(get_defined_functions()['internal'], get_defined_functions()['user']);
197
+            $hint = self::getSuggestion($funcs, $m[1] . $m[2]) ?: self::getSuggestion($funcs, $m[2]);
198
+            $message = "Call to undefined function $m[2](), did you mean $hint()?";
199
+            $replace = ["$m[2](", "$hint("];
200
+
201
+        } elseif (preg_match('#^Call to undefined method ([\w\\\\]+)::(\w+)#', $message, $m)) {
202
+            $hint = self::getSuggestion(get_class_methods($m[1]), $m[2]);
203
+            $message .= ", did you mean $hint()?";
204
+            $replace = ["$m[2](", "$hint("];
205
+
206
+        } elseif (preg_match('#^Undefined variable: (\w+)#', $message, $m) && !empty($e->context)) {
207
+            $hint = self::getSuggestion(array_keys($e->context), $m[1]);
208
+            $message = "Undefined variable $$m[1], did you mean $$hint?";
209
+            $replace = ["$$m[1]", "$$hint"];
210
+
211
+        } elseif (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
212
+            $rc = new \ReflectionClass($m[1]);
213
+            $items = array_diff($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC));
214
+            $hint = self::getSuggestion($items, $m[2]);
215
+            $message .= ", did you mean $$hint?";
216
+            $replace = ["->$m[2]", "->$hint"];
217
+
218
+        } elseif (preg_match('#^Access to undeclared static property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
219
+            $rc = new \ReflectionClass($m[1]);
220
+            $items = array_intersect($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC));
221
+            $hint = self::getSuggestion($items, $m[2]);
222
+            $message .= ", did you mean $$hint?";
223
+            $replace = ["::$$m[2]", "::$$hint"];
224
+        }
225
+
226
+        if (isset($hint)) {
227
+            $ref = new \ReflectionProperty($e, 'message');
228
+            $ref->setAccessible(true);
229
+            $ref->setValue($e, $message);
230
+            $e->tracyAction = [
231
+                'link' => self::editorUri($e->getFile(), $e->getLine(), 'fix', $replace[0], $replace[1]),
232
+                'label' => 'fix it',
233
+            ];
234
+        }
235
+    }
236
+
237
+
238
+    /** @internal */
239
+    public static function improveError($message, array $context = [])
240
+    {
241
+        if (preg_match('#^Undefined variable: (\w+)#', $message, $m) && $context) {
242
+            $hint = self::getSuggestion(array_keys($context), $m[1]);
243
+            return $hint ? "Undefined variable $$m[1], did you mean $$hint?" : $message;
244
+
245
+        } elseif (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
246
+            $rc = new \ReflectionClass($m[1]);
247
+            $items = array_diff($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC));
248
+            $hint = self::getSuggestion($items, $m[2]);
249
+            return $hint ? $message . ", did you mean $$hint?" : $message;
250
+        }
251
+        return $message;
252
+    }
253
+
254
+
255
+    /** @internal */
256
+    public static function guessClassFile($class)
257
+    {
258
+        $segments = explode(DIRECTORY_SEPARATOR, $class);
259
+        $res = null;
260
+        $max = 0;
261
+        foreach (get_declared_classes() as $class) {
262
+            $parts = explode(DIRECTORY_SEPARATOR, $class);
263
+            foreach ($parts as $i => $part) {
264
+                if (!isset($segments[$i]) || $part !== $segments[$i]) {
265
+                    break;
266
+                }
267
+            }
268
+            if ($i > $max && ($file = (new \ReflectionClass($class))->getFileName())) {
269
+                $max = $i;
270
+                $res = array_merge(array_slice(explode(DIRECTORY_SEPARATOR, $file), 0, $i - count($parts)), array_slice($segments, $i));
271
+                $res = implode(DIRECTORY_SEPARATOR, $res) . '.php';
272
+            }
273
+        }
274
+        return $res;
275
+    }
276
+
277
+
278
+    /**
279
+     * Finds the best suggestion.
280
+     * @return string|null
281
+     * @internal
282
+     */
283
+    public static function getSuggestion(array $items, $value)
284
+    {
285
+        $best = null;
286
+        $min = (strlen($value) / 4 + 1) * 10 + .1;
287
+        foreach (array_unique($items, SORT_REGULAR) as $item) {
288
+            $item = is_object($item) ? $item->getName() : $item;
289
+            if (($len = levenshtein($item, $value, 10, 11, 10)) > 0 && $len < $min) {
290
+                $min = $len;
291
+                $best = $item;
292
+            }
293
+        }
294
+        return $best;
295
+    }
296
+
297
+
298
+    /** @internal */
299
+    public static function isHtmlMode()
300
+    {
301
+        return empty($_SERVER['HTTP_X_REQUESTED_WITH']) && empty($_SERVER['HTTP_X_TRACY_AJAX'])
302
+            && PHP_SAPI !== 'cli'
303
+            && !preg_match('#^Content-Type: (?!text/html)#im', implode("\n", headers_list()));
304
+    }
305
+
306
+
307
+    /** @internal */
308
+    public static function isAjax()
309
+    {
310
+        return isset($_SERVER['HTTP_X_TRACY_AJAX']) && preg_match('#^\w{10}\z#', $_SERVER['HTTP_X_TRACY_AJAX']);
311
+    }
312
+
313
+
314
+    /** @internal */
315
+    public static function getNonce()
316
+    {
317
+        return preg_match('#^Content-Security-Policy(?:-Report-Only)?:.*\sscript-src\s+(?:[^;]+\s)?\'nonce-([\w+/]+=*)\'#mi', implode("\n", headers_list()), $m)
318
+            ? $m[1]
319
+            : null;
320
+    }
321 321
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
24 24
 		if ($editor = self::editorUri($origFile, $line)) {
25 25
 			$file = strtr($file, '\\', '/');
26 26
 			if (preg_match('#(^[a-z]:)?/.{1,50}$#i', $file, $m) && strlen($file) > strlen($m[0])) {
27
-				$file = '...' . $m[0];
27
+				$file = '...'.$m[0];
28 28
 			}
29 29
 			$file = strtr($file, '/', DIRECTORY_SEPARATOR);
30 30
 			return self::formatHtml('<a href="%" title="%">%<b>%</b>%</a>',
31 31
 				$editor,
32
-				$file . ($line ? ":$line" : ''),
33
-				rtrim(dirname($file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR,
32
+				$file.($line ? ":$line" : ''),
33
+				rtrim(dirname($file), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR,
34 34
 				basename($file),
35 35
 				$line ? ":$line" : ''
36 36
 			);
37 37
 		} else {
38
-			return self::formatHtml('<span>%</span>', $file . ($line ? ":$line" : ''));
38
+			return self::formatHtml('<span>%</span>', $file.($line ? ":$line" : ''));
39 39
 		}
40 40
 	}
41 41
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	public static function formatHtml($mask)
64 64
 	{
65 65
 		$args = func_get_args();
66
-		return preg_replace_callback('#%#', function () use (&$args, &$count) {
66
+		return preg_replace_callback('#%#', function() use (&$args, &$count) {
67 67
 			return self::escapeHtml($args[++$count]);
68 68
 		}, $mask);
69 69
 	}
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 				. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '')
167 167
 				. $_SERVER['REQUEST_URI'];
168 168
 		} else {
169
-			return 'CLI (PID: ' . getmypid() . ')'
170
-				. (empty($_SERVER['argv']) ? '' : ': ' . implode(' ', $_SERVER['argv']));
169
+			return 'CLI (PID: '.getmypid().')'
170
+				. (empty($_SERVER['argv']) ? '' : ': '.implode(' ', $_SERVER['argv']));
171 171
 		}
172 172
 	}
173 173
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 			// do nothing
195 195
 		} elseif (preg_match('#^Call to undefined function (\S+\\\\)?(\w+)\(#', $message, $m)) {
196 196
 			$funcs = array_merge(get_defined_functions()['internal'], get_defined_functions()['user']);
197
-			$hint = self::getSuggestion($funcs, $m[1] . $m[2]) ?: self::getSuggestion($funcs, $m[2]);
197
+			$hint = self::getSuggestion($funcs, $m[1].$m[2]) ?: self::getSuggestion($funcs, $m[2]);
198 198
 			$message = "Call to undefined function $m[2](), did you mean $hint()?";
199 199
 			$replace = ["$m[2](", "$hint("];
200 200
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			$rc = new \ReflectionClass($m[1]);
247 247
 			$items = array_diff($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC));
248 248
 			$hint = self::getSuggestion($items, $m[2]);
249
-			return $hint ? $message . ", did you mean $$hint?" : $message;
249
+			return $hint ? $message.", did you mean $$hint?" : $message;
250 250
 		}
251 251
 		return $message;
252 252
 	}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			if ($i > $max && ($file = (new \ReflectionClass($class))->getFileName())) {
269 269
 				$max = $i;
270 270
 				$res = array_merge(array_slice(explode(DIRECTORY_SEPARATOR, $file), 0, $i - count($parts)), array_slice($segments, $i));
271
-				$res = implode(DIRECTORY_SEPARATOR, $res) . '.php';
271
+				$res = implode(DIRECTORY_SEPARATOR, $res).'.php';
272 272
 			}
273 273
 		}
274 274
 		return $res;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
 	public static function formatHtml($mask)
64 64
 	{
65 65
 		$args = func_get_args();
66
-		return preg_replace_callback('#%#', function () use (&$args, &$count) {
66
+		return preg_replace_callback('#%#', function () use (&$args, &$count){
67 67
 			return self::escapeHtml($args[++$count]);
68 68
 		}, $mask);
69 69
 	}
Please login to merge, or discard this patch.
core/vendor/tracy/tracy/src/Tracy/Logger.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -107,6 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 	/**
109 109
 	 * @param  mixed  $message
110
+	 * @param string $exceptionFile
110 111
 	 * @return string
111 112
 	 */
112 113
 	public static function formatLogLine($message, $exceptionFile = null)
@@ -147,6 +148,7 @@  discard block
 block discarded – undo
147 148
 	/**
148 149
 	 * Logs exception to the file if file doesn't exist.
149 150
 	 * @param  \Exception|\Throwable  $exception
151
+	 * @param string $file
150 152
 	 * @return string logged error filename
151 153
 	 */
152 154
 	protected function logException($exception, $file = null)
Please login to merge, or discard this patch.
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -13,197 +13,197 @@
 block discarded – undo
13 13
  */
14 14
 class Logger implements ILogger
15 15
 {
16
-	/** @var string|null name of the directory where errors should be logged */
17
-	public $directory;
18
-
19
-	/** @var string|array|null email or emails to which send error notifications */
20
-	public $email;
21
-
22
-	/** @var string|null sender of email notifications */
23
-	public $fromEmail;
24
-
25
-	/** @var mixed interval for sending email is 2 days */
26
-	public $emailSnooze = '2 days';
27
-
28
-	/** @var callable handler for sending emails */
29
-	public $mailer;
30
-
31
-	/** @var BlueScreen|null */
32
-	private $blueScreen;
33
-
34
-
35
-	/**
36
-	 * @param  string|null  $directory
37
-	 * @param  string|array|null  $email
38
-	 */
39
-	public function __construct($directory, $email = null, BlueScreen $blueScreen = null)
40
-	{
41
-		$this->directory = $directory;
42
-		$this->email = $email;
43
-		$this->blueScreen = $blueScreen;
44
-		$this->mailer = [$this, 'defaultMailer'];
45
-	}
46
-
47
-
48
-	/**
49
-	 * Logs message or exception to file and sends email notification.
50
-	 * @param  mixed  $message
51
-	 * @param  string  $priority  one of constant ILogger::INFO, WARNING, ERROR (sends email), EXCEPTION (sends email), CRITICAL (sends email)
52
-	 * @return string|null logged error filename
53
-	 */
54
-	public function log($message, $priority = self::INFO)
55
-	{
56
-		if (!$this->directory) {
57
-			throw new \LogicException('Logging directory is not specified.');
58
-		} elseif (!is_dir($this->directory)) {
59
-			throw new \RuntimeException("Logging directory '$this->directory' is not found or is not directory.");
60
-		}
61
-
62
-		$exceptionFile = $message instanceof \Exception || $message instanceof \Throwable
63
-			? $this->getExceptionFile($message)
64
-			: null;
65
-		$line = static::formatLogLine($message, $exceptionFile);
66
-		$file = $this->directory . '/' . strtolower($priority ?: self::INFO) . '.log';
67
-
68
-		if (!@file_put_contents($file, $line . PHP_EOL, FILE_APPEND | LOCK_EX)) { // @ is escalated to exception
69
-			throw new \RuntimeException("Unable to write to log file '$file'. Is directory writable?");
70
-		}
71
-
72
-		if ($exceptionFile) {
73
-			$this->logException($message, $exceptionFile);
74
-		}
75
-
76
-		if (in_array($priority, [self::ERROR, self::EXCEPTION, self::CRITICAL], true)) {
77
-			$this->sendEmail($message);
78
-		}
79
-
80
-		return $exceptionFile;
81
-	}
82
-
83
-
84
-	/**
85
-	 * @param  mixed  $message
86
-	 * @return string
87
-	 */
88
-	public static function formatMessage($message)
89
-	{
90
-		if ($message instanceof \Exception || $message instanceof \Throwable) {
91
-			while ($message) {
92
-				$tmp[] = ($message instanceof \ErrorException
93
-					? Helpers::errorTypeToString($message->getSeverity()) . ': ' . $message->getMessage()
94
-					: Helpers::getClass($message) . ': ' . $message->getMessage() . ($message->getCode() ? ' #' . $message->getCode() : '')
95
-				) . ' in ' . $message->getFile() . ':' . $message->getLine();
96
-				$message = $message->getPrevious();
97
-			}
98
-			$message = implode("\ncaused by ", $tmp);
99
-
100
-		} elseif (!is_string($message)) {
101
-			$message = Dumper::toText($message);
102
-		}
103
-
104
-		return trim($message);
105
-	}
106
-
107
-
108
-	/**
109
-	 * @param  mixed  $message
110
-	 * @return string
111
-	 */
112
-	public static function formatLogLine($message, $exceptionFile = null)
113
-	{
114
-		return implode(' ', [
115
-			@date('[Y-m-d H-i-s]'), // @ timezone may not be set
116
-			preg_replace('#\s*\r?\n\s*#', ' ', static::formatMessage($message)),
117
-			' @  ' . Helpers::getSource(),
118
-			$exceptionFile ? ' @@  ' . basename($exceptionFile) : null,
119
-		]);
120
-	}
121
-
122
-
123
-	/**
124
-	 * @param  \Exception|\Throwable  $exception
125
-	 * @return string
126
-	 */
127
-	public function getExceptionFile($exception)
128
-	{
129
-		while ($exception) {
130
-			$data[] = [
131
-				get_class($exception), $exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine(),
132
-				array_map(function ($item) { unset($item['args']); return $item; }, $exception->getTrace()),
133
-			];
134
-			$exception = $exception->getPrevious();
135
-		}
136
-		$hash = substr(md5(serialize($data)), 0, 10);
137
-		$dir = strtr($this->directory . '/', '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
138
-		foreach (new \DirectoryIterator($this->directory) as $file) {
139
-			if (strpos($file->getBasename(), $hash)) {
140
-				return $dir . $file;
141
-			}
142
-		}
143
-		return $dir . 'exception--' . @date('Y-m-d--H-i') . "--$hash.html"; // @ timezone may not be set
144
-	}
145
-
146
-
147
-	/**
148
-	 * Logs exception to the file if file doesn't exist.
149
-	 * @param  \Exception|\Throwable  $exception
150
-	 * @return string logged error filename
151
-	 */
152
-	protected function logException($exception, $file = null)
153
-	{
154
-		$file = $file ?: $this->getExceptionFile($exception);
155
-		$bs = $this->blueScreen ?: new BlueScreen;
156
-		$bs->renderToFile($exception, $file);
157
-		return $file;
158
-	}
159
-
160
-
161
-	/**
162
-	 * @param  mixed  $message
163
-	 * @return void
164
-	 */
165
-	protected function sendEmail($message)
166
-	{
167
-		$snooze = is_numeric($this->emailSnooze)
168
-			? $this->emailSnooze
169
-			: @strtotime($this->emailSnooze) - time(); // @ timezone may not be set
170
-
171
-		if (
172
-			$this->email
173
-			&& $this->mailer
174
-			&& @filemtime($this->directory . '/email-sent') + $snooze < time() // @ file may not exist
175
-			&& @file_put_contents($this->directory . '/email-sent', 'sent') // @ file may not be writable
176
-		) {
177
-			call_user_func($this->mailer, $message, implode(', ', (array) $this->email));
178
-		}
179
-	}
180
-
181
-
182
-	/**
183
-	 * Default mailer.
184
-	 * @param  mixed  $message
185
-	 * @param  string  $email
186
-	 * @return void
187
-	 * @internal
188
-	 */
189
-	public function defaultMailer($message, $email)
190
-	{
191
-		$host = preg_replace('#[^\w.-]+#', '', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n'));
192
-		$parts = str_replace(
193
-			["\r\n", "\n"],
194
-			["\n", PHP_EOL],
195
-			[
196
-				'headers' => implode("\n", [
197
-					'From: ' . ($this->fromEmail ?: "noreply@$host"),
198
-					'X-Mailer: Tracy',
199
-					'Content-Type: text/plain; charset=UTF-8',
200
-					'Content-Transfer-Encoding: 8bit',
201
-				]) . "\n",
202
-				'subject' => "PHP: An error occurred on the server $host",
203
-				'body' => static::formatMessage($message) . "\n\nsource: " . Helpers::getSource(),
204
-			]
205
-		);
206
-
207
-		mail($email, $parts['subject'], $parts['body'], $parts['headers']);
208
-	}
16
+    /** @var string|null name of the directory where errors should be logged */
17
+    public $directory;
18
+
19
+    /** @var string|array|null email or emails to which send error notifications */
20
+    public $email;
21
+
22
+    /** @var string|null sender of email notifications */
23
+    public $fromEmail;
24
+
25
+    /** @var mixed interval for sending email is 2 days */
26
+    public $emailSnooze = '2 days';
27
+
28
+    /** @var callable handler for sending emails */
29
+    public $mailer;
30
+
31
+    /** @var BlueScreen|null */
32
+    private $blueScreen;
33
+
34
+
35
+    /**
36
+     * @param  string|null  $directory
37
+     * @param  string|array|null  $email
38
+     */
39
+    public function __construct($directory, $email = null, BlueScreen $blueScreen = null)
40
+    {
41
+        $this->directory = $directory;
42
+        $this->email = $email;
43
+        $this->blueScreen = $blueScreen;
44
+        $this->mailer = [$this, 'defaultMailer'];
45
+    }
46
+
47
+
48
+    /**
49
+     * Logs message or exception to file and sends email notification.
50
+     * @param  mixed  $message
51
+     * @param  string  $priority  one of constant ILogger::INFO, WARNING, ERROR (sends email), EXCEPTION (sends email), CRITICAL (sends email)
52
+     * @return string|null logged error filename
53
+     */
54
+    public function log($message, $priority = self::INFO)
55
+    {
56
+        if (!$this->directory) {
57
+            throw new \LogicException('Logging directory is not specified.');
58
+        } elseif (!is_dir($this->directory)) {
59
+            throw new \RuntimeException("Logging directory '$this->directory' is not found or is not directory.");
60
+        }
61
+
62
+        $exceptionFile = $message instanceof \Exception || $message instanceof \Throwable
63
+            ? $this->getExceptionFile($message)
64
+            : null;
65
+        $line = static::formatLogLine($message, $exceptionFile);
66
+        $file = $this->directory . '/' . strtolower($priority ?: self::INFO) . '.log';
67
+
68
+        if (!@file_put_contents($file, $line . PHP_EOL, FILE_APPEND | LOCK_EX)) { // @ is escalated to exception
69
+            throw new \RuntimeException("Unable to write to log file '$file'. Is directory writable?");
70
+        }
71
+
72
+        if ($exceptionFile) {
73
+            $this->logException($message, $exceptionFile);
74
+        }
75
+
76
+        if (in_array($priority, [self::ERROR, self::EXCEPTION, self::CRITICAL], true)) {
77
+            $this->sendEmail($message);
78
+        }
79
+
80
+        return $exceptionFile;
81
+    }
82
+
83
+
84
+    /**
85
+     * @param  mixed  $message
86
+     * @return string
87
+     */
88
+    public static function formatMessage($message)
89
+    {
90
+        if ($message instanceof \Exception || $message instanceof \Throwable) {
91
+            while ($message) {
92
+                $tmp[] = ($message instanceof \ErrorException
93
+                    ? Helpers::errorTypeToString($message->getSeverity()) . ': ' . $message->getMessage()
94
+                    : Helpers::getClass($message) . ': ' . $message->getMessage() . ($message->getCode() ? ' #' . $message->getCode() : '')
95
+                ) . ' in ' . $message->getFile() . ':' . $message->getLine();
96
+                $message = $message->getPrevious();
97
+            }
98
+            $message = implode("\ncaused by ", $tmp);
99
+
100
+        } elseif (!is_string($message)) {
101
+            $message = Dumper::toText($message);
102
+        }
103
+
104
+        return trim($message);
105
+    }
106
+
107
+
108
+    /**
109
+     * @param  mixed  $message
110
+     * @return string
111
+     */
112
+    public static function formatLogLine($message, $exceptionFile = null)
113
+    {
114
+        return implode(' ', [
115
+            @date('[Y-m-d H-i-s]'), // @ timezone may not be set
116
+            preg_replace('#\s*\r?\n\s*#', ' ', static::formatMessage($message)),
117
+            ' @  ' . Helpers::getSource(),
118
+            $exceptionFile ? ' @@  ' . basename($exceptionFile) : null,
119
+        ]);
120
+    }
121
+
122
+
123
+    /**
124
+     * @param  \Exception|\Throwable  $exception
125
+     * @return string
126
+     */
127
+    public function getExceptionFile($exception)
128
+    {
129
+        while ($exception) {
130
+            $data[] = [
131
+                get_class($exception), $exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine(),
132
+                array_map(function ($item) { unset($item['args']); return $item; }, $exception->getTrace()),
133
+            ];
134
+            $exception = $exception->getPrevious();
135
+        }
136
+        $hash = substr(md5(serialize($data)), 0, 10);
137
+        $dir = strtr($this->directory . '/', '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
138
+        foreach (new \DirectoryIterator($this->directory) as $file) {
139
+            if (strpos($file->getBasename(), $hash)) {
140
+                return $dir . $file;
141
+            }
142
+        }
143
+        return $dir . 'exception--' . @date('Y-m-d--H-i') . "--$hash.html"; // @ timezone may not be set
144
+    }
145
+
146
+
147
+    /**
148
+     * Logs exception to the file if file doesn't exist.
149
+     * @param  \Exception|\Throwable  $exception
150
+     * @return string logged error filename
151
+     */
152
+    protected function logException($exception, $file = null)
153
+    {
154
+        $file = $file ?: $this->getExceptionFile($exception);
155
+        $bs = $this->blueScreen ?: new BlueScreen;
156
+        $bs->renderToFile($exception, $file);
157
+        return $file;
158
+    }
159
+
160
+
161
+    /**
162
+     * @param  mixed  $message
163
+     * @return void
164
+     */
165
+    protected function sendEmail($message)
166
+    {
167
+        $snooze = is_numeric($this->emailSnooze)
168
+            ? $this->emailSnooze
169
+            : @strtotime($this->emailSnooze) - time(); // @ timezone may not be set
170
+
171
+        if (
172
+            $this->email
173
+            && $this->mailer
174
+            && @filemtime($this->directory . '/email-sent') + $snooze < time() // @ file may not exist
175
+            && @file_put_contents($this->directory . '/email-sent', 'sent') // @ file may not be writable
176
+        ) {
177
+            call_user_func($this->mailer, $message, implode(', ', (array) $this->email));
178
+        }
179
+    }
180
+
181
+
182
+    /**
183
+     * Default mailer.
184
+     * @param  mixed  $message
185
+     * @param  string  $email
186
+     * @return void
187
+     * @internal
188
+     */
189
+    public function defaultMailer($message, $email)
190
+    {
191
+        $host = preg_replace('#[^\w.-]+#', '', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n'));
192
+        $parts = str_replace(
193
+            ["\r\n", "\n"],
194
+            ["\n", PHP_EOL],
195
+            [
196
+                'headers' => implode("\n", [
197
+                    'From: ' . ($this->fromEmail ?: "noreply@$host"),
198
+                    'X-Mailer: Tracy',
199
+                    'Content-Type: text/plain; charset=UTF-8',
200
+                    'Content-Transfer-Encoding: 8bit',
201
+                ]) . "\n",
202
+                'subject' => "PHP: An error occurred on the server $host",
203
+                'body' => static::formatMessage($message) . "\n\nsource: " . Helpers::getSource(),
204
+            ]
205
+        );
206
+
207
+        mail($email, $parts['subject'], $parts['body'], $parts['headers']);
208
+    }
209 209
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 			? $this->getExceptionFile($message)
64 64
 			: null;
65 65
 		$line = static::formatLogLine($message, $exceptionFile);
66
-		$file = $this->directory . '/' . strtolower($priority ?: self::INFO) . '.log';
66
+		$file = $this->directory.'/'.strtolower($priority ?: self::INFO).'.log';
67 67
 
68
-		if (!@file_put_contents($file, $line . PHP_EOL, FILE_APPEND | LOCK_EX)) { // @ is escalated to exception
68
+		if (!@file_put_contents($file, $line.PHP_EOL, FILE_APPEND | LOCK_EX)) { // @ is escalated to exception
69 69
 			throw new \RuntimeException("Unable to write to log file '$file'. Is directory writable?");
70 70
 		}
71 71
 
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 		if ($message instanceof \Exception || $message instanceof \Throwable) {
91 91
 			while ($message) {
92 92
 				$tmp[] = ($message instanceof \ErrorException
93
-					? Helpers::errorTypeToString($message->getSeverity()) . ': ' . $message->getMessage()
94
-					: Helpers::getClass($message) . ': ' . $message->getMessage() . ($message->getCode() ? ' #' . $message->getCode() : '')
95
-				) . ' in ' . $message->getFile() . ':' . $message->getLine();
93
+					? Helpers::errorTypeToString($message->getSeverity()).': '.$message->getMessage()
94
+					: Helpers::getClass($message).': '.$message->getMessage().($message->getCode() ? ' #'.$message->getCode() : '')
95
+				).' in '.$message->getFile().':'.$message->getLine();
96 96
 				$message = $message->getPrevious();
97 97
 			}
98 98
 			$message = implode("\ncaused by ", $tmp);
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 		return implode(' ', [
115 115
 			@date('[Y-m-d H-i-s]'), // @ timezone may not be set
116 116
 			preg_replace('#\s*\r?\n\s*#', ' ', static::formatMessage($message)),
117
-			' @  ' . Helpers::getSource(),
118
-			$exceptionFile ? ' @@  ' . basename($exceptionFile) : null,
117
+			' @  '.Helpers::getSource(),
118
+			$exceptionFile ? ' @@  '.basename($exceptionFile) : null,
119 119
 		]);
120 120
 	}
121 121
 
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 		while ($exception) {
130 130
 			$data[] = [
131 131
 				get_class($exception), $exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine(),
132
-				array_map(function ($item) { unset($item['args']); return $item; }, $exception->getTrace()),
132
+				array_map(function($item){ unset($item['args']); return $item; }, $exception->getTrace()),
133 133
 			];
134 134
 			$exception = $exception->getPrevious();
135 135
 		}
136 136
 		$hash = substr(md5(serialize($data)), 0, 10);
137
-		$dir = strtr($this->directory . '/', '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
137
+		$dir = strtr($this->directory.'/', '\\/', DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR);
138 138
 		foreach (new \DirectoryIterator($this->directory) as $file) {
139 139
 			if (strpos($file->getBasename(), $hash)) {
140
-				return $dir . $file;
140
+				return $dir.$file;
141 141
 			}
142 142
 		}
143
-		return $dir . 'exception--' . @date('Y-m-d--H-i') . "--$hash.html"; // @ timezone may not be set
143
+		return $dir.'exception--'.@date('Y-m-d--H-i')."--$hash.html"; // @ timezone may not be set
144 144
 	}
145 145
 
146 146
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 		if (
172 172
 			$this->email
173 173
 			&& $this->mailer
174
-			&& @filemtime($this->directory . '/email-sent') + $snooze < time() // @ file may not exist
175
-			&& @file_put_contents($this->directory . '/email-sent', 'sent') // @ file may not be writable
174
+			&& @filemtime($this->directory.'/email-sent') + $snooze < time() // @ file may not exist
175
+			&& @file_put_contents($this->directory.'/email-sent', 'sent') // @ file may not be writable
176 176
 		) {
177 177
 			call_user_func($this->mailer, $message, implode(', ', (array) $this->email));
178 178
 		}
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
 			["\n", PHP_EOL],
195 195
 			[
196 196
 				'headers' => implode("\n", [
197
-					'From: ' . ($this->fromEmail ?: "noreply@$host"),
197
+					'From: '.($this->fromEmail ?: "noreply@$host"),
198 198
 					'X-Mailer: Tracy',
199 199
 					'Content-Type: text/plain; charset=UTF-8',
200 200
 					'Content-Transfer-Encoding: 8bit',
201
-				]) . "\n",
201
+				])."\n",
202 202
 				'subject' => "PHP: An error occurred on the server $host",
203
-				'body' => static::formatMessage($message) . "\n\nsource: " . Helpers::getSource(),
203
+				'body' => static::formatMessage($message)."\n\nsource: ".Helpers::getSource(),
204 204
 			]
205 205
 		);
206 206
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,8 @@
 block discarded – undo
65 65
 		$line = static::formatLogLine($message, $exceptionFile);
66 66
 		$file = $this->directory . '/' . strtolower($priority ?: self::INFO) . '.log';
67 67
 
68
-		if (!@file_put_contents($file, $line . PHP_EOL, FILE_APPEND | LOCK_EX)) { // @ is escalated to exception
68
+		if (!@file_put_contents($file, $line . PHP_EOL, FILE_APPEND | LOCK_EX)) {
69
+// @ is escalated to exception
69 70
 			throw new \RuntimeException("Unable to write to log file '$file'. Is directory writable?");
70 71
 		}
71 72
 
Please login to merge, or discard this patch.
core/vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php 4 patches
Unused Use Statements   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,6 @@  discard block
 block discarded – undo
10 10
 
11 11
 namespace Wikimedia\Composer\Merge;
12 12
 
13
-use Wikimedia\Composer\Logger;
14
-
15 13
 use Composer\Composer;
16 14
 use Composer\Json\JsonFile;
17 15
 use Composer\Package\BasePackage;
@@ -23,6 +21,7 @@  discard block
 block discarded – undo
23 21
 use Composer\Package\RootPackageInterface;
24 22
 use Composer\Package\Version\VersionParser;
25 23
 use UnexpectedValueException;
24
+use Wikimedia\Composer\Logger;
26 25
 
27 26
 /**
28 27
  * Processing for a composer.json file that will be merged into
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $file = new JsonFile($path);
117 117
         $json = $file->read();
118 118
         if (!isset($json['name'])) {
119
-            $json['name'] = 'merge-plugin/' .
119
+            $json['name'] = 'merge-plugin/'.
120 120
                 strtr($path, DIRECTORY_SEPARATOR, '-');
121 121
         }
122 122
         if (!isset($json['version'])) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         // @codeCoverageIgnoreStart
137 137
         if (!$package instanceof CompletePackage) {
138 138
             throw new UnexpectedValueException(
139
-                'Expected instance of CompletePackage, got ' .
139
+                'Expected instance of CompletePackage, got '.
140 140
                 get_class($package)
141 141
             );
142 142
         }
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
         $type,
234 234
         RootPackageInterface $root,
235 235
         PluginState $state
236
-    ) {
236
+    ){
237 237
         $linkType = BasePackage::$supportedLinkTypes[$type];
238
-        $getter = 'get' . ucfirst($linkType['method']);
239
-        $setter = 'set' . ucfirst($linkType['method']);
238
+        $getter = 'get'.ucfirst($linkType['method']);
239
+        $setter = 'set'.ucfirst($linkType['method']);
240 240
 
241 241
         $requires = $this->package->{$getter}();
242 242
         if (empty($requires)) {
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         array $origin,
275 275
         array $merge,
276 276
         $state
277
-    ) {
277
+    ){
278 278
         if ($state->ignoreDuplicateLinks() && $state->replaceDuplicateLinks()) {
279 279
             $this->logger->warning("Both replace and ignore-duplicates are true. These are mutually exclusive.");
280 280
             $this->logger->warning("Duplicate packages will be ignored.");
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
      */
309 309
     protected function mergeAutoload($type, RootPackageInterface $root)
310 310
     {
311
-        $getter = 'get' . ucfirst($type);
312
-        $setter = 'set' . ucfirst($type);
311
+        $getter = 'get'.ucfirst($type);
312
+        $setter = 'set'.ucfirst($type);
313 313
 
314 314
         $autoload = $this->package->{$getter}();
315 315
         if (empty($autoload)) {
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
         array_walk_recursive(
339 339
             $paths,
340
-            function (&$path) use ($base) {
340
+            function(&$path) use ($base) {
341 341
                 $path = "{$base}{$path}";
342 342
             }
343 343
         );
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
     protected function mergeStabilityFlags(
355 355
         RootPackageInterface $root,
356 356
         array $requires
357
-    ) {
357
+    ){
358 358
         $flags = $root->getStabilityFlags();
359 359
         $sf = new StabilityFlags($flags, $root->getMinimumStability());
360 360
 
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
     protected function mergePackageLinks($type, RootPackageInterface $root)
375 375
     {
376 376
         $linkType = BasePackage::$supportedLinkTypes[$type];
377
-        $getter = 'get' . ucfirst($linkType['method']);
378
-        $setter = 'set' . ucfirst($linkType['method']);
377
+        $getter = 'get'.ucfirst($linkType['method']);
378
+        $setter = 'set'.ucfirst($linkType['method']);
379 379
 
380 380
         $links = $this->package->{$getter}();
381 381
         if (!empty($links)) {
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             // @codeCoverageIgnoreStart
384 384
             if ($root !== $unwrapped) {
385 385
                 $this->logger->warning(
386
-                    'This Composer version does not support ' .
386
+                    'This Composer version does not support '.
387 387
                     "'{$type}' merging for aliased packages."
388 388
                 );
389 389
             }
@@ -508,17 +508,17 @@  discard block
 block discarded – undo
508 508
         $type,
509 509
         array $links,
510 510
         RootPackageInterface $root
511
-    ) {
511
+    ){
512 512
         $linkType = BasePackage::$supportedLinkTypes[$type];
513 513
         $version = $root->getVersion();
514 514
         $prettyVersion = $root->getPrettyVersion();
515 515
         $vp = $this->versionParser;
516 516
 
517
-        $method = 'get' . ucfirst($linkType['method']);
517
+        $method = 'get'.ucfirst($linkType['method']);
518 518
         $packages = $root->$method();
519 519
 
520 520
         return array_map(
521
-            function ($link) use ($linkType, $version, $prettyVersion, $vp, $packages) {
521
+            function($link) use ($linkType, $version, $prettyVersion, $vp, $packages) {
522 522
                 if ('self.version' === $link->getPrettyConstraint()) {
523 523
                     if (isset($packages[$link->getSource()])) {
524 524
                         /** @var Link $package */
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
     public static function unwrapIfNeeded(
567 567
         RootPackageInterface $root,
568 568
         $method = 'setExtra'
569
-    ) {
569
+    ){
570 570
         // @codeCoverageIgnoreStart
571 571
         if ($root instanceof RootAliasPackage &&
572 572
             !method_exists($root, $method)
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
         array_walk_recursive(
339 339
             $paths,
340
-            function (&$path) use ($base) {
340
+            function (&$path) use ($base){
341 341
                 $path = "{$base}{$path}";
342 342
             }
343 343
         );
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
         $packages = $root->$method();
519 519
 
520 520
         return array_map(
521
-            function ($link) use ($linkType, $version, $prettyVersion, $vp, $packages) {
521
+            function ($link) use ($linkType, $version, $prettyVersion, $vp, $packages){
522 522
                 if ('self.version' === $link->getPrettyConstraint()) {
523 523
                     if (isset($packages[$link->getSource()])) {
524 524
                         /** @var Link $package */
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@
 block discarded – undo
206 206
             if (!isset($repoJson['type'])) {
207 207
                 continue;
208 208
             }
209
-            $this->logger->info("Prepending {$repoJson['type']} repository");
209
+            $this->logger->info("prepending {$repoJson['type']} repository");
210 210
             $repo = $repoManager->createRepository(
211 211
                 $repoJson['type'],
212 212
                 $repoJson
Please login to merge, or discard this patch.
core/vendor/wikimedia/composer-merge-plugin/src/Merge/PluginState.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
     /**
230 230
      * Should an update be forced?
231 231
      *
232
-     * @return true If packages are not locked
232
+     * @return boolean If packages are not locked
233 233
      */
234 234
     public function forceUpdate()
235 235
     {
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
             $config['include'] : array($config['include']);
158 158
         $this->requires = (is_array($config['require'])) ?
159 159
             $config['require'] : array($config['require']);
160
-        $this->recurse = (bool)$config['recurse'];
161
-        $this->replace = (bool)$config['replace'];
162
-        $this->ignore = (bool)$config['ignore-duplicates'];
163
-        $this->mergeDev = (bool)$config['merge-dev'];
164
-        $this->mergeExtra = (bool)$config['merge-extra'];
165
-        $this->mergeExtraDeep = (bool)$config['merge-extra-deep'];
166
-        $this->mergeScripts = (bool)$config['merge-scripts'];
160
+        $this->recurse = (bool) $config['recurse'];
161
+        $this->replace = (bool) $config['replace'];
162
+        $this->ignore = (bool) $config['ignore-duplicates'];
163
+        $this->mergeDev = (bool) $config['merge-dev'];
164
+        $this->mergeExtra = (bool) $config['merge-extra'];
165
+        $this->mergeExtraDeep = (bool) $config['merge-extra-deep'];
166
+        $this->mergeScripts = (bool) $config['merge-scripts'];
167 167
     }
168 168
 
169 169
     /**
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function setFirstInstall($flag)
195 195
     {
196
-        $this->firstInstall = (bool)$flag;
196
+        $this->firstInstall = (bool) $flag;
197 197
     }
198 198
 
199 199
     /**
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function setLocked($flag)
215 215
     {
216
-        $this->locked = (bool)$flag;
216
+        $this->locked = (bool) $flag;
217 217
     }
218 218
 
219 219
     /**
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      */
244 244
     public function setDevMode($flag)
245 245
     {
246
-        $this->devMode = (bool)$flag;
246
+        $this->devMode = (bool) $flag;
247 247
     }
248 248
 
249 249
     /**
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      */
274 274
     public function setDumpAutoloader($flag)
275 275
     {
276
-        $this->dumpAutoloader = (bool)$flag;
276
+        $this->dumpAutoloader = (bool) $flag;
277 277
     }
278 278
 
279 279
     /**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function setOptimizeAutoloader($flag)
295 295
     {
296
-        $this->optimizeAutoloader = (bool)$flag;
296
+        $this->optimizeAutoloader = (bool) $flag;
297 297
     }
298 298
 
299 299
     /**
Please login to merge, or discard this patch.
core/vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php 3 patches
Unused Use Statements   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,25 +10,24 @@
 block discarded – undo
10 10
 
11 11
 namespace Wikimedia\Composer;
12 12
 
13
-use Wikimedia\Composer\Merge\ExtraPackage;
14
-use Wikimedia\Composer\Merge\MissingFileException;
15
-use Wikimedia\Composer\Merge\PluginState;
16
-
17 13
 use Composer\Composer;
18 14
 use Composer\DependencyResolver\Operation\InstallOperation;
19 15
 use Composer\EventDispatcher\Event as BaseEvent;
20 16
 use Composer\EventDispatcher\EventSubscriberInterface;
21 17
 use Composer\Factory;
18
+use Composer\IO\IOInterface;
22 19
 use Composer\Installer;
23 20
 use Composer\Installer\InstallerEvent;
24 21
 use Composer\Installer\InstallerEvents;
25 22
 use Composer\Installer\PackageEvent;
26 23
 use Composer\Installer\PackageEvents;
27
-use Composer\IO\IOInterface;
28 24
 use Composer\Package\RootPackageInterface;
29 25
 use Composer\Plugin\PluginInterface;
30 26
 use Composer\Script\Event as ScriptEvent;
31 27
 use Composer\Script\ScriptEvents;
28
+use Wikimedia\Composer\Merge\ExtraPackage;
29
+use Wikimedia\Composer\Merge\MissingFileException;
30
+use Wikimedia\Composer\Merge\PluginState;
32 31
 
33 32
 /**
34 33
  * Composer plugin that allows merging multiple composer.json files.
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         $root = $this->composer->getPackage();
218 218
 
219 219
         $files = array_map(
220
-            function ($files, $pattern) use ($required) {
220
+            function($files, $pattern) use ($required) {
221 221
                 if ($required && !$files) {
222 222
                     throw new MissingFileException(
223 223
                         "merge-plugin: No files matched required '{$pattern}'"
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
         if ($this->state->isFirstInstall()) {
342 342
             $this->state->setFirstInstall(false);
343 343
             $this->logger->info(
344
-                '<comment>' .
345
-                'Running additional update to apply merge settings' .
344
+                '<comment>'.
345
+                'Running additional update to apply merge settings'.
346 346
                 '</comment>'
347 347
             );
348 348
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@
 block discarded – undo
217 217
         $root = $this->composer->getPackage();
218 218
 
219 219
         $files = array_map(
220
-            function ($files, $pattern) use ($required) {
220
+            function ($files, $pattern) use ($required){
221 221
                 if ($required && !$files) {
222 222
                     throw new MissingFileException(
223 223
                         "merge-plugin: No files matched required '{$pattern}'"
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/browser.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     }
318 318
 
319 319
     /**
320
-     * @return bool
320
+     * @return null|boolean
321 321
      */
322 322
     protected function act_deleteDir()
323 323
     {
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     }
483 483
 
484 484
     /**
485
-     * @return bool
485
+     * @return null|boolean
486 486
      */
487 487
     protected function act_delete()
488 488
     {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 
864 864
     /**
865 865
      * @param $file
866
-     * @param $dir
866
+     * @param string $dir
867 867
      * @return array
868 868
      */
869 869
     protected function moveUploadFile($file, $dir)
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
     }
919 919
 
920 920
     /**
921
-     * @param null $file
921
+     * @param string $file
922 922
      */
923 923
     protected function sendDefaultThumb($file = null)
924 924
     {
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
     }
1175 1175
 
1176 1176
     /**
1177
-     * @param $message
1177
+     * @param string $message
1178 1178
      * @param array|null $data
1179 1179
      */
1180 1180
     protected function errorMsg($message, array $data = null)
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $this->get['dir'] = $dir;
43 43
         }
44 44
 
45
-        $thumbsDir = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'];
45
+        $thumbsDir = $this->config['uploadDir']."/".$this->config['thumbsDir'];
46 46
         if ((
47 47
                 !is_dir($thumbsDir) &&
48 48
                 !@mkdir($thumbsDir, $this->config['dirPerms'])
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             $this->session['dir'] = $this->type;
115 115
         } else {
116 116
             $type = $this->getTypeFromPath($this->session['dir']);
117
-            $dir = $this->config['uploadDir'] . "/" . $this->session['dir'];
117
+            $dir = $this->config['uploadDir']."/".$this->session['dir'];
118 118
             if (($type != $this->type) || !is_dir($dir) || !is_readable($dir)) {
119 119
                 $this->session['dir'] = $this->type;
120 120
             }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         }
189 189
         $file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/$file";
190 190
         if (!is_file($file) || !is_readable($file)) {
191
-            $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
191
+            $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/".basename($file);
192 192
             if (!is_file($file) || !is_readable($file)) {
193 193
                 $this->sendDefaultThumb($file);
194 194
             }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     protected function act_chDir()
228 228
     {
229 229
         $this->postDir(); // Just for existing check
230
-        $this->session['dir'] = $this->type . "/" . $this->post['dir'];
230
+        $this->session['dir'] = $this->type."/".$this->post['dir'];
231 231
         $dirWritable = dir::isWritable("{$this->config['uploadDir']}/{$this->session['dir']}");
232 232
 
233 233
         return json_encode(array(
@@ -300,12 +300,12 @@  discard block
 block discarded – undo
300 300
         if (is_array($evtOut) && !empty($evtOut)) {
301 301
             $this->errorMsg(implode('\n', $evtOut));
302 302
         }
303
-        if (!@rename($dir, dirname($dir) . "/$newName")) {
303
+        if (!@rename($dir, dirname($dir)."/$newName")) {
304 304
             $this->errorMsg("Cannot rename the folder.");
305 305
         }
306 306
         $thumbDir = "$this->thumbsTypeDir/{$this->post['dir']}";
307 307
         if (is_dir($thumbDir)) {
308
-            @rename($thumbDir, dirname($thumbDir) . "/$newName");
308
+            @rename($thumbDir, dirname($thumbDir)."/$newName");
309 309
         }
310 310
 
311 311
         $this->modx->invokeEvent('OnFileBrowserRename', array(
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
402 402
         header("Cache-Control: private", false);
403 403
         header("Content-Type: application/octet-stream");
404
-        header('Content-Disposition: attachment; filename="' . str_replace('"', "_", $this->post['file']) . '"');
404
+        header('Content-Disposition: attachment; filename="'.str_replace('"', "_", $this->post['file']).'"');
405 405
         header("Content-Transfer-Encoding:­ binary");
406
-        header("Content-Length: " . filesize($file));
406
+        header("Content-Length: ".filesize($file));
407 407
         readfile($file);
408 408
         die;
409 409
     }
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
         $thumbFile = "$thumbDir/{$this->post['file']}";
476 476
 
477 477
         if (file_exists($thumbFile)) {
478
-            @rename($thumbFile, "$thumbDir/" . basename($newName));
478
+            @rename($thumbFile, "$thumbDir/".basename($newName));
479 479
         }
480 480
 
481 481
         return true;
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
             } elseif (!file_exists($path)) {
565 565
                 $error[] = $this->label("The file '{file}' does not exist.", $replace);
566 566
             } elseif (substr($base, 0, 1) == ".") {
567
-                $error[] = "$base: " . $this->label("File name shouldn't begins with '.'");
567
+                $error[] = "$base: ".$this->label("File name shouldn't begins with '.'");
568 568
             } elseif (!$this->validateExtension($ext, $type)) {
569
-                $error[] = "$base: " . $this->label("Denied file extension.");
569
+                $error[] = "$base: ".$this->label("Denied file extension.");
570 570
             } elseif (file_exists("$dir/$base")) {
571
-                $error[] = "$base: " . $this->label("A file or folder with that name already exists.");
571
+                $error[] = "$base: ".$this->label("A file or folder with that name already exists.");
572 572
             } elseif (!is_readable($path) || !is_file($path)) {
573 573
                 $error[] = $this->label("Cannot read '{file}'.", $replace);
574 574
             } elseif (!@copy($path, "$dir/$base")) {
@@ -640,11 +640,11 @@  discard block
 block discarded – undo
640 640
             } elseif (!file_exists($path)) {
641 641
                 $error[] = $this->label("The file '{file}' does not exist.", $replace);
642 642
             } elseif (substr($base, 0, 1) == ".") {
643
-                $error[] = "$base: " . $this->label("File name shouldn't begins with '.'");
643
+                $error[] = "$base: ".$this->label("File name shouldn't begins with '.'");
644 644
             } elseif (!$this->validateExtension($ext, $type)) {
645
-                $error[] = "$base: " . $this->label("Denied file extension.");
645
+                $error[] = "$base: ".$this->label("Denied file extension.");
646 646
             } elseif (file_exists("$dir/$base")) {
647
-                $error[] = "$base: " . $this->label("A file or folder with that name already exists.");
647
+                $error[] = "$base: ".$this->label("A file or folder with that name already exists.");
648 648
             } elseif (!is_readable($path) || !is_file($path)) {
649 649
                 $error[] = $this->label("Cannot read '{file}'.", $replace);
650 650
             } elseif (!file::isWritable($path) || !@rename($path, "$dir/$base")) {
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
             }
703 703
             $path = "{$this->config['uploadDir']}/$file";
704 704
             $base = basename($file);
705
-            $filepath = str_replace('/' . $base, '', $path);
705
+            $filepath = str_replace('/'.$base, '', $path);
706 706
             $replace = array('file' => $base);
707 707
             if (!is_file($path)) {
708 708
                 $error[] = $this->label("The file '{file}' does not exist.", $replace);
@@ -748,15 +748,15 @@  discard block
 block discarded – undo
748 748
         if (!isset($this->post['dir']) || $this->config['denyZipDownload']) {
749 749
             $this->errorMsg("Unknown error.");
750 750
         }
751
-        $filename = basename($dir) . ".zip";
751
+        $filename = basename($dir).".zip";
752 752
         do {
753
-            $file = md5(time() . session_id());
753
+            $file = md5(time().session_id());
754 754
             $file = "{$this->config['uploadDir']}/$file.zip";
755 755
         } while (file_exists($file));
756 756
         new zipFolder($file, $dir);
757 757
         header("Content-Type: application/x-zip");
758
-        header('Content-Disposition: attachment; filename="' . str_replace('"', "_", $filename) . '"');
759
-        header("Content-Length: " . filesize($file));
758
+        header('Content-Disposition: attachment; filename="'.str_replace('"', "_", $filename).'"');
759
+        header("Content-Length: ".filesize($file));
760 760
         readfile($file);
761 761
         unlink($file);
762 762
         die;
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
         }
791 791
 
792 792
         do {
793
-            $file = md5(time() . session_id());
793
+            $file = md5(time().session_id());
794 794
             $file = "{$this->config['uploadDir']}/$file.zip";
795 795
         } while (file_exists($file));
796 796
 
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
             $zip->close();
804 804
         }
805 805
         header("Content-Type: application/x-zip");
806
-        header('Content-Disposition: attachment; filename="selected_files_' . basename($file) . '"');
807
-        header("Content-Length: " . filesize($file));
806
+        header('Content-Disposition: attachment; filename="selected_files_'.basename($file).'"');
807
+        header("Content-Length: ".filesize($file));
808 808
         readfile($file);
809 809
         unlink($file);
810 810
         die;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
             if ($type != $this->type) {
834 834
                 continue;
835 835
             }
836
-            $file = $this->config['uploadDir'] . "/$file";
836
+            $file = $this->config['uploadDir']."/$file";
837 837
             if (!is_file($file) || !is_readable($file)) {
838 838
                 continue;
839 839
             }
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
         }
842 842
 
843 843
         do {
844
-            $file = md5(time() . session_id());
844
+            $file = md5(time().session_id());
845 845
             $file = "{$this->config['uploadDir']}/$file.zip";
846 846
         } while (file_exists($file));
847 847
 
@@ -854,8 +854,8 @@  discard block
 block discarded – undo
854 854
             $zip->close();
855 855
         }
856 856
         header("Content-Type: application/x-zip");
857
-        header('Content-Disposition: attachment; filename="clipboard_' . basename($file) . '"');
858
-        header("Content-Length: " . filesize($file));
857
+        header('Content-Disposition: attachment; filename="clipboard_'.basename($file).'"');
858
+        header("Content-Length: ".filesize($file));
859 859
         readfile($file);
860 860
         unlink($file);
861 861
         die;
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
             return $response;
892 892
         }
893 893
         $filename = $this->normalizeFilename($file['name']);
894
-        $target = "$dir/" . file::getInexistantFilename($filename, $dir);
894
+        $target = "$dir/".file::getInexistantFilename($filename, $dir);
895 895
 
896 896
         if (!@move_uploaded_file($file['tmp_name'], $target) &&
897 897
             !@rename($file['tmp_name'], $target) &&
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
                 if (is_array($size) && count($size)) {
958 958
                     $preview = true;
959 959
                     if (!$this->config['noThumbnailsRecreation']) {
960
-                        $thumb_file = "$thumbDir/" . basename($file);
960
+                        $thumb_file = "$thumbDir/".basename($file);
961 961
                         if (!is_file($thumb_file) || filemtime($file) > filemtime($thumb_file)) {
962 962
                             $this->makeThumb($file);
963 963
                         }
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
             }
975 975
             $name = basename($file);
976 976
             $types = $this->config['types'];
977
-            $types = explode(' ', $types['images'] . ' ' . $types['image']);
977
+            $types = explode(' ', $types['images'].' '.$types['image']);
978 978
             if (substr($name, 0, 1) == '.' && !$this->config['showHiddenFiles']) {
979 979
                 continue;
980 980
             }
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
     {
1055 1055
         $dir = $this->typeDir;
1056 1056
         if (isset($this->post['dir'])) {
1057
-            $dir .= "/" . $this->post['dir'];
1057
+            $dir .= "/".$this->post['dir'];
1058 1058
         }
1059 1059
         if ($existent && (!is_dir($dir) || !is_readable($dir))) {
1060 1060
             $this->errorMsg("Inexistant or inaccessible folder.");
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
     {
1072 1072
         $dir = $this->typeDir;
1073 1073
         if (isset($this->get['dir'])) {
1074
-            $dir .= "/" . $this->get['dir'];
1074
+            $dir .= "/".$this->get['dir'];
1075 1075
         }
1076 1076
         if ($existent && (!is_dir($dir) || !is_readable($dir))) {
1077 1077
             $this->errorMsg("Inexistant or inaccessible folder.");
Please login to merge, or discard this patch.
Braces   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  * @link http://kcfinder.sunhater.com
13 13
  */
14 14
 
15
-class browser extends uploader
16
-{
15
+class browser extends uploader
16
+{
17 17
     protected $action;
18 18
     protected $thumbsDir;
19 19
     protected $thumbsTypeDir;
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
      * browser constructor.
23 23
      * @param DocumentParser $modx
24 24
      */
25
-    public function __construct(DocumentParser $modx)
26
-    {
25
+    public function __construct(DocumentParser $modx)
26
+    {
27 27
         parent::__construct($modx);
28 28
 
29
-        if (isset($this->post['dir'])) {
29
+        if (isset($this->post['dir'])) {
30 30
             $dir = $this->checkInputDir($this->post['dir'], true, false);
31
-            if ($dir === false) {
31
+            if ($dir === false) {
32 32
                 unset($this->post['dir']);
33 33
             }
34 34
             $this->post['dir'] = $dir;
35 35
         }
36 36
 
37
-        if (isset($this->get['dir'])) {
37
+        if (isset($this->get['dir'])) {
38 38
             $dir = $this->checkInputDir($this->get['dir'], true, false);
39
-            if ($dir === false) {
39
+            if ($dir === false) {
40 40
                 unset($this->get['dir']);
41 41
             }
42 42
             $this->get['dir'] = $dir;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                 !is_dir("$thumbsDir/{$this->type}") &&
55 55
                 !@mkdir("$thumbsDir/{$this->type}", $this->config['dirPerms'])
56 56
             )
57
-        ) {
57
+        ) {
58 58
             $this->errorMsg("Cannot access or create thumbnails folder.");
59 59
         }
60 60
 
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
             'pattern' => '/^.*\.zip$/i'
68 68
         ));
69 69
 
70
-        if (is_array($files) && count($files)) {
70
+        if (is_array($files) && count($files)) {
71 71
             $time = time();
72
-            foreach ($files as $file) {
73
-                if (is_file($file) && ($time - filemtime($file) > 3600)) {
72
+            foreach ($files as $file) {
73
+                if (is_file($file) && ($time - filemtime($file) > 3600)) {
74 74
                     unlink($file);
75 75
                 }
76 76
             }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         if (isset($this->get['theme']) &&
80 80
             ($this->get['theme'] == basename($this->get['theme'])) &&
81 81
             is_dir("themes/{$this->get['theme']}")
82
-        ) {
82
+        ) {
83 83
             $this->config['theme'] = $this->get['theme'];
84 84
         }
85 85
     }
@@ -87,47 +87,47 @@  discard block
 block discarded – undo
87 87
     /**
88 88
      *
89 89
      */
90
-    public function action()
91
-    {
90
+    public function action()
91
+    {
92 92
         $act = isset($this->get['act']) ? $this->get['act'] : "browser";
93
-        if (!preg_match('@^[0-9a-zA-Z_]+$@', $act)) {
93
+        if (!preg_match('@^[0-9a-zA-Z_]+$@', $act)) {
94 94
             $this->errorMsg("Unknown error.");
95 95
         }
96
-        if (!method_exists($this, "act_$act")) {
96
+        if (!method_exists($this, "act_$act")) {
97 97
             $act = "browser";
98 98
         }
99 99
         $this->action = $act;
100 100
         $method = "act_$act";
101
-        if ($this->config['disabled']) {
101
+        if ($this->config['disabled']) {
102 102
             $message = $this->label("You don't have permissions to browse server.");
103 103
             if (in_array($act, array("browser", "upload")) ||
104 104
                 (substr($act, 0, 8) == "download")
105
-            ) {
105
+            ) {
106 106
                 $this->backMsg($message);
107
-            } else {
107
+            } else {
108 108
                 header("Content-Type: text/plain; charset={$this->charset}");
109 109
                 die(json_encode(array('error' => $message)));
110 110
             }
111 111
         }
112 112
 
113
-        if (!isset($this->session['dir'])) {
113
+        if (!isset($this->session['dir'])) {
114 114
             $this->session['dir'] = $this->type;
115
-        } else {
115
+        } else {
116 116
             $type = $this->getTypeFromPath($this->session['dir']);
117 117
             $dir = $this->config['uploadDir'] . "/" . $this->session['dir'];
118
-            if (($type != $this->type) || !is_dir($dir) || !is_readable($dir)) {
118
+            if (($type != $this->type) || !is_dir($dir) || !is_readable($dir)) {
119 119
                 $this->session['dir'] = $this->type;
120 120
             }
121 121
         }
122 122
         $this->session['dir'] = path::normalize($this->session['dir']);
123 123
 
124
-        if ($act == "browser") {
124
+        if ($act == "browser") {
125 125
             header("X-UA-Compatible: chrome=1");
126 126
             header("Content-Type: text/html; charset={$this->charset}");
127 127
         } elseif (
128 128
             (substr($act, 0, 8) != "download") &&
129 129
             !in_array($act, array("thumb", "upload"))
130
-        ) {
130
+        ) {
131 131
             header("Content-Type: text/plain; charset={$this->charset}");
132 132
         }
133 133
 
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
     /**
141 141
      * @return string
142 142
      */
143
-    protected function act_browser()
144
-    {
143
+    protected function act_browser()
144
+    {
145 145
         if (isset($this->get['dir']) &&
146 146
             is_dir("{$this->typeDir}/{$this->get['dir']}") &&
147 147
             is_readable("{$this->typeDir}/{$this->get['dir']}")
148
-        ) {
148
+        ) {
149 149
             $this->session['dir'] = path::normalize("{$this->type}/{$this->get['dir']}");
150 150
         }
151 151
 
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
     /**
156 156
      * @return string
157 157
      */
158
-    protected function act_init()
159
-    {
158
+    protected function act_init()
159
+    {
160 160
         $tree = $this->getDirInfo($this->typeDir);
161 161
         $tree['dirs'] = $this->getTree($this->session['dir']);
162
-        if (!is_array($tree['dirs']) || !count($tree['dirs'])) {
162
+        if (!is_array($tree['dirs']) || !count($tree['dirs'])) {
163 163
             unset($tree['dirs']);
164 164
         }
165 165
         $files = $this->getFiles($this->session['dir']);
@@ -176,37 +176,37 @@  discard block
 block discarded – undo
176 176
     /**
177 177
      *
178 178
      */
179
-    protected function act_thumb()
180
-    {
179
+    protected function act_thumb()
180
+    {
181 181
         $this->getDir($this->get['dir'], true);
182
-        if (!isset($this->get['file']) || !isset($this->get['dir'])) {
182
+        if (!isset($this->get['file']) || !isset($this->get['dir'])) {
183 183
             $this->sendDefaultThumb();
184 184
         }
185 185
         $file = $this->get['file'];
186
-        if (basename($file) != $file) {
186
+        if (basename($file) != $file) {
187 187
             $this->sendDefaultThumb();
188 188
         }
189 189
         $file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/$file";
190
-        if (!is_file($file) || !is_readable($file)) {
190
+        if (!is_file($file) || !is_readable($file)) {
191 191
             $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
192
-            if (!is_file($file) || !is_readable($file)) {
192
+            if (!is_file($file) || !is_readable($file)) {
193 193
                 $this->sendDefaultThumb($file);
194 194
             }
195 195
             $image = image::factory($this->imageDriver, $file);
196
-            if ($image->initError) {
196
+            if ($image->initError) {
197 197
                 $this->sendDefaultThumb($file);
198 198
             }
199 199
             list($tmp, $tmp, $type) = getimagesize($file);
200 200
             if (in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) &&
201 201
                 ($image->width <= $this->config['thumbWidth']) &&
202 202
                 ($image->height <= $this->config['thumbHeight'])
203
-            ) {
203
+            ) {
204 204
                 $mime =
205 205
                     ($type == IMAGETYPE_GIF) ? "gif" : (
206 206
                     ($type == IMAGETYPE_PNG) ? "png" : "jpeg");
207 207
                 $mime = "image/$mime";
208 208
                 httpCache::file($file, $mime);
209
-            } else {
209
+            } else {
210 210
                 $this->sendDefaultThumb($file);
211 211
             }
212 212
         }
@@ -216,16 +216,16 @@  discard block
 block discarded – undo
216 216
     /**
217 217
      * @return string
218 218
      */
219
-    protected function act_expand()
220
-    {
219
+    protected function act_expand()
220
+    {
221 221
         return json_encode(array('dirs' => $this->getDirs($this->postDir())));
222 222
     }
223 223
 
224 224
     /**
225 225
      * @return string
226 226
      */
227
-    protected function act_chDir()
228
-    {
227
+    protected function act_chDir()
228
+    {
229 229
         $this->postDir(); // Just for existing check
230 230
         $this->session['dir'] = $this->type . "/" . $this->post['dir'];
231 231
         $dirWritable = dir::isWritable("{$this->config['uploadDir']}/{$this->session['dir']}");
@@ -239,30 +239,30 @@  discard block
 block discarded – undo
239 239
     /**
240 240
      * @return bool
241 241
      */
242
-    protected function act_newDir()
243
-    {
242
+    protected function act_newDir()
243
+    {
244 244
         if (!$this->config['access']['dirs']['create'] ||
245 245
             !isset($this->post['dir']) ||
246 246
             !isset($this->post['newDir'])
247
-        ) {
247
+        ) {
248 248
             $this->errorMsg("Unknown error.");
249 249
         }
250 250
 
251 251
         $dir = $this->postDir();
252 252
         $newDir = $this->normalizeDirname(trim($this->post['newDir']));
253
-        if (!strlen($newDir)) {
253
+        if (!strlen($newDir)) {
254 254
             $this->errorMsg("Please enter new folder name.");
255 255
         }
256
-        if (preg_match('/[\/\\\\]/s', $newDir)) {
256
+        if (preg_match('/[\/\\\\]/s', $newDir)) {
257 257
             $this->errorMsg("Unallowable characters in folder name.");
258 258
         }
259
-        if (substr($newDir, 0, 1) == ".") {
259
+        if (substr($newDir, 0, 1) == ".") {
260 260
             $this->errorMsg("Folder name shouldn't begins with '.'");
261 261
         }
262
-        if (file_exists("$dir/$newDir")) {
262
+        if (file_exists("$dir/$newDir")) {
263 263
             $this->errorMsg("A file or folder with that name already exists.");
264 264
         }
265
-        if (!@mkdir("$dir/$newDir", $this->config['dirPerms'])) {
265
+        if (!@mkdir("$dir/$newDir", $this->config['dirPerms'])) {
266 266
             $this->errorMsg("Cannot create {dir} folder.", array('dir' => $newDir));
267 267
         }
268 268
 
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
     /**
273 273
      * @return string
274 274
      */
275
-    protected function act_renameDir()
276
-    {
275
+    protected function act_renameDir()
276
+    {
277 277
         if (!$this->config['access']['dirs']['rename'] ||
278 278
             !isset($this->post['dir']) ||
279 279
             !isset($this->post['newName'])
280
-        ) {
280
+        ) {
281 281
             $this->errorMsg("Unknown error.");
282 282
         }
283 283
 
@@ -288,23 +288,23 @@  discard block
 block discarded – undo
288 288
             'filepath' => realpath($dir),
289 289
             'newname' => &$newName
290 290
         ));
291
-        if (!strlen($newName)) {
291
+        if (!strlen($newName)) {
292 292
             $this->errorMsg("Please enter new folder name.");
293 293
         }
294
-        if (preg_match('/[\/\\\\]/s', $newName)) {
294
+        if (preg_match('/[\/\\\\]/s', $newName)) {
295 295
             $this->errorMsg("Unallowable characters in folder name.");
296 296
         }
297
-        if (substr($newName, 0, 1) == ".") {
297
+        if (substr($newName, 0, 1) == ".") {
298 298
             $this->errorMsg("Folder name shouldn't begins with '.'");
299 299
         }
300
-        if (is_array($evtOut) && !empty($evtOut)) {
300
+        if (is_array($evtOut) && !empty($evtOut)) {
301 301
             $this->errorMsg(implode('\n', $evtOut));
302 302
         }
303
-        if (!@rename($dir, dirname($dir) . "/$newName")) {
303
+        if (!@rename($dir, dirname($dir) . "/$newName")) {
304 304
             $this->errorMsg("Cannot rename the folder.");
305 305
         }
306 306
         $thumbDir = "$this->thumbsTypeDir/{$this->post['dir']}";
307
-        if (is_dir($thumbDir)) {
307
+        if (is_dir($thumbDir)) {
308 308
             @rename($thumbDir, dirname($thumbDir) . "/$newName");
309 309
         }
310 310
 
@@ -319,18 +319,18 @@  discard block
 block discarded – undo
319 319
     /**
320 320
      * @return bool
321 321
      */
322
-    protected function act_deleteDir()
323
-    {
322
+    protected function act_deleteDir()
323
+    {
324 324
         if (!$this->config['access']['dirs']['delete'] ||
325 325
             !isset($this->post['dir']) ||
326 326
             !strlen(trim($this->post['dir']))
327
-        ) {
327
+        ) {
328 328
             $this->errorMsg("Unknown error.");
329 329
         }
330 330
 
331 331
         $dir = $this->postDir();
332 332
 
333
-        if (!dir::isWritable($dir)) {
333
+        if (!dir::isWritable($dir)) {
334 334
             $this->errorMsg("Cannot delete the folder.");
335 335
         }
336 336
 
@@ -338,17 +338,17 @@  discard block
 block discarded – undo
338 338
             'element'  => 'dir',
339 339
             'filepath' => realpath($dir)
340 340
         ));
341
-        if (is_array($evtOut) && !empty($evtOut)) {
341
+        if (is_array($evtOut) && !empty($evtOut)) {
342 342
             die(json_encode(array('error' => $evtOut)));
343 343
         }
344 344
 
345 345
         $result = !dir::prune($dir, false);
346
-        if (is_array($result) && count($result)) {
346
+        if (is_array($result) && count($result)) {
347 347
             $this->errorMsg("Failed to delete {count} files/folders.",
348 348
                 array('count' => count($result)));
349 349
         }
350 350
         $thumbDir = "$this->thumbsTypeDir/{$this->post['dir']}";
351
-        if (is_dir($thumbDir)) {
351
+        if (is_dir($thumbDir)) {
352 352
             dir::prune($thumbDir);
353 353
         }
354 354
         $this->modx->invokeEvent('OnFileBrowserDelete', array(
@@ -362,16 +362,16 @@  discard block
 block discarded – undo
362 362
     /**
363 363
      * @return string
364 364
      */
365
-    protected function act_upload()
366
-    {
365
+    protected function act_upload()
366
+    {
367 367
         $response = array('success' => false, 'message' => $this->label("Unknown error."));
368 368
         if (!$this->config['access']['files']['upload'] ||
369 369
             !isset($this->post['dir'])
370
-        ) {
370
+        ) {
371 371
             return json_encode($response);
372 372
         }
373 373
         $dir = $this->postDir();
374
-        if (!dir::isWritable($dir)) {
374
+        if (!dir::isWritable($dir)) {
375 375
             $response['message'] = $this->label("Cannot access or write to upload folder.");
376 376
 
377 377
             return json_encode($response);
@@ -384,15 +384,15 @@  discard block
 block discarded – undo
384 384
     /**
385 385
      *
386 386
      */
387
-    protected function act_download()
388
-    {
387
+    protected function act_download()
388
+    {
389 389
         $dir = $this->postDir();
390 390
         if (!isset($this->post['dir']) ||
391 391
             !isset($this->post['file']) ||
392 392
             strpos($this->post['file'], '../') !== false ||
393 393
             (false === ($file = "$dir/{$this->post['file']}")) ||
394 394
             !file_exists($file) || !is_readable($file)
395
-        ) {
395
+        ) {
396 396
             $this->errorMsg("Unknown error.");
397 397
         }
398 398
 
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
     /**
412 412
      * @return bool
413 413
      */
414
-    protected function act_rename()
415
-    {
414
+    protected function act_rename()
415
+    {
416 416
         $dir = $this->postDir();
417 417
         if (!$this->config['access']['files']['rename'] ||
418 418
             !isset($this->post['dir']) ||
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
             !isset($this->post['newName']) ||
422 422
             (false === ($file = "$dir/{$this->post['file']}")) ||
423 423
             !file_exists($file) || !is_readable($file) || !file::isWritable($file)
424
-        ) {
424
+        ) {
425 425
             $this->errorMsg("Unknown error.");
426 426
         }
427 427
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             (file::getExtension($this->post['file'], true) !==
431 431
                 file::getExtension($this->post['newName'], true)
432 432
             )
433
-        ) {
433
+        ) {
434 434
             $this->errorMsg("You cannot rename the extension of files!");
435 435
         }
436 436
 
@@ -441,28 +441,28 @@  discard block
 block discarded – undo
441 441
             'filename' => $this->post['file'],
442 442
             'newname' => &$newName
443 443
         ));
444
-        if (!strlen($newName)) {
444
+        if (!strlen($newName)) {
445 445
             $this->errorMsg("Please enter new file name.");
446 446
         }
447
-        if (preg_match('/[\/\\\\]/s', $newName)) {
447
+        if (preg_match('/[\/\\\\]/s', $newName)) {
448 448
             $this->errorMsg("Unallowable characters in file name.");
449 449
         }
450
-        if (substr($newName, 0, 1) == ".") {
450
+        if (substr($newName, 0, 1) == ".") {
451 451
             $this->errorMsg("File name shouldn't begins with '.'");
452 452
         }
453 453
         $_newName = $newName;
454 454
         $newName = "$dir/$newName";
455
-        if (file_exists($newName)) {
455
+        if (file_exists($newName)) {
456 456
             $this->errorMsg("A file or folder with that name already exists.");
457 457
         }
458 458
         $ext = file::getExtension($newName);
459
-        if (!$this->validateExtension($ext, $this->type)) {
459
+        if (!$this->validateExtension($ext, $this->type)) {
460 460
             $this->errorMsg("Denied file extension.");
461 461
         }
462
-        if (is_array($evtOut) && !empty($evtOut)) {
462
+        if (is_array($evtOut) && !empty($evtOut)) {
463 463
             $this->errorMsg(implode('\n', $evtOut));
464 464
         }
465
-        if (!@rename($file, $newName)) {
465
+        if (!@rename($file, $newName)) {
466 466
             $this->errorMsg("Unknown error.");
467 467
         }
468 468
         $this->modx->invokeEvent('OnFileBrowserRename', array(
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         $thumbDir = "{$this->thumbsTypeDir}/{$this->post['dir']}";
475 475
         $thumbFile = "$thumbDir/{$this->post['file']}";
476 476
 
477
-        if (file_exists($thumbFile)) {
477
+        if (file_exists($thumbFile)) {
478 478
             @rename($thumbFile, "$thumbDir/" . basename($newName));
479 479
         }
480 480
 
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
     /**
485 485
      * @return bool
486 486
      */
487
-    protected function act_delete()
488
-    {
487
+    protected function act_delete()
488
+    {
489 489
         $dir = $this->postDir();
490 490
 
491 491
         if (!$this->config['access']['files']['delete'] ||
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
             strpos($this->post['file'], '../') !== false ||
495 495
             (false === ($file = "$dir/{$this->post['file']}")) ||
496 496
             !file_exists($file) || !is_readable($file) || !file::isWritable($file)
497
-        ) {
497
+        ) {
498 498
             $this->errorMsg("Cannot delete '{file}'.", array('file' => basename($file)));
499 499
         }
500 500
 
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
             'filepath' => realpath($dir)
505 505
         ));
506 506
 
507
-        if (is_array($evtOut) && !empty($evtOut)) {
507
+        if (is_array($evtOut) && !empty($evtOut)) {
508 508
             die(json_encode(array('error' => $evtOut)));
509 509
         }
510 510
 
511 511
         @unlink($file);
512 512
 
513 513
         $thumb = "{$this->thumbsTypeDir}/{$this->post['dir']}/{$this->post['file']}";
514
-        if (file_exists($thumb)) {
514
+        if (file_exists($thumb)) {
515 515
             @unlink($thumb);
516 516
         }
517 517
 
@@ -527,27 +527,27 @@  discard block
 block discarded – undo
527 527
     /**
528 528
      * @return bool|string
529 529
      */
530
-    protected function act_cp_cbd()
531
-    {
530
+    protected function act_cp_cbd()
531
+    {
532 532
         $dir = $this->postDir();
533 533
         if (!$this->config['access']['files']['copy'] ||
534 534
             !isset($this->post['dir']) ||
535 535
             !is_dir($dir) || !is_readable($dir) || !dir::isWritable($dir) ||
536 536
             !isset($this->post['files']) || !is_array($this->post['files']) ||
537 537
             !count($this->post['files'])
538
-        ) {
538
+        ) {
539 539
             $this->errorMsg("Unknown error.");
540 540
         }
541 541
 
542 542
         $error = array();
543
-        foreach ($this->post['files'] as $file) {
543
+        foreach ($this->post['files'] as $file) {
544 544
             $file = path::normalize($file);
545
-            if (substr($file, 0, 1) == ".") {
545
+            if (substr($file, 0, 1) == ".") {
546 546
                 continue;
547 547
             }
548 548
             $type = explode("/", $file);
549 549
             $type = $type[0];
550
-            if ($type != $this->type) {
550
+            if ($type != $this->type) {
551 551
                 continue;
552 552
             }
553 553
             $path = "{$this->config['uploadDir']}/$file";
@@ -559,22 +559,22 @@  discard block
 block discarded – undo
559 559
                 'filename' => $base,
560 560
                 'newpath' => realpath($dir)
561 561
             ));
562
-            if (is_array($evtOut) && !empty($evtOut)) {
562
+            if (is_array($evtOut) && !empty($evtOut)) {
563 563
                 $error[] = implode("\n", $evtOut);
564
-            } elseif (!file_exists($path)) {
564
+            } elseif (!file_exists($path)) {
565 565
                 $error[] = $this->label("The file '{file}' does not exist.", $replace);
566
-            } elseif (substr($base, 0, 1) == ".") {
566
+            } elseif (substr($base, 0, 1) == ".") {
567 567
                 $error[] = "$base: " . $this->label("File name shouldn't begins with '.'");
568
-            } elseif (!$this->validateExtension($ext, $type)) {
568
+            } elseif (!$this->validateExtension($ext, $type)) {
569 569
                 $error[] = "$base: " . $this->label("Denied file extension.");
570
-            } elseif (file_exists("$dir/$base")) {
570
+            } elseif (file_exists("$dir/$base")) {
571 571
                 $error[] = "$base: " . $this->label("A file or folder with that name already exists.");
572
-            } elseif (!is_readable($path) || !is_file($path)) {
572
+            } elseif (!is_readable($path) || !is_file($path)) {
573 573
                 $error[] = $this->label("Cannot read '{file}'.", $replace);
574
-            } elseif (!@copy($path, "$dir/$base")) {
574
+            } elseif (!@copy($path, "$dir/$base")) {
575 575
                 $error[] = $this->label("Cannot copy '{file}'.", $replace);
576
-            } else {
577
-                if (function_exists("chmod")) {
576
+            } else {
577
+                if (function_exists("chmod")) {
578 578
                     @chmod("$dir/$base", $this->config['filePerms']);
579 579
                 }
580 580
                 $this->modx->invokeEvent('OnFileBrowserCopy', array(
@@ -583,9 +583,9 @@  discard block
 block discarded – undo
583 583
                     'newpath' => realpath($dir)
584 584
                 ));
585 585
                 $fromThumb = "{$this->thumbsDir}/$file";
586
-                if (is_file($fromThumb) && is_readable($fromThumb)) {
586
+                if (is_file($fromThumb) && is_readable($fromThumb)) {
587 587
                     $toThumb = "{$this->thumbsTypeDir}/{$this->post['dir']}";
588
-                    if (!is_dir($toThumb)) {
588
+                    if (!is_dir($toThumb)) {
589 589
                         @mkdir($toThumb, $this->config['dirPerms'], true);
590 590
                     }
591 591
                     $toThumb .= "/$base";
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
                 }
594 594
             }
595 595
         }
596
-        if (count($error)) {
596
+        if (count($error)) {
597 597
             return json_encode(array('error' => $error));
598 598
         }
599 599
 
@@ -603,27 +603,27 @@  discard block
 block discarded – undo
603 603
     /**
604 604
      * @return bool|string
605 605
      */
606
-    protected function act_mv_cbd()
607
-    {
606
+    protected function act_mv_cbd()
607
+    {
608 608
         $dir = $this->postDir();
609 609
         if (!$this->config['access']['files']['move'] ||
610 610
             !isset($this->post['dir']) ||
611 611
             !is_dir($dir) || !is_readable($dir) || !dir::isWritable($dir) ||
612 612
             !isset($this->post['files']) || !is_array($this->post['files']) ||
613 613
             !count($this->post['files'])
614
-        ) {
614
+        ) {
615 615
             $this->errorMsg("Unknown error.");
616 616
         }
617 617
 
618 618
         $error = array();
619
-        foreach ($this->post['files'] as $file) {
619
+        foreach ($this->post['files'] as $file) {
620 620
             $file = path::normalize($file);
621
-            if (substr($file, 0, 1) == ".") {
621
+            if (substr($file, 0, 1) == ".") {
622 622
                 continue;
623 623
             }
624 624
             $type = explode("/", $file);
625 625
             $type = $type[0];
626
-            if ($type != $this->type) {
626
+            if ($type != $this->type) {
627 627
                 continue;
628 628
             }
629 629
             $path = "{$this->config['uploadDir']}/$file";
@@ -635,28 +635,28 @@  discard block
 block discarded – undo
635 635
                 'filename' => $base,
636 636
                 'newpath' => realpath($dir)
637 637
             ));
638
-            if (is_array($evtOut) && !empty($evtOut)) {
638
+            if (is_array($evtOut) && !empty($evtOut)) {
639 639
                 $error[] = implode("\n", $evtOut);
640
-            } elseif (!file_exists($path)) {
640
+            } elseif (!file_exists($path)) {
641 641
                 $error[] = $this->label("The file '{file}' does not exist.", $replace);
642
-            } elseif (substr($base, 0, 1) == ".") {
642
+            } elseif (substr($base, 0, 1) == ".") {
643 643
                 $error[] = "$base: " . $this->label("File name shouldn't begins with '.'");
644
-            } elseif (!$this->validateExtension($ext, $type)) {
644
+            } elseif (!$this->validateExtension($ext, $type)) {
645 645
                 $error[] = "$base: " . $this->label("Denied file extension.");
646
-            } elseif (file_exists("$dir/$base")) {
646
+            } elseif (file_exists("$dir/$base")) {
647 647
                 $error[] = "$base: " . $this->label("A file or folder with that name already exists.");
648
-            } elseif (!is_readable($path) || !is_file($path)) {
648
+            } elseif (!is_readable($path) || !is_file($path)) {
649 649
                 $error[] = $this->label("Cannot read '{file}'.", $replace);
650
-            } elseif (!file::isWritable($path) || !@rename($path, "$dir/$base")) {
650
+            } elseif (!file::isWritable($path) || !@rename($path, "$dir/$base")) {
651 651
                 $error[] = $this->label("Cannot move '{file}'.", $replace);
652
-            } else {
653
-                if (function_exists("chmod")) {
652
+            } else {
653
+                if (function_exists("chmod")) {
654 654
                     @chmod("$dir/$base", $this->config['filePerms']);
655 655
                 }
656 656
                 $fromThumb = "{$this->thumbsDir}/$file";
657
-                if (is_file($fromThumb) && is_readable($fromThumb)) {
657
+                if (is_file($fromThumb) && is_readable($fromThumb)) {
658 658
                     $toThumb = "{$this->thumbsTypeDir}/{$this->post['dir']}";
659
-                    if (!is_dir($toThumb)) {
659
+                    if (!is_dir($toThumb)) {
660 660
                         @mkdir($toThumb, $this->config['dirPerms'], true);
661 661
                     }
662 662
                     $toThumb .= "/$base";
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
                 ));
670 670
             }
671 671
         }
672
-        if (count($error)) {
672
+        if (count($error)) {
673 673
             return json_encode(array('error' => $error));
674 674
         }
675 675
 
@@ -679,60 +679,60 @@  discard block
 block discarded – undo
679 679
     /**
680 680
      * @return bool|string
681 681
      */
682
-    protected function act_rm_cbd()
683
-    {
682
+    protected function act_rm_cbd()
683
+    {
684 684
         if (!$this->config['access']['files']['delete'] ||
685 685
             !isset($this->post['files']) ||
686 686
             !is_array($this->post['files']) ||
687 687
             !count($this->post['files'])
688
-        ) {
688
+        ) {
689 689
             $this->errorMsg("Unknown error.");
690 690
         }
691 691
 
692 692
         $error = array();
693
-        foreach ($this->post['files'] as $file) {
693
+        foreach ($this->post['files'] as $file) {
694 694
             $file = path::normalize($file);
695
-            if (substr($file, 0, 1) == ".") {
695
+            if (substr($file, 0, 1) == ".") {
696 696
                 continue;
697 697
             }
698 698
             $type = explode("/", $file);
699 699
             $type = $type[0];
700
-            if ($type != $this->type) {
700
+            if ($type != $this->type) {
701 701
                 continue;
702 702
             }
703 703
             $path = "{$this->config['uploadDir']}/$file";
704 704
             $base = basename($file);
705 705
             $filepath = str_replace('/' . $base, '', $path);
706 706
             $replace = array('file' => $base);
707
-            if (!is_file($path)) {
707
+            if (!is_file($path)) {
708 708
                 $error[] = $this->label("The file '{file}' does not exist.", $replace);
709
-            } else {
709
+            } else {
710 710
                 $evtOut = $this->modx->invokeEvent('OnBeforeFileBrowserDelete', array(
711 711
                     'element'  => 'file',
712 712
                     'filename' => $base,
713 713
                     'filepath' => $filepath
714 714
                 ));
715 715
 
716
-                if (is_array($evtOut) && !empty($evtOut)) {
716
+                if (is_array($evtOut) && !empty($evtOut)) {
717 717
                     $error[] = implode("\n", $evtOut);
718
-                } else {
719
-                    if (!@unlink($path)) {
718
+                } else {
719
+                    if (!@unlink($path)) {
720 720
                         $error[] = $this->label("Cannot delete '{file}'.", $replace);
721
-                    } else {
721
+                    } else {
722 722
                         $this->modx->invokeEvent('OnFileBrowserDelete', array(
723 723
                             'element'  => 'file',
724 724
                             'filename' => $base,
725 725
                             'filepath' => $filepath
726 726
                         ));
727 727
                         $thumb = "{$this->thumbsDir}/$file";
728
-                        if (is_file($thumb)) {
728
+                        if (is_file($thumb)) {
729 729
                             @unlink($thumb);
730 730
                         }
731 731
                     }
732 732
                 }
733 733
             }
734 734
         }
735
-        if (count($error)) {
735
+        if (count($error)) {
736 736
             return json_encode(array('error' => $error));
737 737
         }
738 738
 
@@ -742,14 +742,14 @@  discard block
 block discarded – undo
742 742
     /**
743 743
      * @throws Exception
744 744
      */
745
-    protected function act_downloadDir()
746
-    {
745
+    protected function act_downloadDir()
746
+    {
747 747
         $dir = $this->postDir();
748
-        if (!isset($this->post['dir']) || $this->config['denyZipDownload']) {
748
+        if (!isset($this->post['dir']) || $this->config['denyZipDownload']) {
749 749
             $this->errorMsg("Unknown error.");
750 750
         }
751 751
         $filename = basename($dir) . ".zip";
752
-        do {
752
+        do {
753 753
             $file = md5(time() . session_id());
754 754
             $file = "{$this->config['uploadDir']}/$file.zip";
755 755
         } while (file_exists($file));
@@ -765,39 +765,39 @@  discard block
 block discarded – undo
765 765
     /**
766 766
      *
767 767
      */
768
-    protected function act_downloadSelected()
769
-    {
768
+    protected function act_downloadSelected()
769
+    {
770 770
         $dir = $this->postDir();
771 771
         if (!isset($this->post['dir']) ||
772 772
             !isset($this->post['files']) ||
773 773
             !is_array($this->post['files']) ||
774 774
             $this->config['denyZipDownload']
775
-        ) {
775
+        ) {
776 776
             $this->errorMsg("Unknown error.");
777 777
         }
778 778
 
779 779
         $zipFiles = array();
780
-        foreach ($this->post['files'] as $file) {
780
+        foreach ($this->post['files'] as $file) {
781 781
             $file = path::normalize($file);
782
-            if ((substr($file, 0, 1) == ".") || (strpos($file, '/') !== false)) {
782
+            if ((substr($file, 0, 1) == ".") || (strpos($file, '/') !== false)) {
783 783
                 continue;
784 784
             }
785 785
             $file = "$dir/$file";
786
-            if (!is_file($file) || !is_readable($file)) {
786
+            if (!is_file($file) || !is_readable($file)) {
787 787
                 continue;
788 788
             }
789 789
             $zipFiles[] = $file;
790 790
         }
791 791
 
792
-        do {
792
+        do {
793 793
             $file = md5(time() . session_id());
794 794
             $file = "{$this->config['uploadDir']}/$file.zip";
795 795
         } while (file_exists($file));
796 796
 
797 797
         $zip = new ZipArchive();
798 798
         $res = $zip->open($file, ZipArchive::CREATE);
799
-        if ($res === true) {
800
-            foreach ($zipFiles as $cfile) {
799
+        if ($res === true) {
800
+            foreach ($zipFiles as $cfile) {
801 801
                 $zip->addFile($cfile, basename($cfile));
802 802
             }
803 803
             $zip->close();
@@ -813,42 +813,42 @@  discard block
 block discarded – undo
813 813
     /**
814 814
      *
815 815
      */
816
-    protected function act_downloadClipboard()
817
-    {
816
+    protected function act_downloadClipboard()
817
+    {
818 818
         if (!isset($this->post['files']) ||
819 819
             !is_array($this->post['files']) ||
820 820
             $this->config['denyZipDownload']
821
-        ) {
821
+        ) {
822 822
             $this->errorMsg("Unknown error.");
823 823
         }
824 824
 
825 825
         $zipFiles = array();
826
-        foreach ($this->post['files'] as $file) {
826
+        foreach ($this->post['files'] as $file) {
827 827
             $file = path::normalize($file);
828
-            if ((substr($file, 0, 1) == ".")) {
828
+            if ((substr($file, 0, 1) == ".")) {
829 829
                 continue;
830 830
             }
831 831
             $type = explode("/", $file);
832 832
             $type = $type[0];
833
-            if ($type != $this->type) {
833
+            if ($type != $this->type) {
834 834
                 continue;
835 835
             }
836 836
             $file = $this->config['uploadDir'] . "/$file";
837
-            if (!is_file($file) || !is_readable($file)) {
837
+            if (!is_file($file) || !is_readable($file)) {
838 838
                 continue;
839 839
             }
840 840
             $zipFiles[] = $file;
841 841
         }
842 842
 
843
-        do {
843
+        do {
844 844
             $file = md5(time() . session_id());
845 845
             $file = "{$this->config['uploadDir']}/$file.zip";
846 846
         } while (file_exists($file));
847 847
 
848 848
         $zip = new ZipArchive();
849 849
         $res = $zip->open($file, ZipArchive::CREATE);
850
-        if ($res === true) {
851
-            foreach ($zipFiles as $cfile) {
850
+        if ($res === true) {
851
+            foreach ($zipFiles as $cfile) {
852 852
                 $zip->addFile($cfile, basename($cfile));
853 853
             }
854 854
             $zip->close();
@@ -866,13 +866,13 @@  discard block
 block discarded – undo
866 866
      * @param $dir
867 867
      * @return array
868 868
      */
869
-    protected function moveUploadFile($file, $dir)
870
-    {
869
+    protected function moveUploadFile($file, $dir)
870
+    {
871 871
         $response = array('success' => false, 'message' => $this->label('Unknown error.'));
872 872
         $message = $this->checkUploadedFile($file);
873 873
 
874
-        if ($message !== true) {
875
-            if (isset($file['tmp_name'])) {
874
+        if ($message !== true) {
875
+            if (isset($file['tmp_name'])) {
876 876
                 @unlink($file['tmp_name']);
877 877
             }
878 878
             $response['message'] = $message;
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
             'filepath' => realpath($dir)
886 886
         ));
887 887
 
888
-        if (is_array($evtOut) && !empty($evtOut)) {
888
+        if (is_array($evtOut) && !empty($evtOut)) {
889 889
             $response['message'] = $evtOut;
890 890
 
891 891
             return $response;
@@ -896,13 +896,13 @@  discard block
 block discarded – undo
896 896
         if (!@move_uploaded_file($file['tmp_name'], $target) &&
897 897
             !@rename($file['tmp_name'], $target) &&
898 898
             !@copy($file['tmp_name'], $target)
899
-        ) {
899
+        ) {
900 900
             @unlink($file['tmp_name']);
901 901
 
902 902
             $response['message'] = $this->label("Cannot move uploaded file to target folder.");
903 903
 
904 904
             return $response;
905
-        } elseif (function_exists('chmod')) {
905
+        } elseif (function_exists('chmod')) {
906 906
             chmod($target, $this->config['filePerms']);
907 907
         }
908 908
 
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
     /**
921 921
      * @param null $file
922 922
      */
923
-    protected function sendDefaultThumb($file = null)
924
-    {
925
-        if ($file !== null) {
923
+    protected function sendDefaultThumb($file = null)
924
+    {
925
+        if ($file !== null) {
926 926
             $ext = file::getExtension($file);
927 927
             $thumb = "themes/{$this->config['theme']}/img/files/big/$ext.png";
928 928
         }
929
-        if (!isset($thumb) || !file_exists($thumb)) {
929
+        if (!isset($thumb) || !file_exists($thumb)) {
930 930
             $thumb = "themes/{$this->config['theme']}/img/files/big/..png";
931 931
         }
932 932
         header("Content-Type: image/png");
@@ -938,27 +938,27 @@  discard block
 block discarded – undo
938 938
      * @param $dir
939 939
      * @return array
940 940
      */
941
-    protected function getFiles($dir)
942
-    {
941
+    protected function getFiles($dir)
942
+    {
943 943
         $thumbDir = "{$this->config['uploadDir']}/{$this->config['thumbsDir']}/$dir";
944 944
         $dir = "{$this->config['uploadDir']}/$dir";
945 945
         $return = array();
946 946
         $files = dir::content($dir, array('types' => "file"));
947
-        if ($files === false) {
947
+        if ($files === false) {
948 948
             return $return;
949 949
         }
950 950
 
951
-        foreach ($files as $file) {
951
+        foreach ($files as $file) {
952 952
             $ext = file::getExtension($file);
953 953
             $smallThumb = false;
954 954
             $preview = false;
955
-            if (in_array(strtolower($ext), array('png', 'jpg', 'gif', 'jpeg'))) {
955
+            if (in_array(strtolower($ext), array('png', 'jpg', 'gif', 'jpeg'))) {
956 956
                 $size = @getimagesize($file);
957
-                if (is_array($size) && count($size)) {
957
+                if (is_array($size) && count($size)) {
958 958
                     $preview = true;
959
-                    if (!$this->config['noThumbnailsRecreation']) {
959
+                    if (!$this->config['noThumbnailsRecreation']) {
960 960
                         $thumb_file = "$thumbDir/" . basename($file);
961
-                        if (!is_file($thumb_file) || filemtime($file) > filemtime($thumb_file)) {
961
+                        if (!is_file($thumb_file) || filemtime($file) > filemtime($thumb_file)) {
962 962
                             $this->makeThumb($file);
963 963
                         }
964 964
                         $smallThumb =
@@ -969,16 +969,16 @@  discard block
 block discarded – undo
969 969
                 }
970 970
             }
971 971
             $stat = stat($file);
972
-            if ($stat === false) {
972
+            if ($stat === false) {
973 973
                 continue;
974 974
             }
975 975
             $name = basename($file);
976 976
             $types = $this->config['types'];
977 977
             $types = explode(' ', $types['images'] . ' ' . $types['image']);
978
-            if (substr($name, 0, 1) == '.' && !$this->config['showHiddenFiles']) {
978
+            if (substr($name, 0, 1) == '.' && !$this->config['showHiddenFiles']) {
979 979
                 continue;
980 980
             }
981
-            if ($this->type == 'images' && !in_array(strtolower($ext), $types)) {
981
+            if ($this->type == 'images' && !in_array(strtolower($ext), $types)) {
982 982
                 continue;
983 983
             }
984 984
             $bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/$ext.png");
@@ -1007,15 +1007,15 @@  discard block
 block discarded – undo
1007 1007
      * @param int $index
1008 1008
      * @return array|bool
1009 1009
      */
1010
-    protected function getTree($dir, $index = 0)
1011
-    {
1010
+    protected function getTree($dir, $index = 0)
1011
+    {
1012 1012
         $path = explode("/", $dir);
1013 1013
 
1014 1014
         $pdir = "";
1015
-        for ($i = 0; ($i <= $index && $i < count($path)); $i++) {
1015
+        for ($i = 0; ($i <= $index && $i < count($path)); $i++) {
1016 1016
             $pdir .= "/{$path[$i]}";
1017 1017
         }
1018
-        if (strlen($pdir)) {
1018
+        if (strlen($pdir)) {
1019 1019
             $pdir = substr($pdir, 1);
1020 1020
         }
1021 1021
 
@@ -1023,23 +1023,23 @@  discard block
 block discarded – undo
1023 1023
 
1024 1024
         $dirs = $this->getDirs($fdir);
1025 1025
 
1026
-        if (is_array($dirs) && count($dirs) && ($index <= count($path) - 1)) {
1026
+        if (is_array($dirs) && count($dirs) && ($index <= count($path) - 1)) {
1027 1027
 
1028
-            foreach ($dirs as $i => $cdir) {
1028
+            foreach ($dirs as $i => $cdir) {
1029 1029
                 if ($cdir['hasDirs'] &&
1030 1030
                     (
1031 1031
                         ($index == count($path) - 1) ||
1032 1032
                         ($cdir['name'] == $path[$index + 1])
1033 1033
                     )
1034
-                ) {
1034
+                ) {
1035 1035
                     $dirs[$i]['dirs'] = $this->getTree($dir, $index + 1);
1036
-                    if (!is_array($dirs[$i]['dirs']) || !count($dirs[$i]['dirs'])) {
1036
+                    if (!is_array($dirs[$i]['dirs']) || !count($dirs[$i]['dirs'])) {
1037 1037
                         unset($dirs[$i]['dirs']);
1038 1038
                         continue;
1039 1039
                     }
1040 1040
                 }
1041 1041
             }
1042
-        } else {
1042
+        } else {
1043 1043
             return false;
1044 1044
         }
1045 1045
 
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
      * @param bool $existent
1051 1051
      * @return string
1052 1052
      */
1053
-    protected function postDir($existent = true)
1054
-    {
1053
+    protected function postDir($existent = true)
1054
+    {
1055 1055
         $dir = $this->typeDir;
1056
-        if (isset($this->post['dir'])) {
1056
+        if (isset($this->post['dir'])) {
1057 1057
             $dir .= "/" . $this->post['dir'];
1058 1058
         }
1059
-        if ($existent && (!is_dir($dir) || !is_readable($dir))) {
1059
+        if ($existent && (!is_dir($dir) || !is_readable($dir))) {
1060 1060
             $this->errorMsg("Inexistant or inaccessible folder.");
1061 1061
         }
1062 1062
 
@@ -1067,13 +1067,13 @@  discard block
 block discarded – undo
1067 1067
      * @param bool $existent
1068 1068
      * @return string
1069 1069
      */
1070
-    protected function getDir($existent = true)
1071
-    {
1070
+    protected function getDir($existent = true)
1071
+    {
1072 1072
         $dir = $this->typeDir;
1073
-        if (isset($this->get['dir'])) {
1073
+        if (isset($this->get['dir'])) {
1074 1074
             $dir .= "/" . $this->get['dir'];
1075 1075
         }
1076
-        if ($existent && (!is_dir($dir) || !is_readable($dir))) {
1076
+        if ($existent && (!is_dir($dir) || !is_readable($dir))) {
1077 1077
             $this->errorMsg("Inexistant or inaccessible folder.");
1078 1078
         }
1079 1079
 
@@ -1084,15 +1084,15 @@  discard block
 block discarded – undo
1084 1084
      * @param $dir
1085 1085
      * @return array
1086 1086
      */
1087
-    protected function getDirs($dir)
1088
-    {
1087
+    protected function getDirs($dir)
1088
+    {
1089 1089
         $dirs = dir::content($dir, array('types' => "dir"));
1090 1090
         $return = array();
1091
-        if (is_array($dirs)) {
1091
+        if (is_array($dirs)) {
1092 1092
             $writable = dir::isWritable($dir);
1093
-            foreach ($dirs as $cdir) {
1093
+            foreach ($dirs as $cdir) {
1094 1094
                 $info = $this->getDirInfo($cdir);
1095
-                if ($info === false) {
1095
+                if ($info === false) {
1096 1096
                     continue;
1097 1097
                 }
1098 1098
                 $info['removable'] = $writable && $info['writable'];
@@ -1108,20 +1108,20 @@  discard block
 block discarded – undo
1108 1108
      * @param bool $removable
1109 1109
      * @return array|bool
1110 1110
      */
1111
-    protected function getDirInfo($dir, $removable = false)
1112
-    {
1113
-        if ((substr(basename($dir), 0, 1) == ".") || !is_dir($dir) || !is_readable($dir)) {
1111
+    protected function getDirInfo($dir, $removable = false)
1112
+    {
1113
+        if ((substr(basename($dir), 0, 1) == ".") || !is_dir($dir) || !is_readable($dir)) {
1114 1114
             return false;
1115 1115
         }
1116 1116
         $dirs = dir::content($dir, array('types' => "dir"));
1117
-        if (is_array($dirs)) {
1118
-            foreach ($dirs as $key => $cdir) {
1119
-                if (substr(basename($cdir), 0, 1) == ".") {
1117
+        if (is_array($dirs)) {
1118
+            foreach ($dirs as $key => $cdir) {
1119
+                if (substr(basename($cdir), 0, 1) == ".") {
1120 1120
                     unset($dirs[$key]);
1121 1121
                 }
1122 1122
             }
1123 1123
             $hasDirs = count($dirs) ? true : false;
1124
-        } else {
1124
+        } else {
1125 1125
             $hasDirs = false;
1126 1126
         }
1127 1127
 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
             'hasDirs'   => $hasDirs
1135 1135
         );
1136 1136
 
1137
-        if ($dir == "{$this->config['uploadDir']}/{$this->session['dir']}") {
1137
+        if ($dir == "{$this->config['uploadDir']}/{$this->session['dir']}") {
1138 1138
             $info['current'] = true;
1139 1139
         }
1140 1140
 
@@ -1146,21 +1146,21 @@  discard block
 block discarded – undo
1146 1146
      * @param null $template
1147 1147
      * @return string
1148 1148
      */
1149
-    protected function output($data = null, $template = null)
1150
-    {
1151
-        if (!is_array($data)) {
1149
+    protected function output($data = null, $template = null)
1150
+    {
1151
+        if (!is_array($data)) {
1152 1152
             $data = array();
1153 1153
         }
1154
-        if ($template === null) {
1154
+        if ($template === null) {
1155 1155
             $template = $this->action;
1156 1156
         }
1157 1157
 
1158
-        if (file_exists("tpl/tpl_$template.php")) {
1158
+        if (file_exists("tpl/tpl_$template.php")) {
1159 1159
             ob_start();
1160 1160
             $eval = "unset(\$data);unset(\$template);unset(\$eval);";
1161 1161
             $_ = $data;
1162
-            foreach (array_keys($data) as $key) {
1163
-                if (preg_match('/^[a-z\d_]+$/i', $key)) {
1162
+            foreach (array_keys($data) as $key) {
1163
+                if (preg_match('/^[a-z\d_]+$/i', $key)) {
1164 1164
                     $eval .= "\$$key=\$_['$key'];";
1165 1165
                 }
1166 1166
             }
@@ -1177,14 +1177,14 @@  discard block
 block discarded – undo
1177 1177
      * @param $message
1178 1178
      * @param array|null $data
1179 1179
      */
1180
-    protected function errorMsg($message, array $data = null)
1181
-    {
1182
-        if (in_array($this->action, array("thumb", "upload", "download", "downloadDir"))) {
1180
+    protected function errorMsg($message, array $data = null)
1181
+    {
1182
+        if (in_array($this->action, array("thumb", "upload", "download", "downloadDir"))) {
1183 1183
             die($this->label($message, $data));
1184 1184
         }
1185
-        if (($this->action === null) || ($this->action == "browser")) {
1185
+        if (($this->action === null) || ($this->action == "browser")) {
1186 1186
             $this->backMsg($message, $data);
1187
-        } else {
1187
+        } else {
1188 1188
             $message = $this->label($message, $data);
1189 1189
             die(json_encode(array('error' => $message)));
1190 1190
         }
Please login to merge, or discard this patch.
manager/views/frame/1.blade.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
                 mail_check_timeperiod: {{ $modx->getConfig('mail_check_timeperiod') }},
38 38
                 menu_height: {{ (int)$modx->getConfig('manager_menu_height') }},
39 39
                 tree_width: {{ (int)$MODX_widthSideBar }},
40
-                tree_min_width: <?= (int)$tree_min_width ?>,
41
-                session_timeout: <?= (int)$modx->getConfig('session_timeout') ?>,
42
-                site_start: <?= (int)$modx->getConfig('site_start') ?>,
40
+                tree_min_width: <?= (int) $tree_min_width ?>,
41
+                session_timeout: <?= (int) $modx->getConfig('session_timeout') ?>,
42
+                site_start: <?= (int) $modx->getConfig('site_start') ?>,
43 43
                 tree_page_click: {{ $modx->getConfig('tree_page_click') }},
44 44
                 theme: '{{ ManagerTheme::getTheme() }}',
45 45
                 theme_mode: '{{ ManagerTheme::getThemeStyle() }}',
46 46
                 which_browser: '<?= $user['which_browser'] ?>',
47
-                layout: <?= (int)$modx->getConfig('manager_layout') ?>,
47
+                layout: <?= (int) $modx->getConfig('manager_layout') ?>,
48 48
                 textdir: '<?= ManagerTheme::getTextDir() ?>',
49 49
                 global_tabs: <?= $modx->getConfig('global_tabs') ?>
50 50
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                 delete a[b];
130 130
             },
131 131
             openedArray: [],
132
-            lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE) . "\n" ?>
132
+            lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE)."\n" ?>
133 133
         };
134 134
         <?php
135 135
         $opened = array_filter(
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 )
142 142
             )
143 143
         );
144
-        echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n		modx.openedArray[", $opened) . '] = 1;') . "\n";
144
+        echo (empty($opened) ? '' : 'modx.openedArray['.implode("] = 1;\n		modx.openedArray[", $opened).'] = 1;')."\n";
145 145
         ?>
146 146
     </script>
147 147
     <script src="{{ ManagerTheme::getThemeUrl() }}js/modx.min.js?v=<?= EVO_INSTALL_TIME ?>"></script>
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
                             <a href="javascript:;" class="dropdown-toggle" onclick="return false;">
222 222
                                 <span class="username"><?= entities($user['username'], $modx->getConfig('modx_charset')) ?></span>
223 223
                                 <?php if ($user['photo']) { ?>
224
-                                <span class="icon photo" style="background-image: url(<?= MODX_SITE_URL . entities($user['photo'], $modx->getConfig('modx_charset')) ?>);"></span>
224
+                                <span class="icon photo" style="background-image: url(<?= MODX_SITE_URL.entities($user['photo'], $modx->getConfig('modx_charset')) ?>);"></span>
225 225
                                 <?php } else { ?>
226 226
                                 <span class="icon"><i class="fa fa-user-circle"></i></span>
227 227
                                 <?php } ?>
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                                 $version = 'Evolution';
249 249
                                 ?>
250 250
                                 <?php
251
-                                echo sprintf('<li><span class="dropdown-item" title="%s &ndash; %s" %s>' . $version . ' %s</span></li>', $modx->getPhpCompat()->entities($modx->getConfig('site_name')), $modx->getVersionData('full_appname'), $style, $modx->getConfig('settings_version'));
251
+                                echo sprintf('<li><span class="dropdown-item" title="%s &ndash; %s" %s>'.$version.' %s</span></li>', $modx->getPhpCompat()->entities($modx->getConfig('site_name')), $modx->getVersionData('full_appname'), $style, $modx->getConfig('settings_version'));
252 252
                                 ?>
253 253
                             </ul>
254 254
                         </li>
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         <?php
316 316
         // invoke OnManagerTreeInit event
317 317
         $evtOut = $modx->invokeEvent('OnManagerTreeInit', $_REQUEST);
318
-        if(is_array($evtOut)) {
318
+        if (is_array($evtOut)) {
319 319
             echo implode("\n", $evtOut);
320 320
         }
321 321
         ?>
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
                 <a class="treeButton" id="treeMenu_collapsetree" onclick="modx.tree.collapseTree();" title="<?php echo $_lang['collapse_tree']; ?>"><i class="fa fa-arrow-circle-up"></i></a>
329 329
 
330
-                <?php if($modx->hasPermission('new_document')) { ?>
330
+                <?php if ($modx->hasPermission('new_document')) { ?>
331 331
                 <a class="treeButton" id="treeMenu_addresource" onclick="modx.tabs({url:'<?= MODX_MANAGER_URL ?>?a=4', title: '<?php echo $_lang['add_resource']; ?>'});" title="<?php echo $_lang['add_resource']; ?>"><i class="fa fa-file"></i></a>
332 332
                 <a class="treeButton" id="treeMenu_addweblink" onclick="modx.tabs({url:'<?= MODX_MANAGER_URL ?>?a=72', title: '<?php echo $_lang['add_weblink']; ?>'});" title="<?php echo $_lang['add_weblink']; ?>"><i class="fa fa-link"></i></a>
333 333
                 <?php } ?>
@@ -336,23 +336,23 @@  discard block
 block discarded – undo
336 336
 
337 337
                 <a class="treeButton" id="treeMenu_sortingtree" onclick="modx.tree.showSorter(event);" title="<?php echo $_lang['sort_tree']; ?>"><i class="fa fa-sort"></i></a>
338 338
 
339
-                <?php if($modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) { ?>
339
+                <?php if ($modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) { ?>
340 340
                 <a class="treeButton" id="treeMenu_sortingindex" onclick="modx.tabs({url: '<?= MODX_MANAGER_URL ?>?a=56&id=0', title: '<?php echo $_lang['sort_menuindex']; ?>'});" title="<?php echo $_lang['sort_menuindex']; ?>"><i class="fa fa-sort-numeric-asc"></i></a>
341 341
                 <?php } ?>
342 342
 
343 343
                 @if($modx->getConfig('use_browser') && $modx->hasPermission('assets_images'))
344
-                <a class="treeButton" id="treeMenu_openimages" title="<?php echo $_lang["images_management"] . "\n" . $_lang['em_button_shift'] ?>"><i class="fa fa-camera"></i></a>
344
+                <a class="treeButton" id="treeMenu_openimages" title="<?php echo $_lang["images_management"]."\n".$_lang['em_button_shift'] ?>"><i class="fa fa-camera"></i></a>
345 345
                 @endif
346 346
 
347 347
                 @if($modx->getConfig('use_browser') && $modx->hasPermission('assets_files'))
348
-                <a class="treeButton" id="treeMenu_openfiles" title="<?php echo $_lang["files_management"] . "\n" . $_lang['em_button_shift'] ?>"><i class="fa fa-files-o"></i></a>
348
+                <a class="treeButton" id="treeMenu_openfiles" title="<?php echo $_lang["files_management"]."\n".$_lang['em_button_shift'] ?>"><i class="fa fa-files-o"></i></a>
349 349
                 @endif
350 350
 
351
-                <?php if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?>
352
-                <a class="treeButton" id="treeMenu_openelements" title="<?php echo $_lang["element_management"] . "\n" . $_lang['em_button_shift'] ?>"><i class="fa fa-th"></i></a>
351
+                <?php if ($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?>
352
+                <a class="treeButton" id="treeMenu_openelements" title="<?php echo $_lang["element_management"]."\n".$_lang['em_button_shift'] ?>"><i class="fa fa-th"></i></a>
353 353
                 <?php } ?>
354 354
 
355
-                <?php if($modx->hasPermission('empty_trash')) { ?>
355
+                <?php if ($modx->hasPermission('empty_trash')) { ?>
356 356
                 <a class="treeButton treeButtonDisabled" id="treeMenu_emptytrash" title="<?php echo $_lang['empty_recycle_bin_empty']; ?>"><i class="fa fa-trash-o"></i></a>
357 357
                 <?php } ?>
358 358
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                 <?php
365 365
                 // invoke OnManagerTreePrerender event
366 366
                 $evtOut = $modx->invokeEvent('OnManagerTreePrerender', $modx->getDatabase()->escape($_REQUEST));
367
-                if(is_array($evtOut)) {
367
+                if (is_array($evtOut)) {
368 368
                     echo implode("\n", $evtOut);
369 369
                 }
370 370
                 $siteName = $modx->getPhpCompat()->entities($modx->getConfig('site_name'));
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                 <?php
377 377
                 // invoke OnManagerTreeRender event
378 378
                 $evtOut = $modx->invokeEvent('OnManagerTreeRender', $modx->getDatabase()->escape($_REQUEST));
379
-                if(is_array($evtOut)) {
379
+                if (is_array($evtOut)) {
380 380
                     echo implode("\n", $evtOut);
381 381
                 }
382 382
                 ?>
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     </div>
471 471
 
472 472
 <?php
473
-if(!function_exists('constructLink')) {
473
+if (!function_exists('constructLink')) {
474 474
     /**
475 475
      * @param string $action
476 476
      * @param string $img
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
      */
480 480
     function constructLink($action, $img, $text, $allowed)
481 481
     {
482
-        if ((bool)$allowed) {
482
+        if ((bool) $allowed) {
483 483
             echo sprintf('<div class="menuLink" id="item%s" onclick="modx.tree.menuHandler(%s);">', $action,
484 484
                 $action);
485 485
             echo sprintf('<i class="%s"></i> %s</div>', $img, $text);
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
     <script type="text/javascript">
521 521
 
522 522
         if (document.getElementById('treeMenu')) {
523
-            <?php if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?>
523
+            <?php if ($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?>
524 524
 
525 525
             document.getElementById('treeMenu_openelements').onclick = function(e) {
526 526
                 e.preventDefault();
Please login to merge, or discard this patch.
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     <?php
154 154
     // invoke OnManagerTopPrerender event
155 155
     $evtOut = $modx->invokeEvent('OnManagerTopPrerender', $_REQUEST);
156
-    if (is_array($evtOut)) {
156
+    if (is_array($evtOut)) {
157 157
         echo implode("\n", $evtOut);
158 158
     }
159 159
     ?>
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         <?php
316 316
         // invoke OnManagerTreeInit event
317 317
         $evtOut = $modx->invokeEvent('OnManagerTreeInit', $_REQUEST);
318
-        if(is_array($evtOut)) {
318
+        if(is_array($evtOut)) {
319 319
             echo implode("\n", $evtOut);
320 320
         }
321 321
         ?>
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                 <?php
365 365
                 // invoke OnManagerTreePrerender event
366 366
                 $evtOut = $modx->invokeEvent('OnManagerTreePrerender', $modx->getDatabase()->escape($_REQUEST));
367
-                if(is_array($evtOut)) {
367
+                if(is_array($evtOut)) {
368 368
                     echo implode("\n", $evtOut);
369 369
                 }
370 370
                 $siteName = $modx->getPhpCompat()->entities($modx->getConfig('site_name'));
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                 <?php
377 377
                 // invoke OnManagerTreeRender event
378 378
                 $evtOut = $modx->invokeEvent('OnManagerTreeRender', $modx->getDatabase()->escape($_REQUEST));
379
-                if(is_array($evtOut)) {
379
+                if(is_array($evtOut)) {
380 380
                     echo implode("\n", $evtOut);
381 381
                 }
382 382
                 ?>
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
             'tree_sortdir',
415 415
             'tree_nodename'
416 416
         );
417
-        foreach ($sortParams as $param) {
418
-            if (isset($_REQUEST[$param])) {
417
+        foreach ($sortParams as $param) {
418
+            if (isset($_REQUEST[$param])) {
419 419
                 $modx->getManagerApi()->saveLastUserSetting($param, $_REQUEST[$param]);
420 420
                 $_SESSION[$param] = $_REQUEST[$param];
421
-            } else if (!isset($_SESSION[$param])) {
421
+            } else if (!isset($_SESSION[$param])) {
422 422
                 $_SESSION[$param] = $modx->getManagerApi()->getLastUserSetting($param);
423 423
             }
424 424
         }
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
     </div>
471 471
 
472 472
 <?php
473
-if(!function_exists('constructLink')) {
473
+if(!function_exists('constructLink')) {
474 474
     /**
475 475
      * @param string $action
476 476
      * @param string $img
477 477
      * @param string $text
478 478
      * @param bool $allowed
479 479
      */
480
-    function constructLink($action, $img, $text, $allowed)
481
-    {
482
-        if ((bool)$allowed) {
480
+    function constructLink($action, $img, $text, $allowed)
481
+    {
482
+        if ((bool)$allowed) {
483 483
             echo sprintf('<div class="menuLink" id="item%s" onclick="modx.tree.menuHandler(%s);">', $action,
484 484
                 $action);
485 485
             echo sprintf('<i class="%s"></i> %s</div>', $img, $text);
Please login to merge, or discard this patch.
manager/views/partials/footer.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 global $SystemAlertMsgQueque;
3 3
 // display system alert window if messages are available
4 4
 if (count($SystemAlertMsgQueque) > 0) {
5
-    include MODX_MANAGER_PATH . 'includes/sysalert.display.inc.php';
5
+    include MODX_MANAGER_PATH.'includes/sysalert.display.inc.php';
6 6
 }
7 7
 ?>
8 8
 @stack('scripts.bot')
Please login to merge, or discard this patch.
manager/views/page/4.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php /** get the mutate page for adding content */ ?>
2 2
 @extends('manager::template.page')
3 3
 @section('content')
4
-    <?php include_once evolutionCMS()->get('ManagerTheme')->getFileProcessor("actions/mutate_content.dynamic.php");?>
4
+    <?php include_once evolutionCMS()->get('ManagerTheme')->getFileProcessor("actions/mutate_content.dynamic.php"); ?>
5 5
 @endsection
Please login to merge, or discard this patch.