Merge branch 'develop' into stable
This commit is contained in:
commit
142944a3f3
4 changed files with 153 additions and 27 deletions
|
@ -106,6 +106,10 @@ class Page
|
||||||
<i class="list icon"></i>
|
<i class="list icon"></i>
|
||||||
Create
|
Create
|
||||||
</a>
|
</a>
|
||||||
|
<a class="item" href="/?page=wishlist-view">
|
||||||
|
<i class="list icon"></i>
|
||||||
|
View
|
||||||
|
</a>
|
||||||
<a class="item" href="/?page=wishlist-product-add">
|
<a class="item" href="/?page=wishlist-product-add">
|
||||||
<i class="plus square icon"></i>
|
<i class="plus square icon"></i>
|
||||||
Add product
|
Add product
|
||||||
|
|
|
@ -46,9 +46,29 @@ class User
|
||||||
$wishlists = $database->query(
|
$wishlists = $database->query(
|
||||||
'SELECT *
|
'SELECT *
|
||||||
FROM wishlists
|
FROM wishlists
|
||||||
WHERE user = ' . $_SESSION['user']['id'] . ';'
|
WHERE user = ' . $this->id . ';'
|
||||||
)->fetchAll();
|
)->fetchAll();
|
||||||
|
|
||||||
return $wishlists;
|
return $wishlists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of products for a given wishlist.
|
||||||
|
*
|
||||||
|
* @param int $wishlist
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getProducts(int $wishlist): array
|
||||||
|
{
|
||||||
|
global $database;
|
||||||
|
|
||||||
|
$products = $database->query(
|
||||||
|
'SELECT *
|
||||||
|
FROM products
|
||||||
|
WHERE wishlist = ' . $this->id . ';'
|
||||||
|
)->fetchAll();
|
||||||
|
|
||||||
|
return $products;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use wishthis\{Page, User};
|
use wishthis\{Page, User};
|
||||||
use Embed\Embed;
|
|
||||||
|
|
||||||
if (isset($_POST['url'], $_POST['wishlist'])) {
|
if (isset($_POST['url'], $_POST['wishlist'])) {
|
||||||
$database->query('INSERT INTO `products`
|
$database->query('INSERT INTO `products`
|
||||||
|
@ -16,41 +15,32 @@ if (isset($_POST['url'], $_POST['wishlist'])) {
|
||||||
;');
|
;');
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = 'https://www.amazon.de/Adventskalender-2020-Schokolade-Weihnachtskalender-346g/dp/B08CTTP5JX';
|
|
||||||
$embed = new Embed();
|
|
||||||
$info = $embed->get($url);
|
|
||||||
|
|
||||||
// https://github.com/oscarotero/Embed
|
|
||||||
// echo '<pre>';
|
|
||||||
// var_dump($info);
|
|
||||||
// echo '</pre>';
|
|
||||||
|
|
||||||
$page = new page(__FILE__, 'Add a product');
|
$page = new page(__FILE__, 'Add a product');
|
||||||
$page->header();
|
$page->header();
|
||||||
$page->navigation();
|
$page->navigation();
|
||||||
$user = new User();
|
$user = new User();
|
||||||
?>
|
?>
|
||||||
<main>
|
<main>
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<h1 class="ui header">Add a product</h1>
|
<h1 class="ui header">Add a product</h1>
|
||||||
|
|
||||||
<form class="ui form" method="post">
|
<form class="ui form" method="post">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>URL</label>
|
<label>URL</label>
|
||||||
<input type="url" name="url" value="<?= $url ?>" />
|
<input type="url" name="url" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<select class="ui search selection dropdown loading wishlists" name="wishlist">
|
<select class="ui search selection dropdown loading wishlists" name="wishlist">
|
||||||
<option value="">Loading your wishlists...</option>
|
<option value="">Loading your wishlists...</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input class="ui primary button" type="submit" value="Add" />
|
<input class="ui primary button" type="submit" value="Add" />
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
112
includes/pages/wishlist-view.php
Normal file
112
includes/pages/wishlist-view.php
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
<?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();
|
||||||
|
|
||||||
|
if (isset($_GET['wishlist'])) {
|
||||||
|
$user = new User();
|
||||||
|
$wishlist = $_GET['wishlist'];
|
||||||
|
$products = $user->getProducts($wishlist);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<main>
|
||||||
|
<div class="ui container">
|
||||||
|
<div class="ui segment">
|
||||||
|
<h1 class="ui header">View wishlist</h1>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<input class="ui primary button" type="submit" value="View" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (!empty($products)) { ?>
|
||||||
|
<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 } ?>
|
||||||
|
|
||||||
|
<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 } ?>
|
||||||
|
</div>
|
||||||
|
<div class="extra content">
|
||||||
|
<?php if ($info->publishedTime) { ?>
|
||||||
|
<span class="right floated">
|
||||||
|
<?= $info->publishedTime ?>
|
||||||
|
</span>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if ($info->favicon) { ?>
|
||||||
|
<?php if ($info->providerName) { ?>
|
||||||
|
<img src="<?= $info->favicon ?>" title="<?= $info->providerName ?>" alt="<?= $info->providerName ?>" />
|
||||||
|
<?php } else { ?>
|
||||||
|
<img src="<?= $info->favicon ?>" />
|
||||||
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$page->footer();
|
Loading…
Reference in a new issue