Completed
Push — develop ( 6c715c...e575c7 )
by Dmytro
13s
created
manager/media/browser/mcpuk/lib/helper_path.php 3 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Path helper class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Path helper class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class path {
16 16
 
17
-  /** Get the absolute URL path of the given one. Returns FALSE if the URL
18
-    * is not valid or the current directory cannot be resolved (getcwd())
19
-    * @param string $path
20
-    * @return string */
17
+    /** Get the absolute URL path of the given one. Returns FALSE if the URL
18
+     * is not valid or the current directory cannot be resolved (getcwd())
19
+     * @param string $path
20
+     * @return string */
21 21
 
22 22
     static function rel2abs_url($path) {
23 23
         if (substr($path, 0, 1) == "/") return $path;
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
         return $return;
40 40
     }
41 41
 
42
-  /** Resolve full filesystem path of given URL. Returns FALSE if the URL
43
-    * cannot be resolved
44
-    * @param string $url
45
-    * @return string */
42
+    /** Resolve full filesystem path of given URL. Returns FALSE if the URL
43
+     * cannot be resolved
44
+     * @param string $url
45
+     * @return string */
46 46
 
47 47
     static function url2fullPath($url) {
48 48
         $url = self::normalize($url);
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
         }
85 85
     }
86 86
 
87
-  /** Normalize the given path. On Windows servers backslash will be replaced
88
-    * with slash. Remobes unnecessary doble slashes and double dots. Removes
89
-    * last slash if it exists. Examples:
90
-    * path::normalize("C:\\any\\path\\") returns "C:/any/path"
91
-    * path::normalize("/your/path/..//home/") returns "/your/home"
92
-    * @param string $path
93
-    * @return string */
87
+    /** Normalize the given path. On Windows servers backslash will be replaced
88
+     * with slash. Remobes unnecessary doble slashes and double dots. Removes
89
+     * last slash if it exists. Examples:
90
+     * path::normalize("C:\\any\\path\\") returns "C:/any/path"
91
+     * path::normalize("/your/path/..//home/") returns "/your/home"
92
+     * @param string $path
93
+     * @return string */
94 94
 
95 95
     static function normalize($path) {
96 96
         if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
         return $path;
115 115
     }
116 116
 
117
-  /** Encode URL Path
118
-    * @param string $path
119
-    * @return string */
117
+    /** Encode URL Path
118
+     * @param string $path
119
+     * @return string */
120 120
 
121 121
     static function urlPathEncode($path) {
122 122
         $path = self::normalize($path);
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
         return $encoded;
128 128
     }
129 129
 
130
-  /** Decode URL Path
131
-    * @param string $path
132
-    * @return string */
130
+    /** Decode URL Path
131
+     * @param string $path
132
+     * @return string */
133 133
 
134 134
     static function urlPathDecode($path) {
135 135
         $path = self::normalize($path);
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class path {
15
+class path{
16 16
 
17 17
   /** Get the absolute URL path of the given one. Returns FALSE if the URL
18 18
     * is not valid or the current directory cannot be resolved (getcwd())
19 19
     * @param string $path
20 20
     * @return string */
21 21
 
22
-    static function rel2abs_url($path) {
22
+    static function rel2abs_url($path){
23 23
         if (substr($path, 0, 1) == "/") return $path;
24 24
         $dir = @getcwd();
25 25
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         if (substr($dir, 0, strlen($doc_root)) != $doc_root)
33 33
             return false;
34 34
 
35
-        $return = self::normalize(substr($dir, strlen($doc_root)) . "/$path");
35
+        $return = self::normalize(substr($dir, strlen($doc_root))."/$path");
36 36
         if (substr($return, 0, 1) !== "/")
37 37
             $return = "/$return";
38 38
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     * @param string $url
45 45
     * @return string */
46 46
 
47
-    static function url2fullPath($url) {
47
+    static function url2fullPath($url){
48 48
         $url = self::normalize($url);
49 49
 
50 50
         $uri = isset($_SERVER['SCRIPT_NAME'])
@@ -56,18 +56,18 @@  discard block
 block discarded – undo
56 56
 
57 57
         if (substr($url, 0, 1) !== "/") {
58 58
             if ($uri === false) return false;
59
-            $url = dirname($uri) . "/$url";
59
+            $url = dirname($uri)."/$url";
60 60
         }
61 61
 
62 62
         if (isset($_SERVER['DOCUMENT_ROOT'])) {
63
-            return self::normalize($_SERVER['DOCUMENT_ROOT'] . "/$url");
63
+            return self::normalize($_SERVER['DOCUMENT_ROOT']."/$url");
64 64
 
65 65
         } else {
66 66
             if ($uri === false) return false;
67 67
 
68 68
             if (isset($_SERVER['SCRIPT_FILENAME'])) {
69 69
                 $scr_filename = self::normalize($_SERVER['SCRIPT_FILENAME']);
70
-                return self::normalize(substr($scr_filename, 0, -strlen($uri)) . "/$url");
70
+                return self::normalize(substr($scr_filename, 0, -strlen($uri))."/$url");
71 71
             }
72 72
 
73 73
             $count = count(explode('/', $uri)) - 1;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 return false;
81 81
             $rdir = getcwd();
82 82
             chdir($dir);
83
-            return ($rdir !== false) ? self::normalize($rdir . "/$url") : false;
83
+            return ($rdir !== false) ? self::normalize($rdir."/$url") : false;
84 84
         }
85 85
     }
86 86
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
     * @param string $path
93 93
     * @return string */
94 94
 
95
-    static function normalize($path) {
95
+    static function normalize($path){
96 96
         if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
97 97
             $path = preg_replace('/([^\\\])\\\([^\\\])/', "$1/$2", $path);
98 98
             if (substr($path, -1) == "\\") $path = substr($path, 0, -1);
99
-            if (substr($path, 0, 1) == "\\") $path = "/" . substr($path, 1);
99
+            if (substr($path, 0, 1) == "\\") $path = "/".substr($path, 1);
100 100
         }
101 101
 
102 102
         $path = preg_replace('/\/+/s', "/", $path);
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
     * @param string $path
119 119
     * @return string */
120 120
 
121
-    static function urlPathEncode($path) {
121
+    static function urlPathEncode($path){
122 122
         $path = self::normalize($path);
123 123
         $encoded = "";
124 124
         foreach (explode("/", $path) as $dir)
125
-            $encoded .= rawurlencode($dir) . "/";
125
+            $encoded .= rawurlencode($dir)."/";
126 126
         $encoded = substr($encoded, 0, -1);
127 127
         return $encoded;
128 128
     }
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
     * @param string $path
132 132
     * @return string */
133 133
 
134
-    static function urlPathDecode($path) {
134
+    static function urlPathDecode($path){
135 135
         $path = self::normalize($path);
136 136
         $decoded = "";
137 137
         foreach (explode("/", $path) as $dir)
138
-            $decoded .= rawurldecode($dir) . "/";
138
+            $decoded .= rawurldecode($dir)."/";
139 139
         $decoded = substr($decoded, 0, -1);
140 140
         return $decoded;
141 141
     }
Please login to merge, or discard this patch.
Braces   +54 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,29 +12,36 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class path {
15
+class path
16
+{
16 17
 
17 18
   /** Get the absolute URL path of the given one. Returns FALSE if the URL
18 19
     * is not valid or the current directory cannot be resolved (getcwd())
19 20
     * @param string $path
20 21
     * @return string */
21 22
 
22
-    static function rel2abs_url($path) {
23
-        if (substr($path, 0, 1) == "/") return $path;
23
+    static function rel2abs_url($path)
24
+    {
25
+        if (substr($path, 0, 1) == "/") {
26
+            return $path;
27
+        }
24 28
         $dir = @getcwd();
25 29
 
26
-        if (!isset($_SERVER['DOCUMENT_ROOT']) || ($dir === false))
27
-            return false;
30
+        if (!isset($_SERVER['DOCUMENT_ROOT']) || ($dir === false)) {
31
+                    return false;
32
+        }
28 33
 
29 34
         $dir = self::normalize($dir);
30 35
         $doc_root = self::normalize($_SERVER['DOCUMENT_ROOT']);
31 36
 
32
-        if (substr($dir, 0, strlen($doc_root)) != $doc_root)
33
-            return false;
37
+        if (substr($dir, 0, strlen($doc_root)) != $doc_root) {
38
+                    return false;
39
+        }
34 40
 
35 41
         $return = self::normalize(substr($dir, strlen($doc_root)) . "/$path");
36
-        if (substr($return, 0, 1) !== "/")
37
-            $return = "/$return";
42
+        if (substr($return, 0, 1) !== "/") {
43
+                    $return = "/$return";
44
+        }
38 45
 
39 46
         return $return;
40 47
     }
@@ -44,7 +51,8 @@  discard block
 block discarded – undo
44 51
     * @param string $url
45 52
     * @return string */
46 53
 
47
-    static function url2fullPath($url) {
54
+    static function url2fullPath($url)
55
+    {
48 56
         $url = self::normalize($url);
49 57
 
50 58
         $uri = isset($_SERVER['SCRIPT_NAME'])
@@ -55,7 +63,9 @@  discard block
 block discarded – undo
55 63
         $uri = self::normalize($uri);
56 64
 
57 65
         if (substr($url, 0, 1) !== "/") {
58
-            if ($uri === false) return false;
66
+            if ($uri === false) {
67
+                return false;
68
+            }
59 69
             $url = dirname($uri) . "/$url";
60 70
         }
61 71
 
@@ -63,7 +73,9 @@  discard block
 block discarded – undo
63 73
             return self::normalize($_SERVER['DOCUMENT_ROOT'] . "/$url");
64 74
 
65 75
         } else {
66
-            if ($uri === false) return false;
76
+            if ($uri === false) {
77
+                return false;
78
+            }
67 79
 
68 80
             if (isset($_SERVER['SCRIPT_FILENAME'])) {
69 81
                 $scr_filename = self::normalize($_SERVER['SCRIPT_FILENAME']);
@@ -71,13 +83,15 @@  discard block
 block discarded – undo
71 83
             }
72 84
 
73 85
             $count = count(explode('/', $uri)) - 1;
74
-            for ($i = 0, $chdir = ""; $i < $count; $i++)
75
-                $chdir .= "../";
86
+            for ($i = 0, $chdir = ""; $i < $count; $i++) {
87
+                            $chdir .= "../";
88
+            }
76 89
             $chdir = self::normalize($chdir);
77 90
 
78 91
             $dir = getcwd();
79
-            if (($dir === false) || !@chdir($chdir))
80
-                return false;
92
+            if (($dir === false) || !@chdir($chdir)) {
93
+                            return false;
94
+            }
81 95
             $rdir = getcwd();
82 96
             chdir($dir);
83 97
             return ($rdir !== false) ? self::normalize($rdir . "/$url") : false;
@@ -92,22 +106,29 @@  discard block
 block discarded – undo
92 106
     * @param string $path
93 107
     * @return string */
94 108
 
95
-    static function normalize($path) {
109
+    static function normalize($path)
110
+    {
96 111
         if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
97 112
             $path = preg_replace('/([^\\\])\\\([^\\\])/', "$1/$2", $path);
98
-            if (substr($path, -1) == "\\") $path = substr($path, 0, -1);
99
-            if (substr($path, 0, 1) == "\\") $path = "/" . substr($path, 1);
113
+            if (substr($path, -1) == "\\") {
114
+                $path = substr($path, 0, -1);
115
+            }
116
+            if (substr($path, 0, 1) == "\\") {
117
+                $path = "/" . substr($path, 1);
118
+            }
100 119
         }
101 120
 
102 121
         $path = preg_replace('/\/+/s', "/", $path);
103 122
 
104 123
         $path = "/$path";
105
-        if (substr($path, -1) != "/")
106
-            $path .= "/";
124
+        if (substr($path, -1) != "/") {
125
+                    $path .= "/";
126
+        }
107 127
 
108 128
         $expr = '/\/([^\/]{1}|[^\.\/]{2}|[^\/]{3,})\/\.\.\//s';
109
-        while (preg_match($expr, $path))
110
-            $path = preg_replace($expr, "/", $path);
129
+        while (preg_match($expr, $path)) {
130
+                    $path = preg_replace($expr, "/", $path);
131
+        }
111 132
 
112 133
         $path = substr($path, 0, -1);
113 134
         $path = substr($path, 1);
@@ -118,11 +139,13 @@  discard block
 block discarded – undo
118 139
     * @param string $path
119 140
     * @return string */
120 141
 
121
-    static function urlPathEncode($path) {
142
+    static function urlPathEncode($path)
143
+    {
122 144
         $path = self::normalize($path);
123 145
         $encoded = "";
124
-        foreach (explode("/", $path) as $dir)
125
-            $encoded .= rawurlencode($dir) . "/";
146
+        foreach (explode("/", $path) as $dir) {
147
+                    $encoded .= rawurlencode($dir) . "/";
148
+        }
126 149
         $encoded = substr($encoded, 0, -1);
127 150
         return $encoded;
128 151
     }
@@ -131,11 +154,13 @@  discard block
 block discarded – undo
131 154
     * @param string $path
132 155
     * @return string */
133 156
 
134
-    static function urlPathDecode($path) {
157
+    static function urlPathDecode($path)
158
+    {
135 159
         $path = self::normalize($path);
136 160
         $decoded = "";
137
-        foreach (explode("/", $path) as $dir)
138
-            $decoded .= rawurldecode($dir) . "/";
161
+        foreach (explode("/", $path) as $dir) {
162
+                    $decoded .= rawurldecode($dir) . "/";
163
+        }
139 164
         $decoded = substr($decoded, 0, -1);
140 165
         return $decoded;
141 166
     }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/helper_httpCache.php 3 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc HTTP cache helper class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc HTTP cache helper class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class httpCache {
16 16
     const DEFAULT_TYPE = "text/html";
17 17
     const DEFAULT_EXPIRE = 604800; // in seconds
18 18
 
19
-  /** Cache a file. The $type parameter might define the MIME type of the file
20
-    * or path to magic file to autodetect the MIME type. If you skip $type
21
-    * parameter the method will try with the default magic file. Autodetection
22
-    * of MIME type requires Fileinfo PHP extension used in file::getMimeType()
23
-    * @param string $file
24
-    * @param string $type
25
-    * @param integer $expire
26
-    * @param array $headers */
19
+    /** Cache a file. The $type parameter might define the MIME type of the file
20
+     * or path to magic file to autodetect the MIME type. If you skip $type
21
+     * parameter the method will try with the default magic file. Autodetection
22
+     * of MIME type requires Fileinfo PHP extension used in file::getMimeType()
23
+     * @param string $file
24
+     * @param string $type
25
+     * @param integer $expire
26
+     * @param array $headers */
27 27
 
28 28
     static function file($file, $type=null, $expire=null, array $headers=null) {
29 29
         $mtime = @filemtime($file);
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
         self::content(@file_get_contents($file), $mtime, $type, $expire, $headers, false);
40 40
     }
41 41
 
42
-  /** Cache the given $content with $mtime modification time.
43
-    * @param binary $content
44
-    * @param integer $mtime
45
-    * @param string $type
46
-    * @param integer $expire
47
-    * @param array $headers
48
-    * @param bool $checkMTime */
42
+    /** Cache the given $content with $mtime modification time.
43
+     * @param binary $content
44
+     * @param integer $mtime
45
+     * @param string $type
46
+     * @param integer $expire
47
+     * @param array $headers
48
+     * @param bool $checkMTime */
49 49
 
50 50
     static function content($content, $mtime, $type=null, $expire=null, array $headers=null, $checkMTime=true) {
51 51
         if ($checkMTime) self::checkMTime($mtime);
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
         echo $content;
63 63
     }
64 64
 
65
-  /** Check if given modification time is newer than client-side one. If not,
66
-    * the method will tell the client to get the content from its own cache.
67
-    * Afterwards the script process will be terminated. This feature requires
68
-    * the PHP to be configured as Apache module.
69
-    * @param integer $mtime */
65
+    /** Check if given modification time is newer than client-side one. If not,
66
+     * the method will tell the client to get the content from its own cache.
67
+     * Afterwards the script process will be terminated. This feature requires
68
+     * the PHP to be configured as Apache module.
69
+     * @param integer $mtime */
70 70
 
71 71
     static function checkMTime($mtime, $sendHeaders=null) {
72 72
         header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT");
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class httpCache {
15
+class httpCache{
16 16
     const DEFAULT_TYPE = "text/html";
17 17
     const DEFAULT_EXPIRE = 604800; // in seconds
18 18
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     * @param integer $expire
26 26
     * @param array $headers */
27 27
 
28
-    static function file($file, $type=null, $expire=null, array $headers=null) {
28
+    static function file($file, $type = null, $expire = null, array $headers = null){
29 29
         $mtime = @filemtime($file);
30 30
         if ($mtime !== false) self::checkMTime($mtime);
31 31
 
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
     * @param array $headers
48 48
     * @param bool $checkMTime */
49 49
 
50
-    static function content($content, $mtime, $type=null, $expire=null, array $headers=null, $checkMTime=true) {
50
+    static function content($content, $mtime, $type = null, $expire = null, array $headers = null, $checkMTime = true){
51 51
         if ($checkMTime) self::checkMTime($mtime);
52 52
         if ($type === null) $type = self::DEFAULT_TYPE;
53 53
         if ($expire === null) $expire = self::DEFAULT_EXPIRE;
54 54
         $size = strlen($content);
55
-        $expires = gmdate("D, d M Y H:i:s", time() + $expire) . " GMT";
55
+        $expires = gmdate("D, d M Y H:i:s", time() + $expire)." GMT";
56 56
         header("Content-Type: $type");
57 57
         header("Expires: $expires");
58 58
         header("Cache-Control: max-age=$expire");
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
     * the PHP to be configured as Apache module.
69 69
     * @param integer $mtime */
70 70
 
71
-    static function checkMTime($mtime, $sendHeaders=null) {
72
-        header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT");
71
+    static function checkMTime($mtime, $sendHeaders = null){
72
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mtime)." GMT");
73 73
 
74 74
         $headers = function_exists("getallheaders")
75 75
             ? getallheaders()
Please login to merge, or discard this patch.
Braces   +31 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class httpCache {
15
+class httpCache
16
+{
16 17
     const DEFAULT_TYPE = "text/html";
17 18
     const DEFAULT_EXPIRE = 604800; // in seconds
18 19
 
@@ -25,15 +26,20 @@  discard block
 block discarded – undo
25 26
     * @param integer $expire
26 27
     * @param array $headers */
27 28
 
28
-    static function file($file, $type=null, $expire=null, array $headers=null) {
29
+    static function file($file, $type=null, $expire=null, array $headers=null)
30
+    {
29 31
         $mtime = @filemtime($file);
30
-        if ($mtime !== false) self::checkMTime($mtime);
32
+        if ($mtime !== false) {
33
+            self::checkMTime($mtime);
34
+        }
31 35
 
32 36
         if ($type === null) {
33 37
             $magic = ((substr($type, 0, 1) == "/") || preg_match('/^[a-z]\:/i', $type))
34 38
                 ? $type : null;
35 39
             $type = file::getMimeType($file, $magic);
36
-            if (!$type) $type = null;
40
+            if (!$type) {
41
+                $type = null;
42
+            }
37 43
         }
38 44
 
39 45
         self::content(@file_get_contents($file), $mtime, $type, $expire, $headers, false);
@@ -47,10 +53,17 @@  discard block
 block discarded – undo
47 53
     * @param array $headers
48 54
     * @param bool $checkMTime */
49 55
 
50
-    static function content($content, $mtime, $type=null, $expire=null, array $headers=null, $checkMTime=true) {
51
-        if ($checkMTime) self::checkMTime($mtime);
52
-        if ($type === null) $type = self::DEFAULT_TYPE;
53
-        if ($expire === null) $expire = self::DEFAULT_EXPIRE;
56
+    static function content($content, $mtime, $type=null, $expire=null, array $headers=null, $checkMTime=true)
57
+    {
58
+        if ($checkMTime) {
59
+            self::checkMTime($mtime);
60
+        }
61
+        if ($type === null) {
62
+            $type = self::DEFAULT_TYPE;
63
+        }
64
+        if ($expire === null) {
65
+            $expire = self::DEFAULT_EXPIRE;
66
+        }
54 67
         $size = strlen($content);
55 68
         $expires = gmdate("D, d M Y H:i:s", time() + $expire) . " GMT";
56 69
         header("Content-Type: $type");
@@ -58,7 +71,9 @@  discard block
 block discarded – undo
58 71
         header("Cache-Control: max-age=$expire");
59 72
         header("Pragma: !invalid");
60 73
         header("Content-Length: $size");
61
-        if ($headers !== null) foreach ($headers as $header) header($header);
74
+        if ($headers !== null) {
75
+            foreach ($headers as $header) header($header);
76
+        }
62 77
         echo $content;
63 78
     }
64 79
 
@@ -68,7 +83,8 @@  discard block
 block discarded – undo
68 83
     * the PHP to be configured as Apache module.
69 84
     * @param integer $mtime */
70 85
 
71
-    static function checkMTime($mtime, $sendHeaders=null) {
86
+    static function checkMTime($mtime, $sendHeaders=null)
87
+    {
72 88
         header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT");
73 89
 
74 90
         $headers = function_exists("getallheaders")
@@ -82,11 +98,12 @@  discard block
 block discarded – undo
82 98
             $client_mtime = @strtotime($client_mtime[0]);
83 99
             if ($client_mtime >= $mtime) {
84 100
                 header('HTTP/1.1 304 Not Modified');
85
-                if (is_array($sendHeaders) && count($sendHeaders))
86
-                    foreach ($sendHeaders as $header)
101
+                if (is_array($sendHeaders) && count($sendHeaders)) {
102
+                                    foreach ($sendHeaders as $header)
87 103
                         header($header);
88
-                elseif ($sendHeaders !== null)
89
-                    header($sendHeaders);
104
+                } elseif ($sendHeaders !== null) {
105
+                                    header($sendHeaders);
106
+                }
90 107
 
91 108
 
92 109
                 die;
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/helper_text.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Text processing helper class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Text processing helper class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class text {
16 16
 
17
-  /** Replace repeated white spaces to single space
18
-    * @param string $string
19
-    * @return string */
17
+    /** Replace repeated white spaces to single space
18
+     * @param string $string
19
+     * @return string */
20 20
 
21 21
     static function clearWhitespaces($string) {
22 22
         return trim(preg_replace('/\s+/s', " ", $string));
23 23
     }
24 24
 
25
-  /** Normalize the string for HTML attribute value
26
-    * @param string $string
27
-    * @return string */
25
+    /** Normalize the string for HTML attribute value
26
+     * @param string $string
27
+     * @return string */
28 28
 
29 29
     static function htmlValue($string) {
30 30
         return
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
         $string))));
36 36
     }
37 37
 
38
-  /** Normalize the string for JavaScript string value
39
-    * @param string $string
40
-    * @return string */
38
+    /** Normalize the string for JavaScript string value
39
+     * @param string $string
40
+     * @return string */
41 41
 
42 42
     static function jsValue($string) {
43 43
         return
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
         $string))));
49 49
     }
50 50
 
51
-  /** Normalize the string for XML tag content data
52
-    * @param string $string
53
-    * @param bool $cdata */
51
+    /** Normalize the string for XML tag content data
52
+     * @param string $string
53
+     * @param bool $cdata */
54 54
 
55 55
     static function xmlData($string, $cdata=false) {
56 56
         $string = str_replace("]]>", "]]]]><![CDATA[>", $string);
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
         return $string;
60 60
     }
61 61
 
62
-  /** Returns compressed content of given CSS code
63
-    * @param string $code
64
-    * @return string */
62
+    /** Returns compressed content of given CSS code
63
+     * @param string $code
64
+     * @return string */
65 65
 
66 66
     static function compressCSS($code) {
67 67
         $code = self::clearWhitespaces($code);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class text {
15
+class text{
16 16
 
17 17
   /** Replace repeated white spaces to single space
18 18
     * @param string $string
19 19
     * @return string */
20 20
 
21
-    static function clearWhitespaces($string) {
21
+    static function clearWhitespaces($string){
22 22
         return trim(preg_replace('/\s+/s', " ", $string));
23 23
     }
24 24
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     * @param string $string
27 27
     * @return string */
28 28
 
29
-    static function htmlValue($string) {
29
+    static function htmlValue($string){
30 30
         return
31 31
             str_replace('"', "&quot;",
32 32
             str_replace("'", '&#39;',
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     * @param string $string
40 40
     * @return string */
41 41
 
42
-    static function jsValue($string) {
42
+    static function jsValue($string){
43 43
         return
44 44
             preg_replace('/\r?\n/', "\\n",
45 45
             str_replace('"', "\\\"",
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     * @param string $string
53 53
     * @param bool $cdata */
54 54
 
55
-    static function xmlData($string, $cdata=false) {
55
+    static function xmlData($string, $cdata = false){
56 56
         $string = str_replace("]]>", "]]]]><![CDATA[>", $string);
57 57
         if (!$cdata)
58 58
             $string = "<![CDATA[$string]]>";
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     * @param string $code
64 64
     * @return string */
65 65
 
66
-    static function compressCSS($code) {
66
+    static function compressCSS($code){
67 67
         $code = self::clearWhitespaces($code);
68 68
         $code = preg_replace('/ ?\{ ?/', "{", $code);
69 69
         $code = preg_replace('/ ?\} ?/', "}", $code);
Please login to merge, or discard this patch.
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,13 +12,15 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class text {
15
+class text
16
+{
16 17
 
17 18
   /** Replace repeated white spaces to single space
18 19
     * @param string $string
19 20
     * @return string */
20 21
 
21
-    static function clearWhitespaces($string) {
22
+    static function clearWhitespaces($string)
23
+    {
22 24
         return trim(preg_replace('/\s+/s', " ", $string));
23 25
     }
24 26
 
@@ -26,7 +28,8 @@  discard block
 block discarded – undo
26 28
     * @param string $string
27 29
     * @return string */
28 30
 
29
-    static function htmlValue($string) {
31
+    static function htmlValue($string)
32
+    {
30 33
         return
31 34
             str_replace('"', "&quot;",
32 35
             str_replace("'", '&#39;',
@@ -39,7 +42,8 @@  discard block
 block discarded – undo
39 42
     * @param string $string
40 43
     * @return string */
41 44
 
42
-    static function jsValue($string) {
45
+    static function jsValue($string)
46
+    {
43 47
         return
44 48
             preg_replace('/\r?\n/', "\\n",
45 49
             str_replace('"', "\\\"",
@@ -52,10 +56,12 @@  discard block
 block discarded – undo
52 56
     * @param string $string
53 57
     * @param bool $cdata */
54 58
 
55
-    static function xmlData($string, $cdata=false) {
59
+    static function xmlData($string, $cdata=false)
60
+    {
56 61
         $string = str_replace("]]>", "]]]]><![CDATA[>", $string);
57
-        if (!$cdata)
58
-            $string = "<![CDATA[$string]]>";
62
+        if (!$cdata) {
63
+                    $string = "<![CDATA[$string]]>";
64
+        }
59 65
         return $string;
60 66
     }
61 67
 
@@ -63,7 +69,8 @@  discard block
 block discarded – undo
63 69
     * @param string $code
64 70
     * @return string */
65 71
 
66
-    static function compressCSS($code) {
72
+    static function compressCSS($code)
73
+    {
67 74
         $code = self::clearWhitespaces($code);
68 75
         $code = preg_replace('/ ?\{ ?/', "{", $code);
69 76
         $code = preg_replace('/ ?\} ?/', "}", $code);
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_image_gmagick.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc GraphicsMagick image driver class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc GraphicsMagick image driver class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class image_gmagick extends image {
16 16
 
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class image_gmagick extends image {
15
+class image_gmagick extends image{
16 16
 
17 17
     static $MIMES = array(
18 18
         //'tif' => "image/tiff"
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     // ABSTRACT PUBLIC METHODS
23 23
 
24
-    public function resize($width, $height) {//
24
+    public function resize($width, $height){//
25 25
         if (!$width) $width = 1;
26 26
         if (!$height) $height = 1;
27 27
         try {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         return true;
35 35
     }
36 36
 
37
-    public function resizeFit($width, $height, $background=false) {//
37
+    public function resizeFit($width, $height, $background = false){//
38 38
         if (!$width) $width = 1;
39 39
         if (!$height) $height = 1;
40 40
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         }
70 70
     }
71 71
 
72
-    public function resizeCrop($width, $height, $offset=false) {
72
+    public function resizeCrop($width, $height, $offset = false){
73 73
         if (!$width) $width = 1;
74 74
         if (!$height) $height = 1;
75 75
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         return true;
120 120
     }
121 121
 
122
-    public function rotate($angle, $background="#000000") {
122
+    public function rotate($angle, $background = "#000000"){
123 123
         try {
124 124
             $this->image->rotateImage($background, $angle);
125 125
             $w = $this->image->getImageWidth();
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         return true;
133 133
     }
134 134
 
135
-    public function flipHorizontal() {
135
+    public function flipHorizontal(){
136 136
         try {
137 137
             $this->image->flopImage();
138 138
         } catch (Exception $e) {
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         return true;
142 142
     }
143 143
 
144
-    public function flipVertical() {
144
+    public function flipVertical(){
145 145
         try {
146 146
             $this->image->flipImage();
147 147
         } catch (Exception $e) {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         return true;
151 151
     }
152 152
 
153
-    public function watermark($file, $left=false, $top=false) {
153
+    public function watermark($file, $left = false, $top = false){
154 154
         try {
155 155
             $wm = new Gmagick($file);
156 156
             $w = $wm->getImageWidth();
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
     // ABSTRACT PROTECTED METHODS
187 187
 
188
-    protected function getBlankImage($width, $height) {
188
+    protected function getBlankImage($width, $height){
189 189
         try {
190 190
             $img = new Gmagick();
191 191
             $img->newImage($width, $height, "none");
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         return $img;
196 196
     }
197 197
 
198
-    protected function getImage($image, &$width, &$height) {
198
+    protected function getImage($image, &$width, &$height){
199 199
 
200 200
         if (is_object($image) && ($image instanceof image_gmagick)) {
201 201
             $width = $image->width;
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 
233 233
     // PSEUDO-ABSTRACT STATIC METHODS
234 234
 
235
-    static function available() {
235
+    static function available(){
236 236
         return class_exists("Gmagick");
237 237
     }
238 238
 
239
-    static function checkImage($file) {
239
+    static function checkImage($file){
240 240
         try {
241 241
             new Gmagick($file);
242 242
         } catch (Exception $e) {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
     // INHERIT METHODS
250 250
 
251
-    public function output($type="jpeg", array $options=array()) {
251
+    public function output($type = "jpeg", array $options = array()){
252 252
         $type = strtolower($type);
253 253
         try {
254 254
             $this->image->setImageFormat($type);
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
             echo $this->image;
268 268
 
269 269
         } else {
270
-            $file = $options['file'] . ".$type";
270
+            $file = $options['file'].".$type";
271 271
             try {
272 272
                 $this->image->writeImage($file);
273 273
             } catch (Exception $e) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
     // OWN METHODS
289 289
 
290
-    protected function optimize_jpeg(array $options=array()) {
290
+    protected function optimize_jpeg(array $options = array()){
291 291
         $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY;
292 292
         try {
293 293
             $this->image->setCompressionQuality($quality);
Please login to merge, or discard this patch.
Braces   +81 added lines, -40 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class image_gmagick extends image {
15
+class image_gmagick extends image
16
+{
16 17
 
17 18
     static $MIMES = array(
18 19
         //'tif' => "image/tiff"
@@ -21,9 +22,15 @@  discard block
 block discarded – undo
21 22
 
22 23
     // ABSTRACT PUBLIC METHODS
23 24
 
24
-    public function resize($width, $height) {//
25
-        if (!$width) $width = 1;
26
-        if (!$height) $height = 1;
25
+    public function resize($width, $height)
26
+    {
27
+//
28
+        if (!$width) {
29
+            $width = 1;
30
+        }
31
+        if (!$height) {
32
+            $height = 1;
33
+        }
27 34
         try {
28 35
             $this->image->scaleImage($width, $height);
29 36
         } catch (Exception $e) {
@@ -34,9 +41,15 @@  discard block
 block discarded – undo
34 41
         return true;
35 42
     }
36 43
 
37
-    public function resizeFit($width, $height, $background=false) {//
38
-        if (!$width) $width = 1;
39
-        if (!$height) $height = 1;
44
+    public function resizeFit($width, $height, $background=false)
45
+    {
46
+//
47
+        if (!$width) {
48
+            $width = 1;
49
+        }
50
+        if (!$height) {
51
+            $height = 1;
52
+        }
40 53
 
41 54
         try {
42 55
             $this->image->scaleImage($width, $height, true);
@@ -69,43 +82,58 @@  discard block
 block discarded – undo
69 82
         }
70 83
     }
71 84
 
72
-    public function resizeCrop($width, $height, $offset=false) {
73
-        if (!$width) $width = 1;
74
-        if (!$height) $height = 1;
85
+    public function resizeCrop($width, $height, $offset=false)
86
+    {
87
+        if (!$width) {
88
+            $width = 1;
89
+        }
90
+        if (!$height) {
91
+            $height = 1;
92
+        }
75 93
 
76 94
         if (($this->width / $this->height) > ($width / $height)) {
77 95
             $h = $height;
78 96
             $w = ($this->width * $h) / $this->height;
79 97
             $y = 0;
80 98
             if ($offset !== false) {
81
-                if ($offset > 0)
82
-                    $offset = -$offset;
83
-                if (($w + $offset) <= $width)
84
-                    $offset = $width - $w;
99
+                if ($offset > 0) {
100
+                                    $offset = -$offset;
101
+                }
102
+                if (($w + $offset) <= $width) {
103
+                                    $offset = $width - $w;
104
+                }
85 105
                 $x = $offset;
86
-            } else
87
-                $x = ($width - $w) / 2;
106
+            } else {
107
+                            $x = ($width - $w) / 2;
108
+            }
88 109
 
89 110
         } else {
90 111
             $w = $width;
91 112
             $h = ($this->height * $w) / $this->width;
92 113
             $x = 0;
93 114
             if ($offset !== false) {
94
-                if ($offset > 0)
95
-                    $offset = -$offset;
96
-                if (($h + $offset) <= $height)
97
-                    $offset = $height - $h;
115
+                if ($offset > 0) {
116
+                                    $offset = -$offset;
117
+                }
118
+                if (($h + $offset) <= $height) {
119
+                                    $offset = $height - $h;
120
+                }
98 121
                 $y = $offset;
99
-            } else
100
-                $y = ($height - $h) / 2;
122
+            } else {
123
+                            $y = ($height - $h) / 2;
124
+            }
101 125
         }
102 126
 
103 127
         $x = round($x);
104 128
         $y = round($y);
105 129
         $w = round($w);
106 130
         $h = round($h);
107
-        if (!$w) $w = 1;
108
-        if (!$h) $h = 1;
131
+        if (!$w) {
132
+            $w = 1;
133
+        }
134
+        if (!$h) {
135
+            $h = 1;
136
+        }
109 137
 
110 138
         try {
111 139
             $this->image->scaleImage($w, $h);
@@ -119,7 +147,8 @@  discard block
 block discarded – undo
119 147
         return true;
120 148
     }
121 149
 
122
-    public function rotate($angle, $background="#000000") {
150
+    public function rotate($angle, $background="#000000")
151
+    {
123 152
         try {
124 153
             $this->image->rotateImage($background, $angle);
125 154
             $w = $this->image->getImageWidth();
@@ -132,7 +161,8 @@  discard block
 block discarded – undo
132 161
         return true;
133 162
     }
134 163
 
135
-    public function flipHorizontal() {
164
+    public function flipHorizontal()
165
+    {
136 166
         try {
137 167
             $this->image->flopImage();
138 168
         } catch (Exception $e) {
@@ -141,7 +171,8 @@  discard block
 block discarded – undo
141 171
         return true;
142 172
     }
143 173
 
144
-    public function flipVertical() {
174
+    public function flipVertical()
175
+    {
145 176
         try {
146 177
             $this->image->flipImage();
147 178
         } catch (Exception $e) {
@@ -150,7 +181,8 @@  discard block
 block discarded – undo
150 181
         return true;
151 182
     }
152 183
 
153
-    public function watermark($file, $left=false, $top=false) {
184
+    public function watermark($file, $left=false, $top=false)
185
+    {
154 186
         try {
155 187
             $wm = new Gmagick($file);
156 188
             $w = $wm->getImageWidth();
@@ -171,8 +203,9 @@  discard block
 block discarded – undo
171 203
         if ((($x + $w) > $this->width) ||
172 204
             (($y + $h) > $this->height) ||
173 205
             ($x < 0) || ($y < 0)
174
-        )
175
-            return false;
206
+        ) {
207
+                    return false;
208
+        }
176 209
 
177 210
         try {
178 211
             $this->image->compositeImage($wm, 1, $x, $y);
@@ -185,7 +218,8 @@  discard block
 block discarded – undo
185 218
 
186 219
     // ABSTRACT PROTECTED METHODS
187 220
 
188
-    protected function getBlankImage($width, $height) {
221
+    protected function getBlankImage($width, $height)
222
+    {
189 223
         try {
190 224
             $img = new Gmagick();
191 225
             $img->newImage($width, $height, "none");
@@ -195,7 +229,8 @@  discard block
 block discarded – undo
195 229
         return $img;
196 230
     }
197 231
 
198
-    protected function getImage($image, &$width, &$height) {
232
+    protected function getImage($image, &$width, &$height)
233
+    {
199 234
 
200 235
         if (is_object($image) && ($image instanceof image_gmagick)) {
201 236
             $width = $image->width;
@@ -225,18 +260,21 @@  discard block
 block discarded – undo
225 260
             $height = $h;
226 261
             return $image;
227 262
 
228
-        } else
229
-            return false;
263
+        } else {
264
+                    return false;
265
+        }
230 266
     }
231 267
 
232 268
 
233 269
     // PSEUDO-ABSTRACT STATIC METHODS
234 270
 
235
-    static function available() {
271
+    static function available()
272
+    {
236 273
         return class_exists("Gmagick");
237 274
     }
238 275
 
239
-    static function checkImage($file) {
276
+    static function checkImage($file)
277
+    {
240 278
         try {
241 279
             new Gmagick($file);
242 280
         } catch (Exception $e) {
@@ -248,7 +286,8 @@  discard block
 block discarded – undo
248 286
 
249 287
     // INHERIT METHODS
250 288
 
251
-    public function output($type="jpeg", array $options=array()) {
289
+    public function output($type="jpeg", array $options=array())
290
+    {
252 291
         $type = strtolower($type);
253 292
         try {
254 293
             $this->image->setImageFormat($type);
@@ -256,8 +295,9 @@  discard block
 block discarded – undo
256 295
             return false;
257 296
         }
258 297
         $method = "optimize_$type";
259
-        if (method_exists($this, $method) && !$this->$method($options))
260
-            return false;
298
+        if (method_exists($this, $method) && !$this->$method($options)) {
299
+                    return false;
300
+        }
261 301
 
262 302
         if (!isset($options['file'])) {
263 303
             if (!headers_sent()) {
@@ -287,7 +327,8 @@  discard block
 block discarded – undo
287 327
 
288 328
     // OWN METHODS
289 329
 
290
-    protected function optimize_jpeg(array $options=array()) {
330
+    protected function optimize_jpeg(array $options=array())
331
+    {
291 332
         $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY;
292 333
         try {
293 334
             $this->image->setCompressionQuality($quality);
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/config.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	
27 27
     'theme' => "evo",
28 28
 
29
-    'uploadURL' => rtrim($modx->config['rb_base_url'],'/'),
30
-    'uploadDir' => rtrim($modx->config['rb_base_dir'],'/'),
29
+    'uploadURL' => rtrim($modx->config['rb_base_url'], '/'),
30
+    'uploadDir' => rtrim($modx->config['rb_base_dir'], '/'),
31 31
     'siteURL' => $modx->config['site_url'],
32
-    'assetsURL' => rtrim($modx->config['rb_base_url'],'/'),
33
-    'dirPerms' => intval($modx->config['new_folder_permissions'],8),
34
-    'filePerms' => intval($modx->config['new_file_permissions'],8),
32
+    'assetsURL' => rtrim($modx->config['rb_base_url'], '/'),
33
+    'dirPerms' => intval($modx->config['new_folder_permissions'], 8),
34
+    'filePerms' => intval($modx->config['new_file_permissions'], 8),
35 35
     'maxfilesize' => $settings['upload_maxsize'],
36 36
     'denyUpdateCheck' => true,
37 37
 
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
     'types' => array(
59 59
 
60 60
         // CKEditor & FCKEditor types
61
-        'files'   =>  str_replace(',',' ',$modx->config['upload_files']),
62
-        'flash'   =>  str_replace(',',' ',$modx->config['upload_flash']),
63
-        'images'  =>  str_replace(',',' ',$modx->config['upload_images']),
61
+        'files'   =>  str_replace(',', ' ', $modx->config['upload_files']),
62
+        'flash'   =>  str_replace(',', ' ', $modx->config['upload_flash']),
63
+        'images'  =>  str_replace(',', ' ', $modx->config['upload_images']),
64 64
 
65 65
         // TinyMCE types
66
-        'file'    =>  str_replace(',',' ',$modx->config['upload_files']),
67
-        'media'   =>  str_replace(',',' ',$modx->config['upload_media']),
68
-        'image'   =>  str_replace(',',' ',$modx->config['upload_images']),
66
+        'file'    =>  str_replace(',', ' ', $modx->config['upload_files']),
67
+        'media'   =>  str_replace(',', ' ', $modx->config['upload_media']),
68
+        'image'   =>  str_replace(',', ' ', $modx->config['upload_images']),
69 69
     ),
70 70
     'dirnameChangeChars' => array(
71 71
         ' ' => "_",
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
     // THE FOLLOWING SETTINGS CANNOT BE OVERRIDED WITH SESSION CONFIGURATION
91 91
     '_check4htaccess' => false,
92
-    '_tinyMCEPath' => MODX_BASE_URL . "assets/plugins/tinymce/tiny_mce",
92
+    '_tinyMCEPath' => MODX_BASE_URL."assets/plugins/tinymce/tiny_mce",
93 93
 
94 94
     '_sessionVar' => &$_SESSION['KCFINDER'],
95 95
     //'_sessionLifetime' => 30,
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Base configuration file
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Base configuration file
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 // IMPORTANT!!! Do not remove uncommented settings in this file even if
16 16
 // you are using session configuration.
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     'dirnameChangeChars' => array(
71 71
         ' ' => "_",
72 72
         ':' => "."
73
-     ),
73
+        ),
74 74
     'mime_magic' => "",
75 75
 
76 76
     'maxImageWidth' => $modx->config['maxImageWidth'],
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/browse.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Browser calling script
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Browser calling script
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 require "core/autoload.php"; // Init MODX
16 16
 
17 17
 function returnNoPermissionsMessage($role) {
18
-	global $_lang;
19
-	echo sprintf($_lang['files_management_no_permission'], $role);
20
-	exit;
18
+    global $_lang;
19
+    echo sprintf($_lang['files_management_no_permission'], $role);
20
+    exit;
21 21
 }
22 22
 
23 23
 if( $_GET['type'] == 'images' && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_images')) returnNoPermissionsMessage('assets_images');
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 
15 15
 require "core/autoload.php"; // Init MODX
16 16
 
17
-function returnNoPermissionsMessage($role) {
17
+function returnNoPermissionsMessage($role){
18 18
 	global $_lang;
19 19
 	echo sprintf($_lang['files_management_no_permission'], $role);
20 20
 	exit;
21 21
 }
22 22
 
23
-if( $_GET['type'] == 'images' && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_images')) returnNoPermissionsMessage('assets_images');
24
-if( $_GET['type'] == 'files'  && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_files'))  returnNoPermissionsMessage('assets_files');
23
+if ($_GET['type'] == 'images' && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_images')) returnNoPermissionsMessage('assets_images');
24
+if ($_GET['type'] == 'files' && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_files'))  returnNoPermissionsMessage('assets_files');
25 25
 
26 26
 $browser = new browser($modx);
27 27
 $browser->action();
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,14 +14,19 @@
 block discarded – undo
14 14
 
15 15
 require "core/autoload.php"; // Init MODX
16 16
 
17
-function returnNoPermissionsMessage($role) {
17
+function returnNoPermissionsMessage($role)
18
+{
18 19
 	global $_lang;
19 20
 	echo sprintf($_lang['files_management_no_permission'], $role);
20 21
 	exit;
21 22
 }
22 23
 
23
-if( $_GET['type'] == 'images' && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_images')) returnNoPermissionsMessage('assets_images');
24
-if( $_GET['type'] == 'files'  && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_files'))  returnNoPermissionsMessage('assets_files');
24
+if( $_GET['type'] == 'images' && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_images')) {
25
+    returnNoPermissionsMessage('assets_images');
26
+}
27
+if( $_GET['type'] == 'files'  && !$modx->hasPermission('file_manager') && !$modx->hasPermission('assets_files')) {
28
+    returnNoPermissionsMessage('assets_files');
29
+}
25 30
 
26 31
 $browser = new browser($modx);
27 32
 $browser->action();
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/upload.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Upload calling script
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Upload calling script
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 require "core/autoload.php";
16 16
 $uploader = new uploader($modx);
Please login to merge, or discard this patch.
manager/media/style/default/welcome.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 $modx->config['enable_filter'] = 1;
3 3
 
4
-$modx->addSnippet('hasPermission','return $modx->hasPermission($key);');
4
+$modx->addSnippet('hasPermission', 'return $modx->hasPermission($key);');
5 5
 
6
-if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags'))
6
+if ($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags'))
7 7
     $hasAnyPermission = 1;
8 8
 else $hasAnyPermission = 0;
9
-$modx->addSnippet('hasAnyPermission','global $hasAnyPermission; return $hasAnyPermission;');
10
-$modx->addSnippet('getLoginUserName','return $modx->getLoginUserName();');
9
+$modx->addSnippet('hasAnyPermission', 'global $hasAnyPermission; return $hasAnyPermission;');
10
+$modx->addSnippet('getLoginUserName', 'return $modx->getLoginUserName();');
11 11
 $code = 'global $_lang;return $_SESSION["nrtotalmessages"] ? sprintf($_lang["welcome_messages"], $_SESSION["nrtotalmessages"], \'<span style="color:red;">\' . $_SESSION["nrnewmessages"] . "</span>") : $_lang["messages_no_messages"];';
12
-$modx->addSnippet('getMessageCount',$code);
12
+$modx->addSnippet('getMessageCount', $code);
13 13
 
14 14
 // Large Icons
15 15
 $_style['icons_backup_large']       = 'fa fa-database fa-fw fa-2x';
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,9 +3,11 @@
 block discarded – undo
3 3
 
4 4
 $modx->addSnippet('hasPermission','return $modx->hasPermission($key);');
5 5
 
6
-if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags'))
7
-    $hasAnyPermission = 1;
8
-else $hasAnyPermission = 0;
6
+if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
7
+    $hasAnyPermission = 1;
8
+} else {
9
+    $hasAnyPermission = 0;
10
+}
9 11
 $modx->addSnippet('hasAnyPermission','global $hasAnyPermission; return $hasAnyPermission;');
10 12
 $modx->addSnippet('getLoginUserName','return $modx->getLoginUserName();');
11 13
 $code = 'global $_lang;return $_SESSION["nrtotalmessages"] ? sprintf($_lang["welcome_messages"], $_SESSION["nrtotalmessages"], \'<span style="color:red;">\' . $_SESSION["nrnewmessages"] . "</span>") : $_lang["messages_no_messages"];';
Please login to merge, or discard this patch.
manager/media/style/default/ajax.php 2 patches
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 $modx->loadExtension("ManagerAPI");
20 20
 
21 21
 $_lang = array();
22
-include_once MODX_MANAGER_PATH . '/includes/lang/english.inc.php';
22
+include_once MODX_MANAGER_PATH.'/includes/lang/english.inc.php';
23 23
 if ($modx->config['manager_language'] != 'english') {
24
-    include_once MODX_MANAGER_PATH . '/includes/lang/' . $modx->config['manager_language'] . '.inc.php';
24
+    include_once MODX_MANAGER_PATH.'/includes/lang/'.$modx->config['manager_language'].'.inc.php';
25 25
 }
26
-include_once MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/style.php';
26
+include_once MODX_MANAGER_PATH.'/media/style/'.$modx->config['manager_theme'].'/style.php';
27 27
 
28 28
 $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
29 29
 $frame = isset($_REQUEST['f']) ? $_REQUEST['f'] : '';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
             switch ($frame) {
42 42
                 case 'nodes':
43
-                    include_once MODX_MANAGER_PATH . '/frames/nodes.php';
43
+                    include_once MODX_MANAGER_PATH.'/frames/nodes.php';
44 44
 
45 45
                     break;
46 46
             }
@@ -58,21 +58,21 @@  discard block
 block discarded – undo
58 58
                 $sql = '';
59 59
                 $a = '';
60 60
                 $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '%*_') : '';
61
-                $sqlLike = $filter ? 'WHERE t1.name LIKE "' . $modx->db->escape($filter) . '%"' : '';
62
-                $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
61
+                $sqlLike = $filter ? 'WHERE t1.name LIKE "'.$modx->db->escape($filter).'%"' : '';
62
+                $sqlLimit = $sqlLike ? '' : 'LIMIT '.$limit;
63 63
 
64 64
                 switch ($elements) {
65 65
                     case 'element_templates':
66 66
                         $a = 16;
67
-                        $sqlLike = $filter ? 'WHERE t1.templatename LIKE "' . $modx->db->escape($filter) . '%"' : '';
67
+                        $sqlLike = $filter ? 'WHERE t1.templatename LIKE "'.$modx->db->escape($filter).'%"' : '';
68 68
                         $sql = $modx->db->query('SELECT t1.*, t1.templatename AS name
69
-                        FROM ' . $modx->getFullTableName('site_templates') . ' AS t1
70
-                        ' . $sqlLike . '
69
+                        FROM ' . $modx->getFullTableName('site_templates').' AS t1
70
+                        ' . $sqlLike.'
71 71
                         ORDER BY t1.templatename ASC
72 72
                         ' . $sqlLimit);
73 73
 
74 74
                         if ($modx->hasPermission('new_template')) {
75
-                            $output .= '<li><a id="a_19" href="index.php?a=19" target="main"><i class="fa fa-plus"></i>' . $_lang['new_template'] . '</a></li>';
75
+                            $output .= '<li><a id="a_19" href="index.php?a=19" target="main"><i class="fa fa-plus"></i>'.$_lang['new_template'].'</a></li>';
76 76
                         }
77 77
 
78 78
                         break;
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
                     case 'element_tplvars':
81 81
                         $a = 301;
82 82
                         $sql = $modx->db->query('SELECT t1.*, IF(t2.templateid,0,1) AS disabled
83
-                        FROM ' . $modx->getFullTableName('site_tmplvars') . ' AS t1
84
-                        LEFT JOIN ' . $modx->getFullTableName('site_tmplvar_templates') . ' AS t2 ON t1.id=t2.tmplvarid
85
-                        ' . $sqlLike . '
83
+                        FROM ' . $modx->getFullTableName('site_tmplvars').' AS t1
84
+                        LEFT JOIN ' . $modx->getFullTableName('site_tmplvar_templates').' AS t2 ON t1.id=t2.tmplvarid
85
+                        ' . $sqlLike.'
86 86
                         GROUP BY t1.id
87 87
                         ORDER BY t1.name ASC
88 88
                         ' . $sqlLimit);
89 89
 
90 90
                         if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
91
-                            $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>' . $_lang['new_tmplvars'] . '</a></li>';
91
+                            $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>'.$_lang['new_tmplvars'].'</a></li>';
92 92
                         }
93 93
 
94 94
                         break;
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
                     case 'element_htmlsnippets':
97 97
                         $a = 78;
98 98
                         $sql = $modx->db->query('SELECT t1.*
99
-                        FROM ' . $modx->getFullTableName('site_htmlsnippets') . ' AS t1
100
-                        ' . $sqlLike . '
99
+                        FROM ' . $modx->getFullTableName('site_htmlsnippets').' AS t1
100
+                        ' . $sqlLike.'
101 101
                         ORDER BY t1.name ASC
102 102
                         ' . $sqlLimit);
103 103
 
104 104
                         if ($modx->hasPermission('new_chunk')) {
105
-                            $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>' . $_lang['new_htmlsnippet'] . '</a></li>';
105
+                            $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>'.$_lang['new_htmlsnippet'].'</a></li>';
106 106
                         }
107 107
 
108 108
                         break;
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
                     case 'element_snippets':
111 111
                         $a = 22;
112 112
                         $sql = $modx->db->query('SELECT t1.*
113
-                        FROM ' . $modx->getFullTableName('site_snippets') . ' AS t1
114
-                        ' . $sqlLike . '
113
+                        FROM ' . $modx->getFullTableName('site_snippets').' AS t1
114
+                        ' . $sqlLike.'
115 115
                         ORDER BY t1.name ASC
116 116
                         ' . $sqlLimit);
117 117
 
118 118
                         if ($modx->hasPermission('new_snippet')) {
119
-                            $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>' . $_lang['new_snippet'] . '</a></li>';
119
+                            $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>'.$_lang['new_snippet'].'</a></li>';
120 120
                         }
121 121
 
122 122
                         break;
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
                     case 'element_plugins':
125 125
                         $a = 102;
126 126
                         $sql = $modx->db->query('SELECT t1.*
127
-                        FROM ' . $modx->getFullTableName('site_plugins') . ' AS t1
128
-                        ' . $sqlLike . '
127
+                        FROM ' . $modx->getFullTableName('site_plugins').' AS t1
128
+                        ' . $sqlLike.'
129 129
                         ORDER BY t1.name ASC
130 130
                         ' . $sqlLimit);
131 131
 
132 132
                         if ($modx->hasPermission('new_plugin')) {
133
-                            $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>' . $_lang['new_plugin'] . '</a></li>';
133
+                            $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>'.$_lang['new_plugin'].'</a></li>';
134 134
                         }
135 135
 
136 136
                         break;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                             continue;
146 146
                         }
147 147
 
148
-                        $items .= '<li class="item ' . ($row['disabled'] ? 'disabled' : '') . ($row['locked'] ? ' locked' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main" data-parent-id="a_76__elements_' . $elements . '">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>' . "\n";
148
+                        $items .= '<li class="item '.($row['disabled'] ? 'disabled' : '').($row['locked'] ? ' locked' : '').'"><a id="a_'.$a.'__id_'.$row['id'].'" href="index.php?a='.$a.'&id='.$row['id'].'" target="main" data-parent-id="a_76__elements_'.$elements.'">'.$row['name'].' <small>('.$row['id'].')</small></a></li>'."\n";
149 149
                     }
150 150
                 }
151 151
 
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
             $output = '';
167 167
             $items = '';
168 168
             $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
169
-            $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
170
-            $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
169
+            $sqlLike = $filter ? 'WHERE t1.username LIKE "'.$modx->db->escape($filter).'%"' : '';
170
+            $sqlLimit = $sqlLike ? '' : 'LIMIT '.$limit;
171 171
 
172 172
             $sql = $modx->db->query('SELECT t1.*, t1.username AS name, t2.blocked
173
-				FROM ' . $modx->getFullTableName('manager_users') . ' AS t1
174
-				LEFT JOIN ' . $modx->getFullTableName('user_attributes') . ' AS t2 ON t1.id=t2.internalKey
175
-				' . $sqlLike . '
173
+				FROM ' . $modx->getFullTableName('manager_users').' AS t1
174
+				LEFT JOIN ' . $modx->getFullTableName('user_attributes').' AS t2 ON t1.id=t2.internalKey
175
+				' . $sqlLike.'
176 176
 				ORDER BY t1.username ASC
177 177
 				' . $sqlLimit);
178 178
 
179 179
             if ($modx->hasPermission('new_user')) {
180
-                $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>' . $_lang['new_user'] . '</a></li>';
180
+                $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>'.$_lang['new_user'].'</a></li>';
181 181
             }
182 182
 
183 183
             if ($count = $modx->db->getRecordCount($sql)) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
186 186
                 }
187 187
                 while ($row = $modx->db->getRow($sql)) {
188
-                    $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
188
+                    $items .= '<li class="item '.($row['blocked'] ? 'disabled' : '').'"><a id="a_'.$a.'__id_'.$row['id'].'" href="index.php?a='.$a.'&id='.$row['id'].'" target="main">'.$row['name'].' <small>('.$row['id'].')</small></a></li>';
189 189
                 }
190 190
             }
191 191
 
@@ -205,18 +205,18 @@  discard block
 block discarded – undo
205 205
             $output = '';
206 206
             $items = '';
207 207
             $filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
208
-            $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
209
-            $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
208
+            $sqlLike = $filter ? 'WHERE t1.username LIKE "'.$modx->db->escape($filter).'%"' : '';
209
+            $sqlLimit = $sqlLike ? '' : 'LIMIT '.$limit;
210 210
 
211 211
             $sql = $modx->db->query('SELECT t1.*, t1.username AS name, t2.blocked
212
-				FROM ' . $modx->getFullTableName('web_users') . ' AS t1
213
-				LEFT JOIN ' . $modx->getFullTableName('web_user_attributes') . ' AS t2 ON t1.id=t2.internalKey
214
-				' . $sqlLike . '
212
+				FROM ' . $modx->getFullTableName('web_users').' AS t1
213
+				LEFT JOIN ' . $modx->getFullTableName('web_user_attributes').' AS t2 ON t1.id=t2.internalKey
214
+				' . $sqlLike.'
215 215
 				ORDER BY t1.username ASC
216 216
 				' . $sqlLimit);
217 217
 
218 218
             if ($modx->hasPermission('new_web_user')) {
219
-                $output .= '<li><a id="a_87" href="index.php?a=87" target="main"><i class="fa fa-plus"></i>' . $_lang['new_web_user'] . '</a></li>';
219
+                $output .= '<li><a id="a_87" href="index.php?a=87" target="main"><i class="fa fa-plus"></i>'.$_lang['new_web_user'].'</a></li>';
220 220
             }
221 221
 
222 222
             if ($count = $modx->db->getRecordCount($sql)) {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
225 225
                 }
226 226
                 while ($row = $modx->db->getRow($sql)) {
227
-                    $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
227
+                    $items .= '<li class="item '.($row['blocked'] ? 'disabled' : '').'"><a id="a_'.$a.'__id_'.$row['id'].'" href="index.php?a='.$a.'&id='.$row['id'].'" target="main">'.$row['name'].' <small>('.$row['id'].')</small></a></li>';
228 228
                 }
229 229
             }
230 230
 
@@ -250,35 +250,35 @@  discard block
 block discarded – undo
250 250
                     case 'SnippetNoCache': {
251 251
 
252 252
                         $sql = $modx->db->query('SELECT *
253
-						FROM ' . $modx->getFullTableName('site_snippets') . '
254
-						WHERE name="' . $name . '"
253
+						FROM ' . $modx->getFullTableName('site_snippets').'
254
+						WHERE name="' . $name.'"
255 255
 						LIMIT 1');
256 256
 
257 257
                         if ($modx->db->getRecordCount($sql)) {
258 258
                             $row = $modx->db->getRow($sql);
259 259
                             $contextmenu = array(
260 260
                                 'header' => array(
261
-                                    'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
261
+                                    'innerHTML' => '<i class="fa fa-code"></i> '.$row['name']
262 262
                                 ),
263 263
                                 'item' => array(
264
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
265
-                                    'url' => "index.php?a=22&id=" . $row['id']
264
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
265
+                                    'url' => "index.php?a=22&id=".$row['id']
266 266
                                 )
267 267
                             );
268 268
                             if (!empty($row['description'])) {
269 269
                                 $contextmenu['seperator'] = '';
270 270
                                 $contextmenu['description'] = array(
271
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
271
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
272 272
                                 );
273 273
                             }
274 274
                         } else {
275 275
                             $contextmenu = array(
276 276
                                 'header' => array(
277
-                                    'innerHTML' => '<i class="fa fa-code"></i> ' . $name
277
+                                    'innerHTML' => '<i class="fa fa-code"></i> '.$name
278 278
                                 ),
279 279
                                 'item' => array(
280
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
281
-                                    'url' => "index.php?a=23&itemname=" . $name
280
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_snippet'],
281
+                                    'url' => "index.php?a=23&itemname=".$name
282 282
                                 )
283 283
                             );
284 284
                         }
@@ -288,35 +288,35 @@  discard block
 block discarded – undo
288 288
                     case 'Chunk' : {
289 289
 
290 290
                         $sql = $modx->db->query('SELECT *
291
-						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
292
-						WHERE name="' . $name . '"
291
+						FROM ' . $modx->getFullTableName('site_htmlsnippets').'
292
+						WHERE name="' . $name.'"
293 293
 						LIMIT 1');
294 294
 
295 295
                         if ($modx->db->getRecordCount($sql)) {
296 296
                             $row = $modx->db->getRow($sql);
297 297
                             $contextmenu = array(
298 298
                                 'header' => array(
299
-                                    'innerHTML' => '<i class="fa fa-th-large"></i> ' . $row['name']
299
+                                    'innerHTML' => '<i class="fa fa-th-large"></i> '.$row['name']
300 300
                                 ),
301 301
                                 'item' => array(
302
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
303
-                                    'url' => "index.php?a=78&id=" . $row['id']
302
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
303
+                                    'url' => "index.php?a=78&id=".$row['id']
304 304
                                 )
305 305
                             );
306 306
                             if (!empty($row['description'])) {
307 307
                                 $contextmenu['seperator'] = '';
308 308
                                 $contextmenu['description'] = array(
309
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
309
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
310 310
                                 );
311 311
                             }
312 312
                         } else {
313 313
                             $contextmenu = array(
314 314
                                 'header' => array(
315
-                                    'innerHTML' => '<i class="fa fa-th-large"></i> ' . $name
315
+                                    'innerHTML' => '<i class="fa fa-th-large"></i> '.$name
316 316
                                 ),
317 317
                                 'item' => array(
318
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
319
-                                    'url' => "index.php?a=77&itemname=" . $name
318
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_htmlsnippet'],
319
+                                    'url' => "index.php?a=77&itemname=".$name
320 320
                                 )
321 321
                             );
322 322
                         }
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
                     }
326 326
                     case 'AttributeValue': {
327 327
                         $sql = $modx->db->query('SELECT *
328
-						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
329
-						WHERE name="' . $name . '"
328
+						FROM ' . $modx->getFullTableName('site_htmlsnippets').'
329
+						WHERE name="' . $name.'"
330 330
 						LIMIT 1');
331 331
 
332 332
                         if ($modx->db->getRecordCount($sql)) {
@@ -336,52 +336,52 @@  discard block
 block discarded – undo
336 336
                                     'innerText' => $row['name']
337 337
                                 ),
338 338
                                 'item' => array(
339
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
340
-                                    'url' => "index.php?a=78&id=" . $row['id']
339
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
340
+                                    'url' => "index.php?a=78&id=".$row['id']
341 341
                                 )
342 342
                             );
343 343
                             if (!empty($row['description'])) {
344 344
                                 $contextmenu['seperator'] = '';
345 345
                                 $contextmenu['description'] = array(
346
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
346
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
347 347
                                 );
348 348
                             }
349 349
                         } else {
350 350
 
351 351
                             $sql = $modx->db->query('SELECT *
352
-							FROM ' . $modx->getFullTableName('site_snippets') . '
353
-							WHERE name="' . $name . '"
352
+							FROM ' . $modx->getFullTableName('site_snippets').'
353
+							WHERE name="' . $name.'"
354 354
 							LIMIT 1');
355 355
 
356 356
                             if ($modx->db->getRecordCount($sql)) {
357 357
                                 $row = $modx->db->getRow($sql);
358 358
                                 $contextmenu = array(
359 359
                                     'header' => array(
360
-                                        'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
360
+                                        'innerHTML' => '<i class="fa fa-code"></i> '.$row['name']
361 361
                                     ),
362 362
                                     'item' => array(
363
-                                        'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
364
-                                        'url' => "index.php?a=22&id=" . $row['id']
363
+                                        'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
364
+                                        'url' => "index.php?a=22&id=".$row['id']
365 365
                                     )
366 366
                                 );
367 367
                                 if (!empty($row['description'])) {
368 368
                                     $contextmenu['seperator'] = '';
369 369
                                     $contextmenu['description'] = array(
370
-                                        'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
370
+                                        'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
371 371
                                     );
372 372
                                 }
373 373
                             } else {
374 374
                                 $contextmenu = array(
375 375
                                     'header' => array(
376
-                                        'innerHTML' => '<i class="fa fa-code"></i> ' . $name
376
+                                        'innerHTML' => '<i class="fa fa-code"></i> '.$name
377 377
                                     ),
378 378
                                     'item' => array(
379
-                                        'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
380
-                                        'url' => "index.php?a=77&itemname=" . $name
379
+                                        'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_htmlsnippet'],
380
+                                        'url' => "index.php?a=77&itemname=".$name
381 381
                                     ),
382 382
                                     'item2' => array(
383
-                                        'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
384
-                                        'url' => "index.php?a=23&itemname=" . $name
383
+                                        'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_snippet'],
384
+                                        'url' => "index.php?a=23&itemname=".$name
385 385
                                     )
386 386
                                 );
387 387
                             }
@@ -437,35 +437,35 @@  discard block
 block discarded – undo
437 437
                         }
438 438
 
439 439
                         $sql = $modx->db->query('SELECT *
440
-						FROM ' . $modx->getFullTableName('site_tmplvars') . '
441
-						WHERE name="' . $name . '"
440
+						FROM ' . $modx->getFullTableName('site_tmplvars').'
441
+						WHERE name="' . $name.'"
442 442
 						LIMIT 1');
443 443
 
444 444
                         if ($modx->db->getRecordCount($sql)) {
445 445
                             $row = $modx->db->getRow($sql);
446 446
                             $contextmenu = array(
447 447
                                 'header' => array(
448
-                                    'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $row['name']
448
+                                    'innerHTML' => '<i class="fa fa-list-alt"></i> '.$row['name']
449 449
                                 ),
450 450
                                 'item' => array(
451
-                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
452
-                                    'url' => "index.php?a=301&id=" . $row['id']
451
+                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> '.$_lang['edit'],
452
+                                    'url' => "index.php?a=301&id=".$row['id']
453 453
                                 )
454 454
                             );
455 455
                             if (!empty($row['description'])) {
456 456
                                 $contextmenu['seperator'] = '';
457 457
                                 $contextmenu['description'] = array(
458
-                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
458
+                                    'innerHTML' => '<i class="fa fa-info"></i> '.$row['description']
459 459
                                 );
460 460
                             }
461 461
                         } else {
462 462
                             $contextmenu = array(
463 463
                                 'header' => array(
464
-                                    'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $name
464
+                                    'innerHTML' => '<i class="fa fa-list-alt"></i> '.$name
465 465
                                 ),
466 466
                                 'item' => array(
467
-                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_tmplvars'],
468
-                                    'url' => "index.php?a=300&itemname=" . $name
467
+                                    'innerHTML' => '<i class="fa fa-plus"></i> '.$_lang['new_tmplvars'],
468
+                                    'url' => "index.php?a=300&itemname=".$name
469 469
                                 )
470 470
                             );
471 471
                         }
@@ -484,15 +484,15 @@  discard block
 block discarded – undo
484 484
             $json = array();
485 485
 
486 486
             if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
487
-                $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : '';
488
-                $parent = isset($_REQUEST['parent']) ? (int)$_REQUEST['parent'] : 0;
487
+                $id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
488
+                $parent = isset($_REQUEST['parent']) ? (int) $_REQUEST['parent'] : 0;
489 489
                 $menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0;
490 490
 
491 491
                 // set parent
492 492
                 if ($id && $parent >= 0) {
493 493
 
494 494
                     // find older parent
495
-                    $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id=' . $id));
495
+                    $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id='.$id));
496 496
 
497 497
                     $eventOut = $modx->invokeEvent('onBeforeMoveDocument', [
498 498
                         'id_document' => $id,
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
                     if (empty($json['errors'])) {
514 514
                         // check privileges user for move docs
515 515
                         if (!empty($modx->config['tree_show_protected']) && $role != 1) {
516
-                            $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN(' . $id . ',' . $parent . ',' . $parentOld . ')');
516
+                            $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN('.$id.','.$parent.','.$parentOld.')');
517 517
                             if ($modx->db->getRecordCount($sql)) {
518 518
                                 $document_groups = array();
519 519
                                 while ($row = $modx->db->getRow($sql)) {
@@ -538,22 +538,22 @@  discard block
 block discarded – undo
538 538
                             // set new parent
539 539
                             $modx->db->update(array(
540 540
                                 'parent' => $parent
541
-                            ), $modx->getFullTableName('site_content'), 'id=' . $id);
541
+                            ), $modx->getFullTableName('site_content'), 'id='.$id);
542 542
                             // set parent isfolder = 1
543 543
                             $modx->db->update(array(
544 544
                                 'isfolder' => 1
545
-                            ), $modx->getFullTableName('site_content'), 'id=' . $parent);
545
+                            ), $modx->getFullTableName('site_content'), 'id='.$parent);
546 546
 
547 547
                             if ($parent != $parentOld) {
548 548
                                 // check children docs and set parent isfolder
549
-                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
549
+                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent='.$parentOld))) {
550 550
                                     $modx->db->update(array(
551 551
                                         'isfolder' => 1
552
-                                    ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
552
+                                    ), $modx->getFullTableName('site_content'), 'id='.$parentOld);
553 553
                                 } else {
554 554
                                     $modx->db->update(array(
555 555
                                         'isfolder' => 0
556
-                                    ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
556
+                                    ), $modx->getFullTableName('site_content'), 'id='.$parentOld);
557 557
                                 }
558 558
                             }
559 559
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
                             if (!empty($menuindex)) {
562 562
                                 $menuindex = explode(',', $menuindex);
563 563
                                 foreach ($menuindex as $key => $value) {
564
-                                    $modx->db->query('UPDATE ' . $modx->getFullTableName('site_content') . ' SET menuindex=' . $key . ' WHERE id=' . $value);
564
+                                    $modx->db->query('UPDATE '.$modx->getFullTableName('site_content').' SET menuindex='.$key.' WHERE id='.$value);
565 565
                                 }
566 566
                             } else {
567 567
                                 // TODO: max(*) menuindex
@@ -590,19 +590,19 @@  discard block
 block discarded – undo
590 590
         }
591 591
 
592 592
         case 'getLockedElements': {
593
-            $type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : 0;
594
-            $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
593
+            $type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : 0;
594
+            $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
595 595
 
596 596
             $output = !!$modx->elementIsLocked($type, $id, true);
597 597
 
598 598
             if (!$output) {
599 599
                 $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
600
-                $docgrp_cond = $docgrp ? ' OR dg.document_group IN (' . $docgrp . ')' : '';
600
+                $docgrp_cond = $docgrp ? ' OR dg.document_group IN ('.$docgrp.')' : '';
601 601
                 $sql = '
602
-                    SELECT MAX(IF(1=' . $role . ' OR sc.privatemgr=0' . $docgrp_cond . ', 0, 1)) AS locked
603
-                    FROM ' . $modx->getFullTableName('site_content') . ' AS sc 
604
-                    LEFT JOIN ' . $modx->getFullTableName('document_groups') . ' dg ON dg.document=sc.id
605
-                    WHERE sc.id=' . $id . ' GROUP BY sc.id';
602
+                    SELECT MAX(IF(1=' . $role.' OR sc.privatemgr=0'.$docgrp_cond.', 0, 1)) AS locked
603
+                    FROM ' . $modx->getFullTableName('site_content').' AS sc 
604
+                    LEFT JOIN ' . $modx->getFullTableName('document_groups').' dg ON dg.document=sc.id
605
+                    WHERE sc.id=' . $id.' GROUP BY sc.id';
606 606
                 $sql = $modx->db->query($sql);
607 607
                 if ($modx->db->getRecordCount($sql)) {
608 608
                     $row = $modx->db->getRow($sql);
Please login to merge, or discard this patch.
Braces   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
 
8 8
 $modx->db->connect();
9 9
 
10
-if (empty ($modx->config)) {
10
+if (empty ($modx->config)) {
11 11
     $modx->getSettings();
12 12
 }
13 13
 
14
-if (!isset($_SESSION['mgrValidated']) || !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
14
+if (!isset($_SESSION['mgrValidated']) || !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
15 15
     $modx->sendErrorPage();
16 16
 }
17 17
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
 $_lang = array();
22 22
 include_once MODX_MANAGER_PATH . '/includes/lang/english.inc.php';
23
-if ($modx->config['manager_language'] != 'english') {
23
+if ($modx->config['manager_language'] != 'english') {
24 24
     include_once MODX_MANAGER_PATH . '/includes/lang/' . $modx->config['manager_language'] . '.inc.php';
25 25
 }
26 26
 include_once MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/style.php';
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 // set limit sql query
34 34
 $limit = !empty($modx->config['number_of_results']) ? (int) $modx->config['number_of_results'] : 100;
35 35
 
36
-if (isset($action)) {
37
-    switch ($action) {
36
+if (isset($action)) {
37
+    switch ($action) {
38 38
 
39 39
         case '1': {
40 40
 
41
-            switch ($frame) {
41
+            switch ($frame) {
42 42
                 case 'nodes':
43 43
                     include_once MODX_MANAGER_PATH . '/frames/nodes.php';
44 44
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
             $elements = isset($_REQUEST['elements']) && is_scalar($_REQUEST['elements']) ? htmlentities($_REQUEST['elements']) : '';
54 54
 
55
-            if ($elements) {
55
+            if ($elements) {
56 56
                 $output = '';
57 57
                 $items = '';
58 58
                 $sql = '';
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                 $sqlLike = $filter ? 'WHERE t1.name LIKE "' . $modx->db->escape($filter) . '%"' : '';
62 62
                 $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;
63 63
 
64
-                switch ($elements) {
64
+                switch ($elements) {
65 65
                     case 'element_templates':
66 66
                         $a = 16;
67 67
                         $sqlLike = $filter ? 'WHERE t1.templatename LIKE "' . $modx->db->escape($filter) . '%"' : '';
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                         ORDER BY t1.templatename ASC
72 72
                         ' . $sqlLimit);
73 73
 
74
-                        if ($modx->hasPermission('new_template')) {
74
+                        if ($modx->hasPermission('new_template')) {
75 75
                             $output .= '<li><a id="a_19" href="index.php?a=19" target="main"><i class="fa fa-plus"></i>' . $_lang['new_template'] . '</a></li>';
76 76
                         }
77 77
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                         ORDER BY t1.name ASC
88 88
                         ' . $sqlLimit);
89 89
 
90
-                        if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
90
+                        if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
91 91
                             $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>' . $_lang['new_tmplvars'] . '</a></li>';
92 92
                         }
93 93
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
                         ORDER BY t1.name ASC
102 102
                         ' . $sqlLimit);
103 103
 
104
-                        if ($modx->hasPermission('new_chunk')) {
104
+                        if ($modx->hasPermission('new_chunk')) {
105 105
                             $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>' . $_lang['new_htmlsnippet'] . '</a></li>';
106 106
                         }
107 107
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                         ORDER BY t1.name ASC
116 116
                         ' . $sqlLimit);
117 117
 
118
-                        if ($modx->hasPermission('new_snippet')) {
118
+                        if ($modx->hasPermission('new_snippet')) {
119 119
                             $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>' . $_lang['new_snippet'] . '</a></li>';
120 120
                         }
121 121
 
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
                         ORDER BY t1.name ASC
130 130
                         ' . $sqlLimit);
131 131
 
132
-                        if ($modx->hasPermission('new_plugin')) {
132
+                        if ($modx->hasPermission('new_plugin')) {
133 133
                             $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>' . $_lang['new_plugin'] . '</a></li>';
134 134
                         }
135 135
 
136 136
                         break;
137 137
                 }
138 138
 
139
-                if ($count = $modx->db->getRecordCount($sql)) {
140
-                    if ($count == $limit) {
139
+                if ($count = $modx->db->getRecordCount($sql)) {
140
+                    if ($count == $limit) {
141 141
                         $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
142 142
                     }
143
-                    while ($row = $modx->db->getRow($sql)) {
144
-                        if (($row['disabled'] || $row['locked']) && $role != 1) {
143
+                    while ($row = $modx->db->getRow($sql)) {
144
+                        if (($row['disabled'] || $row['locked']) && $role != 1) {
145 145
                             continue;
146 146
                         }
147 147
 
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
                     }
150 150
                 }
151 151
 
152
-                if (isset($_REQUEST['filter'])) {
152
+                if (isset($_REQUEST['filter'])) {
153 153
                     $output = $items;
154
-                } else {
154
+                } else {
155 155
                     $output .= $items;
156 156
                 }
157 157
 
@@ -176,22 +176,22 @@  discard block
 block discarded – undo
176 176
 				ORDER BY t1.username ASC
177 177
 				' . $sqlLimit);
178 178
 
179
-            if ($modx->hasPermission('new_user')) {
179
+            if ($modx->hasPermission('new_user')) {
180 180
                 $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>' . $_lang['new_user'] . '</a></li>';
181 181
             }
182 182
 
183
-            if ($count = $modx->db->getRecordCount($sql)) {
184
-                if ($count == $limit) {
183
+            if ($count = $modx->db->getRecordCount($sql)) {
184
+                if ($count == $limit) {
185 185
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
186 186
                 }
187
-                while ($row = $modx->db->getRow($sql)) {
187
+                while ($row = $modx->db->getRow($sql)) {
188 188
                     $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
189 189
                 }
190 190
             }
191 191
 
192
-            if (isset($_REQUEST['filter'])) {
192
+            if (isset($_REQUEST['filter'])) {
193 193
                 $output = $items;
194
-            } else {
194
+            } else {
195 195
                 $output .= $items;
196 196
             }
197 197
 
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 				ORDER BY t1.username ASC
216 216
 				' . $sqlLimit);
217 217
 
218
-            if ($modx->hasPermission('new_web_user')) {
218
+            if ($modx->hasPermission('new_web_user')) {
219 219
                 $output .= '<li><a id="a_87" href="index.php?a=87" target="main"><i class="fa fa-plus"></i>' . $_lang['new_web_user'] . '</a></li>';
220 220
             }
221 221
 
222
-            if ($count = $modx->db->getRecordCount($sql)) {
223
-                if ($count == $limit) {
222
+            if ($count = $modx->db->getRecordCount($sql)) {
223
+                if ($count == $limit) {
224 224
                     $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>';
225 225
                 }
226
-                while ($row = $modx->db->getRow($sql)) {
226
+                while ($row = $modx->db->getRow($sql)) {
227 227
                     $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
228 228
                 }
229 229
             }
230 230
 
231
-            if (isset($_REQUEST['filter'])) {
231
+            if (isset($_REQUEST['filter'])) {
232 232
                 $output = $items;
233
-            } else {
233
+            } else {
234 234
                 $output .= $items;
235 235
             }
236 236
 
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
             $type = isset($_REQUEST['type']) && is_scalar($_REQUEST['type']) ? $modx->db->escape($_REQUEST['type']) : false;
245 245
             $contextmenu = '';
246 246
 
247
-            if ($role && $name && $type) {
248
-                switch ($type) {
247
+            if ($role && $name && $type) {
248
+                switch ($type) {
249 249
                     case 'Snippet':
250 250
                     case 'SnippetNoCache': {
251 251
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 						WHERE name="' . $name . '"
255 255
 						LIMIT 1');
256 256
 
257
-                        if ($modx->db->getRecordCount($sql)) {
257
+                        if ($modx->db->getRecordCount($sql)) {
258 258
                             $row = $modx->db->getRow($sql);
259 259
                             $contextmenu = array(
260 260
                                 'header' => array(
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
                                     'url' => "index.php?a=22&id=" . $row['id']
266 266
                                 )
267 267
                             );
268
-                            if (!empty($row['description'])) {
268
+                            if (!empty($row['description'])) {
269 269
                                 $contextmenu['seperator'] = '';
270 270
                                 $contextmenu['description'] = array(
271 271
                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
272 272
                                 );
273 273
                             }
274
-                        } else {
274
+                        } else {
275 275
                             $contextmenu = array(
276 276
                                 'header' => array(
277 277
                                     'innerHTML' => '<i class="fa fa-code"></i> ' . $name
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 						WHERE name="' . $name . '"
293 293
 						LIMIT 1');
294 294
 
295
-                        if ($modx->db->getRecordCount($sql)) {
295
+                        if ($modx->db->getRecordCount($sql)) {
296 296
                             $row = $modx->db->getRow($sql);
297 297
                             $contextmenu = array(
298 298
                                 'header' => array(
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
                                     'url' => "index.php?a=78&id=" . $row['id']
304 304
                                 )
305 305
                             );
306
-                            if (!empty($row['description'])) {
306
+                            if (!empty($row['description'])) {
307 307
                                 $contextmenu['seperator'] = '';
308 308
                                 $contextmenu['description'] = array(
309 309
                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
310 310
                                 );
311 311
                             }
312
-                        } else {
312
+                        } else {
313 313
                             $contextmenu = array(
314 314
                                 'header' => array(
315 315
                                     'innerHTML' => '<i class="fa fa-th-large"></i> ' . $name
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 						WHERE name="' . $name . '"
330 330
 						LIMIT 1');
331 331
 
332
-                        if ($modx->db->getRecordCount($sql)) {
332
+                        if ($modx->db->getRecordCount($sql)) {
333 333
                             $row = $modx->db->getRow($sql);
334 334
                             $contextmenu = array(
335 335
                                 'header' => array(
@@ -340,20 +340,20 @@  discard block
 block discarded – undo
340 340
                                     'url' => "index.php?a=78&id=" . $row['id']
341 341
                                 )
342 342
                             );
343
-                            if (!empty($row['description'])) {
343
+                            if (!empty($row['description'])) {
344 344
                                 $contextmenu['seperator'] = '';
345 345
                                 $contextmenu['description'] = array(
346 346
                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
347 347
                                 );
348 348
                             }
349
-                        } else {
349
+                        } else {
350 350
 
351 351
                             $sql = $modx->db->query('SELECT *
352 352
 							FROM ' . $modx->getFullTableName('site_snippets') . '
353 353
 							WHERE name="' . $name . '"
354 354
 							LIMIT 1');
355 355
 
356
-                            if ($modx->db->getRecordCount($sql)) {
356
+                            if ($modx->db->getRecordCount($sql)) {
357 357
                                 $row = $modx->db->getRow($sql);
358 358
                                 $contextmenu = array(
359 359
                                     'header' => array(
@@ -364,13 +364,13 @@  discard block
 block discarded – undo
364 364
                                         'url' => "index.php?a=22&id=" . $row['id']
365 365
                                     )
366 366
                                 );
367
-                                if (!empty($row['description'])) {
367
+                                if (!empty($row['description'])) {
368 368
                                     $contextmenu['seperator'] = '';
369 369
                                     $contextmenu['description'] = array(
370 370
                                         'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
371 371
                                     );
372 372
                                 }
373
-                            } else {
373
+                            } else {
374 374
                                 $contextmenu = array(
375 375
                                     'header' => array(
376 376
                                         'innerHTML' => '<i class="fa fa-code"></i> ' . $name
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
                             'alias_visible'
433 433
                         );
434 434
 
435
-                        if (in_array($name, $default_field)) {
435
+                        if (in_array($name, $default_field)) {
436 436
                             return;
437 437
                         }
438 438
 
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 						WHERE name="' . $name . '"
442 442
 						LIMIT 1');
443 443
 
444
-                        if ($modx->db->getRecordCount($sql)) {
444
+                        if ($modx->db->getRecordCount($sql)) {
445 445
                             $row = $modx->db->getRow($sql);
446 446
                             $contextmenu = array(
447 447
                                 'header' => array(
@@ -452,13 +452,13 @@  discard block
 block discarded – undo
452 452
                                     'url' => "index.php?a=301&id=" . $row['id']
453 453
                                 )
454 454
                             );
455
-                            if (!empty($row['description'])) {
455
+                            if (!empty($row['description'])) {
456 456
                                 $contextmenu['seperator'] = '';
457 457
                                 $contextmenu['description'] = array(
458 458
                                     'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
459 459
                                 );
460 460
                             }
461
-                        } else {
461
+                        } else {
462 462
                             $contextmenu = array(
463 463
                                 'header' => array(
464 464
                                     'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $name
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
         case 'movedocument' : {
484 484
             $json = array();
485 485
 
486
-            if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
486
+            if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
487 487
                 $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : '';
488 488
                 $parent = isset($_REQUEST['parent']) ? (int)$_REQUEST['parent'] : 0;
489 489
                 $menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0;
490 490
 
491 491
                 // set parent
492
-                if ($id && $parent >= 0) {
492
+                if ($id && $parent >= 0) {
493 493
 
494 494
                     // find older parent
495 495
                     $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id=' . $id));
@@ -500,31 +500,31 @@  discard block
 block discarded – undo
500 500
                         'new_parent'  => $parent,
501 501
                     ]);
502 502
 
503
-                    if (is_array($eventOut) && count($eventOut) > 0) {
503
+                    if (is_array($eventOut) && count($eventOut) > 0) {
504 504
                         $eventParent = array_pop($eventOut);
505 505
 
506
-                        if ($eventParent == $parentOld) {
506
+                        if ($eventParent == $parentOld) {
507 507
                             $json['errors'] = $_lang['error_movedocument2'];
508
-                        } else {
508
+                        } else {
509 509
                             $parent = $eventParent;
510 510
                         }
511 511
                     }
512 512
 
513
-                    if (empty($json['errors'])) {
513
+                    if (empty($json['errors'])) {
514 514
                         // check privileges user for move docs
515
-                        if (!empty($modx->config['tree_show_protected']) && $role != 1) {
515
+                        if (!empty($modx->config['tree_show_protected']) && $role != 1) {
516 516
                             $sql = $modx->db->select('*', $modx->getFullTableName('document_groups'), 'document IN(' . $id . ',' . $parent . ',' . $parentOld . ')');
517
-                            if ($modx->db->getRecordCount($sql)) {
517
+                            if ($modx->db->getRecordCount($sql)) {
518 518
                                 $document_groups = array();
519
-                                while ($row = $modx->db->getRow($sql)) {
519
+                                while ($row = $modx->db->getRow($sql)) {
520 520
                                     $document_groups[$row['document']]['groups'][] = $row['document_group'];
521 521
                                 }
522
-                                foreach ($document_groups as $key => $value) {
523
-                                    if (($key == $parent || $key == $parentOld || $key == $id) && !in_array($role, $value['groups'])) {
522
+                                foreach ($document_groups as $key => $value) {
523
+                                    if (($key == $parent || $key == $parentOld || $key == $id) && !in_array($role, $value['groups'])) {
524 524
                                         $json['errors'] = $_lang["error_no_privileges"];
525 525
                                     }
526 526
                                 }
527
-                                if ($json['errors']) {
527
+                                if ($json['errors']) {
528 528
                                     header('content-type: application/json');
529 529
                                     echo json_encode($json, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);
530 530
                                     break;
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
                             }
533 533
                         }
534 534
 
535
-                        if ($parent == 0 && $parent != $parentOld && !$modx->config['udperms_allowroot'] && $role != 1) {
535
+                        if ($parent == 0 && $parent != $parentOld && !$modx->config['udperms_allowroot'] && $role != 1) {
536 536
                             $json['errors'] = $_lang["error_no_privileges"];
537
-                        } else {
537
+                        } else {
538 538
                             // set new parent
539 539
                             $modx->db->update(array(
540 540
                                 'parent' => $parent
@@ -544,13 +544,13 @@  discard block
 block discarded – undo
544 544
                                 'isfolder' => 1
545 545
                             ), $modx->getFullTableName('site_content'), 'id=' . $parent);
546 546
 
547
-                            if ($parent != $parentOld) {
547
+                            if ($parent != $parentOld) {
548 548
                                 // check children docs and set parent isfolder
549
-                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
549
+                                if ($modx->db->getRecordCount($modx->db->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
550 550
                                     $modx->db->update(array(
551 551
                                         'isfolder' => 1
552 552
                                     ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
553
-                                } else {
553
+                                } else {
554 554
                                     $modx->db->update(array(
555 555
                                         'isfolder' => 0
556 556
                                     ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
@@ -558,16 +558,16 @@  discard block
 block discarded – undo
558 558
                             }
559 559
 
560 560
                             // set menuindex
561
-                            if (!empty($menuindex)) {
561
+                            if (!empty($menuindex)) {
562 562
                                 $menuindex = explode(',', $menuindex);
563
-                                foreach ($menuindex as $key => $value) {
563
+                                foreach ($menuindex as $key => $value) {
564 564
                                     $modx->db->query('UPDATE ' . $modx->getFullTableName('site_content') . ' SET menuindex=' . $key . ' WHERE id=' . $value);
565 565
                                 }
566
-                            } else {
566
+                            } else {
567 567
                                 // TODO: max(*) menuindex
568 568
                             }
569 569
 
570
-                            if (!$json['errors']) {
570
+                            if (!$json['errors']) {
571 571
                                 $json['success'] = $_lang["actioncomplete"];
572 572
 
573 573
                                 $modx->invokeEvent('onAfterMoveDocument', [
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
                         }
580 580
                     }
581 581
                 }
582
-            } else {
582
+            } else {
583 583
                 $json['errors'] = $_lang["error_no_privileges"];
584 584
             }
585 585
 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 
596 596
             $output = !!$modx->elementIsLocked($type, $id, true);
597 597
 
598
-            if (!$output) {
598
+            if (!$output) {
599 599
                 $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
600 600
                 $docgrp_cond = $docgrp ? ' OR dg.document_group IN (' . $docgrp . ')' : '';
601 601
                 $sql = '
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
                     LEFT JOIN ' . $modx->getFullTableName('document_groups') . ' dg ON dg.document=sc.id
605 605
                     WHERE sc.id=' . $id . ' GROUP BY sc.id';
606 606
                 $sql = $modx->db->query($sql);
607
-                if ($modx->db->getRecordCount($sql)) {
607
+                if ($modx->db->getRecordCount($sql)) {
608 608
                     $row = $modx->db->getRow($sql);
609 609
                     $output = !!$row['locked'];
610 610
                 }
Please login to merge, or discard this patch.