Skip to content

Commit

Permalink
Replace category by album (the same for plural forms)
Browse files Browse the repository at this point in the history
Cope with #65
  • Loading branch information
nikrou committed Mar 4, 2022
1 parent 65de033 commit 608efc1
Show file tree
Hide file tree
Showing 12 changed files with 252 additions and 182 deletions.
16 changes: 8 additions & 8 deletions config/routes/album.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
albums_flat__start:
path: /categories/flat/start-{start}
path: /albums/flat/start-{start}
controller: App\Controller\AlbumController::albumsFlat
defaults:
start: 0
requirements:
start: \d+

albums_flat:
path: /categories/flat
path: /albums/flat
controller: App\Controller\AlbumController::albumsFlat
defaults:
start: 0

albums__start:
path: /categories/start-{start}
path: /albums/start-{start}
controller: App\Controller\AlbumController::albums
requirements:
start: \d+

albums:
path: /categories
path: /albums
controller: App\Controller\AlbumController::albums
defaults:
start: 0

album__start:
path: /category/{category_id}/start-{start}
path: /album/{album_id}/start-{start}
controller: App\Controller\AlbumController::album
defaults:
start: 0
requirements:
start: \d+

album:
path: /category/{category_id}
path: /album/{album_id}
controller: App\Controller\AlbumController::album
defaults:
start: 0

album_flat__start:
path: /category/{category_id}/flat/start-{start}
path: /album/{album_id}/flat/start-{start}
controller: App\Controller\AlbumController::albumFlat
defaults:
start: 0
Expand All @@ -48,7 +48,7 @@ album_flat__start:
start: \d+

album_flat:
path: /category/{category_id}/flat
path: /album/{album_id}/flat
controller: App\Controller\AlbumController::albumFlat
defaults:
start: 0
Expand Down
2 changes: 1 addition & 1 deletion config/routes/picture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ picture:
controller: App\Controller\PictureController::picture
requirements:
element_id: .+
type: category|list|tags|search|favorites|most_visited|best_rated|recent_pics|recent_cats|file|from_calendar
type: album|list|tags|search|favorites|most_visited|best_rated|recent_pics|recent_cats|file|from_calendar

picture_rate:
path: /rate
Expand Down
20 changes: 10 additions & 10 deletions features/web/admin/album.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Feature: Album
| user1 | pass1 | webmaster |

And some albums:
| name | parent | comment | status |
| album 1 | | album 1 description | public |
| album 2 | | album 2 description | public |
| name | parent | comment | status |
| album 1 | | album 1 description | public |
| album 2 | | album 2 description | public |

And some images:
| name | album |
| photo 1 | album 1 |
| photo 2 | album 2 |
| name | album |
| photo 1 | album 1 |
| photo 2 | album 2 |

Scenario: Move album in sub-album
Given I am logged in as "user1" with password "pass1"
Expand All @@ -25,10 +25,10 @@ Feature: Album

When I go to "admin/albums/move"
Then the select "Virtual albums to move" should contain:
"""
album 1
album 2
"""
"""
album 1
album 2
"""
When I select "album 2" from "Virtual albums to move"
And I select "album 1" from "New parent album"
And I press "Submit"
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/AdminAlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function properties(
$tpl_params['CAT_NAME'] = $album->getName();
$tpl_params['CAT_COMMENT'] = $album->getComment();
$tpl_params['CAT_LOCK'] = $album->isVisible() ? 'false': 'true';
$tpl_params['U_JUMPTO'] = $this->generateUrl('album', ['category_id' => $album_id]);
$tpl_params['U_JUMPTO'] = $this->generateUrl('album', ['album_id' => $album_id]);
$tpl_params['U_ADD_PHOTOS_ALBUM'] = $this->generateUrl('admin_photos_add', ['album_id' => $album_id]);
$tpl_params['U_CHILDREN'] = $this->generateUrl('admin_albums', ['parent_id' => $album_id]);
$tpl_params['ws'] = $this->generateUrl('ws');
Expand Down Expand Up @@ -549,7 +549,7 @@ public function notification(
'derivative' => $derivative->getUrlType(),
'image_extension' => $element->getExtension()
]);
$img_url = '<a href="' . $this->generateUrl('picture', ['image_id' => $element->getId(), 'type' => 'category', 'element_id' => $album_id], UrlGeneratorInterface::ABSOLUTE_URL);
$img_url = '<a href="' . $this->generateUrl('picture', ['image_id' => $element->getId(), 'type' => 'album', 'element_id' => $album_id], UrlGeneratorInterface::ABSOLUTE_URL);
$img_url .= '"><img src="' . $img_src . '" alt="X"></a>';
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Admin/AdminAlbumsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function list(
'NB_SUB_ALBUMS' => $subcats_of[$album->getId()] ?? 0,
'ID' => $album->getId(),
'RANK' => $album->getRank() * 10,
'U_JUMPTO' => $this->generateUrl('album', ['category_id' => $album->getId()]),
'U_JUMPTO' => $this->generateUrl('album', ['album_id' => $album->getId()]),
'U_CHILDREN' => $this->generateUrl('admin_albums', ['parent_id' => $album->getId()]),
'U_EDIT' => $this->generateUrl('admin_album', ['album_id' => $album->getId(), 'parent_id' => $parent_id]),
'IS_VIRTUAL' => $album->isVirtual(),
Expand Down
49 changes: 25 additions & 24 deletions src/Controller/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use App\Repository\UserCacheAlbumRepository;
use App\Security\AppUserService;
use Phyxo\Functions\Utils;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Security;
Expand All @@ -39,18 +40,18 @@ public function album(
AppUserService $appUserService,
RouterInterface $router,
int $start = 0,
int $category_id = 0
) {
int $album_id = 0
): Response {
$tpl_params = [];
$this->image_std_params = $image_std_params;

if ($request->cookies->has('category_view')) {
$tpl_params['category_view'] = $request->cookies->get('category_view');
}

$album = $albumMapper->getRepository()->find($category_id);
$album = $albumMapper->getRepository()->find($album_id);

if (in_array($category_id, $appUserService->getUser()->getUserInfos()->getForbiddenCategories())) {
if (in_array($album_id, $appUserService->getUser()->getUserInfos()->getForbiddenCategories())) {
throw new AccessDeniedHttpException("Access denied to that album");
}

Expand Down Expand Up @@ -86,7 +87,7 @@ public function album(
if ($order[2] === true) {
$tpl_params['image_orders'][] = [
'DISPLAY' => $order[0],
'URL' => $this->generateUrl('album', ['category_id' => $album->getId(), 'start' => $start, 'order' => $order_id]),
'URL' => $this->generateUrl('album', ['album_id' => $album->getId(), 'start' => $start, 'order' => $order_id]),
'SELECTED' => false
];
}
Expand All @@ -103,7 +104,7 @@ public function album(

list($is_child_date_last, $albums, $image_ids, $user_representative_updates_for) = $albumMapper->getAlbumThumbnails(
$appUserService->getUser(),
$albumMapper->getRepository()->findByParentId($category_id, $appUserService->getUser()->getId())
$albumMapper->getRepository()->findByParentId($album_id, $appUserService->getUser()->getId())
);

if (count($albums) > 0) {
Expand Down Expand Up @@ -137,7 +138,7 @@ public function album(
'representative' => $representative_infos,
'TN_ALT' => $currentAlbum->getName(),
'TN_TITLE' => $imageMapper->getThumbnailTitle(['rating_score' => '', 'nb_comments' => ''], $currentAlbum->getName(), $currentAlbum->getComment()),
'URL' => $this->generateUrl('album', ['category_id' => $currentAlbum->getId(), 'start' => $start]),
'URL' => $this->generateUrl('album', ['album_id' => $currentAlbum->getId(), 'start' => $start]),
'CAPTION_NB_IMAGES' => $albumMapper->getDisplayImagesCount(
$userCacheAlbum->getNbImages(),
$userCacheAlbum->getCountImages(),
Expand Down Expand Up @@ -202,7 +203,7 @@ public function album(
$tpl_params['thumb_navbar'] = Utils::createNavigationBar(
$router,
'album',
['category_id' => $category_id],
['album_id' => $album_id],
count($tpl_params['items']),
$start,
$nb_image_page,
Expand All @@ -213,9 +214,9 @@ public function album(
$tpl_params = array_merge(
$tpl_params,
$imageMapper->getPicturesFromSelection(
$category_id,
$album_id,
array_slice($tpl_params['items'], $start, $nb_image_page),
'category',
'album',
$start
)
);
Expand All @@ -224,8 +225,8 @@ public function album(
$tpl_params = array_merge($this->addThemeParams($conf), $tpl_params);

$tpl_params['SHOW_THUMBNAIL_CAPTION'] = $conf['show_thumbnail_caption'];
$tpl_params['U_MODE_POSTED'] = $this->generateUrl('calendar', ['date_type' => 'posted', 'category_id' => $category_id]);
$tpl_params['U_MODE_CREATED'] = $this->generateUrl('calendar', ['date_type' => 'created', 'category_id' => $category_id]);
$tpl_params['U_MODE_POSTED'] = $this->generateUrl('calendar', ['date_type' => 'posted', 'album_id' => $album_id]);
$tpl_params['U_MODE_CREATED'] = $this->generateUrl('calendar', ['date_type' => 'created', 'album_id' => $album_id]);
$tpl_params['START_ID'] = $start;
$tpl_params = array_merge($tpl_params, $this->loadThemeConf($request->getSession()->get('_theme'), $conf));

Expand All @@ -238,20 +239,20 @@ public function albumFlat(
ImageStandardParams $image_std_params,
AlbumMapper $albumMapper,
ImageMapper $imageMapper,
int $category_id,
int $album_id,
TranslatorInterface $translator,
RouterInterface $router,
AppUserService $appUserService,
int $start = 0
) {
): Response {
$tpl_params = [];
$this->image_std_params = $image_std_params;

if ($request->cookies->has('category_view')) {
$tpl_params['category_view'] = $request->cookies->get('category_view');
}

$album = $albumMapper->getRepository()->find($category_id);
$album = $albumMapper->getRepository()->find($album_id);
$subcat_ids[] = $album->getId();
foreach ($albumMapper->getRepository()->findAllowedSubAlbums($album->getUppercats(), $appUserService->getUser()->getUserInfos()->getForbiddenCategories()) as $sub_album) {
$subcat_ids[] = $sub_album->getId();
Expand All @@ -269,7 +270,7 @@ public function albumFlat(
$tpl_params['thumb_navbar'] = Utils::createNavigationBar(
$router,
'album_flat',
['category_id' => $category_id],
['album_id' => $album_id],
count($tpl_params['items']),
$start,
$nb_image_page,
Expand All @@ -280,9 +281,9 @@ public function albumFlat(
$tpl_params = array_merge(
$tpl_params,
$imageMapper->getPicturesFromSelection(
$category_id,
$album_id,
array_slice($tpl_params['items'], $start, $nb_image_page),
'category',
'album',
$start
)
);
Expand All @@ -307,7 +308,7 @@ public function albumsFlat(
RouterInterface $router,
AppUserService $appUserService,
int $start = 0
) {
): Response {
$tpl_params = [];
$this->image_std_params = $image_std_params;

Expand Down Expand Up @@ -342,7 +343,7 @@ public function albumsFlat(
$imageMapper->getPicturesFromSelection(
'flat',
array_slice($tpl_params['items'], $start, $nb_image_page),
'categories',
'albums',
$start
)
);
Expand All @@ -367,7 +368,7 @@ public function albums(
RouterInterface $router,
AppUserService $appUserService,
int $start = 0
) {
): Response {
$tpl_params = [];
$this->image_std_params = $image_std_params;

Expand Down Expand Up @@ -419,7 +420,7 @@ public function albums(
'representative' => $representative_infos,
'TN_ALT' => $album->getName(),
'TN_TITLE' => $imageMapper->getThumbnailTitle(['rating_score' => '', 'nb_comments' => ''], $album->getName(), $album->getComment()),
'URL' => $this->generateUrl('album', ['category_id' => $album->getId(), 'start' => $start]),
'URL' => $this->generateUrl('album', ['album_id' => $album->getId(), 'start' => $start]),
'CAPTION_NB_IMAGES' => $albumMapper->getDisplayImagesCount(
$userCacheAlbum->getNbImages(),
$userCacheAlbum->getCountImages(),
Expand Down Expand Up @@ -492,7 +493,7 @@ public function recentCats(
RouterInterface $router,
AppUserService $appUserService,
int $start = 0
) {
): Response {
$tpl_params = [];
$this->image_std_params = $image_std_params;

Expand Down Expand Up @@ -542,7 +543,7 @@ public function recentCats(
'representative' => $representative_infos,
'TN_ALT' => $album->getName(),
'TN_TITLE' => $imageMapper->getThumbnailTitle(['rating_score' => '', 'nb_comments' => ''], $album->getName(), $album->getComment()),
'URL' => $this->generateUrl('album', ['category_id' => $album->getId(), 'start' => $start]),
'URL' => $this->generateUrl('album', ['album_id' => $album->getId(), 'start' => $start]),
'CAPTION_NB_IMAGES' => $albumMapper->getDisplayImagesCount(
$userCacheAlbum->getNbImages(),
$userCacheAlbum->getCountImages(),
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
use Phyxo\Image\DerivativeImage;
use Phyxo\Image\ImageStandardParams;
use Symfony\Component\HttpFoundation\Response;

class DefaultController extends CommonController
{
public function home()
public function home(): Response
{
return $this->forward('App\Controller\AlbumController::albums');
}
Expand All @@ -32,7 +33,7 @@ public function download(
AppUserService $appUserService,
ImageStandardParams $image_std_params,
string $rootProjectDir
) {
): Response {
$image = $imageMapper->getRepository()->find($image_id);

if (!$albumMapper->getRepository()->hasAccessToImage($image_id, $appUserService->getUser()->getUserInfos()->getForbiddenCategories())) {
Expand Down
1 change: 0 additions & 1 deletion src/Controller/MenubarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Phyxo\Conf;
use Phyxo\MenuBar;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

Expand Down
Loading

0 comments on commit 608efc1

Please sign in to comment.