Skip to content

Commit

Permalink
Remove Photo thumbnails and switch admin viewer to PhotoSwipe
Browse files Browse the repository at this point in the history
  • Loading branch information
tomudding committed Oct 27, 2023
1 parent 1586d86 commit 899698f
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 730 deletions.
48 changes: 0 additions & 48 deletions module/Photo/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
use Photo\Controller\Factory\ApiControllerFactory;
use Photo\Controller\Factory\PhotoAdminControllerFactory;
use Photo\Controller\Factory\PhotoControllerFactory;
use Photo\Controller\Factory\Plugin\AlbumPluginFactory;
use Photo\Controller\Factory\TagControllerFactory;
use Photo\Controller\PhotoAdminController;
use Photo\Controller\PhotoController;
use Photo\Controller\Plugin\AlbumPlugin;
use Photo\Controller\TagController;

return [
Expand Down Expand Up @@ -193,31 +191,6 @@
],
],
],
'album_index' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:album_id]',
'defaults' => [
'action' => 'page',
],
'constraints' => [
'album_id' => '[0-9]+',
],
],
],
'album_page' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:album_id][/:page]',
'defaults' => [
'action' => 'page',
],
'constraints' => [
'album_id' => '[0-9]+',
'page' => '[0-9]+',
],
],
],
'album_edit' => [
'type' => Segment::class,
'options' => [
Expand Down Expand Up @@ -302,19 +275,6 @@
],
],
],
'photo_index' => [
'type' => Segment::class,
'options' => [
'route' => '/photo[/:photo_id]',
'defaults' => [
'controller' => PhotoAdminController::class,
'action' => 'index',
],
'constraints' => [
'photo_id' => '[0-9]+',
],
],
],
'photo_move' => [
'type' => Segment::class,
'options' => [
Expand Down Expand Up @@ -394,14 +354,6 @@
TagController::class => TagControllerFactory::class,
],
],
'controller_plugins' => [
'aliases' => [
'AlbumPlugin' => AlbumPlugin::class,
],
'factories' => [
AlbumPlugin::class => AlbumPluginFactory::class,
],
],
'view_manager' => [
'template_path_stack' => [
'photo' => __DIR__ . '/../view/',
Expand Down
19 changes: 0 additions & 19 deletions module/Photo/src/Controller/AlbumAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,6 @@ public function createAction(): Response|ViewModel
);
}

/**
* Retrieves photos on a certain page.
*/
public function pageAction(): JsonModel|ViewModel
{
$albumId = (int) $this->params()->fromRoute('album_id');
$activePage = (int) $this->params()->fromRoute('page');

if (0 !== $albumId) {
$albumPage = $this->plugin('AlbumPlugin')->getAlbumPageAsArray($albumId, $activePage);

if (null !== $albumPage) {
return new JsonModel($albumPage);
}
}

return $this->notFoundAction();
}

/**
* Retrieves the album editing form and saves changes.
*/
Expand Down
22 changes: 18 additions & 4 deletions module/Photo/src/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Photo\Mapper\Tag as TagMapper;
use Photo\Mapper\Vote as VoteMapper;
use Photo\Service\AclService;
use Photo\Service\Album as AlbumService;
use User\Permissions\NotAllowedException;

class ApiController extends AbstractActionController
Expand All @@ -20,25 +21,38 @@ public function __construct(
private readonly Translator $translator,
private readonly TagMapper $tagMapper,
private readonly VoteMapper $voteMapper,
private readonly AlbumService $albumService,
) {
}

/**
* Retrieve a list of all photo's in an album.
* Retrieve a list of all photos in an album.
*
* This API call is intended for external scripts. Like the AViCo TV screen
* that needs a list of all photo's.
* that needs a list of all photos.
*/
public function listAction(): JsonModel|ViewModel
{
$albumId = (int) $this->params()->fromRoute('album_id');
$album = $this->plugin('AlbumPlugin')->getAlbumAsArray($albumId);
$album = $this->albumService->getAlbum($albumId);

if (null === $album) {
return $this->notFoundAction();
}

return new JsonModel($album);
$albumArray = $album->toArrayWithChildren();

$photos = $albumArray['photos'];
$albums = $albumArray['children'];

$albumArray['photos'] = [];
$albumArray['children'] = [];

return new JsonModel([
'album' => $albumArray,
'photos' => $photos,
'albums' => $albums,
]);
}

public function detailsAction(): JsonModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __invoke(
$container->get(MvcTranslator::class),
$container->get('photo_mapper_tag'),
$container->get('photo_mapper_vote'),
$container->get('photo_service_album'),
);
}
}
27 changes: 0 additions & 27 deletions module/Photo/src/Controller/Factory/Plugin/AlbumPluginFactory.php

This file was deleted.

24 changes: 0 additions & 24 deletions module/Photo/src/Controller/PhotoAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,6 @@ public function __construct(
) {
}

/**
* Shows an admin page for the specified photo.
*
* TODO: Potentially remove, as the admin interface can already move/delete images from the global view.
*/
public function indexAction(): ViewModel
{
$photoId = (int) $this->params()->fromRoute('photo_id');
$data = $this->photoService->getPhotoData($photoId);

if (null === $data) {
return $this->notFoundAction();
}

$path = []; //The path to use in the breadcrumb navigation bar
$parent = $data['photo']->getAlbum();
while (null !== $parent) {
$path[] = $parent;
$parent = $parent->getParent();
}

return new ViewModel(array_merge($data, ['path' => $path]));
}

/**
* Places a photo in another album.
*/
Expand Down
69 changes: 0 additions & 69 deletions module/Photo/src/Controller/Plugin/AlbumPaginatorAdapter.php

This file was deleted.

Loading

0 comments on commit 899698f

Please sign in to comment.