@@ -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); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | public function getDocumentBySlug($slug) |
186 | 186 | { |
187 | - $documentContainer = $this->getDocumentContainerByPath('/' . $slug); |
|
187 | + $documentContainer = $this->getDocumentContainerByPath('/'.$slug); |
|
188 | 188 | $indices = $documentContainer['indices']; |
189 | 189 | |
190 | 190 | $folder = $this->repository->documents; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | // Check for duplicates |
224 | 224 | foreach ($this->repository->documents as $index => $document) { |
225 | 225 | if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') { |
226 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
226 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | $this->repository->documents[end($indices)] = $documentFolderObject; |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | // Check for duplicates |
232 | 232 | foreach ($previousFolder->content as $index => $document) { |
233 | 233 | if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') { |
234 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
234 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
235 | 235 | } |
236 | 236 | } |
237 | - $previousFolder->content[end($indices)] = $documentFolderObject ; |
|
237 | + $previousFolder->content[end($indices)] = $documentFolderObject; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $this->save(); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | foreach ($this->repository->documents as $document) { |
249 | 249 | if ($document->slug == $documentFolderObject->slug && $document->type == 'document') { |
250 | 250 | // TODO make it so it doesnt throw an exception, but instead shows a warning |
251 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
251 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | $this->repository->documents[] = $documentFolderObject; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | foreach ($containerFolder->content as $document) { |
271 | 271 | if ($document->slug == $documentFolderObject->slug && $document->type == 'document') { |
272 | 272 | // TODO make it so it doesnt throw an exception, but instead shows a warning |
273 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
273 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | foreach ($this->repository->documents as $document) { |
354 | 354 | if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') { |
355 | 355 | // TODO make it so it doesnt throw an exception, but instead shows a warning |
356 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
356 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | $this->repository->documents[] = $documentFolderObject; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | foreach ($containerFolder->content as $document) { |
375 | 375 | if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') { |
376 | 376 | // TODO make it so it doesnt throw an exception, but instead shows a warning |
377 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
377 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | $folder->content[] = $documentFolderObject; |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | */ |
427 | 427 | public function getDocumentFolderBySlug($slug) |
428 | 428 | { |
429 | - $documentContainer = $this->getDocumentContainerByPath('/' . $slug); |
|
429 | + $documentContainer = $this->getDocumentContainerByPath('/'.$slug); |
|
430 | 430 | $indices = $documentContainer['indices']; |
431 | 431 | |
432 | 432 | $folder = $this->repository->documents; |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | // Check for duplicates |
473 | 473 | foreach ($this->repository->documents as $index => $document) { |
474 | 474 | if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') { |
475 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
475 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | $this->repository->documents[end($indices)] = $documentFolderObject; |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | // Check for duplicates |
481 | 481 | foreach ($previousFolder->content as $index => $document) { |
482 | 482 | if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') { |
483 | - throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']); |
|
483 | + throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']); |
|
484 | 484 | } |
485 | 485 | } |
486 | - $previousFolder->content[end($indices)] = $documentFolderObject ; |
|
486 | + $previousFolder->content[end($indices)] = $documentFolderObject; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | $this->save(); |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | if ($matched === true) { |
536 | 536 | $noMatches += 1; |
537 | 537 | } else { |
538 | - throw new \Exception('Unknown folder "' . $slug . '" in path: ' . $path); |
|
538 | + throw new \Exception('Unknown folder "'.$slug.'" in path: '.$path); |
|
539 | 539 | } |
540 | 540 | $i += 1; |
541 | 541 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | 'previousDocument' => $previousDocument |
548 | 548 | ); |
549 | 549 | } else { |
550 | - throw new \Exception('Invalid path: ' . $path); |
|
550 | + throw new \Exception('Invalid path: '.$path); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | |
@@ -731,13 +731,13 @@ discard block |
||
731 | 731 | |
732 | 732 | public function addImage($postValues) |
733 | 733 | { |
734 | - $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
734 | + $destinationPath = realpath(__DIR__.'/../../www/images/'); |
|
735 | 735 | |
736 | 736 | $filename = $this->validateFilename($postValues['name'], $destinationPath); |
737 | - $destination = $destinationPath . '/' . $filename; |
|
737 | + $destination = $destinationPath.'/'.$filename; |
|
738 | 738 | |
739 | 739 | if ($postValues['error'] != '0') { |
740 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
740 | + throw new \Exception('Error uploading file. Error code: '.$postValues['error']); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
@@ -759,15 +759,15 @@ discard block |
||
759 | 759 | |
760 | 760 | public function deleteImageByName($filename) |
761 | 761 | { |
762 | - $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
763 | - $destination = $destinationPath . '/' . $filename; |
|
762 | + $destinationPath = realpath(__DIR__.'/../../www/images/'); |
|
763 | + $destination = $destinationPath.'/'.$filename; |
|
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 |