@@ -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 |