Group remembered wishlists by user

This commit is contained in:
grandeljay 2022-06-27 11:36:36 +02:00
parent 3b7a902f8e
commit c0e9d66df0

View file

@ -13,34 +13,48 @@ $page->header();
$page->bodyStart(); $page->bodyStart();
$page->navigation(); $page->navigation();
$wishlists = $_SESSION['user']->getSavedWishlists(); $wishlists = $_SESSION['user']->getSavedWishlists();
$wishlists_by_user = array();
foreach ($wishlists as $wishlist_saved) {
$wishlists_by_user[$wishlist_saved['user']][] = $wishlist_saved;
}
?> ?>
<main> <main>
<div class="ui container"> <div class="ui container">
<h1 class="ui header"><?= $page->title ?></h1> <h1 class="ui header"><?= $page->title ?></h1>
<?php if (!empty($wishlists)) { ?> <?php if (!empty($wishlists_by_user)) { ?>
<div class="ui four column doubling stackable grid wishlists-saved"> <?php foreach ($wishlists_by_user as $wishlist_user => $wishlists_saved) { ?>
<?php foreach ($wishlists as $wishlist_saved) { ?> <?php
<?php $wishlist_user = User::getFromID($wishlist_user);
$wishlist = new Wishlist($wishlist_saved['wishlist']); ?>
$wishlist_user = User::getFromID($wishlist_saved['user']); <h2 class="ui header"><?= $wishlist_user->getDisplayName() ?></h2>
$wishlist_href = Page::PAGE_WISHLIST . '&hash=' . $wishlist->hash;
?>
<div class="column">
<a class="header" href="<?= $wishlist_href ?>">
<div class="ui rounded bordered fluid image">
<?= file_get_contents(ROOT . '/' . Wish::NO_IMAGE) ?>
</div>
</a>
<div class="content"> <?php if (!empty($wishlists_saved)) { ?>
<a class="header" href="<?= $wishlist_href ?>"><?= $wishlist->getTitle(); ?></a> <div class="ui four column doubling stackable grid wishlists-saved">
<div class="description"><?= $wishlist_user->getDisplayName(); ?></div> <?php foreach ($wishlists_saved as $wishlist_saved) { ?>
</div> <?php
$wishlist = new Wishlist($wishlist_saved['wishlist']);
$wishlist_href = Page::PAGE_WISHLIST . '&hash=' . $wishlist->hash;
?>
<div class="column">
<a class="header" href="<?= $wishlist_href ?>">
<div class="ui rounded bordered fluid image">
<?= file_get_contents(ROOT . '/' . Wish::NO_IMAGE) ?>
</div>
</a>
<div class="content">
<a class="header" href="<?= $wishlist_href ?>"><?= $wishlist->getTitle(); ?></a>
<div class="description"><?= $wishlist_user->getDisplayName(); ?></div>
</div>
</div>
<?php } ?>
</div> </div>
<?php } ?> <?php } ?>
</div> <?php } ?>
<?php } else { ?> <?php } else { ?>
<?= Page::info(__('Ask somebody to share their wishlist with you and hit the remember button for it to show up here!'), __('No lists')); ?> <?= Page::info(__('Ask somebody to share their wishlist with you and hit the remember button for it to show up here!'), __('No lists')); ?>
<?php } ?> <?php } ?>