| @@ -38,9 +38,9 @@ discard block | ||
| 38 | 38 | 'webp', | 
| 39 | 39 | ], | 
| 40 | 40 | 'path' => 'files', | 
| 41 | - 'background' => [255, 255, 255, 127], | |
| 41 | + 'background' => [ 255, 255, 255, 127 ], | |
| 42 | 42 | 'watermark' => '', | 
| 43 | - 'thumbs' => [], | |
| 43 | + 'thumbs' => [ ], | |
| 44 | 44 | ]; | 
| 45 | 45 | |
| 46 | 46 | /** | 
| @@ -48,22 +48,22 @@ discard block | ||
| 48 | 48 | * | 
| 49 | 49 | * @var array | 
| 50 | 50 | */ | 
| 51 | - protected $_files = []; | |
| 51 | + protected $_files = [ ]; | |
| 52 | 52 | |
| 53 | 53 | /** | 
| 54 | 54 |       * {@inheritDoc} | 
| 55 | 55 | */ | 
| 56 | 56 | public function initialize(array $config) | 
| 57 | 57 |      { | 
| 58 | - $this->_config = []; | |
| 58 | + $this->_config = [ ]; | |
| 59 | 59 | |
| 60 | 60 |          foreach ($config as $field => $fieldOptions) { | 
| 61 | 61 |              if (is_array($fieldOptions)) { | 
| 62 | - $this->_config[$this->getTable()->getAlias()][$field] = array_merge($this->_defaultConfig, $fieldOptions); | |
| 62 | + $this->_config[ $this->getTable()->getAlias() ][ $field ] = array_merge($this->_defaultConfig, $fieldOptions); | |
| 63 | 63 |              } else { | 
| 64 | 64 | $field = $fieldOptions; | 
| 65 | 65 | |
| 66 | - $this->_config[$this->getTable()->getAlias()][$field] = $this->_defaultConfig; | |
| 66 | + $this->_config[ $this->getTable()->getAlias() ][ $field ] = $this->_defaultConfig; | |
| 67 | 67 | } | 
| 68 | 68 | } | 
| 69 | 69 | } | 
| @@ -71,38 +71,38 @@ discard block | ||
| 71 | 71 | /** | 
| 72 | 72 |       * {@inheritDoc} | 
| 73 | 73 | */ | 
| 74 | - public function beforeMarshal(Event $event, $data = [], $options = []) | |
| 74 | + public function beforeMarshal(Event $event, $data = [ ], $options = [ ]) | |
| 75 | 75 |      { | 
| 76 | 76 |          if (!empty($config = $this->getConfig($this->getTable()->getAlias()))) { | 
| 77 | 77 |              foreach ($config as $field => $fieldOptions) { | 
| 78 | 78 |                  if (array_key_exists($field, $data)) { | 
| 79 | 79 | // Save file array to suffixed field | 
| 80 | - $data['_' . $field] = $data[$field]; | |
| 80 | + $data[ '_'.$field ] = $data[ $field ]; | |
| 81 | 81 | |
| 82 | 82 | // Detect multiple files by array keys | 
| 83 | -                    if (is_numeric(key($data[$field]))) { | |
| 84 | -                        foreach (array_keys($data[$field]) as $key) { | |
| 85 | -                            if (!empty($data[$field][$key]['tmp_name'])) { | |
| 86 | - $this->_files[$field . '_' . $key] = array_merge($fieldOptions, [ | |
| 87 | - 'name' => $this->_prepareName($data[$field][$key]['name']), | |
| 88 | - 'source' => $data[$field][$key]['tmp_name'], | |
| 83 | +                    if (is_numeric(key($data[ $field ]))) { | |
| 84 | +                        foreach (array_keys($data[ $field ]) as $key) { | |
| 85 | +                            if (!empty($data[ $field ][ $key ][ 'tmp_name' ])) { | |
| 86 | + $this->_files[ $field.'_'.$key ] = array_merge($fieldOptions, [ | |
| 87 | + 'name' => $this->_prepareName($data[ $field ][ $key ][ 'name' ]), | |
| 88 | + 'source' => $data[ $field ][ $key ][ 'tmp_name' ], | |
| 89 | 89 | ]); | 
| 90 | 90 | |
| 91 | - $data[$field][$key] = $this->_files[$field . '_' . $key]['name']; | |
| 91 | + $data[ $field ][ $key ] = $this->_files[ $field.'_'.$key ][ 'name' ]; | |
| 92 | 92 |                              } else { | 
| 93 | - unset($data[$field][$key]); | |
| 93 | + unset($data[ $field ][ $key ]); | |
| 94 | 94 | } | 
| 95 | 95 | } | 
| 96 | 96 |                      } else { | 
| 97 | -                        if (!empty($data[$field]['tmp_name'])) { | |
| 98 | - $this->_files[$field] = array_merge($fieldOptions, [ | |
| 99 | - 'name' => $this->_prepareName($data[$field]['name']), | |
| 100 | - 'source' => $data[$field]['tmp_name'], | |
| 97 | +                        if (!empty($data[ $field ][ 'tmp_name' ])) { | |
| 98 | + $this->_files[ $field ] = array_merge($fieldOptions, [ | |
| 99 | + 'name' => $this->_prepareName($data[ $field ][ 'name' ]), | |
| 100 | + 'source' => $data[ $field ][ 'tmp_name' ], | |
| 101 | 101 | ]); | 
| 102 | 102 | |
| 103 | - $data[$field] = $this->_files[$field]['name']; | |
| 103 | + $data[ $field ] = $this->_files[ $field ][ 'name' ]; | |
| 104 | 104 |                          } else { | 
| 105 | - unset($data[$field]); | |
| 105 | + unset($data[ $field ]); | |
| 106 | 106 | } | 
| 107 | 107 | } | 
| 108 | 108 | } | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | /** | 
| 114 | 114 |       * {@inheritDoc} | 
| 115 | 115 | */ | 
| 116 | - public function afterSave(Event $event, EntityInterface $entity, $options = []) | |
| 116 | + public function afterSave(Event $event, EntityInterface $entity, $options = [ ]) | |
| 117 | 117 |      { | 
| 118 | 118 | $this->_prepareFile($entity); | 
| 119 | 119 | } | 
| @@ -134,18 +134,18 @@ discard block | ||
| 134 | 134 | protected function _prepareFile(EntityInterface $entity) | 
| 135 | 135 |      { | 
| 136 | 136 |          foreach ($this->_files as $field => $fieldOptions) { | 
| 137 | -            if (!is_dir($fieldOptions['path'])) { | |
| 138 | - $this->_prepareDir($fieldOptions['path']); | |
| 137 | +            if (!is_dir($fieldOptions[ 'path' ])) { | |
| 138 | + $this->_prepareDir($fieldOptions[ 'path' ]); | |
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | - $file = $fieldOptions['path'] . DS . $fieldOptions['name']; | |
| 141 | + $file = $fieldOptions[ 'path' ].DS.$fieldOptions[ 'name' ]; | |
| 142 | 142 | |
| 143 | -            if (move_uploaded_file($fieldOptions['source'], $file) || (file_exists($fieldOptions['source']) && rename($fieldOptions['source'], $file))) { | |
| 144 | - $fileType = mb_strtolower(getimagesize($fieldOptions['source'])['mime']); | |
| 143 | +            if (move_uploaded_file($fieldOptions[ 'source' ], $file) || (file_exists($fieldOptions[ 'source' ]) && rename($fieldOptions[ 'source' ], $file))) { | |
| 144 | + $fileType = mb_strtolower(getimagesize($fieldOptions[ 'source' ])[ 'mime' ]); | |
| 145 | 145 | |
| 146 | -                $fieldTypes = array_map(function ($fieldType) { | |
| 146 | +                $fieldTypes = array_map(function($fieldType) { | |
| 147 | 147 | return mb_strtolower($fieldType); | 
| 148 | - }, $fieldOptions['types']); | |
| 148 | + }, $fieldOptions[ 'types' ]); | |
| 149 | 149 | |
| 150 | 150 | // Create thumbs | 
| 151 | 151 |                  if (mb_strpos($fileType, 'image/') !== false && in_array($fileType, $fieldTypes)) { | 
| @@ -165,10 +165,10 @@ discard block | ||
| 165 | 165 |      { | 
| 166 | 166 |          if (!empty($config = $this->getConfig($this->getTable()->getAlias()))) { | 
| 167 | 167 |              foreach ($config as $field => $fieldOptions) { | 
| 168 | -                if (isset($entity[$field])) { | |
| 169 | - $path = $fieldOptions['path'] . DS . substr($entity[$field], 0, 37); | |
| 168 | +                if (isset($entity[ $field ])) { | |
| 169 | + $path = $fieldOptions[ 'path' ].DS.substr($entity[ $field ], 0, 37); | |
| 170 | 170 | |
| 171 | -                    foreach (glob($path . '*') as $file) { | |
| 171 | +                    foreach (glob($path.'*') as $file) { | |
| 172 | 172 |                          if (file_exists($file)) { | 
| 173 | 173 | unlink($file); | 
| 174 | 174 | } | 
| @@ -191,14 +191,14 @@ discard block | ||
| 191 | 191 |      { | 
| 192 | 192 |          if (is_file($originalFile) && is_array($settingParams)) { | 
| 193 | 193 | // Check image library | 
| 194 | -            if (!extension_loaded($settingParams['library'])) { | |
| 195 | -                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $settingParams['library'])); | |
| 194 | +            if (!extension_loaded($settingParams[ 'library' ])) { | |
| 195 | +                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $settingParams[ 'library' ])); | |
| 196 | 196 | } | 
| 197 | 197 | |
| 198 | 198 | // Get extension from original file | 
| 199 | 199 | $fileExtension = $this->getExtension($originalFile); | 
| 200 | 200 | |
| 201 | -            switch ($settingParams['library']) { | |
| 201 | +            switch ($settingParams[ 'library' ]) { | |
| 202 | 202 | // Get image resource | 
| 203 | 203 | case 'gd': | 
| 204 | 204 |                      switch ($fileExtension) { | 
| @@ -240,7 +240,7 @@ discard block | ||
| 240 | 240 | |
| 241 | 241 | break; | 
| 242 | 242 | default: | 
| 243 | -                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $settingParams['library'])); | |
| 243 | +                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $settingParams[ 'library' ])); | |
| 244 | 244 | } | 
| 245 | 245 | |
| 246 | 246 | $offsetX = 0; | 
| @@ -249,48 +249,48 @@ discard block | ||
| 249 | 249 | $cropX = 0; | 
| 250 | 250 | $cropY = 0; | 
| 251 | 251 | |
| 252 | -            foreach ($settingParams['thumbs'] as $thumbName => $thumbParam) { | |
| 252 | +            foreach ($settingParams[ 'thumbs' ] as $thumbName => $thumbParam) { | |
| 253 | 253 |                  if (is_array($thumbParam)) { | 
| 254 | -                    if (isset($thumbParam['width']) && is_array($thumbParam['width']) && count($thumbParam['width']) === 1) { | |
| 255 | - list($newWidth, $newHeight) = $this->_byWidth($originalWidth, $originalHeight, $thumbParam['width'][0]); | |
| 256 | -                    } elseif (isset($thumbParam['height']) && is_array($thumbParam['height']) && count($thumbParam['height']) === 1) { | |
| 257 | - list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $thumbParam['height'][0]); | |
| 258 | -                    } elseif (isset($thumbParam['shorter']) && is_array($thumbParam['shorter']) && count($thumbParam['shorter']) === 2) { | |
| 259 | - list($newWidth, $newHeight) = $this->_byShorter($originalWidth, $originalHeight, $thumbParam['shorter'][0], $thumbParam['shorter'][1]); | |
| 260 | -                    } elseif (isset($thumbParam['longer']) && is_array($thumbParam['longer']) && count($thumbParam['longer']) === 2) { | |
| 261 | - list($newWidth, $newHeight) = $this->_byLonger($originalWidth, $originalHeight, $thumbParam['longer'][0], $thumbParam['longer'][1]); | |
| 262 | -                    } elseif (isset($thumbParam['fit']) && is_array($thumbParam['fit']) && count($thumbParam['fit']) === 2) { | |
| 263 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam['fit'][0], $thumbParam['fit'][1]); | |
| 264 | -                    } elseif (isset($thumbParam['fit']) && is_array($thumbParam['fit']) && count($thumbParam['fit']) === 3) { | |
| 265 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam['fit'][0], $thumbParam['fit'][1], $thumbParam['fit'][2]); | |
| 266 | -                    } elseif (isset($thumbParam['square']) && is_array($thumbParam['square']) && count($thumbParam['square']) === 1) { | |
| 267 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam['square'][0]); | |
| 268 | -                    } elseif (isset($thumbParam['square']) && is_array($thumbParam['square']) && count($thumbParam['square']) === 2) { | |
| 269 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam['square'][0], $thumbParam['square'][1]); | |
| 254 | +                    if (isset($thumbParam[ 'width' ]) && is_array($thumbParam[ 'width' ]) && count($thumbParam[ 'width' ]) === 1) { | |
| 255 | + list($newWidth, $newHeight) = $this->_byWidth($originalWidth, $originalHeight, $thumbParam[ 'width' ][ 0 ]); | |
| 256 | +                    } elseif (isset($thumbParam[ 'height' ]) && is_array($thumbParam[ 'height' ]) && count($thumbParam[ 'height' ]) === 1) { | |
| 257 | + list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $thumbParam[ 'height' ][ 0 ]); | |
| 258 | +                    } elseif (isset($thumbParam[ 'shorter' ]) && is_array($thumbParam[ 'shorter' ]) && count($thumbParam[ 'shorter' ]) === 2) { | |
| 259 | + list($newWidth, $newHeight) = $this->_byShorter($originalWidth, $originalHeight, $thumbParam[ 'shorter' ][ 0 ], $thumbParam[ 'shorter' ][ 1 ]); | |
| 260 | +                    } elseif (isset($thumbParam[ 'longer' ]) && is_array($thumbParam[ 'longer' ]) && count($thumbParam[ 'longer' ]) === 2) { | |
| 261 | + list($newWidth, $newHeight) = $this->_byLonger($originalWidth, $originalHeight, $thumbParam[ 'longer' ][ 0 ], $thumbParam[ 'longer' ][ 1 ]); | |
| 262 | +                    } elseif (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]) && count($thumbParam[ 'fit' ]) === 2) { | |
| 263 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam[ 'fit' ][ 0 ], $thumbParam[ 'fit' ][ 1 ]); | |
| 264 | +                    } elseif (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]) && count($thumbParam[ 'fit' ]) === 3) { | |
| 265 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam[ 'fit' ][ 0 ], $thumbParam[ 'fit' ][ 1 ], $thumbParam[ 'fit' ][ 2 ]); | |
| 266 | +                    } elseif (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) && count($thumbParam[ 'square' ]) === 1) { | |
| 267 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam[ 'square' ][ 0 ]); | |
| 268 | +                    } elseif (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) && count($thumbParam[ 'square' ]) === 2) { | |
| 269 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam[ 'square' ][ 0 ], $thumbParam[ 'square' ][ 1 ]); | |
| 270 | 270 |                      } else { | 
| 271 | 271 |                          throw new ThumbsException(__d('file', 'Unknown type of creating thumbnails!')); | 
| 272 | 272 | } | 
| 273 | 273 | |
| 274 | 274 |                      $thumbFile = str_replace('default', $thumbName, $originalFile); | 
| 275 | 275 | |
| 276 | -                    switch ($settingParams['library']) { | |
| 276 | +                    switch ($settingParams[ 'library' ]) { | |
| 277 | 277 | // Get image resource | 
| 278 | 278 | case 'gd': | 
| 279 | 279 | $newImage = imagecreatetruecolor($newWidth, $newHeight); | 
| 280 | 280 | |
| 281 | -                            if (is_array($settingParams['background'])) { | |
| 281 | +                            if (is_array($settingParams[ 'background' ])) { | |
| 282 | 282 | // Set background color and transparent indicates | 
| 283 | - imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $settingParams['background'][0], $settingParams['background'][1], $settingParams['background'][2], $settingParams['background'][3])); | |
| 283 | + imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $settingParams[ 'background' ][ 0 ], $settingParams[ 'background' ][ 1 ], $settingParams[ 'background' ][ 2 ], $settingParams[ 'background' ][ 3 ])); | |
| 284 | 284 | } | 
| 285 | 285 | |
| 286 | 286 | imagecopyresampled($newImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight); | 
| 287 | 287 | |
| 288 | -                            if ((isset($thumbParam['square']) && is_array($thumbParam['square'])) || (isset($thumbParam['fit']) && is_array($thumbParam['fit']))) { | |
| 288 | +                            if ((isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ])) || (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]))) { | |
| 289 | 289 | $fitImage = imagecreatetruecolor($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY)); | 
| 290 | 290 | |
| 291 | -                                if (is_array($settingParams['background'])) { | |
| 291 | +                                if (is_array($settingParams[ 'background' ])) { | |
| 292 | 292 | // Set background color and transparent indicates | 
| 293 | - imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $settingParams['background'][0], $settingParams['background'][1], $settingParams['background'][2], $settingParams['background'][3])); | |
| 293 | + imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $settingParams[ 'background' ][ 0 ], $settingParams[ 'background' ][ 1 ], $settingParams[ 'background' ][ 2 ], $settingParams[ 'background' ][ 3 ])); | |
| 294 | 294 | } | 
| 295 | 295 | |
| 296 | 296 | imagecopyresampled($fitImage, $newImage, $offsetX, $offsetY, $cropX, $cropY, $newWidth, $newHeight, $newWidth, $newHeight); | 
| @@ -302,10 +302,10 @@ discard block | ||
| 302 | 302 | imagesavealpha($newImage, true); | 
| 303 | 303 | |
| 304 | 304 | // Watermark | 
| 305 | -                            if (isset($thumbParam['watermark']) && ($watermarkSource = file_get_contents($settingParams['watermark'])) !== false) { | |
| 305 | +                            if (isset($thumbParam[ 'watermark' ]) && ($watermarkSource = file_get_contents($settingParams[ 'watermark' ])) !== false) { | |
| 306 | 306 | $watermarkImage = imagecreatefromstring($watermarkSource); | 
| 307 | 307 | |
| 308 | - list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbParam['watermark']); | |
| 308 | + list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbParam[ 'watermark' ]); | |
| 309 | 309 | |
| 310 | 310 | // Set transparent | 
| 311 | 311 | imagealphablending($newImage, true); | 
| @@ -344,16 +344,16 @@ discard block | ||
| 344 | 344 |                              $newImage->setimagebackgroundcolor('transparent'); | 
| 345 | 345 | $newImage->extentimage($newWidth + (2 * $offsetX), $newHeight + (2 * $offsetY), -$offsetX, -$offsetY); | 
| 346 | 346 | |
| 347 | -                            if ((isset($thumbParam['square']) && is_array($thumbParam['square'])) || (isset($thumbParam['fit']) && is_array($thumbParam['fit']))) { | |
| 347 | +                            if ((isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ])) || (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]))) { | |
| 348 | 348 | $newImage->cropimage($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY), $cropX, $cropY); | 
| 349 | 349 | } | 
| 350 | 350 | |
| 351 | 351 | // Watermark | 
| 352 | -                            if (isset($thumbParam['watermark']) && ($watermarkSource = file_get_contents($settingParams['watermark'])) !== false) { | |
| 352 | +                            if (isset($thumbParam[ 'watermark' ]) && ($watermarkSource = file_get_contents($settingParams[ 'watermark' ])) !== false) { | |
| 353 | 353 | $watermarkImage = new \Imagick(); | 
| 354 | 354 | $watermarkImage->readimageblob($watermarkSource); | 
| 355 | 355 | |
| 356 | - list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbParam['watermark']); | |
| 356 | + list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbParam[ 'watermark' ]); | |
| 357 | 357 | |
| 358 | 358 | $newImage->compositeimage($watermarkImage, \Imagick::COMPOSITE_OVER, $watermarkPositionX, $watermarkPositionY); | 
| 359 | 359 | } | 
| @@ -413,43 +413,43 @@ discard block | ||
| 413 | 413 |      { | 
| 414 | 414 |          switch (intval($positionValue)) { | 
| 415 | 415 | case 1: // Top left | 
| 416 | - return [$offsetX, $offsetY]; | |
| 416 | + return [ $offsetX, $offsetY ]; | |
| 417 | 417 | |
| 418 | 418 | break; | 
| 419 | 419 | case 2: // Top center | 
| 420 | - return [($newWidth / 2) - ($watermarkWidth / 2), 0 + $offsetY]; | |
| 420 | + return [ ($newWidth / 2) - ($watermarkWidth / 2), 0 + $offsetY ]; | |
| 421 | 421 | |
| 422 | 422 | break; | 
| 423 | 423 | case 3: // Top right | 
| 424 | - return [($newWidth - $watermarkWidth) - $offsetX, 0 + $offsetY]; | |
| 424 | + return [ ($newWidth - $watermarkWidth) - $offsetX, 0 + $offsetY ]; | |
| 425 | 425 | |
| 426 | 426 | break; | 
| 427 | 427 | case 4: // Middle left | 
| 428 | - return [$offsetX, ($newHeight / 2) - ($watermarkHeight / 2)]; | |
| 428 | + return [ $offsetX, ($newHeight / 2) - ($watermarkHeight / 2) ]; | |
| 429 | 429 | |
| 430 | 430 | break; | 
| 431 | 431 | case 5: // Middle center | 
| 432 | - return [($newWidth / 2) - ($watermarkWidth / 2), ($newHeight / 2) - ($watermarkHeight / 2)]; | |
| 432 | + return [ ($newWidth / 2) - ($watermarkWidth / 2), ($newHeight / 2) - ($watermarkHeight / 2) ]; | |
| 433 | 433 | |
| 434 | 434 | break; | 
| 435 | 435 | case 6: // Middle right | 
| 436 | - return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight / 2) - ($watermarkHeight / 2)]; | |
| 436 | + return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight / 2) - ($watermarkHeight / 2) ]; | |
| 437 | 437 | |
| 438 | 438 | break; | 
| 439 | 439 | case 7: // Bottom left | 
| 440 | - return [$offsetX, ($newHeight - $watermarkHeight) - $offsetY]; | |
| 440 | + return [ $offsetX, ($newHeight - $watermarkHeight) - $offsetY ]; | |
| 441 | 441 | |
| 442 | 442 | break; | 
| 443 | 443 | case 8: // Bottom center | 
| 444 | - return [($newWidth / 2) - ($watermarkWidth / 2), ($newHeight - $watermarkHeight) - $offsetY]; | |
| 444 | + return [ ($newWidth / 2) - ($watermarkWidth / 2), ($newHeight - $watermarkHeight) - $offsetY ]; | |
| 445 | 445 | |
| 446 | 446 | break; | 
| 447 | 447 | case 9: // Bottom right | 
| 448 | - return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY]; | |
| 448 | + return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY ]; | |
| 449 | 449 | |
| 450 | 450 | break; | 
| 451 | 451 | default: | 
| 452 | - return [$offsetX, $offsetY]; | |
| 452 | + return [ $offsetX, $offsetY ]; | |
| 453 | 453 | |
| 454 | 454 | break; | 
| 455 | 455 | } | 
| @@ -466,7 +466,7 @@ discard block | ||
| 466 | 466 | */ | 
| 467 | 467 | protected function _prepareName($fieldName) | 
| 468 | 468 |      { | 
| 469 | - return Text::uuid() . '_default.' . $this->getExtension($fieldName); | |
| 469 | + return Text::uuid().'_default.'.$this->getExtension($fieldName); | |
| 470 | 470 | } | 
| 471 | 471 | |
| 472 | 472 | /** | 
| @@ -478,7 +478,7 @@ discard block | ||
| 478 | 478 | */ | 
| 479 | 479 | protected function _prepareDir($dirPath) | 
| 480 | 480 |      { | 
| 481 | -        $dirPath = WWW_ROOT . str_replace('/', DS, $dirPath); | |
| 481 | +        $dirPath = WWW_ROOT.str_replace('/', DS, $dirPath); | |
| 482 | 482 | |
| 483 | 483 |          if (!is_dir($dirPath) && mb_strlen($dirPath) > 0) { | 
| 484 | 484 | mkdir($dirPath, 0777, true); | 
| @@ -508,7 +508,7 @@ discard block | ||
| 508 | 508 | $newHeight = intval($newWidth * ($originalHeight / $originalWidth)); | 
| 509 | 509 | } | 
| 510 | 510 | |
| 511 | - return [$newWidth, $newHeight]; | |
| 511 | + return [ $newWidth, $newHeight ]; | |
| 512 | 512 | } | 
| 513 | 513 | |
| 514 | 514 | /** | 
| @@ -530,7 +530,7 @@ discard block | ||
| 530 | 530 | $newWidth = intval($newHeight * ($originalWidth / $originalHeight)); | 
| 531 | 531 | } | 
| 532 | 532 | |
| 533 | - return [$newWidth, $newHeight]; | |
| 533 | + return [ $newWidth, $newHeight ]; | |
| 534 | 534 | } | 
| 535 | 535 | |
| 536 | 536 | /** | 
| @@ -553,7 +553,7 @@ discard block | ||
| 553 | 553 | list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $newHeight); | 
| 554 | 554 | } | 
| 555 | 555 | |
| 556 | - return [$newWidth, $newHeight]; | |
| 556 | + return [ $newWidth, $newHeight ]; | |
| 557 | 557 | } | 
| 558 | 558 | |
| 559 | 559 | /** | 
| @@ -576,7 +576,7 @@ discard block | ||
| 576 | 576 | list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $newHeight); | 
| 577 | 577 | } | 
| 578 | 578 | |
| 579 | - return [$newWidth, $newHeight]; | |
| 579 | + return [ $newWidth, $newHeight ]; | |
| 580 | 580 | } | 
| 581 | 581 | |
| 582 | 582 | /** | 
| @@ -605,7 +605,7 @@ discard block | ||
| 605 | 605 |              } else { | 
| 606 | 606 | $newSizes = $this->_byLonger($originalWidth, $originalHeight, $newWidth, $newHeight); | 
| 607 | 607 | |
| 608 | -                if ($newWidth < $newSizes[0] || $newHeight < $newSizes[1]) { | |
| 608 | +                if ($newWidth < $newSizes[ 0 ] || $newHeight < $newSizes[ 1 ]) { | |
| 609 | 609 | $newSizes = $this->_byShorter($originalWidth, $originalHeight, $newWidth, $newHeight); | 
| 610 | 610 | } | 
| 611 | 611 | } | 
| @@ -615,25 +615,25 @@ discard block | ||
| 615 | 615 |              } else { | 
| 616 | 616 | $newSizes = $this->_byShorter($originalWidth, $originalHeight, $newWidth, $newHeight); | 
| 617 | 617 | |
| 618 | -                if ($newWidth > $newSizes[0] || $newHeight > $newSizes[1]) { | |
| 618 | +                if ($newWidth > $newSizes[ 0 ] || $newHeight > $newSizes[ 1 ]) { | |
| 619 | 619 | $newSizes = $this->_byLonger($originalWidth, $originalHeight, $newWidth, $newHeight); | 
| 620 | 620 | } | 
| 621 | 621 | } | 
| 622 | 622 | } | 
| 623 | 623 | |
| 624 | -        if ($newWidth < $newSizes[0]) { | |
| 625 | - $cropX = ($newSizes[0] - $newWidth) / 2; | |
| 624 | +        if ($newWidth < $newSizes[ 0 ]) { | |
| 625 | + $cropX = ($newSizes[ 0 ] - $newWidth) / 2; | |
| 626 | 626 |          } else { | 
| 627 | - $offsetX = ($newWidth - $newSizes[0]) / 2; | |
| 627 | + $offsetX = ($newWidth - $newSizes[ 0 ]) / 2; | |
| 628 | 628 | } | 
| 629 | 629 | |
| 630 | -        if ($newHeight < $newSizes[1]) { | |
| 631 | - $cropY = ($newSizes[1] - $newHeight) / 2; | |
| 630 | +        if ($newHeight < $newSizes[ 1 ]) { | |
| 631 | + $cropY = ($newSizes[ 1 ] - $newHeight) / 2; | |
| 632 | 632 |          } else { | 
| 633 | - $offsetY = ($newHeight - $newSizes[1]) / 2; | |
| 633 | + $offsetY = ($newHeight - $newSizes[ 1 ]) / 2; | |
| 634 | 634 | } | 
| 635 | 635 | |
| 636 | - return [$newSizes[0], $newSizes[1], $offsetX, $offsetY, $cropX, $cropY]; | |
| 636 | + return [ $newSizes[ 0 ], $newSizes[ 1 ], $offsetX, $offsetY, $cropX, $cropY ]; | |
| 637 | 637 | } | 
| 638 | 638 | |
| 639 | 639 | /** | 
| @@ -680,6 +680,6 @@ discard block | ||
| 680 | 680 | } | 
| 681 | 681 | } | 
| 682 | 682 | |
| 683 | - return [$newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY]; | |
| 683 | + return [ $newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY ]; | |
| 684 | 684 | } | 
| 685 | 685 | } | 
| 686 | 686 | \ No newline at end of file |