resolves #6: finished implementing the bulk update functionality for photos in the album view
This commit is contained in:
parent
fe0b4c2108
commit
45277efbb8
@ -78,7 +78,7 @@ class ImageHelper
|
|||||||
|
|
||||||
public function openImage($imagePath, &$imageInfo)
|
public function openImage($imagePath, &$imageInfo)
|
||||||
{
|
{
|
||||||
$imageInfo = getimagesize($imagePath);
|
$imageInfo = @getimagesize($imagePath);
|
||||||
if ($imageInfo === false)
|
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)));
|
throw new \Exception(sprintf('The image "%s" does not appear to be a valid image, or cannot be read', pathinfo($imagePath, PATHINFO_FILENAME)));
|
||||||
|
@ -173,7 +173,8 @@ class AlbumController extends Controller
|
|||||||
'is_upload_enabled' => $isUploadEnabled,
|
'is_upload_enabled' => $isUploadEnabled,
|
||||||
'max_post_limit' => $postLimit,
|
'max_post_limit' => $postLimit,
|
||||||
'max_post_limit_bulk' => $fileUploadOrPostLowerLimit,
|
'max_post_limit_bulk' => $fileUploadOrPostLowerLimit,
|
||||||
'photos' => $photos
|
'photos' => $photos,
|
||||||
|
'success' => $request->session()->get('success')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,10 +346,7 @@ class PhotoController extends Controller
|
|||||||
|
|
||||||
public function updateBulk(Request $request, $albumId)
|
public function updateBulk(Request $request, $albumId)
|
||||||
{
|
{
|
||||||
$photos = $request->get('photo');
|
$photoIds = $request->get('select-photo');
|
||||||
|
|
||||||
dump($request->all());
|
|
||||||
exit();
|
|
||||||
|
|
||||||
/** @var Album $album */
|
/** @var Album $album */
|
||||||
$album = Album::where('id', intval($albumId))->first();
|
$album = Album::where('id', intval($albumId))->first();
|
||||||
@ -360,7 +357,10 @@ class PhotoController extends Controller
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($photos as $photoId => $value)
|
$action = $request->get('bulk-action');
|
||||||
|
$numberChanged = 0;
|
||||||
|
|
||||||
|
foreach ($photoIds as $photoId)
|
||||||
{
|
{
|
||||||
/** @var Photo $photo */
|
/** @var Photo $photo */
|
||||||
$photo = $album->photos()->where('id', intval($photoId))->first();
|
$photo = $album->photos()->where('id', intval($photoId))->first();
|
||||||
@ -369,10 +369,43 @@ class PhotoController extends Controller
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$photo->fill($value);
|
$photoService = new PhotoService($photo);
|
||||||
$photo->save();
|
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)));
|
return redirect(route('albums.show', array('id' => $albumId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ return [
|
|||||||
'album_settings_tab' => 'Settings',
|
'album_settings_tab' => 'Settings',
|
||||||
'album_upload_tab' => 'Upload',
|
'album_upload_tab' => 'Upload',
|
||||||
'analyse_photos_failed' => 'The following items could not be analysed and were removed:',
|
'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_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.',
|
'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',
|
'create_album' => 'Create a photo album',
|
||||||
|
Loading…
Reference in New Issue
Block a user