Completed
Push — develop ( cb7ecf...5e631f )
by Dmytro
17s
created
manager/includes/controls/phpmailer/PHPMailer.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3968,7 +3968,7 @@
 block discarded – undo
3968 3968
      * @param int|string $options Either a PATHINFO_* constant,
3969 3969
      *                            or a string name to return only the specified piece
3970 3970
      *
3971
-     * @return string|array
3971
+     * @return string
3972 3972
      */
3973 3973
     public static function mb_pathinfo($path, $options = null)
3974 3974
     {
Please login to merge, or discard this patch.
manager/includes/controls/phpmailer/POP3.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
      * Connect to a POP3 server.
210 210
      *
211 211
      * @param string   $host
212
-     * @param int|bool $port
212
+     * @param integer $port
213 213
      * @param int      $tval
214 214
      *
215 215
      * @return bool
Please login to merge, or discard this patch.
manager/includes/controls/phpmailer/SMTP.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1314,7 +1314,7 @@
 block discarded – undo
1314 1314
      * If no reply has been received yet, it will return null.
1315 1315
      * If no pattern was matched, it will return false.
1316 1316
      *
1317
-     * @return bool|null|string
1317
+     * @return string
1318 1318
      *
1319 1319
      * @see recordLastTransactionID()
1320 1320
      */
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/browser.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -666,6 +666,9 @@  discard block
 block discarded – undo
666 666
             return json_encode(array('version' => false));
667 667
     }
668 668
 
669
+    /**
670
+     * @param string $dir
671
+     */
669 672
     protected function moveUploadFile($file, $dir) {
670 673
         $message = $this->checkUploadedFile($file);
671 674
 
@@ -697,6 +700,9 @@  discard block
 block discarded – undo
697 700
         return "/" . basename($target);
698 701
     }
699 702
 
703
+    /**
704
+     * @param string $file
705
+     */
700 706
     protected function sendDefaultThumb($file=null) {
701 707
         if ($file !== null) {
702 708
             $ext = file::getExtension($file);
@@ -873,6 +879,9 @@  discard block
 block discarded – undo
873 879
         return "";
874 880
     }
875 881
 
882
+    /**
883
+     * @param string $message
884
+     */
876 885
     protected function errorMsg($message, array $data=null) {
877 886
         if (in_array($this->action, array("thumb", "upload", "download", "downloadDir")))
878 887
             die($this->label($message, $data));
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 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 Browser actions 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 Browser actions 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 browser extends uploader {
16 16
     protected $action;
@@ -709,54 +709,54 @@  discard block
 block discarded – undo
709 709
         die;
710 710
     }
711 711
 
712
-	protected function getFiles($dir) {
713
-		$thumbDir = "{$this->config['uploadDir']}/{$this->config['thumbsDir']}/$dir";
714
-		$dir = "{$this->config['uploadDir']}/$dir";
715
-		$return = array();
716
-		$files = dir::content($dir, array('types' => "file"));
717
-		if ($files === false)
718
-			return $return;
719
-
720
-		foreach ($files as $file) {
721
-			$ext = file::getExtension($file);
722
-			$smallThumb = false;
723
-			if (in_array(strtolower($ext), array('png', 'jpg', 'gif', 'jpeg' )) ) {
724
-				$size = @getimagesize($file);
725
-				if (is_array($size) && count($size)) {
726
-					$thumb_file = "$thumbDir/" . basename($file);
727
-					if (!is_file($thumb_file) || filemtime($file) > filemtime($thumb_file))
728
-						$this->makeThumb($file);
729
-					$smallThumb =
730
-						($size[0] <= $this->config['thumbWidth']) &&
731
-						($size[1] <= $this->config['thumbHeight']) &&
732
-						in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_JPEG));
733
-				}
734
-			}
735
-			$stat = stat($file);
736
-			if ($stat === false) continue;
737
-			$name = basename($file);
738
-			$types = $this->config['types'];
739
-			$types = explode(' ',$types['images'].' '.$types['image']);
740
-			if (substr($name,0,1) == '.' && !$this->config['showHiddenFiles']) continue;
741
-			if ($this->type == 'images' && !in_array(strtolower($ext),$types)) continue;
742
-			$bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/$ext.png");
743
-			$smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/$ext.png");
744
-			$thumb = file_exists("$thumbDir/$name");
745
-			$return[] = array(
746
-				'name' => stripcslashes($name),
747
-				'size' => $stat['size'],
748
-				'mtime' => $stat['mtime'],
749
-				'date' => @strftime($this->dateTimeSmall, $stat['mtime']),
750
-				'readable' => is_readable($file),
751
-				'writable' => file::isWritable($file),
752
-				'bigIcon' => $bigIcon,
753
-				'smallIcon' => $smallIcon,
754
-				'thumb' => $thumb,
755
-				'smallThumb' => $smallThumb
756
-			);
757
-		}
758
-		return $return;
759
-	}
712
+    protected function getFiles($dir) {
713
+        $thumbDir = "{$this->config['uploadDir']}/{$this->config['thumbsDir']}/$dir";
714
+        $dir = "{$this->config['uploadDir']}/$dir";
715
+        $return = array();
716
+        $files = dir::content($dir, array('types' => "file"));
717
+        if ($files === false)
718
+            return $return;
719
+
720
+        foreach ($files as $file) {
721
+            $ext = file::getExtension($file);
722
+            $smallThumb = false;
723
+            if (in_array(strtolower($ext), array('png', 'jpg', 'gif', 'jpeg' )) ) {
724
+                $size = @getimagesize($file);
725
+                if (is_array($size) && count($size)) {
726
+                    $thumb_file = "$thumbDir/" . basename($file);
727
+                    if (!is_file($thumb_file) || filemtime($file) > filemtime($thumb_file))
728
+                        $this->makeThumb($file);
729
+                    $smallThumb =
730
+                        ($size[0] <= $this->config['thumbWidth']) &&
731
+                        ($size[1] <= $this->config['thumbHeight']) &&
732
+                        in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_JPEG));
733
+                }
734
+            }
735
+            $stat = stat($file);
736
+            if ($stat === false) continue;
737
+            $name = basename($file);
738
+            $types = $this->config['types'];
739
+            $types = explode(' ',$types['images'].' '.$types['image']);
740
+            if (substr($name,0,1) == '.' && !$this->config['showHiddenFiles']) continue;
741
+            if ($this->type == 'images' && !in_array(strtolower($ext),$types)) continue;
742
+            $bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/$ext.png");
743
+            $smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/$ext.png");
744
+            $thumb = file_exists("$thumbDir/$name");
745
+            $return[] = array(
746
+                'name' => stripcslashes($name),
747
+                'size' => $stat['size'],
748
+                'mtime' => $stat['mtime'],
749
+                'date' => @strftime($this->dateTimeSmall, $stat['mtime']),
750
+                'readable' => is_readable($file),
751
+                'writable' => file::isWritable($file),
752
+                'bigIcon' => $bigIcon,
753
+                'smallIcon' => $smallIcon,
754
+                'thumb' => $thumb,
755
+                'smallThumb' => $smallThumb
756
+            );
757
+        }
758
+        return $return;
759
+    }
760 760
 
761 761
     protected function getTree($dir, $index=0) {
762 762
         $path = explode("/", $dir);
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/uploader.php 2 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -385,6 +385,9 @@  discard block
 block discarded – undo
385 385
 	}
386 386
 
387 387
 
388
+	/**
389
+	 * @return string
390
+	 */
388 391
 	protected function normalizeFilename($filename) {
389 392
 		if ($this->getTransaliasSettings()) {
390 393
         		$format = strrchr($filename, ".");
@@ -394,6 +397,9 @@  discard block
 block discarded – undo
394 397
         	return $filename;
395 398
 	}
396 399
 
400
+	/**
401
+	 * @param string $dirname
402
+	 */
397 403
 	protected function normalizeDirname($dirname) {
398 404
         return $this->modx->stripAlias($dirname);
399 405
     }
@@ -506,6 +512,9 @@  discard block
 block discarded – undo
506 512
         return (is_dir($path) && is_readable($path)) ? $return : false;
507 513
     }
508 514
 
515
+    /**
516
+     * @param string $ext
517
+     */
509 518
     protected function validateExtension($ext, $type) {
510 519
         $ext = trim(strtolower($ext));
511 520
         if (!isset($this->types[$type]))
@@ -531,11 +540,17 @@  discard block
 block discarded – undo
531 540
         return in_array($ext, $exts);
532 541
     }
533 542
 
543
+    /**
544
+     * @return string
545
+     */
534 546
     protected function getTypeFromPath($path) {
535 547
         return preg_match('/^([^\/]*)\/.*$/', $path, $patt)
536 548
             ? $patt[1] : $path;
537 549
     }
538 550
 
551
+    /**
552
+     * @param string $path
553
+     */
539 554
     protected function removeTypeFromPath($path) {
540 555
         return preg_match('/^[^\/]*\/(.*)$/', $path, $patt)
541 556
             ? $patt[1] : "";
@@ -728,6 +743,9 @@  discard block
 block discarded – undo
728 743
         die;
729 744
     }
730 745
 
746
+    /**
747
+     * @param string $url
748
+     */
731 749
     protected function callBack($url, $message="") {
732 750
         $message = text::jsValue($message);
733 751
         $CKfuncNum = isset($this->opener['CKEditor']['funcNum'])
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 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 Uploader 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 Uploader 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 uploader {
16 16
 
@@ -18,92 +18,92 @@  discard block
 block discarded – undo
18 18
     const VERSION = "2.54";
19 19
 
20 20
 /** Config session-overrided settings
21
-  * @var array */
21
+ * @var array */
22 22
     protected $config = array();
23 23
 
24 24
 /** Default image driver
25
-  * @var string */
25
+ * @var string */
26 26
     protected $imageDriver = "gd";
27 27
 
28 28
 /** Opener applocation properties
29
-  *   $opener['name']                 Got from $_GET['opener'];
30
-  *   $opener['CKEditor']['funcNum']  CKEditor function number (got from $_GET)
31
-  *   $opener['TinyMCE']              Boolean
32
-  * @var array */
29
+ *   $opener['name']                 Got from $_GET['opener'];
30
+ *   $opener['CKEditor']['funcNum']  CKEditor function number (got from $_GET)
31
+ *   $opener['TinyMCE']              Boolean
32
+ * @var array */
33 33
     protected $opener = array();
34 34
 
35 35
 /** Got from $_GET['type'] or first one $config['types'] array key, if inexistant
36
-  * @var string */
36
+ * @var string */
37 37
     protected $type;
38 38
 
39 39
 /** Helper property. Local filesystem path to the Type Directory
40
-  * Equivalent: $config['uploadDir'] . "/" . $type
41
-  * @var string */
40
+ * Equivalent: $config['uploadDir'] . "/" . $type
41
+ * @var string */
42 42
     protected $typeDir;
43 43
 
44 44
 /** Helper property. Web URL to the Type Directory
45
-  * Equivalent: $config['uploadURL'] . "/" . $type
46
-  * @var string */
45
+ * Equivalent: $config['uploadURL'] . "/" . $type
46
+ * @var string */
47 47
     protected $typeURL;
48 48
 
49 49
 /** Linked to $config['types']
50
-  * @var array */
50
+ * @var array */
51 51
     protected $types = array();
52 52
 
53 53
 /** Settings which can override default settings if exists as keys in $config['types'][$type] array
54
-  * @var array */
54
+ * @var array */
55 55
     protected $typeSettings = array('disabled', 'theme', 'dirPerms', 'filePerms', 'denyZipDownload', 'maxImageWidth', 'maxImageHeight', 'thumbWidth', 'thumbHeight', 'jpegQuality', 'access', 'filenameChangeChars', 'dirnameChangeChars', 'denyExtensionRename', 'deniedExts', 'watermark');
56 56
 
57 57
 /** Got from language file
58
-  * @var string */
58
+ * @var string */
59 59
     protected $charset;
60 60
 
61 61
 /** The language got from $_GET['lng'] or $_GET['lang'] or... Please see next property
62
-  * @var string */
62
+ * @var string */
63 63
     protected $lang = 'en';
64 64
 
65 65
 /** Possible language $_GET keys
66
-  * @var array */
66
+ * @var array */
67 67
     protected $langInputNames = array('lang', 'langCode', 'lng', 'language', 'lang_code');
68 68
 
69 69
 /** Uploaded file(s) info. Linked to first $_FILES element
70
-  * @var array */
70
+ * @var array */
71 71
     protected $file;
72 72
 
73 73
 /** Next three properties are got from the current language file
74
-  * @var string */
74
+ * @var string */
75 75
     protected $dateTimeFull;   // Currently not used
76 76
     protected $dateTimeMid;    // Currently not used
77 77
     protected $dateTimeSmall;
78 78
 
79 79
 /** Contain Specified language labels
80
-  * @var array */
80
+ * @var array */
81 81
     protected $labels = array();
82 82
 
83 83
 /** Contain unprocessed $_GET array. Please use this instead of $_GET
84
-  * @var array */
84
+ * @var array */
85 85
     protected $get;
86 86
 
87 87
 /** Contain unprocessed $_POST array. Please use this instead of $_POST
88
-  * @var array */
88
+ * @var array */
89 89
     protected $post;
90 90
 
91 91
 /** Contain unprocessed $_COOKIE array. Please use this instead of $_COOKIE
92
-  * @var array */
92
+ * @var array */
93 93
     protected $cookie;
94 94
 
95 95
 /** Session array. Please use this property instead of $_SESSION
96
-  * @var array */
96
+ * @var array */
97 97
     protected $session;
98 98
 
99 99
 /** CMS integration attribute (got from $_GET['cms'])
100
-  * @var string */
100
+ * @var string */
101 101
     protected $cms = "";
102 102
 
103 103
     protected $modx = null;
104 104
 /** Magic method which allows read-only access to protected or private class properties
105
-  * @param string $property
106
-  * @return mixed */
105
+     * @param string $property
106
+     * @return mixed */
107 107
     public function __get($property) {
108 108
         return property_exists($this, $property) ? $this->$property : null;
109 109
     }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         )
133 133
             $this->cms = $this->get['cms'];
134 134
 
135
-		// LINKING UPLOADED FILE
135
+        // LINKING UPLOADED FILE
136 136
         if (count($_FILES))
137 137
             $this->file = &$_FILES[key($_FILES)];
138 138
 
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
             $this->config['uploadDir'] = strlen($this->config['uploadDir'])
229 229
                 ? path::normalize($this->config['uploadDir'])
230 230
                 : path::url2fullPath("/$path");
231
-         $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
232
-         $this->typeURL = "{$this->config['siteURL']}/{$this->config['uploadURL']}/{$this->type}";
231
+            $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
232
+            $this->typeURL = "{$this->config['siteURL']}/{$this->config['uploadURL']}/{$this->type}";
233 233
 
234 234
         // SITE ROOT
235 235
         } elseif ($this->config['uploadURL'] == "/") {
@@ -365,36 +365,36 @@  discard block
 block discarded – undo
365 365
     }
366 366
 
367 367
 
368
-	protected function getTransaliasSettings() {
369
-		$modx = evolutionCMS();
370
-
371
-		// Cleaning uploaded filename?
372
-		$setting = $modx->getDatabase()->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1');
373
-		if ($modx->getDatabase()->getValue($setting)>0) {
374
-			// Transalias plugin active?
375
-			$res = $modx->getDatabase()->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0');
376
-			if ($properties = $modx->getDatabase()->getValue($res)) {
377
-				$properties = $modx->parseProperties($properties, 'TransAlias', 'plugin');
378
-			} else {
379
-				$properties = NULL;
380
-			}
381
-		} else {
382
-			$properties = NULL;
383
-		}
384
-		return $properties;
385
-	}
386
-
387
-
388
-	protected function normalizeFilename($filename) {
389
-		if ($this->getTransaliasSettings()) {
390
-        		$format = strrchr($filename, ".");
391
-        		$filename = str_replace($format, "", $filename);
392
-            		$filename = $this->modx->stripAlias($filename).$format;
393
-        	}
394
-        	return $filename;
395
-	}
396
-
397
-	protected function normalizeDirname($dirname) {
368
+    protected function getTransaliasSettings() {
369
+        $modx = evolutionCMS();
370
+
371
+        // Cleaning uploaded filename?
372
+        $setting = $modx->getDatabase()->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1');
373
+        if ($modx->getDatabase()->getValue($setting)>0) {
374
+            // Transalias plugin active?
375
+            $res = $modx->getDatabase()->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0');
376
+            if ($properties = $modx->getDatabase()->getValue($res)) {
377
+                $properties = $modx->parseProperties($properties, 'TransAlias', 'plugin');
378
+            } else {
379
+                $properties = NULL;
380
+            }
381
+        } else {
382
+            $properties = NULL;
383
+        }
384
+        return $properties;
385
+    }
386
+
387
+
388
+    protected function normalizeFilename($filename) {
389
+        if ($this->getTransaliasSettings()) {
390
+                $format = strrchr($filename, ".");
391
+                $filename = str_replace($format, "", $filename);
392
+                    $filename = $this->modx->stripAlias($filename).$format;
393
+            }
394
+            return $filename;
395
+    }
396
+
397
+    protected function normalizeDirname($dirname) {
398 398
         return $this->modx->stripAlias($dirname);
399 399
     }
400 400
 
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
             return $this->label("The image is too big and/or cannot be resized.");
473 473
 
474 474
 
475
-	// CHECK FOR MODX MAX FILE SIZE
476
-	$actualfilesize=filesize($file['tmp_name']);
477
-	if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478
-	    return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
475
+    // CHECK FOR MODX MAX FILE SIZE
476
+    $actualfilesize=filesize($file['tmp_name']);
477
+    if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478
+        return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
479 479
 
480 480
         return true;
481 481
     }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             $top = isset($this->config['watermark']['top'])
628 628
                 ? $this->config['watermark']['top'] : false;
629 629
             $img->watermark($this->config['watermark']['file'], $left, $top);
630
-		}
630
+        }
631 631
 
632 632
         $options = array( 'file' => $file );
633 633
 
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_fastImage.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -183,6 +183,9 @@  discard block
 block discarded – undo
183 183
 	}
184 184
 
185 185
 
186
+	/**
187
+	 * @param integer $n
188
+	 */
186 189
 	private function getChars($n)
187 190
 	{
188 191
 		$response = null;
@@ -225,6 +228,9 @@  discard block
 block discarded – undo
225 228
 	}
226 229
 
227 230
 
231
+	/**
232
+	 * @param false|string $str
233
+	 */
228 234
 	private function readInt($str)
229 235
 	{
230 236
 		$size = unpack("C*", $str);
Please login to merge, or discard this patch.
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -13,227 +13,227 @@
 block discarded – undo
13 13
 
14 14
 class fastImage
15 15
 {
16
-	private $strpos = 0;
17
-	private $str;
18
-	private $uri;
19
-	private $type;
20
-	private $handle;
16
+    private $strpos = 0;
17
+    private $str;
18
+    private $uri;
19
+    private $type;
20
+    private $handle;
21 21
 
22
-	public function __construct($uri = null)
23
-	{
24
-		if ($uri) $this->load($uri);
25
-	}
22
+    public function __construct($uri = null)
23
+    {
24
+        if ($uri) $this->load($uri);
25
+    }
26 26
 
27 27
 
28
-	public function load($uri)
29
-	{
30
-		if ($this->handle) $this->close();
31
-
32
-		$this->uri = $uri;
33
-		$this->handle = fopen($uri, 'r');
34
-	}
35
-
36
-
37
-	public function close()
38
-	{
39
-		if (is_resource($this->handle)) fclose($this->handle);
40
-	}
28
+    public function load($uri)
29
+    {
30
+        if ($this->handle) $this->close();
31
+
32
+        $this->uri = $uri;
33
+        $this->handle = fopen($uri, 'r');
34
+    }
35
+
36
+
37
+    public function close()
38
+    {
39
+        if (is_resource($this->handle)) fclose($this->handle);
40
+    }
41 41
 
42 42
 
43
-	public function getSize()
44
-	{
45
-		$this->strpos = 0;
46
-		if ($this->getType())
47
-		{
48
-			return array_values($this->parseSize());
49
-		}
50
-
51
-		return false;
52
-	}
53
-
54
-
55
-	public function getType()
56
-	{
57
-		$this->strpos = 0;
58
-
59
-		if (!$this->type)
60
-		{
61
-			switch ($this->getChars(2))
62
-			{
63
-				case "BM":
64
-					return $this->type = 'bmp';
65
-				case "GI":
66
-					return $this->type = 'gif';
67
-				case chr(0xFF).chr(0xd8):
68
-					return $this->type = 'jpeg';
69
-				case chr(0x89).'P':
70
-					return $this->type = 'png';
71
-				default:
72
-					return false;
73
-			}
74
-		}
75
-
76
-		return $this->type;
77
-	}
78
-
79
-
80
-	private function parseSize()
81
-	{
82
-		$this->strpos = 0;
83
-
84
-		switch ($this->type)
85
-		{
86
-			case 'png':
87
-				return $this->parseSizeForPNG();
88
-			case 'gif':
89
-				return $this->parseSizeForGIF();
90
-			case 'bmp':
91
-				return $this->parseSizeForBMP();
92
-			case 'jpeg':
93
-				return $this->parseSizeForJPEG();
94
-		}
95
-
96
-		return null;
97
-	}
98
-
99
-
100
-	private function parseSizeForPNG()
101
-	{
102
-		$chars = $this->getChars(25);
103
-
104
-		return unpack("N*", substr($chars, 16, 8));
105
-	}
106
-
107
-
108
-	private function parseSizeForGIF()
109
-	{
110
-		$chars = $this->getChars(11);
111
-
112
-		return unpack("S*", substr($chars, 6, 4));
113
-	}
114
-
115
-
116
-	private function parseSizeForBMP()
117
-	{
118
-		$chars = $this->getChars(29);
119
-	 	$chars = substr($chars, 14, 14);
120
-		$type = unpack('C', $chars);
121
-
122
-		return (reset($type) == 40) ? unpack('L*', substr($chars, 4)) : unpack('L*', substr($chars, 4, 8));
123
-	}
124
-
125
-
126
-	private function parseSizeForJPEG()
127
-	{
128
-		$state = null;
129
-
130
-		while (true)
131
-		{
132
-			switch ($state)
133
-			{
134
-				default:
135
-					$this->getChars(2);
136
-					$state = 'started';
137
-					break;
138
-
139
-				case 'started':
140
-					$b = $this->getByte();
141
-					if ($b === false) return false;
142
-
143
-					$state = $b == 0xFF ? 'sof' : 'started';
144
-					break;
145
-
146
-				case 'sof':
147
-					$b = $this->getByte();
148
-					if (in_array($b, range(0xe0, 0xef)))
149
-					{
150
-						$state = 'skipframe';
151
-					}
152
-					elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF))))
153
-					{
154
-						$state = 'readsize';
155
-					}
156
-					elseif ($b == 0xFF)
157
-					{
158
-						$state = 'sof';
159
-					}
160
-					else
161
-					{
162
-						$state = 'skipframe';
163
-					}
164
-					break;
165
-
166
-				case 'skipframe':
167
-					$skip = $this->readInt($this->getChars(2)) - 2;
168
-					$state = 'doskip';
169
-					break;
170
-
171
-				case 'doskip':
172
-					$this->getChars($skip);
173
-					$state = 'started';
174
-					break;
175
-
176
-				case 'readsize':
177
-					$c = $this->getChars(7);
178
-
179
-					return array($this->readInt(substr($c, 5, 2)), $this->readInt(substr($c, 3, 2)));
180
-			}
181
-		}
182
-	}
183
-
184
-
185
-	private function getChars($n)
186
-	{
187
-		$response = null;
188
-
189
-		// do we need more data?
190
-		if ($this->strpos + $n -1 >= strlen($this->str))
191
-		{
192
-			$end = ($this->strpos + $n);
193
-
194
-			while (strlen($this->str) < $end && $response !== false)
195
-			{
196
-				// read more from the file handle
197
-				$need = $end - ftell($this->handle);
198
-
199
-				if ($response = fread($this->handle, $need))
200
-				{
201
-					$this->str .= $response;
202
-				}
203
-				else
204
-				{
205
-					return false;
206
-				}
207
-			}
208
-		}
209
-
210
-		$result = substr($this->str, $this->strpos, $n);
211
-		$this->strpos += $n;
212
-
213
-		// we are dealing with bytes here, so force the encoding
214
-		return mb_convert_encoding($result, "8BIT");
215
-	}
216
-
217
-
218
-	private function getByte()
219
-	{
220
-		$c = $this->getChars(1);
221
-		$b = unpack("C", $c);
222
-
223
-		return reset($b);
224
-	}
225
-
226
-
227
-	private function readInt($str)
228
-	{
229
-		$size = unpack("C*", $str);
230
-
231
-	    	return ($size[1] << 8) + $size[2];
232
-	}
233
-
234
-
235
-	public function __destruct()
236
-	{
237
-		$this->close();
238
-	}
43
+    public function getSize()
44
+    {
45
+        $this->strpos = 0;
46
+        if ($this->getType())
47
+        {
48
+            return array_values($this->parseSize());
49
+        }
50
+
51
+        return false;
52
+    }
53
+
54
+
55
+    public function getType()
56
+    {
57
+        $this->strpos = 0;
58
+
59
+        if (!$this->type)
60
+        {
61
+            switch ($this->getChars(2))
62
+            {
63
+                case "BM":
64
+                    return $this->type = 'bmp';
65
+                case "GI":
66
+                    return $this->type = 'gif';
67
+                case chr(0xFF).chr(0xd8):
68
+                    return $this->type = 'jpeg';
69
+                case chr(0x89).'P':
70
+                    return $this->type = 'png';
71
+                default:
72
+                    return false;
73
+            }
74
+        }
75
+
76
+        return $this->type;
77
+    }
78
+
79
+
80
+    private function parseSize()
81
+    {
82
+        $this->strpos = 0;
83
+
84
+        switch ($this->type)
85
+        {
86
+            case 'png':
87
+                return $this->parseSizeForPNG();
88
+            case 'gif':
89
+                return $this->parseSizeForGIF();
90
+            case 'bmp':
91
+                return $this->parseSizeForBMP();
92
+            case 'jpeg':
93
+                return $this->parseSizeForJPEG();
94
+        }
95
+
96
+        return null;
97
+    }
98
+
99
+
100
+    private function parseSizeForPNG()
101
+    {
102
+        $chars = $this->getChars(25);
103
+
104
+        return unpack("N*", substr($chars, 16, 8));
105
+    }
106
+
107
+
108
+    private function parseSizeForGIF()
109
+    {
110
+        $chars = $this->getChars(11);
111
+
112
+        return unpack("S*", substr($chars, 6, 4));
113
+    }
114
+
115
+
116
+    private function parseSizeForBMP()
117
+    {
118
+        $chars = $this->getChars(29);
119
+            $chars = substr($chars, 14, 14);
120
+        $type = unpack('C', $chars);
121
+
122
+        return (reset($type) == 40) ? unpack('L*', substr($chars, 4)) : unpack('L*', substr($chars, 4, 8));
123
+    }
124
+
125
+
126
+    private function parseSizeForJPEG()
127
+    {
128
+        $state = null;
129
+
130
+        while (true)
131
+        {
132
+            switch ($state)
133
+            {
134
+                default:
135
+                    $this->getChars(2);
136
+                    $state = 'started';
137
+                    break;
138
+
139
+                case 'started':
140
+                    $b = $this->getByte();
141
+                    if ($b === false) return false;
142
+
143
+                    $state = $b == 0xFF ? 'sof' : 'started';
144
+                    break;
145
+
146
+                case 'sof':
147
+                    $b = $this->getByte();
148
+                    if (in_array($b, range(0xe0, 0xef)))
149
+                    {
150
+                        $state = 'skipframe';
151
+                    }
152
+                    elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF))))
153
+                    {
154
+                        $state = 'readsize';
155
+                    }
156
+                    elseif ($b == 0xFF)
157
+                    {
158
+                        $state = 'sof';
159
+                    }
160
+                    else
161
+                    {
162
+                        $state = 'skipframe';
163
+                    }
164
+                    break;
165
+
166
+                case 'skipframe':
167
+                    $skip = $this->readInt($this->getChars(2)) - 2;
168
+                    $state = 'doskip';
169
+                    break;
170
+
171
+                case 'doskip':
172
+                    $this->getChars($skip);
173
+                    $state = 'started';
174
+                    break;
175
+
176
+                case 'readsize':
177
+                    $c = $this->getChars(7);
178
+
179
+                    return array($this->readInt(substr($c, 5, 2)), $this->readInt(substr($c, 3, 2)));
180
+            }
181
+        }
182
+    }
183
+
184
+
185
+    private function getChars($n)
186
+    {
187
+        $response = null;
188
+
189
+        // do we need more data?
190
+        if ($this->strpos + $n -1 >= strlen($this->str))
191
+        {
192
+            $end = ($this->strpos + $n);
193
+
194
+            while (strlen($this->str) < $end && $response !== false)
195
+            {
196
+                // read more from the file handle
197
+                $need = $end - ftell($this->handle);
198
+
199
+                if ($response = fread($this->handle, $need))
200
+                {
201
+                    $this->str .= $response;
202
+                }
203
+                else
204
+                {
205
+                    return false;
206
+                }
207
+            }
208
+        }
209
+
210
+        $result = substr($this->str, $this->strpos, $n);
211
+        $this->strpos += $n;
212
+
213
+        // we are dealing with bytes here, so force the encoding
214
+        return mb_convert_encoding($result, "8BIT");
215
+    }
216
+
217
+
218
+    private function getByte()
219
+    {
220
+        $c = $this->getChars(1);
221
+        $b = unpack("C", $c);
222
+
223
+        return reset($b);
224
+    }
225
+
226
+
227
+    private function readInt($str)
228
+    {
229
+        $size = unpack("C*", $str);
230
+
231
+            return ($size[1] << 8) + $size[2];
232
+    }
233
+
234
+
235
+    public function __destruct()
236
+    {
237
+        $this->close();
238
+    }
239 239
 }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_gd.php 2 patches
Doc Comments   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes.
169 169
     * The other dimension (height or width) will be calculated autamaticaly
170 170
     * @param integer $bigger_size
171
-    * @return array */
171
+    * @return integer[] */
172 172
 
173 173
     public function get_prop_size($bigger_size) {
174 174
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     * no samo po edno (x ili y) izmerenie
256 256
     * @param integer $width
257 257
     * @param integer $height
258
-    * @return bool */
258
+    * @return gd */
259 259
 
260 260
     public function resize_overflow($width, $height) {
261 261
 
@@ -397,6 +397,12 @@  discard block
 block discarded – undo
397 397
             return false;
398 398
     }
399 399
 
400
+    /**
401
+     * @param integer $x1
402
+     * @param integer $y1
403
+     * @param integer $x2
404
+     * @param integer $y2
405
+     */
400 406
     public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) {
401 407
         $color = $this->gd_color($color);
402 408
         if ($color === false) return false;
Please login to merge, or discard this patch.
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -1,44 +1,44 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc GD extension class
6
-  *   @package KCFinder
7
-  *   @version 2.51
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010, 2011 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 GD extension class
6
+ *   @package KCFinder
7
+ *   @version 2.51
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010, 2011 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 gd {
16 16
 
17
-  /** GD resource
18
-    * @var resource */
17
+    /** GD resource
18
+     * @var resource */
19 19
     protected $image;
20 20
 
21
-  /** Image width
22
-    * @var integer */
21
+    /** Image width
22
+     * @var integer */
23 23
     protected $width;
24 24
 
25
-  /** Image height
26
-    * @var integer */
25
+    /** Image height
26
+     * @var integer */
27 27
     protected $height;
28 28
 
29
-  /** Init error
30
-    * @var bool */
29
+    /** Init error
30
+     * @var bool */
31 31
     public $init_error = false;
32 32
 
33
-  /** Last builded image type constant (IMAGETYPE_XXX)
34
-    * @var integer */
33
+    /** Last builded image type constant (IMAGETYPE_XXX)
34
+     * @var integer */
35 35
     public $type;
36 36
 
37
-  /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height.
38
-    * Returns FALSE on failure. The only one parameter $image can be an instance of this class,
39
-    * a GD resource, an array(width, height) or path to image file.
40
-    * @param mixed $image
41
-    * @return array */
37
+    /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height.
38
+     * Returns FALSE on failure. The only one parameter $image can be an instance of this class,
39
+     * a GD resource, an array(width, height) or path to image file.
40
+     * @param mixed $image
41
+     * @return array */
42 42
 
43 43
     protected function build_image($image) {
44 44
 
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
         return $return;
88 88
     }
89 89
 
90
-  /** Parameter $image can be:
91
-    *   1. An instance of this class (copy instance).
92
-    *   2. A GD resource.
93
-    *   3. An array with two elements. First - width, second - height. Create a blank image.
94
-    *   4. A filename string. Get image form file.
95
-    * The non-required parameter $bigger_size is the bigger dimension (width or height) the image
96
-    * will be resized to. The other dimension (height or width) will be calculated autamaticaly
97
-    * @param mixed $image
98
-    * @param integer $bigger_size
99
-    * @return gd */
90
+    /** Parameter $image can be:
91
+     *   1. An instance of this class (copy instance).
92
+     *   2. A GD resource.
93
+     *   3. An array with two elements. First - width, second - height. Create a blank image.
94
+     *   4. A filename string. Get image form file.
95
+     * The non-required parameter $bigger_size is the bigger dimension (width or height) the image
96
+     * will be resized to. The other dimension (height or width) will be calculated autamaticaly
97
+     * @param mixed $image
98
+     * @param integer $bigger_size
99
+     * @return gd */
100 100
 
101 101
     public function __construct($image, $bigger_size=null) {
102 102
         $this->image = $this->width = $this->height = null;
@@ -123,30 +123,30 @@  discard block
 block discarded – undo
123 123
         }
124 124
     }
125 125
 
126
-  /** Returns the GD resource
127
-    * @return resource */
126
+    /** Returns the GD resource
127
+     * @return resource */
128 128
 
129 129
     public function get_image() {
130 130
         return $this->image;
131 131
     }
132 132
 
133
-  /** Returns the image width
134
-    * @return integer */
133
+    /** Returns the image width
134
+     * @return integer */
135 135
 
136 136
     public function get_width() {
137 137
         return $this->width;
138 138
     }
139 139
 
140
-  /** Returns the image height
141
-    * @return integer */
140
+    /** Returns the image height
141
+     * @return integer */
142 142
 
143 143
     public function get_height() {
144 144
         return $this->height;
145 145
     }
146 146
 
147
-  /** Returns calculated proportional width from the given height
148
-    * @param integer $resized_height
149
-    * @return integer */
147
+    /** Returns calculated proportional width from the given height
148
+     * @param integer $resized_height
149
+     * @return integer */
150 150
 
151 151
     public function get_prop_width($resized_height) {
152 152
         $width = intval(($this->width * $resized_height) / $this->height);
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
         return $width;
155 155
     }
156 156
 
157
-  /** Returns calculated proportional height from the given width
158
-    * @param integer $resized_width
159
-    * @return integer */
157
+    /** Returns calculated proportional height from the given width
158
+     * @param integer $resized_width
159
+     * @return integer */
160 160
 
161 161
     public function get_prop_height($resized_width) {
162 162
         $height = intval(($this->height * $resized_width) / $this->width);
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
         return $height;
165 165
     }
166 166
 
167
-  /** Returns an array with calculated proportional width & height.
168
-    * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes.
169
-    * The other dimension (height or width) will be calculated autamaticaly
170
-    * @param integer $bigger_size
171
-    * @return array */
167
+    /** Returns an array with calculated proportional width & height.
168
+     * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes.
169
+     * The other dimension (height or width) will be calculated autamaticaly
170
+     * @param integer $bigger_size
171
+     * @return array */
172 172
 
173 173
     public function get_prop_size($bigger_size) {
174 174
 
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
         return array($width, $height);
187 187
     }
188 188
 
189
-  /** Resize image. Returns TRUE on success or FALSE on failure
190
-    * @param integer $width
191
-    * @param integer $height
192
-    * @return bool */
189
+    /** Resize image. Returns TRUE on success or FALSE on failure
190
+     * @param integer $width
191
+     * @param integer $height
192
+     * @return bool */
193 193
 
194 194
     public function resize($width, $height) {
195 195
         if (!$width) $width = 1;
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
         );
204 204
     }
205 205
 
206
-  /** Resize the given image source (GD, gd object or image file path) to fit in the own image.
207
-    * The outside ares will be cropped out. Returns TRUE on success or FALSE on failure
208
-    * @param mixed $src
209
-    * @return bool */
206
+    /** Resize the given image source (GD, gd object or image file path) to fit in the own image.
207
+     * The outside ares will be cropped out. Returns TRUE on success or FALSE on failure
208
+     * @param mixed $src
209
+     * @return bool */
210 210
 
211 211
     public function resize_crop($src) {
212 212
         $image_details = $this->build_image($src);
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
             return false;
234 234
     }
235 235
 
236
-  /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure
237
-    * @param integer $width
238
-    * @param integer $height
239
-    * @return bool */
236
+    /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure
237
+     * @param integer $width
238
+     * @param integer $height
239
+     * @return bool */
240 240
 
241 241
     public function resize_fit($width, $height) {
242 242
         if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
         return $this->resize($width, $height);
251 251
     }
252 252
 
253
-  /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height.
254
-    * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik,
255
-    * no samo po edno (x ili y) izmerenie
256
-    * @param integer $width
257
-    * @param integer $height
258
-    * @return bool */
253
+    /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height.
254
+     * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik,
255
+     * no samo po edno (x ili y) izmerenie
256
+     * @param integer $width
257
+     * @param integer $height
258
+     * @return bool */
259 259
 
260 260
     public function resize_overflow($width, $height) {
261 261
 
@@ -368,30 +368,30 @@  discard block
 block discarded – undo
368 368
 
369 369
 
370 370
 
371
-			/*** gif transparent fix - 1.10.2013 ***/
371
+            /*** gif transparent fix - 1.10.2013 ***/
372 372
 
373
-			$transindex = imagecolortransparent($src);
374
-			$palletsize = imagecolorstotal($src);
375
-			if($transindex >= 0 && $transindex < $palletsize) {
376
-				$transcol = imagecolorsforindex($src, $transindex);
373
+            $transindex = imagecolortransparent($src);
374
+            $palletsize = imagecolorstotal($src);
375
+            if($transindex >= 0 && $transindex < $palletsize) {
376
+                $transcol = imagecolorsforindex($src, $transindex);
377 377
 
378
-			/*** end gif transparent fix ***/
378
+            /*** end gif transparent fix ***/
379 379
 
380
-				$transindex = imagecolorallocatealpha($this->image, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
381
-				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382
-				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383
-				imagecolortransparent($this->image, $transindex);
384
-				for($y=0; $y<$dst_h; ++$y)
385
-					for($x=0; $x<$dst_w; ++$x)
386
-						if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
387
-				imagetruecolortopalette($this->image, true, 255);
388
-			}
389
-			else {
390
-				$transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
391
-				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent);
392
-				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
393
-			}
394
-			return $this->image;
380
+                $transindex = imagecolorallocatealpha($this->image, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
381
+                imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382
+                imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383
+                imagecolortransparent($this->image, $transindex);
384
+                for($y=0; $y<$dst_h; ++$y)
385
+                    for($x=0; $x<$dst_w; ++$x)
386
+                        if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
387
+                imagetruecolortopalette($this->image, true, 255);
388
+            }
389
+            else {
390
+                $transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
391
+                imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent);
392
+                imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
393
+            }
394
+            return $this->image;
395 395
 
396 396
         } else
397 397
             return false;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
     public function imagegif($filename=null) {
420 420
         if (is_null($filename) && !headers_sent())
421 421
             header("Content-Type: image/gif");
422
-			@imagesavealpha($this->image, true);
422
+            @imagesavealpha($this->image, true);
423 423
         return imagegif($this->image, $filename);
424 424
     }
425 425
 }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_image.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -179,7 +179,6 @@
 block discarded – undo
179 179
 
180 180
 /** Resize and crop the image to fit in given resolution. Returns TRUE on
181 181
   * success or FALSE on failure
182
-  * @param mixed $src
183 182
   * @param integer $offset
184 183
   * @return bool */
185 184
     abstract public function resizeCrop($width, $height, $offset=false);
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -1,45 +1,45 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Abstract 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 Abstract 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
 abstract class image {
16 16
     const DEFAULT_JPEG_QUALITY = 75;
17 17
 
18 18
 /** Image resource or object
19
-  * @var mixed */
19
+ * @var mixed */
20 20
     protected $image;
21 21
 
22 22
 /** Image width in pixels
23
-  * @var integer */
23
+ * @var integer */
24 24
     protected $width;
25 25
 
26 26
 /** Image height in pixels
27
-  * @var integer */
27
+ * @var integer */
28 28
     protected $height;
29 29
 
30 30
 /** Init error
31
-  * @var bool */
31
+ * @var bool */
32 32
     protected $initError = false;
33 33
 
34 34
 /** Driver specific options
35
-  * @var array */
35
+ * @var array */
36 36
     protected $options = array();
37 37
 
38 38
 
39 39
 /** Magic method which allows read-only access to all protected or private
40
-  * class properties
41
-  * @param string $property
42
-  * @return mixed */
40
+ * class properties
41
+ * @param string $property
42
+ * @return mixed */
43 43
 
44 44
     final public function __get($property) {
45 45
         return property_exists($this, $property) ? $this->$property : null;
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 
48 48
 
49 49
 /** Constructor. Parameter $image should be:
50
-  *   1. An instance of image driver class (copy instance).
51
-  *   2. An image represented by the type of the $image property
52
-  *      (resource or object).
53
-  *   3. An array with two elements. First - width, second - height.
54
-  *      Creates a blank image.
55
-  *   4. A filename string. Get image form file.
56
-  * Second paramaeter is used by pass some specific image driver options
57
-  * @param mixed $image
58
-  * @param array $options */
50
+ *   1. An instance of image driver class (copy instance).
51
+ *   2. An image represented by the type of the $image property
52
+ *      (resource or object).
53
+ *   3. An array with two elements. First - width, second - height.
54
+ *      Creates a blank image.
55
+ *   4. A filename string. Get image form file.
56
+ * Second paramaeter is used by pass some specific image driver options
57
+ * @param mixed $image
58
+ * @param array $options */
59 59
 
60 60
     public function __construct($image, array $options=array()) {
61 61
         $this->image = $this->width = $this->height = null;
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 
71 71
 
72 72
 /** Factory pattern to load selected driver. $image and $options are passed
73
-  * to the constructor of the image driver
74
-  * @param string $driver
75
-  * @param mixed $image
76
-  * @return object */
73
+ * to the constructor of the image driver
74
+ * @param string $driver
75
+ * @param mixed $image
76
+ * @return object */
77 77
 
78 78
     final static function factory($driver, $image, array $options=array()) {
79 79
         $class = "image_$driver";
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 
83 83
 
84 84
 /** Checks if the drivers in the array parameter could be used. Returns first
85
-  * found one
86
-  * @param array $drivers
87
-  * @return string */
85
+ * found one
86
+ * @param array $drivers
87
+ * @return string */
88 88
 
89 89
     final static function getDriver(array $drivers=array('gd')) {
90 90
         foreach ($drivers as $driver) {
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 
102 102
 
103 103
 /** Returns an array. Element 0 - image resource. Element 1 - width. Element 2 - height.
104
-  * Returns FALSE on failure.
105
-  * @param mixed $image
106
-  * @return array */
104
+ * Returns FALSE on failure.
105
+ * @param mixed $image
106
+ * @return array */
107 107
 
108 108
     final protected function buildImage($image) {
109 109
         $class = get_class($this);
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 
129 129
 
130 130
 /** Returns calculated proportional width from the given height
131
-  * @param integer $resizedHeight
132
-  * @return integer */
131
+ * @param integer $resizedHeight
132
+ * @return integer */
133 133
 
134 134
     final public function getPropWidth($resizedHeight) {
135 135
         $width = round(($this->width * $resizedHeight) / $this->height);
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 
140 140
 
141 141
 /** Returns calculated proportional height from the given width
142
-  * @param integer $resizedWidth
143
-  * @return integer */
142
+ * @param integer $resizedWidth
143
+ * @return integer */
144 144
 
145 145
     final public function getPropHeight($resizedWidth) {
146 146
         $height = round(($this->height * $resizedWidth) / $this->width);
@@ -150,45 +150,45 @@  discard block
 block discarded – undo
150 150
 
151 151
 
152 152
 /** Checks if PHP needs some extra extensions to use the image driver. This
153
-  * static method should be implemented into driver classes like abstract
154
-  * methods
155
-  * @return bool */
153
+ * static method should be implemented into driver classes like abstract
154
+ * methods
155
+ * @return bool */
156 156
     static function available() { return false; }
157 157
 
158 158
 /** Checks if file is an image. This static method should be implemented into
159
-  * driver classes like abstract methods
160
-  * @param string $file
161
-  * @return bool */
159
+ * driver classes like abstract methods
160
+ * @param string $file
161
+ * @return bool */
162 162
     static function checkImage($file) { return false; }
163 163
 
164 164
 /** Resize image. Should return TRUE on success or FALSE on failure
165
-  * @param integer $width
166
-  * @param integer $height
167
-  * @return bool */
165
+ * @param integer $width
166
+ * @param integer $height
167
+ * @return bool */
168 168
     abstract public function resize($width, $height);
169 169
 
170 170
 /** Resize image to fit in given resolution. Should returns TRUE on success
171
-  * or FALSE on failure. If $background is set, the image size will be
172
-  * $width x $height and the empty spaces (if any) will be filled with defined
173
-  * color. Background color examples: "#5f5", "#ff67ca", array(255, 255, 255)
174
-  * @param integer $width
175
-  * @param integer $height
176
-  * @param mixed $background
177
-  * @return bool */
171
+ * or FALSE on failure. If $background is set, the image size will be
172
+ * $width x $height and the empty spaces (if any) will be filled with defined
173
+ * color. Background color examples: "#5f5", "#ff67ca", array(255, 255, 255)
174
+ * @param integer $width
175
+ * @param integer $height
176
+ * @param mixed $background
177
+ * @return bool */
178 178
     abstract public function resizeFit($width, $height, $background=false);
179 179
 
180 180
 /** Resize and crop the image to fit in given resolution. Returns TRUE on
181
-  * success or FALSE on failure
182
-  * @param mixed $src
183
-  * @param integer $offset
184
-  * @return bool */
181
+ * success or FALSE on failure
182
+ * @param mixed $src
183
+ * @param integer $offset
184
+ * @return bool */
185 185
     abstract public function resizeCrop($width, $height, $offset=false);
186 186
 
187 187
 
188 188
 /** Rotate image
189
-  * @param integer $angle
190
-  * @param string $background
191
-  * @return bool */
189
+ * @param integer $angle
190
+ * @param string $background
191
+ * @return bool */
192 192
     abstract public function rotate($angle, $background="#000000");
193 193
 
194 194
     abstract public function flipHorizontal();
@@ -196,44 +196,44 @@  discard block
 block discarded – undo
196 196
     abstract public function flipVertical();
197 197
 
198 198
 /** Apply a PNG or GIF watermark to the image. $top and $left parameters sets
199
-  * the offset of the watermark in pixels. Boolean and NULL values are possible
200
-  * too. In default case (FALSE, FALSE) the watermark should be applyed to
201
-  * the bottom right corner. NULL values means center aligning. If the
202
-  * watermark is bigger than the image or it's partialy or fully outside the
203
-  * image, it shoudn't be applied
204
-  * @param string $file
205
-  * @param mixed $top
206
-  * @param mixed $left
207
-  * @return bool */
199
+ * the offset of the watermark in pixels. Boolean and NULL values are possible
200
+ * too. In default case (FALSE, FALSE) the watermark should be applyed to
201
+ * the bottom right corner. NULL values means center aligning. If the
202
+ * watermark is bigger than the image or it's partialy or fully outside the
203
+ * image, it shoudn't be applied
204
+ * @param string $file
205
+ * @param mixed $top
206
+ * @param mixed $left
207
+ * @return bool */
208 208
     abstract public function watermark($file, $left=false, $top=false);
209 209
 
210 210
 /** Should output the image. Second parameter is used to pass some options like
211
-  *   'file' - if is set, the output will be written to a file
212
-  *   'quality' - compression quality
213
-  * It's possible to use extra specific options required by image type ($type)
214
-  * @param string $type
215
-  * @param array $options
216
-  * @return bool */
211
+ *   'file' - if is set, the output will be written to a file
212
+ *   'quality' - compression quality
213
+ * It's possible to use extra specific options required by image type ($type)
214
+ * @param string $type
215
+ * @param array $options
216
+ * @return bool */
217 217
     abstract public function output($type='jpeg', array $options=array());
218 218
 
219 219
 /** This method should create a blank image with selected size. Should returns
220
-  * resource or object related to the created image, which will be passed to
221
-  * $image property
222
-  * @param integer $width
223
-  * @param integer $height
224
-  * @return mixed */
220
+ * resource or object related to the created image, which will be passed to
221
+ * $image property
222
+ * @param integer $width
223
+ * @param integer $height
224
+ * @return mixed */
225 225
     abstract protected function getBlankImage($width, $height);
226 226
 
227 227
 /** This method should create an image from source image. Only first parameter
228
-  * ($image) is input. Its type should be filename string or a type of the
229
-  * $image property. See the constructor reference for details. The
230
-  * parametters $width and $height are output only. Should returns resource or
231
-  * object related to the created image, which will be passed to $image
232
-  * property
233
-  * @param mixed $image
234
-  * @param integer $width
235
-  * @param integer $height
236
-  * @return mixed */
228
+ * ($image) is input. Its type should be filename string or a type of the
229
+ * $image property. See the constructor reference for details. The
230
+ * parametters $width and $height are output only. Should returns resource or
231
+ * object related to the created image, which will be passed to $image
232
+ * property
233
+ * @param mixed $image
234
+ * @param integer $width
235
+ * @param integer $height
236
+ * @return mixed */
237 237
     abstract protected function getImage($image, &$width, &$height);
238 238
 
239 239
 }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_image_gd.php 2 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -327,6 +327,11 @@
 block discarded – undo
327 327
         return imagecolorallocate($this->image, $r, $g, $b);
328 328
     }
329 329
 
330
+    /**
331
+     * @param integer $x1
332
+     * @param integer $y1
333
+     * @param boolean $color
334
+     */
330 335
     protected function imageFilledRectangle($x1, $y1, $x2, $y2, $color) {
331 336
         $color = $this->gdColor($color);
332 337
         if ($color === false) return false;
Please login to merge, or discard this 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 GD 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 GD 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_gd extends image {
16 16
 
Please login to merge, or discard this patch.