resolves #6: finished implementing the bulk update functionality for photos in the album view

This commit is contained in:
Andy Heathershaw 2016-10-03 17:00:37 +01:00
parent fe0b4c2108
commit 45277efbb8
4 changed files with 44 additions and 9 deletions

View File

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

View File

@ -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')
]);
}

View File

@ -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)));
}

View File

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