Completed
Branch master (9528ad)
by Michael
04:32
created
class/wideimage/WideImage.php 2 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-    
22
-    * @package WideImage
23
-  **/
21
+	 * @package WideImage
22
+	 **/
24 23
 	
25 24
 	require_once(WideImage::path() . 'Exception.php');
26 25
 	require_once(WideImage::path() . 'Image.php');
Please login to merge, or discard this patch.
Braces   +35 added lines, -24 removed lines patch added patch discarded remove patch
@@ -74,8 +74,9 @@  discard block
 block discarded – undo
74 74
 		 */
75 75
 		static function path()
76 76
 		{
77
-			if (self::$path === null)
78
-				self::$path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
77
+			if (self::$path === null) {
78
+							self::$path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
79
+			}
79 80
 			return self::$path;
80 81
 		}
81 82
 		
@@ -103,8 +104,9 @@  discard block
 block discarded – undo
103 104
 		{
104 105
 			$predictedSourceType = '';
105 106
 			
106
-			if (!$predictedSourceType && self::isValidImageHandle($source))
107
-				$predictedSourceType = 'Handle';
107
+			if (!$predictedSourceType && self::isValidImageHandle($source)) {
108
+							$predictedSourceType = 'Handle';
109
+			}
108 110
 			
109 111
 			if (!$predictedSourceType)
110 112
 			{
@@ -112,19 +114,22 @@  discard block
 block discarded – undo
112 114
 				$binLength = 64;
113 115
 				$sourceLength = strlen($source);
114 116
 				$maxlen = ($sourceLength > $binLength) ? $binLength : $sourceLength;
115
-				for ($i = 0; $i < $maxlen; $i++)
116
-					if (ord($source[$i]) < 32)
117
+				for ($i = 0; $i < $maxlen; $i++) {
118
+									if (ord($source[$i]) < 32)
117 119
 					{
118 120
 						$predictedSourceType = 'String';
121
+				}
119 122
 						break;
120 123
 					}
121 124
 			}
122 125
 			
123
-			if (isset($_FILES[$source]) && isset($_FILES[$source]['tmp_name']))
124
-				$predictedSourceType = 'Upload';
126
+			if (isset($_FILES[$source]) && isset($_FILES[$source]['tmp_name'])) {
127
+							$predictedSourceType = 'Upload';
128
+			}
125 129
 			
126
-			if (!$predictedSourceType)
127
-				$predictedSourceType = 'File';
130
+			if (!$predictedSourceType) {
131
+							$predictedSourceType = 'File';
132
+			}
128 133
 			
129 134
 			return call_user_func(array('WideImage', 'loadFrom' . $predictedSourceType), $source, $format);
130 135
 		}			
@@ -146,8 +151,9 @@  discard block
 block discarded – undo
146 151
 				$mapper = WideImage_MapperFactory::selectMapper($uri, $format);
147 152
 				$handle = $mapper->load($uri);
148 153
 			}
149
-			if (!self::isValidImageHandle($handle))
150
-				throw new WideImage_InvalidImageSourceException("File '{$uri}' appears to be an invalid image source.");
154
+			if (!self::isValidImageHandle($handle)) {
155
+							throw new WideImage_InvalidImageSourceException("File '{$uri}' appears to be an invalid image source.");
156
+			}
151 157
 			
152 158
 			return self::loadFromHandle($handle);
153 159
 		}
@@ -161,8 +167,9 @@  discard block
 block discarded – undo
161 167
 		static function loadFromString($string)
162 168
 		{
163 169
 			$handle = imagecreatefromstring($string);
164
-			if (!self::isValidImageHandle($handle))
165
-				throw new WideImage_InvalidImageSourceException("String doesn't contain valid image data.");
170
+			if (!self::isValidImageHandle($handle)) {
171
+							throw new WideImage_InvalidImageSourceException("String doesn't contain valid image data.");
172
+			}
166 173
 			
167 174
 			return self::loadFromHandle($handle);
168 175
 		}
@@ -187,13 +194,15 @@  discard block
 block discarded – undo
187 194
 		 */
188 195
 		static function loadFromHandle($handle)
189 196
 		{
190
-			if (!self::isValidImageHandle($handle))
191
-				throw new WideImage_InvalidImageSourceException("Handle is not a valid GD image resource.");
197
+			if (!self::isValidImageHandle($handle)) {
198
+							throw new WideImage_InvalidImageSourceException("Handle is not a valid GD image resource.");
199
+			}
192 200
 			
193
-			if (imageistruecolor($handle))
194
-				return new WideImage_TrueColorImage($handle);
195
-			else
196
-				return new WideImage_PaletteImage($handle);
201
+			if (imageistruecolor($handle)) {
202
+							return new WideImage_TrueColorImage($handle);
203
+			} else {
204
+							return new WideImage_PaletteImage($handle);
205
+			}
197 206
 		}
198 207
 		
199 208
 		/**
@@ -206,8 +215,9 @@  discard block
 block discarded – undo
206 215
 		 */
207 216
 		static function loadFromUpload($field_name)
208 217
 		{
209
-			if (!array_key_exists($field_name, $_FILES) || !file_exists($_FILES[$field_name]['tmp_name']))
210
-				throw new WideImage_InvalidImageSourceException("Upload field '{$field_name}' or file doesn't exist.");
218
+			if (!array_key_exists($field_name, $_FILES) || !file_exists($_FILES[$field_name]['tmp_name'])) {
219
+							throw new WideImage_InvalidImageSourceException("Upload field '{$field_name}' or file doesn't exist.");
220
+			}
211 221
 			
212 222
 			return self::loadFromFile($_FILES[$field_name]['tmp_name'], $_FILES[$field_name]['type']);
213 223
 		}
@@ -230,8 +240,9 @@  discard block
 block discarded – undo
230 240
 		 */
231 241
 		static function assertValidImageHandle($handle)
232 242
 		{
233
-			if (!self::isValidImageHandle($handle))
234
-				throw new WideImage_InvalidImageHandleException("{$handle} is not a valid image handle.");
243
+			if (!self::isValidImageHandle($handle)) {
244
+							throw new WideImage_InvalidImageHandleException("{$handle} is not a valid image handle.");
245
+			}
235 246
 		}
236 247
 		
237 248
 	}
Please login to merge, or discard this patch.
class/wideimage/Canvas.php 2 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-    
22
-    * @package WideImage
23
-  **/
21
+	 * @package WideImage
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * @package Exceptions
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,12 +64,14 @@  discard block
 block discarded – undo
64 64
 		 */
65 65
 		function writeText($x, $y, $text, $angle = 0)
66 66
 		{
67
-			if ($this->font === null)
68
-				throw new WideImage_NoFontException("Can't write text without a font.");
67
+			if ($this->font === null) {
68
+							throw new WideImage_NoFontException("Can't write text without a font.");
69
+			}
69 70
 			
70 71
 			$angle = - floatval($angle);
71
-			if ($angle < 0)
72
-				$angle = 360 + $angle;
72
+			if ($angle < 0) {
73
+							$angle = 360 + $angle;
74
+			}
73 75
 			$angle = $angle % 360;
74 76
 			
75 77
 			$this->font->writeText($this->image, $x, $y, $text, $angle);
@@ -94,9 +96,9 @@  discard block
 block discarded – undo
94 96
 			{
95 97
 				array_unshift($params, $this->handle);
96 98
 				call_user_func_array('image' . $method, $params);
99
+			} else {
100
+							throw new WideImage_InvalidCanvasMethodException("Function doesn't exist: image{$method}.");
97 101
 			}
98
-			else
99
-				throw new WideImage_InvalidCanvasMethodException("Function doesn't exist: image{$method}.");
100 102
 		}
101 103
 	}
102 104
 ?>
103 105
\ No newline at end of file
Please login to merge, or discard this patch.
class/wideimage/Exception.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-	* @package Exceptions
23
-  **/
21
+	 * @package Exceptions
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Base Exception class
Please login to merge, or discard this patch.
class/wideimage/Mapper/GIF.php 2 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for GIF files
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,10 +42,11 @@
 block discarded – undo
42 42
 			// then trying to save an image to a '' location (which results in an
43 43
 			// error, of course). And the same thing works fine for imagepng() and 
44 44
 			// imagejpeg(). It's a bug! ;)
45
-			if ($uri)
46
-				imagegif($handle, $uri);
47
-			else
48
-				imagegif($handle);
45
+			if ($uri) {
46
+							imagegif($handle, $uri);
47
+			} else {
48
+							imagegif($handle);
49
+			}
49 50
 		}
50 51
 	}
51 52
 ?>
52 53
\ No newline at end of file
Please login to merge, or discard this patch.
class/wideimage/Mapper/JPEG.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for JPEG files
Please login to merge, or discard this patch.
class/wideimage/Mapper/GD2.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for GD2 files
Please login to merge, or discard this patch.
class/wideimage/Mapper/PNG.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for PNG files
Please login to merge, or discard this patch.
class/wideimage/Mapper/BMP.php 2 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	include_once(WideImage::path() . '/vendor/JPEXS/bmp.php');
26 25
 	
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,10 +41,11 @@
 block discarded – undo
41 41
 		
42 42
 		function save($handle, $uri = null)
43 43
 		{
44
-			if ($uri == null)
45
-				imagebmp($handle);
46
-			else
47
-				imagebmp($handle, $uri);
44
+			if ($uri == null) {
45
+							imagebmp($handle);
46
+			} else {
47
+							imagebmp($handle, $uri);
48
+			}
48 49
 		}
49 50
 	}
50 51
 ?>
51 52
\ No newline at end of file
Please login to merge, or discard this patch.
class/wideimage/Mapper/GD.php 2 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for GD files
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,10 +36,11 @@
 block discarded – undo
36 36
 		
37 37
 		function save($handle, $uri = null)
38 38
 		{
39
-			if ($uri == null)
40
-				imagegd($handle);
41
-			else
42
-				imagegd($handle, $uri);
39
+			if ($uri == null) {
40
+							imagegd($handle);
41
+			} else {
42
+							imagegd($handle, $uri);
43
+			}
43 44
 		}
44 45
 	}
45 46
 ?>
46 47
\ No newline at end of file
Please login to merge, or discard this patch.