diff --git a/app/Helpers/ImageHelper.php b/app/Helpers/ImageHelper.php index c3f8207..9c72589 100644 --- a/app/Helpers/ImageHelper.php +++ b/app/Helpers/ImageHelper.php @@ -78,7 +78,7 @@ class ImageHelper public function openImage($imagePath, &$imageInfo) { - $imageInfo = getimagesize($imagePath); + $imageInfo = @getimagesize($imagePath); if ($imageInfo === false) { throw new \Exception(sprintf('The image "%s" does not appear to be a valid image, or cannot be read', pathinfo($imagePath, PATHINFO_FILENAME))); diff --git a/app/Http/Controllers/Admin/AlbumController.php b/app/Http/Controllers/Admin/AlbumController.php index d9faff0..2f86258 100644 --- a/app/Http/Controllers/Admin/AlbumController.php +++ b/app/Http/Controllers/Admin/AlbumController.php @@ -173,7 +173,8 @@ class AlbumController extends Controller 'is_upload_enabled' => $isUploadEnabled, 'max_post_limit' => $postLimit, 'max_post_limit_bulk' => $fileUploadOrPostLowerLimit, - 'photos' => $photos + 'photos' => $photos, + 'success' => $request->session()->get('success') ]); } diff --git a/app/Http/Controllers/Admin/PhotoController.php b/app/Http/Controllers/Admin/PhotoController.php index 2ca2779..8bb40d5 100644 --- a/app/Http/Controllers/Admin/PhotoController.php +++ b/app/Http/Controllers/Admin/PhotoController.php @@ -346,10 +346,7 @@ class PhotoController extends Controller public function updateBulk(Request $request, $albumId) { - $photos = $request->get('photo'); - - dump($request->all()); - exit(); + $photoIds = $request->get('select-photo'); /** @var Album $album */ $album = Album::where('id', intval($albumId))->first(); @@ -360,7 +357,10 @@ class PhotoController extends Controller return null; } - foreach ($photos as $photoId => $value) + $action = $request->get('bulk-action'); + $numberChanged = 0; + + foreach ($photoIds as $photoId) { /** @var Photo $photo */ $photo = $album->photos()->where('id', intval($photoId))->first(); @@ -369,10 +369,43 @@ class PhotoController extends Controller continue; } - $photo->fill($value); - $photo->save(); + $photoService = new PhotoService($photo); + switch (strtolower($action)) + { + case 'delete': + $photoService->delete(); + break; + + case 'flip_both': + $photoService->flip(true, true); + break; + + case 'flip_horizontal': + $photoService->flip(true, false); + break; + + case 'flip_vertical': + $photoService->flip(false, true); + break; + + case 'refresh_thumbnails': + $photoService->regenerateThumbnails(); + break; + + case 'rotate_left': + $photoService->rotate(90); + break; + + case 'rotate_right': + $photoService->rotate(270); + break; + } + + $numberChanged++; } + $request->session()->flash('success', trans_choice('admin.bulk_photos_changed', $numberChanged, ['number' => $numberChanged])); + return redirect(route('albums.show', array('id' => $albumId))); } diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 991a193..5fab549 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -11,6 +11,7 @@ return [ 'album_settings_tab' => 'Settings', 'album_upload_tab' => 'Upload', 'analyse_photos_failed' => 'The following items could not be analysed and were removed:', + 'bulk_photos_changed' => ':number photo was updated successfully.|:number photos were updated successfully.', 'cannot_delete_own_user_account' => 'It is not possible to delete your own user account. Please ask another administrator to delete it for you.', 'cannot_remove_own_admin' => 'You cannot remove your own administrator permissions. Please ask another administrator to remove the administrator permissions for you.', 'create_album' => 'Create a photo album',