Completed
Push — develop ( 8dee05 )
by Dmytro
20:08
created
manager/media/browser/mcpuk/lib/helper_text.php 1 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('"', """,
32 35
             str_replace("'", ''',
@@ -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_zipFolder.php 1 patch
Braces   +17 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,20 +13,23 @@  discard block
 block discarded – undo
13 13
   *      @link http://kcfinder.sunhater.com
14 14
   */
15 15
 
16
-class zipFolder {
16
+class zipFolder
17
+{
17 18
     protected $zip;
18 19
     protected $root;
19 20
     protected $ignored;
20 21
 
21
-    function __construct($file, $folder, $ignored=null) {
22
+    function __construct($file, $folder, $ignored=null)
23
+    {
22 24
         $this->zip = new ZipArchive();
23 25
 
24 26
         $this->ignored = is_array($ignored)
25 27
             ? $ignored
26 28
             : ($ignored ? array($ignored) : array());
27 29
 
28
-        if ($this->zip->open($file, ZIPARCHIVE::CREATE) !== TRUE)
29
-            throw new Exception("cannot open <$file>\n");
30
+        if ($this->zip->open($file, ZIPARCHIVE::CREATE) !== TRUE) {
31
+                    throw new Exception("cannot open <$file>\n");
32
+        }
30 33
 
31 34
         $folder = rtrim($folder, '/');
32 35
 
@@ -39,19 +42,22 @@  discard block
 block discarded – undo
39 42
         $this->zip->close();
40 43
     }
41 44
 
42
-    function zip($folder, $parent=null) {
45
+    function zip($folder, $parent=null)
46
+    {
43 47
         $full_path = "{$this->root}$parent$folder";
44 48
         $zip_path = "$parent$folder";
45 49
         $this->zip->addEmptyDir($zip_path);
46 50
         $dir = new DirectoryIterator($full_path);
47
-        foreach ($dir as $file)
48
-            if (!$file->isDot()) {
51
+        foreach ($dir as $file) {
52
+                    if (!$file->isDot()) {
49 53
                 $filename = $file->getFilename();
54
+        }
50 55
                 if (!in_array($filename, $this->ignored)) {
51
-                    if ($file->isDir())
52
-                        $this->zip($filename, "$zip_path/");
53
-                    else
54
-                        $this->zip->addFile("$full_path/$filename", "$zip_path/$filename");
56
+                    if ($file->isDir()) {
57
+                                            $this->zip($filename, "$zip_path/");
58
+                    } else {
59
+                                            $this->zip->addFile("$full_path/$filename", "$zip_path/$filename");
60
+                    }
55 61
                 }
56 62
             }
57 63
     }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/browse.php 1 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/js_localize.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,9 +28,12 @@
 block discarded – undo
28 28
     die;
29 29
 }
30 30
 $mtime = @filemtime($file);
31
-if ($mtime) httpCache::checkMTime($mtime);
31
+if ($mtime) {
32
+    httpCache::checkMTime($mtime);
33
+}
32 34
 require $file;
33 35
 header("Content-Type: text/javascript; charset={$lang['_charset']}");
34
-foreach ($lang as $english => $native)
36
+foreach ($lang as $english => $native) {
35 37
     if (substr($english, 0, 1) != "_")
36 38
         echo "browser.labels['" . text::jsValue($english) . "']=\"" . text::jsValue($native) . "\";";
39
+}
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/js/browser/joiner.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,11 +23,13 @@
 block discarded – undo
23 23
 
24 24
 foreach ($files as $file) {
25 25
     $fmtime = filemtime($file);
26
-    if (!isset($mtime) || ($fmtime > $mtime))
27
-        $mtime = $fmtime;
28
-}
26
+    if (!isset($mtime) || ($fmtime > $mtime)) {
27
+            $mtime = $fmtime;
28
+    }
29
+    }
29 30
 
30 31
 httpCache::checkMTime($mtime);
31 32
 header("Content-Type: text/javascript");
32
-foreach ($files as $file)
33
+foreach ($files as $file) {
33 34
     require $file;
35
+}
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_image_imagick.php 1 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_imagick extends image {
15
+class image_imagick 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);
@@ -65,43 +78,58 @@  discard block
 block discarded – undo
65 78
         }
66 79
     }
67 80
 
68
-    public function resizeCrop($width, $height, $offset=false) {
69
-        if (!$width) $width = 1;
70
-        if (!$height) $height = 1;
81
+    public function resizeCrop($width, $height, $offset=false)
82
+    {
83
+        if (!$width) {
84
+            $width = 1;
85
+        }
86
+        if (!$height) {
87
+            $height = 1;
88
+        }
71 89
 
72 90
         if (($this->width / $this->height) > ($width / $height)) {
73 91
             $h = $height;
74 92
             $w = ($this->width * $h) / $this->height;
75 93
             $y = 0;
76 94
             if ($offset !== false) {
77
-                if ($offset > 0)
78
-                    $offset = -$offset;
79
-                if (($w + $offset) <= $width)
80
-                    $offset = $width - $w;
95
+                if ($offset > 0) {
96
+                                    $offset = -$offset;
97
+                }
98
+                if (($w + $offset) <= $width) {
99
+                                    $offset = $width - $w;
100
+                }
81 101
                 $x = $offset;
82
-            } else
83
-                $x = ($width - $w) / 2;
102
+            } else {
103
+                            $x = ($width - $w) / 2;
104
+            }
84 105
 
85 106
         } else {
86 107
             $w = $width;
87 108
             $h = ($this->height * $w) / $this->width;
88 109
             $x = 0;
89 110
             if ($offset !== false) {
90
-                if ($offset > 0)
91
-                    $offset = -$offset;
92
-                if (($h + $offset) <= $height)
93
-                    $offset = $height - $h;
111
+                if ($offset > 0) {
112
+                                    $offset = -$offset;
113
+                }
114
+                if (($h + $offset) <= $height) {
115
+                                    $offset = $height - $h;
116
+                }
94 117
                 $y = $offset;
95
-            } else
96
-                $y = ($height - $h) / 2;
118
+            } else {
119
+                            $y = ($height - $h) / 2;
120
+            }
97 121
         }
98 122
 
99 123
         $x = round($x);
100 124
         $y = round($y);
101 125
         $w = round($w);
102 126
         $h = round($h);
103
-        if (!$w) $w = 1;
104
-        if (!$h) $h = 1;
127
+        if (!$w) {
128
+            $w = 1;
129
+        }
130
+        if (!$h) {
131
+            $h = 1;
132
+        }
105 133
 
106 134
         try {
107 135
             $this->image->scaleImage($w, $h);
@@ -115,7 +143,8 @@  discard block
 block discarded – undo
115 143
         return true;
116 144
     }
117 145
 
118
-    public function rotate($angle, $background="#000000") {
146
+    public function rotate($angle, $background="#000000")
147
+    {
119 148
         try {
120 149
             $this->image->rotateImage(new ImagickPixel($background), $angle);
121 150
             $size = $this->image->getImageGeometry();
@@ -127,7 +156,8 @@  discard block
 block discarded – undo
127 156
         return true;
128 157
     }
129 158
 
130
-    public function flipHorizontal() {
159
+    public function flipHorizontal()
160
+    {
131 161
         try {
132 162
             $this->image->flopImage();
133 163
         } catch (Exception $e) {
@@ -136,7 +166,8 @@  discard block
 block discarded – undo
136 166
         return true;
137 167
     }
138 168
 
139
-    public function flipVertical() {
169
+    public function flipVertical()
170
+    {
140 171
         try {
141 172
             $this->image->flipImage();
142 173
         } catch (Exception $e) {
@@ -145,7 +176,8 @@  discard block
 block discarded – undo
145 176
         return true;
146 177
     }
147 178
 
148
-    public function watermark($file, $left=false, $top=false) {
179
+    public function watermark($file, $left=false, $top=false)
180
+    {
149 181
         try {
150 182
             $wm = new Imagick($file);
151 183
             $size = $wm->getImageGeometry();
@@ -167,8 +199,9 @@  discard block
 block discarded – undo
167 199
         if ((($x + $w) > $this->width) ||
168 200
             (($y + $h) > $this->height) ||
169 201
             ($x < 0) || ($y < 0)
170
-        )
171
-            return false;
202
+        ) {
203
+                    return false;
204
+        }
172 205
 
173 206
         try {
174 207
             $this->image->compositeImage($wm, Imagick::COMPOSITE_DEFAULT, $x, $y);
@@ -181,7 +214,8 @@  discard block
 block discarded – undo
181 214
 
182 215
     // ABSTRACT PROTECTED METHODS
183 216
 
184
-    protected function getBlankImage($width, $height) {
217
+    protected function getBlankImage($width, $height)
218
+    {
185 219
         try {
186 220
             $img = new Imagick();
187 221
             $img->newImage($width, $height, "none");
@@ -192,7 +226,8 @@  discard block
 block discarded – undo
192 226
         return $img;
193 227
     }
194 228
 
195
-    protected function getImage($image, &$width, &$height) {
229
+    protected function getImage($image, &$width, &$height)
230
+    {
196 231
 
197 232
         if (is_object($image) && ($image instanceof image_imagick)) {
198 233
             try {
@@ -227,18 +262,21 @@  discard block
 block discarded – undo
227 262
             $height = $size['height'];
228 263
             return $image;
229 264
 
230
-        } else
231
-            return false;
265
+        } else {
266
+                    return false;
267
+        }
232 268
     }
233 269
 
234 270
 
235 271
     // PSEUDO-ABSTRACT STATIC METHODS
236 272
 
237
-    static function available() {
273
+    static function available()
274
+    {
238 275
         return class_exists("Imagick");
239 276
     }
240 277
 
241
-    static function checkImage($file) {
278
+    static function checkImage($file)
279
+    {
242 280
         try {
243 281
             new Imagick($file);
244 282
         } catch (Exception $e) {
@@ -250,7 +288,8 @@  discard block
 block discarded – undo
250 288
 
251 289
     // INHERIT METHODS
252 290
 
253
-    public function output($type="jpeg", array $options=array()) {
291
+    public function output($type="jpeg", array $options=array())
292
+    {
254 293
         $type = strtolower($type);
255 294
         try {
256 295
             $this->image->setImageFormat($type);
@@ -258,8 +297,9 @@  discard block
 block discarded – undo
258 297
             return false;
259 298
         }
260 299
         $method = "optimize_$type";
261
-        if (method_exists($this, $method) && !$this->$method($options))
262
-            return false;
300
+        if (method_exists($this, $method) && !$this->$method($options)) {
301
+                    return false;
302
+        }
263 303
 
264 304
         if (!isset($options['file'])) {
265 305
             if (!headers_sent()) {
@@ -289,7 +329,8 @@  discard block
 block discarded – undo
289 329
 
290 330
     // OWN METHODS
291 331
 
292
-    protected function optimize_jpeg(array $options=array()) {
332
+    protected function optimize_jpeg(array $options=array())
333
+    {
293 334
         $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY;
294 335
         try {
295 336
             $this->image->setImageCompression(Imagick::COMPRESSION_JPEG);
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_image_gmagick.php 1 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/lib/class_fastImage.php 1 patch
Braces   +26 added lines, -36 removed lines patch added patch discarded remove patch
@@ -21,13 +21,17 @@  discard block
 block discarded – undo
21 21
 
22 22
 	public function __construct($uri = null)
23 23
 	{
24
-		if ($uri) $this->load($uri);
24
+		if ($uri) {
25
+		    $this->load($uri);
26
+		}
25 27
 	}
26 28
 
27 29
 
28 30
 	public function load($uri)
29 31
 	{
30
-		if ($this->handle) $this->close();
32
+		if ($this->handle) {
33
+		    $this->close();
34
+		}
31 35
 
32 36
 		$this->uri = $uri;
33 37
 		$this->handle = fopen($uri, 'r');
@@ -36,15 +40,16 @@  discard block
 block discarded – undo
36 40
 
37 41
 	public function close()
38 42
 	{
39
-		if (is_resource($this->handle)) fclose($this->handle);
43
+		if (is_resource($this->handle)) {
44
+		    fclose($this->handle);
45
+		}
40 46
 	}
41 47
 
42 48
 
43 49
 	public function getSize()
44 50
 	{
45 51
 		$this->strpos = 0;
46
-		if ($this->getType())
47
-		{
52
+		if ($this->getType()) {
48 53
 			return array_values($this->parseSize());
49 54
 		}
50 55
 
@@ -56,10 +61,8 @@  discard block
 block discarded – undo
56 61
 	{
57 62
 		$this->strpos = 0;
58 63
 
59
-		if (!$this->type)
60
-		{
61
-			switch ($this->getChars(2))
62
-			{
64
+		if (!$this->type) {
65
+			switch ($this->getChars(2)) {
63 66
 				case "BM":
64 67
 					return $this->type = 'bmp';
65 68
 				case "GI":
@@ -81,8 +84,7 @@  discard block
 block discarded – undo
81 84
 	{
82 85
 		$this->strpos = 0;
83 86
 
84
-		switch ($this->type)
85
-		{
87
+		switch ($this->type) {
86 88
 			case 'png':
87 89
 				return $this->parseSizeForPNG();
88 90
 			case 'gif':
@@ -127,10 +129,8 @@  discard block
 block discarded – undo
127 129
 	{
128 130
 		$state = null;
129 131
 
130
-		while (true)
131
-		{
132
-			switch ($state)
133
-			{
132
+		while (true) {
133
+			switch ($state) {
134 134
 				default:
135 135
 					$this->getChars(2);
136 136
 					$state = 'started';
@@ -138,27 +138,22 @@  discard block
 block discarded – undo
138 138
 
139 139
 				case 'started':
140 140
 					$b = $this->getByte();
141
-					if ($b === false) return false;
141
+					if ($b === false) {
142
+					    return false;
143
+					}
142 144
 
143 145
 					$state = $b == 0xFF ? 'sof' : 'started';
144 146
 					break;
145 147
 
146 148
 				case 'sof':
147 149
 					$b = $this->getByte();
148
-					if (in_array($b, range(0xe0, 0xef)))
149
-					{
150
+					if (in_array($b, range(0xe0, 0xef))) {
150 151
 						$state = 'skipframe';
151
-					}
152
-					elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF))))
153
-					{
152
+					} elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF)))) {
154 153
 						$state = 'readsize';
155
-					}
156
-					elseif ($b == 0xFF)
157
-					{
154
+					} elseif ($b == 0xFF) {
158 155
 						$state = 'sof';
159
-					}
160
-					else
161
-					{
156
+					} else {
162 157
 						$state = 'skipframe';
163 158
 					}
164 159
 					break;
@@ -187,21 +182,16 @@  discard block
 block discarded – undo
187 182
 		$response = null;
188 183
 
189 184
 		// do we need more data?
190
-		if ($this->strpos + $n -1 >= strlen($this->str))
191
-		{
185
+		if ($this->strpos + $n -1 >= strlen($this->str)) {
192 186
 			$end = ($this->strpos + $n);
193 187
 
194
-			while (strlen($this->str) < $end && $response !== false)
195
-			{
188
+			while (strlen($this->str) < $end && $response !== false) {
196 189
 				// read more from the file handle
197 190
 				$need = $end - ftell($this->handle);
198 191
 
199
-				if ($response = fread($this->handle, $need))
200
-				{
192
+				if ($response = fread($this->handle, $need)) {
201 193
 					$this->str .= $response;
202
-				}
203
-				else
204
-				{
194
+				} else {
205 195
 					return false;
206 196
 				}
207 197
 			}
Please login to merge, or discard this patch.
manager/actions/category_mgr/inc/request_trigger.inc.php 1 patch
Braces   +31 added lines, -65 removed lines patch added patch discarded remove patch
@@ -6,26 +6,22 @@  discard block
 block discarded – undo
6 6
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
7 7
 }
8 8
 
9
-if( isset( $_REQUEST[$cm->get('request_key')]['ajax'] ) )
10
-{
9
+if( isset( $_REQUEST[$cm->get('request_key')]['ajax'] ) ) {
11 10
     $_data  = $_REQUEST[$cm->get('request_key')];
12 11
     $output = '';
13 12
     $task   = $_data['task'];
14
-    switch( $task )
15
-    {
13
+    switch( $task ) {
16 14
         /**
17 15
          * get categories
18 16
          */
19 17
         case 'categorize_load_elements':
20 18
             $elements = $_data['elements'];
21 19
 
22
-            if( $uncategorized_elements = $cm->getAssignedElements( 0, $_data['elements'] ) )
23
-            {
20
+            if( $uncategorized_elements = $cm->getAssignedElements( 0, $_data['elements'] ) ) {
24 21
                $output .= $cm->renderView('chunks/categorize/uncategorized_elements', $uncategorized_elements);
25 22
             }
26 23
 
27
-            foreach( $cm->getCategories() as $category )
28
-            {
24
+            foreach( $cm->getCategories() as $category ) {
29 25
                 $category['elements'] = $cm->getAssignedElements( $category['id'], $_data['elements'] );
30 26
                 $output .= $cm->renderView('chunks/categorize/category', $category);
31 27
             }
@@ -41,8 +37,7 @@  discard block
 block discarded – undo
41 37
  * @see http://modxcms.com/forums/index.php/topic,40430.msg251476.html#msg251476
42 38
  *
43 39
  */
44
-if( isset( $_POST[$cm->get('request_key')]['categorize']['submit'] ) )
45
-{
40
+if( isset( $_POST[$cm->get('request_key')]['categorize']['submit'] ) ) {
46 41
     $_data = $_POST[$cm->get('request_key')]['categorize'];
47 42
     $_changes = 0;
48 43
 
@@ -54,16 +49,13 @@  discard block
 block discarded – undo
54 49
         'categorize'
55 50
     );
56 51
 
57
-    if( !isset( $_data['elements'] ) )
58
-    {
52
+    if( !isset( $_data['elements'] ) ) {
59 53
         $cm->addMessage( $cm->txt('cm_unknown_error'), 'categorize' );
60 54
         return;
61 55
     }
62 56
 
63
-    foreach( $_data['elements'] as $element_id => $data )
64
-    {
65
-        if( $cm->updateElement( $_data['elementsgroup'], $element_id, $data['category_id'] ) )
66
-        {
57
+    foreach( $_data['elements'] as $element_id => $data ) {
58
+        if( $cm->updateElement( $_data['elementsgroup'], $element_id, $data['category_id'] ) ) {
67 59
             $cm->addMessage(
68 60
                 sprintf(
69 61
                     $cm->txt('cm_x_assigned_to_category_y'),
@@ -78,13 +70,10 @@  discard block
 block discarded – undo
78 70
         }
79 71
     }
80 72
 
81
-    if( $_changes === 0 )
82
-    {
73
+    if( $_changes === 0 ) {
83 74
         $cm->addMessage( $cm->txt('cm_no_categorization'), 'categorize' );
84 75
         return;
85
-    }
86
-    else
87
-    {
76
+    } else {
88 77
         $cm->addMessage(
89 78
             sprintf(
90 79
                 $cm->txt('cm_x_changes_made'),
@@ -98,26 +87,22 @@  discard block
 block discarded – undo
98 87
 /**
99 88
  * Add a new category
100 89
  */
101
-if( isset( $_POST[$cm->get('request_key')]['add']['submit'] ) )
102
-{
90
+if( isset( $_POST[$cm->get('request_key')]['add']['submit'] ) ) {
103 91
     $_data    = $_POST[$cm->get('request_key')]['add']['data'];
104 92
     $category = trim( html_entity_decode($_data['name']) );
105 93
     $rank     = (int) $_data['rank'];
106 94
 
107
-    if( empty( $category ) )
108
-    {
95
+    if( empty( $category ) ) {
109 96
        $cm->addMessage( $cm->txt('cm_enter_name_for_category'), 'add' );
110 97
        return;
111 98
     }
112 99
 
113
-    if( $cm->isCategoryExists( $category ) )
114
-    {
100
+    if( $cm->isCategoryExists( $category ) ) {
115 101
        $cm->addMessage( sprintf( $cm->txt('cm_category_x_exists'), $category ), 'add' );
116 102
        return;
117 103
     }
118 104
 
119
-    if( $cm->addCategory( $category, $rank ) !== 0 )
120
-    {
105
+    if( $cm->addCategory( $category, $rank ) !== 0 ) {
121 106
         $cm->addMessage(
122 107
             sprintf(
123 108
                 $cm->txt( 'cm_category_x_saved_at_position_y' ),
@@ -126,9 +111,7 @@  discard block
 block discarded – undo
126 111
             ),
127 112
             'add'
128 113
         );
129
-    }
130
-    else
131
-    {
114
+    } else {
132 115
         $cm->addMessage( $cm->txt('cm_unknown_error'), 'add' );
133 116
     }
134 117
 }
@@ -136,20 +119,17 @@  discard block
 block discarded – undo
136 119
 /**
137 120
  * Sort categories
138 121
  */
139
-if( isset( $_POST[$cm->get('request_key')]['sort']['submit'] ) )
140
-{
122
+if( isset( $_POST[$cm->get('request_key')]['sort']['submit'] ) ) {
141 123
     $categories = $_POST[$cm->get('request_key')]['sort']['data'];
142 124
     $_changes   = 0;
143 125
 
144
-    foreach( $categories as $category_id => $_data  )
145
-    {
126
+    foreach( $categories as $category_id => $_data  ) {
146 127
         $data = array(
147 128
             'category' => urldecode( $_data['category'] ),
148 129
             'rank'     => $_data['rank']
149 130
         );
150 131
 
151
-        if( $cm->updateCategory( $category_id, $data ) )
152
-        {
132
+        if( $cm->updateCategory( $category_id, $data ) ) {
153 133
             $cm->addMessage(
154 134
                 sprintf(
155 135
                     $cm->txt('cm_category_x_moved_to_position_y'),
@@ -162,12 +142,9 @@  discard block
 block discarded – undo
162 142
         }
163 143
     }
164 144
 
165
-    if( $_changes === 0 )
166
-    {
145
+    if( $_changes === 0 ) {
167 146
         $cm->addMessage( $cm->txt( 'cm_no_changes' ), 'sort');
168
-    }
169
-    else
170
-    {
147
+    } else {
171 148
         $cm->addMessage(
172 149
             sprintf(
173 150
                 $cm->txt('cm_x_changes_made'),
@@ -181,17 +158,13 @@  discard block
 block discarded – undo
181 158
 /**
182 159
  * Edit categories
183 160
  */
184
-if( isset( $_POST[$cm->get('request_key')]['edit']['submit'] ) )
185
-{
161
+if( isset( $_POST[$cm->get('request_key')]['edit']['submit'] ) ) {
186 162
     $categories = $_POST[$cm->get('request_key')]['edit']['data'];
187 163
     $_changes   = 0;
188 164
 
189
-    foreach( $categories as $category_id => $_data  )
190
-    {
191
-        if( isset( $_data['delete'] ) )
192
-        {
193
-            if( $cm->deleteCategory( $category_id ) )
194
-            {
165
+    foreach( $categories as $category_id => $_data  ) {
166
+        if( isset( $_data['delete'] ) ) {
167
+            if( $cm->deleteCategory( $category_id ) ) {
195 168
                 $cm->addMessage(
196 169
                     sprintf(
197 170
                         $cm->txt('cm_category_x_deleted'),
@@ -209,8 +182,7 @@  discard block
 block discarded – undo
209 182
             'rank'     => $_data['rank']
210 183
         );
211 184
 
212
-        if( $cm->updateCategory( $category_id, $data ) )
213
-        {
185
+        if( $cm->updateCategory( $category_id, $data ) ) {
214 186
             $cm->addMessage(
215 187
                 sprintf(
216 188
                     $cm->txt('cm_category_x_renamed_to_y'),
@@ -223,8 +195,7 @@  discard block
 block discarded – undo
223 195
         }
224 196
     }
225 197
 
226
-    if( $_changes === 0 )
227
-    {
198
+    if( $_changes === 0 ) {
228 199
         $cm->addMessage( $cm->txt( 'cm_no_changes' ), 'edit');
229 200
     }
230 201
 }
@@ -233,12 +204,10 @@  discard block
 block discarded – undo
233 204
  * Delete singel category by $_GET
234 205
  */
235 206
 if( isset( $_GET[$cm->get('request_key')]['delete'] )
236
-    && !empty( $_GET[$cm->get('request_key')]['delete'] ) )
237
-{
207
+    && !empty( $_GET[$cm->get('request_key')]['delete'] ) ) {
238 208
     $category_id = (int)$_GET[$cm->get('request_key')]['delete'];
239 209
 
240
-    if( $cm->deleteCategory( $category_id ) )
241
-    {
210
+    if( $cm->deleteCategory( $category_id ) ) {
242 211
         $cm->addMessage(
243 212
             sprintf(
244 213
                 $cm->txt('cm_category_x_deleted'),
@@ -251,16 +220,13 @@  discard block
 block discarded – undo
251 220
 /**
252 221
  * Translate phrases
253 222
  */
254
-if( isset( $_POST[$cm->get('request_key')]['translate']['submit'] ) )
255
-{
223
+if( isset( $_POST[$cm->get('request_key')]['translate']['submit'] ) ) {
256 224
     $translations = $_POST[$cm->get('request_key')]['translate']['data'];
257 225
 
258
-    foreach( $translations as $native_phrase => $translation )
259
-    {
226
+    foreach( $translations as $native_phrase => $translation ) {
260 227
         $native_phrase = urldecode( $native_phrase );
261 228
 
262
-        if( empty( $translation ) )
263
-        {
229
+        if( empty( $translation ) ) {
264 230
             $translation = $native_phrase;
265 231
 
266 232
             $cm->addMessage(
Please login to merge, or discard this patch.