@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * @param $request |
|
71 | + * @param Request $request |
|
72 | 72 | * @param CmsComponent $cmsComponent |
73 | 73 | */ |
74 | 74 | private function newRoute($request, $cmsComponent) |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | - * @param $request |
|
86 | + * @param Request $request |
|
87 | 87 | * @param CmsComponent $cmsComponent |
88 | 88 | */ |
89 | 89 | private function deleteRoute($request, $cmsComponent) |
@@ -40,20 +40,20 @@ discard block |
||
40 | 40 | { |
41 | 41 | $file = $cmsComponent->storage->getFiles()->getFileByName($slug); |
42 | 42 | $path = realpath($cmsComponent->storage->getFiles()->getFilesDir()); |
43 | - $quoted = sprintf('"%s"', addcslashes(basename($path . '/' . $file->file), '"\\')); |
|
44 | - $size = filesize($path . '/' . $file->file); |
|
43 | + $quoted = sprintf('"%s"', addcslashes(basename($path.'/'.$file->file), '"\\')); |
|
44 | + $size = filesize($path.'/'.$file->file); |
|
45 | 45 | |
46 | 46 | header('Content-Description: File Transfer'); |
47 | - header('Content-Type: ' . $file->type); |
|
48 | - header('Content-Disposition: attachment; filename=' . $quoted); |
|
47 | + header('Content-Type: '.$file->type); |
|
48 | + header('Content-Disposition: attachment; filename='.$quoted); |
|
49 | 49 | header('Content-Transfer-Encoding: binary'); |
50 | 50 | header('Connection: Keep-Alive'); |
51 | 51 | header('Expires: 0'); |
52 | 52 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
53 | 53 | header('Pragma: public'); |
54 | - header('Content-Length: ' . $size); |
|
54 | + header('Content-Length: '.$size); |
|
55 | 55 | |
56 | - readfile($path . '/' . $file->file); |
|
56 | + readfile($path.'/'.$file->file); |
|
57 | 57 | exit; |
58 | 58 | } |
59 | 59 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_FILES); |
78 | 78 | if (isset($_FILES[CmsComponent::FILES_PARAMETER_FILE])) { |
79 | 79 | $cmsComponent->storage->getFiles()->addFile($_FILES[CmsComponent::FILES_PARAMETER_FILE]); |
80 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files'); |
|
80 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/files'); |
|
81 | 81 | exit; |
82 | 82 | } |
83 | 83 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | private function deleteRoute($request, $cmsComponent) |
90 | 90 | { |
91 | 91 | $cmsComponent->storage->getFiles()->deleteFileByName($request::$get[CmsComponent::FILES_PARAMETER_FILE]); |
92 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files'); |
|
92 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/files'); |
|
93 | 93 | exit; |
94 | 94 | } |
95 | 95 |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
183 | - * @param \cc\Request $request |
|
183 | + * @param \CloudControl\Cms\cc\Request $request |
|
184 | 184 | * @return array |
185 | 185 | */ |
186 | 186 | private function getPostValues($request) |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | - * @return \cc\Request |
|
294 | + * @return \CloudControl\Cms\cc\Request |
|
295 | 295 | */ |
296 | 296 | private function setPathBackup() |
297 | 297 | { |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | - * @param \cc\Request $request |
|
308 | + * @param \CloudControl\Cms\cc\Request $request |
|
309 | 309 | */ |
310 | 310 | private function resetPathBackup($request) |
311 | 311 | { |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | - * @param $form |
|
320 | + * @param string|null $form |
|
321 | 321 | */ |
322 | 322 | private function setFormParameter($form) |
323 | 323 | { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | if (isset($_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID])) { |
163 | 163 | $this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID]; |
164 | 164 | } else { |
165 | - $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string)microtime(true); |
|
165 | + $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string) microtime(true); |
|
166 | 166 | $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] = false; |
167 | 167 | $this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID]; |
168 | 168 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $postValues = $request::$post; |
191 | 191 | $postValues[self::PARAMETER_DOCUMENT_TYPE] = $this->documentType; |
192 | 192 | $postValues[self::GET_PARAMETER_PATH] = $this->responseFolder; |
193 | - $postValues['title'] = date('r') . ' - From: ' . $request::$requestUri; |
|
193 | + $postValues['title'] = date('r').' - From: '.$request::$requestUri; |
|
194 | 194 | |
195 | 195 | return $postValues; |
196 | 196 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | private function setFormParameter($form) |
326 | 326 | { |
327 | 327 | if ($this->isFormSubmitted($this->request) || $this->isSubmitAllowed() === false) { |
328 | - $this->parameters[$this->formParameterName] = '<a name="' . $this->formId . '"></a>' . $this->thankYouMessage; |
|
328 | + $this->parameters[$this->formParameterName] = '<a name="'.$this->formId.'"></a>'.$this->thankYouMessage; |
|
329 | 329 | } else { |
330 | 330 | $this->parameters[$this->formParameterName] = $form; |
331 | 331 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string $imagePath |
77 | 77 | * @param bool $getExtension |
78 | 78 | * |
79 | - * @return bool|int|string |
|
79 | + * @return integer |
|
80 | 80 | */ |
81 | 81 | public function getImageMimeType($imagePath, $getExtension = false) |
82 | 82 | { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | - * @param $pathToBitmapFile |
|
152 | + * @param string $pathToBitmapFile |
|
153 | 153 | * |
154 | 154 | * @return string |
155 | 155 | */ |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | - * @param $header |
|
168 | + * @param string $header |
|
169 | 169 | * |
170 | 170 | * @return array |
171 | 171 | */ |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | * Loop through the data in the body of the bitmap |
196 | 196 | * file and calculate each individual pixel based on the |
197 | 197 | * bytes |
198 | - * @param $bodySize |
|
199 | - * @param $x |
|
198 | + * @param integer $bodySize |
|
199 | + * @param integer $x |
|
200 | 200 | * @param $width |
201 | - * @param $usePadding |
|
202 | - * @param $y |
|
201 | + * @param boolean $usePadding |
|
202 | + * @param integer $y |
|
203 | 203 | * @param $height |
204 | - * @param $body |
|
205 | - * @param $image |
|
204 | + * @param string $body |
|
205 | + * @param resource $image |
|
206 | 206 | */ |
207 | 207 | private function loopThroughBodyAndCalculatePixels($bodySize, $x, $width, $usePadding, $y, $height, $body, $image) |
208 | 208 | { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } elseif (is_string($imageContainer)) { |
36 | 36 | $this->_imageResource = imagecreatefromstring($imageContainer); |
37 | 37 | } else { |
38 | - throw new \Exception('Could not create image resource, accepted inputs are: "resource of type (gd)", path_to_image and "string". <br /><pre>' . var_export($imageContainer, true) . '</pre>'); |
|
38 | + throw new \Exception('Could not create image resource, accepted inputs are: "resource of type (gd)", path_to_image and "string". <br /><pre>'.var_export($imageContainer, true).'</pre>'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | // Cut it in parts of 2 bytes |
180 | 180 | $header_parts = str_split($header, 2); |
181 | 181 | // Get the width 4 bytes |
182 | - $width = hexdec($header_parts[19] . $header_parts[18]); |
|
182 | + $width = hexdec($header_parts[19].$header_parts[18]); |
|
183 | 183 | // Get the height 4 bytes |
184 | - $height = hexdec($header_parts[23] . $header_parts[22]); |
|
184 | + $height = hexdec($header_parts[23].$header_parts[22]); |
|
185 | 185 | // Unset the header params |
186 | 186 | unset($header_parts); |
187 | 187 | |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | } |
227 | 227 | // Calculation of the RGB-pixel (defined as BGR in image-data). Define $iPos as absolute position in the body |
228 | 228 | $iPos = $i * 2; |
229 | - $r = hexdec($body[$iPos + 4] . $body[$iPos + 5]); |
|
230 | - $g = hexdec($body[$iPos + 2] . $body[$iPos + 3]); |
|
231 | - $b = hexdec($body[$iPos] . $body[$iPos + 1]); |
|
229 | + $r = hexdec($body[$iPos + 4].$body[$iPos + 5]); |
|
230 | + $g = hexdec($body[$iPos + 2].$body[$iPos + 3]); |
|
231 | + $b = hexdec($body[$iPos].$body[$iPos + 1]); |
|
232 | 232 | // Calculate and draw the pixel |
233 | 233 | $color = imagecolorallocate($image, $r, $g, $b); |
234 | 234 | imagesetpixel($image, $x, $height - $y, $color); |
@@ -13,6 +13,10 @@ |
||
13 | 13 | { |
14 | 14 | protected $imagesDir; |
15 | 15 | |
16 | + /** |
|
17 | + * @param \CloudControl\Cms\storage\Repository $repository |
|
18 | + * @param string $imagesDir |
|
19 | + */ |
|
16 | 20 | public function __construct($repository, $imagesDir) |
17 | 21 | { |
18 | 22 | parent::__construct($repository); |
@@ -11,124 +11,124 @@ |
||
11 | 11 | |
12 | 12 | class ImagesStorage extends AbstractStorage |
13 | 13 | { |
14 | - protected $imagesDir; |
|
15 | - |
|
16 | - public function __construct($repository, $imagesDir) |
|
17 | - { |
|
18 | - parent::__construct($repository); |
|
19 | - $this->imagesDir = $imagesDir; |
|
20 | - } |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * @var ImageSetStorage |
|
25 | - */ |
|
26 | - protected $imageSet; |
|
27 | - |
|
28 | - /** |
|
29 | - * Get all images |
|
30 | - * |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function getImages() |
|
34 | - { |
|
35 | - return $this->repository->images; |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @param $postValues |
|
40 | - * |
|
41 | - * @throws \Exception |
|
42 | - */ |
|
43 | - public function addImage($postValues) |
|
44 | - { |
|
45 | - $destinationPath = $this->getDestinationPath(); |
|
46 | - |
|
47 | - $filename = $this->validateFilename($postValues['name'], $destinationPath); |
|
48 | - $destination = $destinationPath . DIRECTORY_SEPARATOR . $filename; |
|
49 | - |
|
50 | - if ($postValues['error'] != '0') { |
|
51 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
52 | - } |
|
53 | - |
|
54 | - if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
|
55 | - $imageResizer = new ImageResizer($this->getImageSet()->getImageSet()); |
|
56 | - $fileNames = $imageResizer->applyImageSetToImage($destination); |
|
57 | - $fileNames['original'] = $filename; |
|
58 | - $imageObject = ImageFactory::createImageFromPostValues($postValues, $filename, $fileNames); |
|
59 | - |
|
60 | - $images = $this->repository->images; |
|
61 | - $images[] = $imageObject; |
|
62 | - $this->repository->images = $images; |
|
63 | - |
|
64 | - $this->save(); |
|
65 | - } else { |
|
66 | - throw new \Exception('Error moving uploaded file'); |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Delete image by name |
|
72 | - * @param $filename |
|
73 | - */ |
|
74 | - public function deleteImageByName($filename) |
|
75 | - { |
|
76 | - $destinationPath = $this->getDestinationPath(); |
|
77 | - |
|
78 | - $images = $this->getImages(); |
|
79 | - |
|
80 | - foreach ($images as $key => $image) { |
|
81 | - if ($image->file == $filename) { |
|
82 | - foreach ($image->set as $imageSetFilename) { |
|
83 | - $destination = $destinationPath . '/' . $imageSetFilename; |
|
84 | - if (file_exists($destination)) { |
|
85 | - unlink($destination); |
|
86 | - } else { |
|
87 | - dump($destination); |
|
88 | - } |
|
89 | - } |
|
90 | - unset($images[$key]); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - $this->repository->images = $images; |
|
95 | - $this->save(); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param $filename |
|
100 | - * |
|
101 | - * @return null |
|
102 | - */ |
|
103 | - public function getImageByName($filename) |
|
104 | - { |
|
105 | - $images = $this->getImages(); |
|
106 | - foreach ($images as $image) { |
|
107 | - if ($image->file == $filename) { |
|
108 | - return $image; |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - return null; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @return \CloudControl\Cms\storage\storage\ImageSetStorage |
|
117 | - */ |
|
118 | - private function getImageSet() |
|
119 | - { |
|
120 | - if (!$this->imageSet instanceof ImageSetStorage) { |
|
121 | - $this->imageSet = new ImageSetStorage($this->repository); |
|
122 | - } |
|
123 | - return $this->imageSet; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @return bool|string |
|
128 | - */ |
|
129 | - private function getDestinationPath() |
|
130 | - { |
|
131 | - $destinationPath = realpath($this->imagesDir . DIRECTORY_SEPARATOR); |
|
132 | - return $destinationPath; |
|
133 | - } |
|
14 | + protected $imagesDir; |
|
15 | + |
|
16 | + public function __construct($repository, $imagesDir) |
|
17 | + { |
|
18 | + parent::__construct($repository); |
|
19 | + $this->imagesDir = $imagesDir; |
|
20 | + } |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * @var ImageSetStorage |
|
25 | + */ |
|
26 | + protected $imageSet; |
|
27 | + |
|
28 | + /** |
|
29 | + * Get all images |
|
30 | + * |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function getImages() |
|
34 | + { |
|
35 | + return $this->repository->images; |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @param $postValues |
|
40 | + * |
|
41 | + * @throws \Exception |
|
42 | + */ |
|
43 | + public function addImage($postValues) |
|
44 | + { |
|
45 | + $destinationPath = $this->getDestinationPath(); |
|
46 | + |
|
47 | + $filename = $this->validateFilename($postValues['name'], $destinationPath); |
|
48 | + $destination = $destinationPath . DIRECTORY_SEPARATOR . $filename; |
|
49 | + |
|
50 | + if ($postValues['error'] != '0') { |
|
51 | + throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
52 | + } |
|
53 | + |
|
54 | + if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
|
55 | + $imageResizer = new ImageResizer($this->getImageSet()->getImageSet()); |
|
56 | + $fileNames = $imageResizer->applyImageSetToImage($destination); |
|
57 | + $fileNames['original'] = $filename; |
|
58 | + $imageObject = ImageFactory::createImageFromPostValues($postValues, $filename, $fileNames); |
|
59 | + |
|
60 | + $images = $this->repository->images; |
|
61 | + $images[] = $imageObject; |
|
62 | + $this->repository->images = $images; |
|
63 | + |
|
64 | + $this->save(); |
|
65 | + } else { |
|
66 | + throw new \Exception('Error moving uploaded file'); |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Delete image by name |
|
72 | + * @param $filename |
|
73 | + */ |
|
74 | + public function deleteImageByName($filename) |
|
75 | + { |
|
76 | + $destinationPath = $this->getDestinationPath(); |
|
77 | + |
|
78 | + $images = $this->getImages(); |
|
79 | + |
|
80 | + foreach ($images as $key => $image) { |
|
81 | + if ($image->file == $filename) { |
|
82 | + foreach ($image->set as $imageSetFilename) { |
|
83 | + $destination = $destinationPath . '/' . $imageSetFilename; |
|
84 | + if (file_exists($destination)) { |
|
85 | + unlink($destination); |
|
86 | + } else { |
|
87 | + dump($destination); |
|
88 | + } |
|
89 | + } |
|
90 | + unset($images[$key]); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + $this->repository->images = $images; |
|
95 | + $this->save(); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @param $filename |
|
100 | + * |
|
101 | + * @return null |
|
102 | + */ |
|
103 | + public function getImageByName($filename) |
|
104 | + { |
|
105 | + $images = $this->getImages(); |
|
106 | + foreach ($images as $image) { |
|
107 | + if ($image->file == $filename) { |
|
108 | + return $image; |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + return null; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @return \CloudControl\Cms\storage\storage\ImageSetStorage |
|
117 | + */ |
|
118 | + private function getImageSet() |
|
119 | + { |
|
120 | + if (!$this->imageSet instanceof ImageSetStorage) { |
|
121 | + $this->imageSet = new ImageSetStorage($this->repository); |
|
122 | + } |
|
123 | + return $this->imageSet; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @return bool|string |
|
128 | + */ |
|
129 | + private function getDestinationPath() |
|
130 | + { |
|
131 | + $destinationPath = realpath($this->imagesDir . DIRECTORY_SEPARATOR); |
|
132 | + return $destinationPath; |
|
133 | + } |
|
134 | 134 | } |
135 | 135 | \ No newline at end of file |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $destinationPath = $this->getDestinationPath(); |
46 | 46 | |
47 | 47 | $filename = $this->validateFilename($postValues['name'], $destinationPath); |
48 | - $destination = $destinationPath . DIRECTORY_SEPARATOR . $filename; |
|
48 | + $destination = $destinationPath.DIRECTORY_SEPARATOR.$filename; |
|
49 | 49 | |
50 | 50 | if ($postValues['error'] != '0') { |
51 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
51 | + throw new \Exception('Error uploading file. Error code: '.$postValues['error']); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | foreach ($images as $key => $image) { |
81 | 81 | if ($image->file == $filename) { |
82 | 82 | foreach ($image->set as $imageSetFilename) { |
83 | - $destination = $destinationPath . '/' . $imageSetFilename; |
|
83 | + $destination = $destinationPath.'/'.$imageSetFilename; |
|
84 | 84 | if (file_exists($destination)) { |
85 | 85 | unlink($destination); |
86 | 86 | } else { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | private function getDestinationPath() |
130 | 130 | { |
131 | - $destinationPath = realpath($this->imagesDir . DIRECTORY_SEPARATOR); |
|
131 | + $destinationPath = realpath($this->imagesDir.DIRECTORY_SEPARATOR); |
|
132 | 132 | return $destinationPath; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | \ No newline at end of file |
@@ -25,5 +25,5 @@ |
||
25 | 25 | \CloudControl\Cms\CloudControl::run(); |
26 | 26 | |
27 | 27 | if (php_sapi_name() != "cli") { |
28 | - ob_end_flush(); |
|
28 | + ob_end_flush(); |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -12,10 +12,10 @@ |
||
12 | 12 | namespace CloudControl\Cms\images\methods |
13 | 13 | { |
14 | 14 | |
15 | - use CloudControl\Cms\images\Image; |
|
16 | - use CloudControl\Cms\images\IMethod; |
|
15 | + use CloudControl\Cms\images\Image; |
|
16 | + use CloudControl\Cms\images\IMethod; |
|
17 | 17 | |
18 | - class Watermark extends IMethod |
|
18 | + class Watermark extends IMethod |
|
19 | 19 | { |
20 | 20 | protected $_x = 0; |
21 | 21 | protected $_y = 0; |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function calculateX($imageResource) |
65 | 65 | { |
66 | - if (intval($this->_x) === $this->_x) return $this->_x; |
|
66 | + if (intval($this->_x) === $this->_x) { |
|
67 | + return $this->_x; |
|
68 | + } |
|
67 | 69 | |
68 | 70 | $x = strtolower($this->_x); |
69 | 71 | |
@@ -88,7 +90,9 @@ discard block |
||
88 | 90 | */ |
89 | 91 | public function calculateY($imageResource) |
90 | 92 | { |
91 | - if (intval($this->_y) === $this->_y) return $this->_y; |
|
93 | + if (intval($this->_y) === $this->_y) { |
|
94 | + return $this->_y; |
|
95 | + } |
|
92 | 96 | |
93 | 97 | $y = strtolower($this->_y); |
94 | 98 | |
@@ -125,7 +129,9 @@ discard block |
||
125 | 129 | */ |
126 | 130 | public function GetWatermark() |
127 | 131 | { |
128 | - if ($this->_watermark == null) throw new \Exception('A watermark is not set. Please supply a \CloudControl\Cms\image\Image using $this->SetWatermark'); |
|
132 | + if ($this->_watermark == null) { |
|
133 | + throw new \Exception('A watermark is not set. Please supply a \CloudControl\Cms\image\Image using $this->SetWatermark'); |
|
134 | + } |
|
129 | 135 | return $this->_watermark; |
130 | 136 | } |
131 | 137 |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | namespace CloudControl\Cms\images\methods |
12 | 12 | { |
13 | 13 | |
14 | - use CloudControl\Cms\images\IMethod; |
|
14 | + use CloudControl\Cms\images\IMethod; |
|
15 | 15 | |
16 | - class Crop extends IMethod |
|
16 | + class Crop extends IMethod |
|
17 | 17 | { |
18 | 18 | protected $_width; |
19 | 19 | protected $_height; |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | |
117 | 117 | // Preserve transparency |
118 | 118 | imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127)); |
119 | - imagealphablending($new, false); |
|
120 | - imagesavealpha($new, true); |
|
119 | + imagealphablending($new, false); |
|
120 | + imagesavealpha($new, true); |
|
121 | 121 | |
122 | 122 | imagecopyresampled($new, $imageResource, $this->_destX, $this->_destY, $this->_x, $this->_y, $this->_destWidth, $this->_destHeight, $this->_destWidth, $this->_destHeight); |
123 | 123 |
@@ -11,9 +11,9 @@ |
||
11 | 11 | namespace CloudControl\Cms\images\methods |
12 | 12 | { |
13 | 13 | |
14 | - use CloudControl\Cms\images\IMethod; |
|
14 | + use CloudControl\Cms\images\IMethod; |
|
15 | 15 | |
16 | - class Resize extends IMethod |
|
16 | + class Resize extends IMethod |
|
17 | 17 | { |
18 | 18 | protected $_width; |
19 | 19 | protected $_height; |
@@ -63,7 +63,7 @@ |
||
63 | 63 | |
64 | 64 | // Define the ratio and adjust the width and height |
65 | 65 | if ($this->_preserveAspectRatio) { |
66 | - $ratio = min($this->_width/$originalWidth, $this->_height/$originalHeight); |
|
66 | + $ratio = min($this->_width / $originalWidth, $this->_height / $originalHeight); |
|
67 | 67 | $this->_width = $originalWidth * $ratio; |
68 | 68 | $this->_height = $originalHeight * $ratio; |
69 | 69 | } |
@@ -62,8 +62,8 @@ |
||
62 | 62 | |
63 | 63 | // Preserve transparency |
64 | 64 | imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127)); |
65 | - imagealphablending($new, false); |
|
66 | - imagesavealpha($new, true); |
|
65 | + imagealphablending($new, false); |
|
66 | + imagesavealpha($new, true); |
|
67 | 67 | |
68 | 68 | imagecopyresampled($new, $imageResource, $this->_destX, $this->_destY, $this->_x, $this->_y, $this->_destWidth, $this->_destHeight, $originalWidth, $originalHeight); |
69 | 69 |
@@ -40,7 +40,9 @@ |
||
40 | 40 | |
41 | 41 | // Define which ratio will be used, depending on which is the biggest side |
42 | 42 | $ratio = $wRatio < $hRatio ? $wRatio : $hRatio; |
43 | - if ($ratio < 1) $ratio = 1; |
|
43 | + if ($ratio < 1) { |
|
44 | + $ratio = 1; |
|
45 | + } |
|
44 | 46 | |
45 | 47 | // Calculate the destination width, height, x and y |
46 | 48 | $this->_destWidth = $originalWidth / $ratio; |