@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | /** |
| 314 | 314 | * @param $filename |
| 315 | - * @return mixed|string |
|
| 315 | + * @return string |
|
| 316 | 316 | */ |
| 317 | 317 | protected function normalizeFilename($filename) { |
| 318 | 318 | if ($this->getTransaliasSettings()) { |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | - * @param $dirname |
|
| 327 | + * @param string $dirname |
|
| 328 | 328 | * @return string |
| 329 | 329 | */ |
| 330 | 330 | protected function normalizeDirname($dirname) { |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @param $dir |
| 409 | 409 | * @param bool $inclType |
| 410 | 410 | * @param bool $existing |
| 411 | - * @return bool|string |
|
| 411 | + * @return false|string |
|
| 412 | 412 | */ |
| 413 | 413 | protected function checkInputDir($dir, $inclType=true, $existing=true) { |
| 414 | 414 | $dir = path::normalize($dir); |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | /** |
| 440 | - * @param $ext |
|
| 440 | + * @param string $ext |
|
| 441 | 441 | * @param $type |
| 442 | 442 | * @return bool |
| 443 | 443 | */ |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | /** |
| 470 | 470 | * @param $path |
| 471 | - * @return mixed |
|
| 471 | + * @return string |
|
| 472 | 472 | */ |
| 473 | 473 | protected function getTypeFromPath($path) { |
| 474 | 474 | return preg_match('/^([^\/]*)\/.*$/', $path, $patt) |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /** |
| 479 | - * @param $path |
|
| 479 | + * @param string $path |
|
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | 482 | protected function removeTypeFromPath($path) { |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** |
| 697 | - * @param $url |
|
| 697 | + * @param string $url |
|
| 698 | 698 | * @param string $message |
| 699 | 699 | */ |
| 700 | 700 | protected function callBack($url, $message="") { |
@@ -1,16 +1,16 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | ) |
| 137 | 137 | $this->cms = $this->get['cms']; |
| 138 | 138 | |
| 139 | - // LINKING UPLOADED FILE |
|
| 139 | + // LINKING UPLOADED FILE |
|
| 140 | 140 | if (count($_FILES)) |
| 141 | 141 | $this->file = &$_FILES[key($_FILES)]; |
| 142 | 142 | |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | $this->config['uploadDir'] = strlen($this->config['uploadDir']) |
| 218 | 218 | ? path::normalize($this->config['uploadDir']) |
| 219 | 219 | : path::url2fullPath("/$path"); |
| 220 | - $this->typeDir = "{$this->config['uploadDir']}/{$this->type}"; |
|
| 221 | - $this->typeURL = "{$this->config['siteURL']}/{$this->config['uploadURL']}/{$this->type}"; |
|
| 220 | + $this->typeDir = "{$this->config['uploadDir']}/{$this->type}"; |
|
| 221 | + $this->typeURL = "{$this->config['siteURL']}/{$this->config['uploadURL']}/{$this->type}"; |
|
| 222 | 222 | |
| 223 | 223 | // SITE ROOT |
| 224 | 224 | } elseif ($this->config['uploadURL'] == "/") { |
@@ -291,23 +291,23 @@ discard block |
||
| 291 | 291 | * @return array|bool|int|null|string|void |
| 292 | 292 | */ |
| 293 | 293 | protected function getTransaliasSettings() { |
| 294 | - $modx = evolutionCMS(); |
|
| 295 | - |
|
| 296 | - // Cleaning uploaded filename? |
|
| 297 | - $setting = $modx->getDatabase()->select('count(*)', $modx->getDatabase()->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1'); |
|
| 298 | - if ($modx->getDatabase()->getValue($setting)>0) { |
|
| 299 | - // Transalias plugin active? |
|
| 300 | - $res = $modx->getDatabase()->select('properties', $modx->getDatabase()->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0'); |
|
| 301 | - if ($properties = $modx->getDatabase()->getValue($res)) { |
|
| 302 | - $properties = $modx->parseProperties($properties, 'TransAlias', 'plugin'); |
|
| 303 | - } else { |
|
| 304 | - $properties = NULL; |
|
| 305 | - } |
|
| 306 | - } else { |
|
| 307 | - $properties = NULL; |
|
| 308 | - } |
|
| 309 | - return $properties; |
|
| 310 | - } |
|
| 294 | + $modx = evolutionCMS(); |
|
| 295 | + |
|
| 296 | + // Cleaning uploaded filename? |
|
| 297 | + $setting = $modx->getDatabase()->select('count(*)', $modx->getDatabase()->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1'); |
|
| 298 | + if ($modx->getDatabase()->getValue($setting)>0) { |
|
| 299 | + // Transalias plugin active? |
|
| 300 | + $res = $modx->getDatabase()->select('properties', $modx->getDatabase()->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0'); |
|
| 301 | + if ($properties = $modx->getDatabase()->getValue($res)) { |
|
| 302 | + $properties = $modx->parseProperties($properties, 'TransAlias', 'plugin'); |
|
| 303 | + } else { |
|
| 304 | + $properties = NULL; |
|
| 305 | + } |
|
| 306 | + } else { |
|
| 307 | + $properties = NULL; |
|
| 308 | + } |
|
| 309 | + return $properties; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -315,13 +315,13 @@ discard block |
||
| 315 | 315 | * @return mixed|string |
| 316 | 316 | */ |
| 317 | 317 | protected function normalizeFilename($filename) { |
| 318 | - if ($this->getTransaliasSettings()) { |
|
| 319 | - $format = strrchr($filename, "."); |
|
| 320 | - $filename = str_replace($format, "", $filename); |
|
| 321 | - $filename = $this->modx->stripAlias($filename).$format; |
|
| 322 | - } |
|
| 323 | - return $filename; |
|
| 324 | - } |
|
| 318 | + if ($this->getTransaliasSettings()) { |
|
| 319 | + $format = strrchr($filename, "."); |
|
| 320 | + $filename = str_replace($format, "", $filename); |
|
| 321 | + $filename = $this->modx->stripAlias($filename).$format; |
|
| 322 | + } |
|
| 323 | + return $filename; |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | 327 | * @param $dirname |
@@ -396,10 +396,10 @@ discard block |
||
| 396 | 396 | return $this->label("The image is too big and/or cannot be resized."); |
| 397 | 397 | |
| 398 | 398 | |
| 399 | - // CHECK FOR MODX MAX FILE SIZE |
|
| 400 | - $actualfilesize=filesize($file['tmp_name']); |
|
| 401 | - if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize']) |
|
| 402 | - return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)"); |
|
| 399 | + // CHECK FOR MODX MAX FILE SIZE |
|
| 400 | + $actualfilesize=filesize($file['tmp_name']); |
|
| 401 | + if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize']) |
|
| 402 | + return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)"); |
|
| 403 | 403 | |
| 404 | 404 | return true; |
| 405 | 405 | } |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | $top = isset($this->config['watermark']['top']) |
| 576 | 576 | ? $this->config['watermark']['top'] : false; |
| 577 | 577 | $img->watermark($this->config['watermark']['file'], $left, $top); |
| 578 | - } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | 580 | $options = array( 'file' => $file ); |
| 581 | 581 | |
@@ -72,8 +72,8 @@ |
||
| 72 | 72 | 'maxImageWidth' => $modx->config['maxImageWidth'], |
| 73 | 73 | 'maxImageHeight' => $modx->config['maxImageHeight'], |
| 74 | 74 | 'clientResize' => $modx->config['clientResize'] && $modx->config['maxImageWidth'] && $modx->config['maxImageHeight'] ? array('maxWidth' => $modx->config['maxImageWidth'], |
| 75 | - 'maxHeight' => $modx->config['maxImageHeight'], |
|
| 76 | - 'quality' => $modx->config['jpegQuality'] / 100 |
|
| 75 | + 'maxHeight' => $modx->config['maxImageHeight'], |
|
| 76 | + 'quality' => $modx->config['jpegQuality'] / 100 |
|
| 77 | 77 | ) : array(), |
| 78 | 78 | |
| 79 | 79 | 'thumbWidth' => $modx->config['thumbWidth'], |
@@ -1,24 +1,24 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** This file is part of KCFinder project |
| 4 | - * |
|
| 5 | - * @desc This file is included first, before each other |
|
| 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 | - * This file is the place you can put any code (at the end of the file), |
|
| 15 | - * which will be executed before any other. Suitable for: |
|
| 16 | - * 1. Set PHP ini settings using ini_set() |
|
| 17 | - * 2. Custom session save handler with session_set_save_handler() |
|
| 18 | - * 3. Any custom integration code. If you use any global variables |
|
| 19 | - * here, they can be accessed in config.php via $GLOBALS array. |
|
| 20 | - * It's recommended to use constants instead. |
|
| 21 | - */ |
|
| 4 | + * |
|
| 5 | + * @desc This file is included first, before each other |
|
| 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 | + * This file is the place you can put any code (at the end of the file), |
|
| 15 | + * which will be executed before any other. Suitable for: |
|
| 16 | + * 1. Set PHP ini settings using ini_set() |
|
| 17 | + * 2. Custom session save handler with session_set_save_handler() |
|
| 18 | + * 3. Any custom integration code. If you use any global variables |
|
| 19 | + * here, they can be accessed in config.php via $GLOBALS array. |
|
| 20 | + * It's recommended to use constants instead. |
|
| 21 | + */ |
|
| 22 | 22 | define('IN_MANAGER_MODE', true); |
| 23 | 23 | define('MODX_API_MODE', true); |
| 24 | 24 | include_once(__DIR__."/../../../../../index.php"); |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | /** |
| 444 | - * @return bool |
|
| 444 | + * @return null|boolean |
|
| 445 | 445 | */ |
| 446 | 446 | protected function act_delete() |
| 447 | 447 | { |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | /** |
| 798 | 798 | * @param $file |
| 799 | - * @param $dir |
|
| 799 | + * @param string $dir |
|
| 800 | 800 | * @return array |
| 801 | 801 | */ |
| 802 | 802 | protected function moveUploadFile($file, $dir) |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | /** |
| 854 | - * @param null $file |
|
| 854 | + * @param string $file |
|
| 855 | 855 | */ |
| 856 | 856 | protected function sendDefaultThumb($file = null) |
| 857 | 857 | { |
@@ -1107,7 +1107,7 @@ discard block |
||
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | /** |
| 1110 | - * @param $message |
|
| 1110 | + * @param string $message |
|
| 1111 | 1111 | * @param array|null $data |
| 1112 | 1112 | */ |
| 1113 | 1113 | protected function errorMsg($message, array $data = null) |
@@ -1,45 +1,45 @@ discard block |
||
| 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 |
||
| 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 parameter 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 parameter 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 | /** Returns calculated proportional width from the given height |
| 129 | - * @param integer $resizedHeight |
|
| 130 | - * @return integer */ |
|
| 129 | + * @param integer $resizedHeight |
|
| 130 | + * @return integer */ |
|
| 131 | 131 | |
| 132 | 132 | final public function getPropWidth($resizedHeight) { |
| 133 | 133 | $width = round(($this->width * $resizedHeight) / $this->height); |
@@ -137,8 +137,8 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | |
| 139 | 139 | /** Returns calculated proportional height from the given width |
| 140 | - * @param integer $resizedWidth |
|
| 141 | - * @return integer */ |
|
| 140 | + * @param integer $resizedWidth |
|
| 141 | + * @return integer */ |
|
| 142 | 142 | |
| 143 | 143 | final public function getPropHeight($resizedWidth) { |
| 144 | 144 | $height = round(($this->height * $resizedWidth) / $this->width); |
@@ -148,45 +148,45 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | /** Checks if PHP needs some extra extensions to use the image driver. This |
| 151 | - * static method should be implemented into driver classes like abstract |
|
| 152 | - * methods |
|
| 153 | - * @return bool */ |
|
| 151 | + * static method should be implemented into driver classes like abstract |
|
| 152 | + * methods |
|
| 153 | + * @return bool */ |
|
| 154 | 154 | static function available() { return false; } |
| 155 | 155 | |
| 156 | 156 | /** Checks if file is an image. This static method should be implemented into |
| 157 | - * driver classes like abstract methods |
|
| 158 | - * @param string $file |
|
| 159 | - * @return bool */ |
|
| 157 | + * driver classes like abstract methods |
|
| 158 | + * @param string $file |
|
| 159 | + * @return bool */ |
|
| 160 | 160 | static function checkImage($file) { return false; } |
| 161 | 161 | |
| 162 | 162 | /** Resize image. Should return TRUE on success or FALSE on failure |
| 163 | - * @param integer $width |
|
| 164 | - * @param integer $height |
|
| 165 | - * @return bool */ |
|
| 163 | + * @param integer $width |
|
| 164 | + * @param integer $height |
|
| 165 | + * @return bool */ |
|
| 166 | 166 | abstract public function resize($width, $height); |
| 167 | 167 | |
| 168 | 168 | /** Resize image to fit in given resolution. Should returns TRUE on success |
| 169 | - * or FALSE on failure. If $background is set, the image size will be |
|
| 170 | - * $width x $height and the empty spaces (if any) will be filled with defined |
|
| 171 | - * color. Background color examples: "#5f5", "#ff67ca", array(255, 255, 255) |
|
| 172 | - * @param integer $width |
|
| 173 | - * @param integer $height |
|
| 174 | - * @param mixed $background |
|
| 175 | - * @return bool */ |
|
| 169 | + * or FALSE on failure. If $background is set, the image size will be |
|
| 170 | + * $width x $height and the empty spaces (if any) will be filled with defined |
|
| 171 | + * color. Background color examples: "#5f5", "#ff67ca", array(255, 255, 255) |
|
| 172 | + * @param integer $width |
|
| 173 | + * @param integer $height |
|
| 174 | + * @param mixed $background |
|
| 175 | + * @return bool */ |
|
| 176 | 176 | abstract public function resizeFit($width, $height, $background=false); |
| 177 | 177 | |
| 178 | 178 | /** Resize and crop the image to fit in given resolution. Returns TRUE on |
| 179 | - * success or FALSE on failure |
|
| 180 | - * @param mixed $src |
|
| 181 | - * @param integer $offset |
|
| 182 | - * @return bool */ |
|
| 179 | + * success or FALSE on failure |
|
| 180 | + * @param mixed $src |
|
| 181 | + * @param integer $offset |
|
| 182 | + * @return bool */ |
|
| 183 | 183 | abstract public function resizeCrop($width, $height, $offset=false); |
| 184 | 184 | |
| 185 | 185 | |
| 186 | 186 | /** Rotate image |
| 187 | - * @param integer $angle |
|
| 188 | - * @param string $background |
|
| 189 | - * @return bool */ |
|
| 187 | + * @param integer $angle |
|
| 188 | + * @param string $background |
|
| 189 | + * @return bool */ |
|
| 190 | 190 | abstract public function rotate($angle, $background="#000000"); |
| 191 | 191 | |
| 192 | 192 | abstract public function flipHorizontal(); |
@@ -194,44 +194,44 @@ discard block |
||
| 194 | 194 | abstract public function flipVertical(); |
| 195 | 195 | |
| 196 | 196 | /** Apply a PNG or GIF watermark to the image. $top and $left parameters sets |
| 197 | - * the offset of the watermark in pixels. Boolean and NULL values are possible |
|
| 198 | - * too. In default case (FALSE, FALSE) the watermark should be applyed to |
|
| 199 | - * the bottom right corner. NULL values means center aligning. If the |
|
| 200 | - * watermark is bigger than the image or it's partialy or fully outside the |
|
| 201 | - * image, it shoudn't be applied |
|
| 202 | - * @param string $file |
|
| 203 | - * @param mixed $top |
|
| 204 | - * @param mixed $left |
|
| 205 | - * @return bool */ |
|
| 197 | + * the offset of the watermark in pixels. Boolean and NULL values are possible |
|
| 198 | + * too. In default case (FALSE, FALSE) the watermark should be applyed to |
|
| 199 | + * the bottom right corner. NULL values means center aligning. If the |
|
| 200 | + * watermark is bigger than the image or it's partialy or fully outside the |
|
| 201 | + * image, it shoudn't be applied |
|
| 202 | + * @param string $file |
|
| 203 | + * @param mixed $top |
|
| 204 | + * @param mixed $left |
|
| 205 | + * @return bool */ |
|
| 206 | 206 | abstract public function watermark($file, $left=false, $top=false); |
| 207 | 207 | |
| 208 | 208 | /** Should output the image. Second parameter is used to pass some options like |
| 209 | - * 'file' - if is set, the output will be written to a file |
|
| 210 | - * 'quality' - compression quality |
|
| 211 | - * It's possible to use extra specific options required by image type ($type) |
|
| 212 | - * @param string $type |
|
| 213 | - * @param array $options |
|
| 214 | - * @return bool */ |
|
| 209 | + * 'file' - if is set, the output will be written to a file |
|
| 210 | + * 'quality' - compression quality |
|
| 211 | + * It's possible to use extra specific options required by image type ($type) |
|
| 212 | + * @param string $type |
|
| 213 | + * @param array $options |
|
| 214 | + * @return bool */ |
|
| 215 | 215 | abstract public function output($type='jpeg', array $options=array()); |
| 216 | 216 | |
| 217 | 217 | /** This method should create a blank image with selected size. Should returns |
| 218 | - * resource or object related to the created image, which will be passed to |
|
| 219 | - * $image property |
|
| 220 | - * @param integer $width |
|
| 221 | - * @param integer $height |
|
| 222 | - * @return mixed */ |
|
| 218 | + * resource or object related to the created image, which will be passed to |
|
| 219 | + * $image property |
|
| 220 | + * @param integer $width |
|
| 221 | + * @param integer $height |
|
| 222 | + * @return mixed */ |
|
| 223 | 223 | abstract protected function getBlankImage($width, $height); |
| 224 | 224 | |
| 225 | 225 | /** This method should create an image from source image. Only first parameter |
| 226 | - * ($image) is input. Its type should be filename string or a type of the |
|
| 227 | - * $image property. See the constructor reference for details. The |
|
| 228 | - * parametters $width and $height are output only. Should returns resource or |
|
| 229 | - * object related to the created image, which will be passed to $image |
|
| 230 | - * property |
|
| 231 | - * @param mixed $image |
|
| 232 | - * @param integer $width |
|
| 233 | - * @param integer $height |
|
| 234 | - * @return mixed */ |
|
| 226 | + * ($image) is input. Its type should be filename string or a type of the |
|
| 227 | + * $image property. See the constructor reference for details. The |
|
| 228 | + * parametters $width and $height are output only. Should returns resource or |
|
| 229 | + * object related to the created image, which will be passed to $image |
|
| 230 | + * property |
|
| 231 | + * @param mixed $image |
|
| 232 | + * @param integer $width |
|
| 233 | + * @param integer $height |
|
| 234 | + * @return mixed */ |
|
| 235 | 235 | abstract protected function getImage($image, &$width, &$height); |
| 236 | 236 | |
| 237 | 237 | } |