diff --git a/includes/assets/js/wishlist-view.js b/includes/assets/js/wishlist-view.js index df0d476a..10dee88d 100644 --- a/includes/assets/js/wishlist-view.js +++ b/includes/assets/js/wishlist-view.js @@ -9,9 +9,11 @@ $(function() { if (wishlistValue) { $('.wishlist-view').removeClass('disabled'); + $('.wishlist-share').removeClass('disabled'); $('.wishlist-delete button').removeClass('disabled'); } else { $('.wishlist-view').addClass('disabled'); + $('.wishlist-share').addClass('disabled'); $('.wishlist-delete button').addClass('disabled'); } }); diff --git a/includes/pages/install.php b/includes/pages/install.php index 7e8fc831..88084b70 100644 --- a/includes/pages/install.php +++ b/includes/pages/install.php @@ -122,7 +122,7 @@ switch ($step) { $database->query('CREATE TABLE `products` ( `id` int NOT NULL PRIMARY KEY AUTO_INCREMENT, `wishlist` int NOT NULL, - `url` VARCHAR(255) NOT NULL, + `hash` VARCHAR(255) NOT NULL INDEX, FOREIGN KEY (`wishlist`) REFERENCES `wishlists` (`id`) ON DELETE CASCADE diff --git a/includes/pages/update.php b/includes/pages/update.php index 9a2f46c7..2c7761ec 100644 --- a/includes/pages/update.php +++ b/includes/pages/update.php @@ -31,8 +31,9 @@ if ('POST' === $_SERVER['REQUEST_METHOD']) { $database->query('ALTER TABLE `users` ADD INDEX(`password`);'); $database->query('ALTER TABLE `wishlists` - ADD `url` VARCHAR(128) NOT NULL AFTER `name` + ADD `hash` VARCHAR(128) NOT NULL AFTER `name` ;'); + $database->query('ALTER TABLE `wishlists` ADD INDEX(`hash`);'); $database->query('INSERT INTO `options` (`key`, `value`) VALUES ("version", "' . VERSION . '");'); diff --git a/includes/pages/wishlist-create.php b/includes/pages/wishlist-create.php index 5ae05b98..ee163869 100644 --- a/includes/pages/wishlist-create.php +++ b/includes/pages/wishlist-create.php @@ -12,8 +12,15 @@ $page = new page(__FILE__, 'Create a wishlist'); if (isset($_POST['name'])) { $database->query('INSERT INTO `wishlists` - (`user`, `name`) VALUES - (' . $_SESSION['user']['id'] . ', "' . $_POST['name'] . '") + ( + `user`, + `name`, + `hash` + ) VALUES ( + ' . $_SESSION['user']['id'] . ', + "' . $_POST['name'] . '", + "' . time() . $_SESSION['user']['id'] . $_POST['name'] . '" + ) ;'); header('Location: /?page=wishlist-product-add'); diff --git a/includes/pages/wishlist-view.php b/includes/pages/wishlist-view.php index 9d48ec02..f6b4a85c 100644 --- a/includes/pages/wishlist-view.php +++ b/includes/pages/wishlist-view.php @@ -20,8 +20,10 @@ $products = array(); */ if (isset($_GET['wishlist'])) { $user = new User(); - $wishlist = $_GET['wishlist']; - $products = $user->getProducts($wishlist); + $wishlist = $database->query('SELECT * FROM `wishlists` + WHERE `id` = "' . $_GET['wishlist'] . '"') + ->fetch(); + $products = $user->getProducts($_GET['wishlist']); } /** @@ -59,10 +61,10 @@ if (isset($_POST['wishlist_delete_id'])) {

Options

Wishlist related options.

- +
diff --git a/includes/pages/wishlist.php b/includes/pages/wishlist.php new file mode 100644 index 00000000..9c6703c1 --- /dev/null +++ b/includes/pages/wishlist.php @@ -0,0 +1,128 @@ + + */ + +use wishthis\{Page, User}; +use Embed\Embed; + +$page = new page(__FILE__, 'Wishlist'); +$page->header(); +$page->navigation(); + +$user = new User(); + +$wishlist = $database->query('SELECT * FROM `wishlists` + WHERE `hash` = "' . $_GET['wishlist'] . '"') + ->fetch(); + +$products = $user->getProducts($wishlist['id']); +?> + +
+
+

title ?>

+ +
+

+
+ + +
+ + + get($product['url']); + ?> +
+
+ + image) { ?> +
+ +
+ + +
+ title) { ?> +
+ url) { ?> + title ?> + + title ?> + +
+ + + keywords) { ?> +
+ keywords ?> +
+ + + description) { ?> +
+ description ?> +
+ +
+
+ publishedTime) { ?> + + publishedTime ?> + + + favicon) { ?> + providerName) { ?> + <?= $info->providerName ?> + + + + +
+ +
+
+ + +
+ + +
+ +
+
+ Empty +
+

The selected wishlist seems to be empty.

+ Add a product +
+
+ +
+ +
+
+ No wishlist selected +
+

Select a wishlist to see it's products.

+
+
+ + +
+
+ +footer(); +?> diff --git a/index.php b/index.php index 03123817..90d412a5 100644 --- a/index.php +++ b/index.php @@ -79,6 +79,13 @@ if ($options) { } } +/** + * Wishlist + */ +if (!isset($_GET['page']) && isset($_GET['wishlist'])) { + $page = 'wishlist'; +} + /** * Page */