@@ -74,7 +74,7 @@ |
||
| 74 | 74 | * @see http://www.php.net/manual/en/function.image-type-to-mime-type.php |
| 75 | 75 | * @param string $imagePath |
| 76 | 76 | * @param bool $getExtension |
| 77 | - * @return bool|int|string |
|
| 77 | + * @return integer |
|
| 78 | 78 | */ |
| 79 | 79 | public function GetImageMimeType($imagePath, $getExtension = false) |
| 80 | 80 | { |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @param resource $imageResource |
| 19 | 19 | * @return resource |
| 20 | - */ |
|
| 20 | + */ |
|
| 21 | 21 | public function Execute($imageResource) |
| 22 | 22 | { |
| 23 | 23 | // Define the origial width and height |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | return $returnFileNames; |
| 49 | 49 | } else { |
| 50 | - throw new \Exception('Image doesnt exist: ' . $imagePath); |
|
| 50 | + throw new \Exception('Image doesnt exist: '.$imagePath); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | * @return string |
| 59 | 59 | * @throws \Exception |
| 60 | 60 | */ |
| 61 | - public function resize($imagePath='', $width='',$height='') |
|
| 61 | + public function resize($imagePath = '', $width = '', $height = '') |
|
| 62 | 62 | { |
| 63 | - $modifier = '-r' . $width . 'x' . $height; |
|
| 63 | + $modifier = '-r'.$width.'x'.$height; |
|
| 64 | 64 | $destination = $this->modifyName($imagePath, $modifier); |
| 65 | 65 | if (file_exists($imagePath)) { |
| 66 | 66 | $image = new Image(); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $resizedImage->SaveImage($destination, $resizedImage->GetImageMimeType($imagePath), 80); |
| 75 | 75 | return basename($destination); |
| 76 | 76 | } else { |
| 77 | - throw new \Exception('Image doesnt exist: ' . $imagePath); |
|
| 77 | + throw new \Exception('Image doesnt exist: '.$imagePath); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | * @return string |
| 86 | 86 | * @throws \Exception |
| 87 | 87 | */ |
| 88 | - public function smartcrop($imagePath='', $width='',$height='') |
|
| 88 | + public function smartcrop($imagePath = '', $width = '', $height = '') |
|
| 89 | 89 | { |
| 90 | - $modifier = '-s' . $width . 'x' . $height; |
|
| 90 | + $modifier = '-s'.$width.'x'.$height; |
|
| 91 | 91 | $destination = $this->modifyName($imagePath, $modifier); |
| 92 | 92 | if (file_exists($imagePath)) { |
| 93 | 93 | $image = new Image(); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $resizedImage->SaveImage($destination, $resizedImage->GetImageMimeType($imagePath), 80); |
| 102 | 102 | return basename($destination); |
| 103 | 103 | } else { |
| 104 | - throw new \Exception('Image doesnt exist: ' . $imagePath); |
|
| 104 | + throw new \Exception('Image doesnt exist: '.$imagePath); |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * @return string |
| 113 | 113 | * @throws \Exception |
| 114 | 114 | */ |
| 115 | - public function boxcrop($imagePath='', $width='',$height='') |
|
| 115 | + public function boxcrop($imagePath = '', $width = '', $height = '') |
|
| 116 | 116 | { |
| 117 | - $modifier = '-b' . $width . 'x' . $height; |
|
| 117 | + $modifier = '-b'.$width.'x'.$height; |
|
| 118 | 118 | $destination = $this->modifyName($imagePath, $modifier); |
| 119 | 119 | if (file_exists($imagePath)) { |
| 120 | 120 | $image = new Image(); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $resizedImage->SaveImage($destination, $resizedImage->GetImageMimeType($imagePath), 80); |
| 129 | 129 | return basename($destination); |
| 130 | 130 | } else { |
| 131 | - throw new \Exception('Image doesnt exist: ' . $imagePath); |
|
| 131 | + throw new \Exception('Image doesnt exist: '.$imagePath); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return string |
| 140 | 140 | */ |
| 141 | - private function modifyName($imagePath, $modifier='') |
|
| 141 | + private function modifyName($imagePath, $modifier = '') |
|
| 142 | 142 | { |
| 143 | 143 | $filename = basename($imagePath); |
| 144 | 144 | $path = dirname($imagePath); |
@@ -148,25 +148,25 @@ discard block |
||
| 148 | 148 | array_pop($fileParts); |
| 149 | 149 | $fileNameWithoutExtension = implode('-', $fileParts); |
| 150 | 150 | $fileNameWithoutExtension = slugify($fileNameWithoutExtension); |
| 151 | - $filename = $fileNameWithoutExtension . $modifier . '.' . $extension; |
|
| 151 | + $filename = $fileNameWithoutExtension.$modifier.'.'.$extension; |
|
| 152 | 152 | } else { |
| 153 | 153 | $filename = slugify($filename); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if (file_exists($path . '/' . $filename)) { |
|
| 156 | + if (file_exists($path.'/'.$filename)) { |
|
| 157 | 157 | $fileParts = explode('.', $filename); |
| 158 | 158 | if (count($fileParts) > 1) { |
| 159 | 159 | $extension = end($fileParts); |
| 160 | 160 | array_pop($fileParts); |
| 161 | 161 | $fileNameWithoutExtension = implode('-', $fileParts); |
| 162 | 162 | $fileNameWithoutExtension .= '-copy'; |
| 163 | - $filename = $fileNameWithoutExtension . '.' . $extension; |
|
| 163 | + $filename = $fileNameWithoutExtension.'.'.$extension; |
|
| 164 | 164 | } else { |
| 165 | 165 | $filename .= '-copy'; |
| 166 | 166 | } |
| 167 | - return $this->modifyName($path . '/' . $filename); |
|
| 167 | + return $this->modifyName($path.'/'.$filename); |
|
| 168 | 168 | } |
| 169 | - return $path . '/' . $filename; |
|
| 169 | + return $path.'/'.$filename; |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | private function config() |
| 35 | 35 | { |
| 36 | - $storagePath = __DIR__ . $this->storagePath; |
|
| 36 | + $storagePath = __DIR__.$this->storagePath; |
|
| 37 | 37 | if (realpath($storagePath) !== false) { |
| 38 | 38 | $jsonString = file_get_contents($storagePath); |
| 39 | 39 | $this->repository = json_decode($jsonString); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function getDocumentBySlug($slug) |
| 191 | 191 | { |
| 192 | - $documentContainer = $this->getDocumentContainerByPath('/' . $slug); |
|
| 192 | + $documentContainer = $this->getDocumentContainerByPath('/'.$slug); |
|
| 193 | 193 | $indices = $documentContainer['indices']; |
| 194 | 194 | |
| 195 | 195 | $folder = $this->repository->documents; |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | // Check for duplicates |
| 227 | 227 | foreach ($this->repository->documents as $index => $document) { |
| 228 | 228 | if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') { |
| 229 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
| 229 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | $this->repository->documents[end($indices)] = $documentFolderObject; |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | // Check for duplicates |
| 235 | 235 | foreach ($previousFolder->content as $index => $document) { |
| 236 | 236 | if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') { |
| 237 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
| 237 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | - $previousFolder->content[end($indices)] = $documentFolderObject ; |
|
| 240 | + $previousFolder->content[end($indices)] = $documentFolderObject; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | $this->save(); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | foreach ($this->repository->documents as $document) { |
| 252 | 252 | if ($document->slug == $documentFolderObject->slug && $document->type == 'document') { |
| 253 | 253 | // TODO make it so it doesnt throw an exception, but instead shows a warning |
| 254 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
| 254 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | $this->repository->documents[] = $documentFolderObject; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | foreach ($containerFolder->content as $document) { |
| 274 | 274 | if ($document->slug == $documentFolderObject->slug && $document->type == 'document') { |
| 275 | 275 | // TODO make it so it doesnt throw an exception, but instead shows a warning |
| 276 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
| 276 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | foreach ($this->repository->documents as $document) { |
| 357 | 357 | if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') { |
| 358 | 358 | // TODO make it so it doesnt throw an exception, but instead shows a warning |
| 359 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
| 359 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | $this->repository->documents[] = $documentFolderObject; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | foreach ($containerFolder->content as $document) { |
| 378 | 378 | if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') { |
| 379 | 379 | // TODO make it so it doesnt throw an exception, but instead shows a warning |
| 380 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
| 380 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | $folder->content[] = $documentFolderObject; |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | public function getDocumentFolderBySlug($slug) |
| 431 | 431 | { |
| 432 | - $documentContainer = $this->getDocumentContainerByPath('/' . $slug); |
|
| 432 | + $documentContainer = $this->getDocumentContainerByPath('/'.$slug); |
|
| 433 | 433 | $indices = $documentContainer['indices']; |
| 434 | 434 | |
| 435 | 435 | $folder = $this->repository->documents; |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | // Check for duplicates |
| 474 | 474 | foreach ($this->repository->documents as $index => $document) { |
| 475 | 475 | if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') { |
| 476 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
| 476 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | $this->repository->documents[end($indices)] = $documentFolderObject; |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | // Check for duplicates |
| 482 | 482 | foreach ($previousFolder->content as $index => $document) { |
| 483 | 483 | if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') { |
| 484 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
| 484 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | - $previousFolder->content[end($indices)] = $documentFolderObject ; |
|
| 487 | + $previousFolder->content[end($indices)] = $documentFolderObject; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | $this->save(); |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | if ($matched === true) { |
| 537 | 537 | $noMatches += 1; |
| 538 | 538 | } else { |
| 539 | - throw new \Exception('Unknown folder "' . $slug . '" in path: ' . $path); |
|
| 539 | + throw new \Exception('Unknown folder "'.$slug.'" in path: '.$path); |
|
| 540 | 540 | } |
| 541 | 541 | $i += 1; |
| 542 | 542 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | 'previousDocument' => $previousDocument |
| 549 | 549 | ); |
| 550 | 550 | } else { |
| 551 | - throw new \Exception('Invalid path: ' . $path); |
|
| 551 | + throw new \Exception('Invalid path: '.$path); |
|
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | |
@@ -732,13 +732,13 @@ discard block |
||
| 732 | 732 | |
| 733 | 733 | public function addImage($postValues) |
| 734 | 734 | { |
| 735 | - $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
| 735 | + $destinationPath = realpath(__DIR__.'/../../www/images/'); |
|
| 736 | 736 | |
| 737 | 737 | $filename = $this->validateFilename($postValues['name'], $destinationPath); |
| 738 | - $destination = $destinationPath . '/' . $filename; |
|
| 738 | + $destination = $destinationPath.'/'.$filename; |
|
| 739 | 739 | |
| 740 | 740 | if ($postValues['error'] != '0') { |
| 741 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
| 741 | + throw new \Exception('Error uploading file. Error code: '.$postValues['error']); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
@@ -760,14 +760,14 @@ discard block |
||
| 760 | 760 | |
| 761 | 761 | public function deleteImageByName($filename) |
| 762 | 762 | { |
| 763 | - $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
| 763 | + $destinationPath = realpath(__DIR__.'/../../www/images/'); |
|
| 764 | 764 | |
| 765 | 765 | $images = $this->getImages(); |
| 766 | 766 | |
| 767 | 767 | foreach ($images as $key => $image) { |
| 768 | 768 | if ($image->file == $filename) { |
| 769 | 769 | foreach ($image->set as $imageSetFilename) { |
| 770 | - $destination = $destinationPath . '/' . $imageSetFilename; |
|
| 770 | + $destination = $destinationPath.'/'.$imageSetFilename; |
|
| 771 | 771 | if (file_exists($destination)) { |
| 772 | 772 | unlink($destination); |
| 773 | 773 | } else { |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | */ |
| 805 | 805 | public function getFiles() |
| 806 | 806 | { |
| 807 | - $files = $this->repository->files; |
|
| 807 | + $files = $this->repository->files; |
|
| 808 | 808 | usort($files, array($this, 'compareFiles')); |
| 809 | 809 | return $files; |
| 810 | 810 | } |
@@ -816,13 +816,13 @@ discard block |
||
| 816 | 816 | |
| 817 | 817 | public function addFile($postValues) |
| 818 | 818 | { |
| 819 | - $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
|
| 819 | + $destinationPath = realpath(__DIR__.'/../../www/files/'); |
|
| 820 | 820 | |
| 821 | 821 | $filename = $this->validateFilename($postValues['name'], $destinationPath); |
| 822 | - $destination = $destinationPath . '/' . $filename; |
|
| 822 | + $destination = $destinationPath.'/'.$filename; |
|
| 823 | 823 | |
| 824 | 824 | if ($postValues['error'] != '0') { |
| 825 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
| 825 | + throw new \Exception('Error uploading file. Error code: '.$postValues['error']); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
@@ -846,23 +846,23 @@ discard block |
||
| 846 | 846 | array_pop($fileParts); |
| 847 | 847 | $fileNameWithoutExtension = implode('-', $fileParts); |
| 848 | 848 | $fileNameWithoutExtension = slugify($fileNameWithoutExtension); |
| 849 | - $filename = $fileNameWithoutExtension . '.' . $extension; |
|
| 849 | + $filename = $fileNameWithoutExtension.'.'.$extension; |
|
| 850 | 850 | } else { |
| 851 | 851 | $filename = slugify($filename); |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - if (file_exists($path . '/' . $filename)) { |
|
| 854 | + if (file_exists($path.'/'.$filename)) { |
|
| 855 | 855 | $fileParts = explode('.', $filename); |
| 856 | 856 | if (count($fileParts) > 1) { |
| 857 | 857 | $extension = end($fileParts); |
| 858 | 858 | array_pop($fileParts); |
| 859 | 859 | $fileNameWithoutExtension = implode('-', $fileParts); |
| 860 | 860 | $fileNameWithoutExtension .= '-copy'; |
| 861 | - $filename = $fileNameWithoutExtension . '.' . $extension; |
|
| 861 | + $filename = $fileNameWithoutExtension.'.'.$extension; |
|
| 862 | 862 | } else { |
| 863 | 863 | $filename .= '-copy'; |
| 864 | 864 | } |
| 865 | - return $this->validateFilename($filename,$path); |
|
| 865 | + return $this->validateFilename($filename, $path); |
|
| 866 | 866 | } |
| 867 | 867 | return $filename; |
| 868 | 868 | } |
@@ -879,8 +879,8 @@ discard block |
||
| 879 | 879 | |
| 880 | 880 | public function deleteFileByName($filename) |
| 881 | 881 | { |
| 882 | - $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
|
| 883 | - $destination = $destinationPath . '/' . $filename; |
|
| 882 | + $destinationPath = realpath(__DIR__.'/../../www/files/'); |
|
| 883 | + $destination = $destinationPath.'/'.$filename; |
|
| 884 | 884 | |
| 885 | 885 | if (file_exists($destination)) { |
| 886 | 886 | $files = $this->getFiles(); |
@@ -1173,11 +1173,11 @@ discard block |
||
| 1173 | 1173 | * @throws \Exception |
| 1174 | 1174 | */ |
| 1175 | 1175 | private function save() { |
| 1176 | - $storagePath = __DIR__ . $this->storagePath; |
|
| 1176 | + $storagePath = __DIR__.$this->storagePath; |
|
| 1177 | 1177 | if (realpath($storagePath) !== false) { |
| 1178 | 1178 | file_put_contents($storagePath, json_encode($this->repository)); |
| 1179 | 1179 | } else { |
| 1180 | - throw new \Exception('Couldnt find storagePath ' . $storagePath); |
|
| 1180 | + throw new \Exception('Couldnt find storagePath '.$storagePath); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | } |
| 1183 | 1183 | |