2022-01-14 08:28:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wishlist.php
|
|
|
|
*
|
|
|
|
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
|
|
|
*/
|
|
|
|
|
|
|
|
use wishthis\{Page, User};
|
|
|
|
use Embed\Embed;
|
|
|
|
|
|
|
|
$page = new page(__FILE__, 'View wishlist');
|
|
|
|
$page->header();
|
|
|
|
$page->navigation();
|
|
|
|
|
|
|
|
$products = array();
|
|
|
|
|
2022-01-17 13:18:49 +00:00
|
|
|
/**
|
|
|
|
* Get wishlist products
|
|
|
|
*/
|
2022-01-14 08:28:41 +00:00
|
|
|
if (isset($_GET['wishlist'])) {
|
2022-01-18 11:43:28 +00:00
|
|
|
$wishlist = $database->query('SELECT * FROM `wishlists`
|
|
|
|
WHERE `id` = "' . $_GET['wishlist'] . '"')
|
|
|
|
->fetch();
|
|
|
|
$products = $user->getProducts($_GET['wishlist']);
|
2022-01-14 08:28:41 +00:00
|
|
|
}
|
2022-01-17 13:18:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete wishlist
|
|
|
|
*/
|
|
|
|
if (isset($_POST['wishlist_delete_id'])) {
|
|
|
|
$database->query('DELETE FROM `wishlists`
|
|
|
|
WHERE id = ' . $_POST['wishlist_delete_id'] . '
|
|
|
|
;');
|
|
|
|
}
|
2022-01-14 08:28:41 +00:00
|
|
|
?>
|
|
|
|
<main>
|
|
|
|
<div class="ui container">
|
2022-01-17 13:52:00 +00:00
|
|
|
<h1 class="ui header"><?= $page->title ?></h1>
|
|
|
|
|
2022-01-14 08:57:33 +00:00
|
|
|
<div class="ui horizontal segments">
|
|
|
|
<div class="ui segment">
|
2022-01-17 13:52:00 +00:00
|
|
|
<h2 class="ui header">Wishlists</h2>
|
2022-01-14 08:57:33 +00:00
|
|
|
<p>Please select a wishlist to view.</p>
|
|
|
|
|
|
|
|
<form class="ui form" method="get">
|
|
|
|
<input type="hidden" name="page" value="wishlist-view" />
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<select class="ui search selection dropdown loading wishlists" name="wishlist">
|
|
|
|
<option value="">Loading your wishlists...</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
2022-01-17 15:06:17 +00:00
|
|
|
<input class="ui primary button wishlist-view disabled" type="submit" value="View" />
|
2022-01-14 08:57:33 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="ui segment">
|
|
|
|
<h2 class="ui header">Options</h1>
|
|
|
|
<p>Wishlist related options.</p>
|
|
|
|
|
2022-01-18 11:43:28 +00:00
|
|
|
<a class="ui small labeled icon button wishlist-share disabled" href="/?wishlist=<?= $wishlist['hash'] ?? '' ?>" target="_blank">
|
2022-01-14 08:57:33 +00:00
|
|
|
<i class="share icon"></i>
|
|
|
|
Share
|
2022-01-18 11:43:28 +00:00
|
|
|
</a>
|
2022-01-17 13:18:01 +00:00
|
|
|
|
2022-01-17 15:06:17 +00:00
|
|
|
<form class="ui form wishlist-delete" method="post" style="display: inline-block;">
|
2022-01-17 13:18:01 +00:00
|
|
|
<input type="hidden" name="wishlist_delete_id" />
|
|
|
|
|
2022-01-17 15:06:17 +00:00
|
|
|
<button class="ui small labeled red icon button disabled" type="submit">
|
2022-01-17 13:18:01 +00:00
|
|
|
<i class="trash icon"></i>
|
|
|
|
Delete
|
|
|
|
</button>
|
|
|
|
</form>
|
2022-01-14 08:57:33 +00:00
|
|
|
</div>
|
2022-01-14 08:28:41 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php if (!empty($products)) { ?>
|
2022-01-14 08:41:58 +00:00
|
|
|
<div class="ui three column grid">
|
|
|
|
|
|
|
|
<?php foreach ($products as $product) { ?>
|
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @link https://github.com/oscarotero/Embed
|
|
|
|
*/
|
|
|
|
$embed = new Embed();
|
|
|
|
$info = $embed->get($product['url']);
|
|
|
|
?>
|
|
|
|
<div class="column">
|
|
|
|
<div class="ui fluid card">
|
|
|
|
|
|
|
|
<?php if ($info->image) { ?>
|
|
|
|
<div class="image">
|
|
|
|
<img src="<?= $info->image ?>" />
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
2022-01-14 08:28:41 +00:00
|
|
|
|
2022-01-14 08:41:58 +00:00
|
|
|
<div class="content">
|
|
|
|
<?php if ($info->title) { ?>
|
|
|
|
<div class="header">
|
|
|
|
<?php if ($info->url) { ?>
|
|
|
|
<a href="<?= $info->url ?>" target="_blank"><?= $info->title ?></a>
|
|
|
|
<?php } else { ?>
|
|
|
|
<?= $info->title ?>
|
|
|
|
<?php } ?>
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($info->keywords) { ?>
|
|
|
|
<div class="meta">
|
|
|
|
<?= $info->keywords ?>
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($info->description) { ?>
|
|
|
|
<div class="description">
|
|
|
|
<?= $info->description ?>
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
2022-01-14 08:28:41 +00:00
|
|
|
</div>
|
2022-01-14 08:41:58 +00:00
|
|
|
<div class="extra content">
|
|
|
|
<?php if ($info->publishedTime) { ?>
|
|
|
|
<span class="right floated">
|
|
|
|
<?= $info->publishedTime ?>
|
|
|
|
</span>
|
|
|
|
<?php } ?>
|
|
|
|
<?php if ($info->favicon) { ?>
|
|
|
|
<?php if ($info->providerName) { ?>
|
2022-01-14 08:57:39 +00:00
|
|
|
<img src="<?= $info->favicon ?>"
|
|
|
|
title="<?= $info->providerName ?>"
|
|
|
|
alt="<?= $info->providerName ?>"
|
|
|
|
/>
|
2022-01-14 08:41:58 +00:00
|
|
|
<?php } else { ?>
|
|
|
|
<img src="<?= $info->favicon ?>" />
|
|
|
|
<?php } ?>
|
|
|
|
<?php } ?>
|
2022-01-14 08:28:41 +00:00
|
|
|
</div>
|
|
|
|
|
2022-01-14 08:41:58 +00:00
|
|
|
</div>
|
2022-01-14 08:28:41 +00:00
|
|
|
</div>
|
2022-01-14 08:41:58 +00:00
|
|
|
<?php } ?>
|
2022-01-14 08:28:41 +00:00
|
|
|
|
2022-01-14 08:41:58 +00:00
|
|
|
</div>
|
2022-01-17 12:52:03 +00:00
|
|
|
<?php } else { ?>
|
|
|
|
<?php if (isset($_GET['wishlist'])) { ?>
|
|
|
|
<div class="ui icon message">
|
2022-01-17 13:59:05 +00:00
|
|
|
<i class="info circle icon"></i>
|
2022-01-17 12:52:03 +00:00
|
|
|
<div class="content">
|
|
|
|
<div class="header">
|
|
|
|
Empty
|
|
|
|
</div>
|
|
|
|
<p>The selected wishlist seems to be empty.</p>
|
2022-01-17 13:18:37 +00:00
|
|
|
<a class="ui mini button" href="/?page=wishlist-product-add">Add a product</a>
|
2022-01-17 12:52:03 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php } else { ?>
|
|
|
|
<div class="ui icon message">
|
2022-01-17 13:59:05 +00:00
|
|
|
<i class="info circle icon"></i>
|
2022-01-17 12:52:03 +00:00
|
|
|
<div class="content">
|
|
|
|
<div class="header">
|
|
|
|
No wishlist selected
|
|
|
|
</div>
|
|
|
|
<p>Select a wishlist to see it's products.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
2022-01-14 08:28:41 +00:00
|
|
|
<?php } ?>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$page->footer();
|