diff --git a/.htaccess b/.htaccess index 1b3e7522..3ecf58b3 100644 --- a/.htaccess +++ b/.htaccess @@ -10,9 +10,6 @@ # Wishlists (My lists) RewriteRule ^(wishlists)/([0-9]+)$ /?page=$1&id=$2 [QSA,L] - # Wish - RewriteRule ^(wish)/(\d+)$ /?page=$1&id=$2 [QSA,L] - # Wishlist RewriteRule ^(wishlist)/([0-9a-f]{40})$ /?page=$1&hash=$2 [QSA,L] diff --git a/src/assets/js/wish.js b/src/assets/js/wish.js deleted file mode 100644 index d06da9df..00000000 --- a/src/assets/js/wish.js +++ /dev/null @@ -1,147 +0,0 @@ -$(function () { - - /** - * Auto fill - */ - if ($('[name="wish_url"]').val()) { - $('.button.auto-fill').removeClass('disabled'); - } - - $(document).on('click', '.button.auto-fill', function () { - var modalAutoFill = $('.modal.auto-fill'); - var modalValidate = $('.modal.validate'); - - var formWish = $('.form.wish'); - var imagePreview = $('img.preview'); - - var inputTitle = $('[name="wish_title"]'); - var inputDescription = $('[name="wish_description"]'); - var inputImage = $('[name="wish_image"]'); - var inputURL = $('[name="wish_url"]'); - - modalAutoFill - .modal({ - autoShow : true, - onApprove: function() { - formWish.addClass('loading'); - - fetch('/src/api/wishes.php?wish_url=' + inputURL.val(), { - method: 'GET' - }) - .then(handleFetchError) - .then(handleFetchResponse) - .then(function(response) { - var info = response.info; - - /** - * Prodiver name - */ - if (info.providerName) { - modalValidate.find('.providerName').text(info.providerName); - } else { - modalValidate.find('.provider').remove(); - } - - /** - * Title - */ - if (info.title) { - inputTitle.val(info.title); - } - - /** - * Description - */ - if (info.description) { - inputDescription.val(info.description); - } - - /** - * Image - */ - if (info.image) { - inputImage.val(info.image); - imagePreview.attr('src', info.image); - } - - /** - * URL - */ - if (info.url && info.url !== inputURL.val()) { - var elementModalFetch = $('.modal.validate'); - - elementModalFetch.find('input.current').val(inputURL.val()); - elementModalFetch.find('input.proposed').val(info.url); - - elementModalFetch - .modal({ - autoShow: true, - onApprove: function (buttonFetch) { - var formData = new URLSearchParams(); - formData.append('wish_url_current', inputURL.val()); - formData.append('wish_url_proposed', info.url); - - buttonFetch.addClass('loading'); - - fetch('/src/api/wishes.php', { - method: 'PUT', - body : formData - }) - .then(handleFetchError) - .then(handleFetchResponse) - .then(function(response) { - inputURL.val(info.url); - - elementModalFetch.modal('hide'); - - $('body').toast({ message: text.toast_wish_update }); - - buttonFetch.removeClass('loading'); - }); - - return false; - }, - onHide: function() { - formWish.removeClass('loading'); - } - }); - } else { - $('body').toast({ - class : 'primary', - classProgress : 'yellow', - message : text.toast_wish_save - }); - - formWish.removeClass('loading'); - } - }) - .catch(handleFetchCatch); - } - }); - - }); - - /** - * Image - */ - $(document).on('click', '.image.preview', function() { - var modalImage = $('.modal.preview'); - - modalImage - .modal({ - autoShow: true, - onApprove: function() { - var newImageURL = modalImage.find('[name="wish_image"]').val(); - - $('img.preview').attr('src', newImageURL); - $('.form.wish [name="wish_image"]').val(newImageURL); - - $('body').toast({ - class : 'primary', - message: text.toast_wish_save - }); - } - }); - }); - -}); diff --git a/src/pages/wish.php b/src/pages/wish.php deleted file mode 100644 index 89ef7a5f..00000000 --- a/src/pages/wish.php +++ /dev/null @@ -1,223 +0,0 @@ - - */ - -namespace wishthis; - -$userIsAuthenticated = false; - -$wish = new Wish($_SESSION['_GET']['id'], false); -$page = new Page(__FILE__, $wish->getTitle()); - -if ('POST' === $_SERVER['REQUEST_METHOD'] && count($_POST) >= 0) { - $wish_id = $_POST['wish_id']; - $wish_title = trim($_POST['wish_title']); - $wish_description = $_POST['wish_description'] ?: ''; - $wish_image = trim($_POST['wish_image']); - $wish_url = trim($_POST['wish_url']); - $wish_priority = isset($_POST['wish_priority']) && $_POST['wish_priority'] ? $_POST['wish_priority'] : 'NULL'; - $wish_is_purchasable = isset($_POST['wish_is_purchasable']) ? 'TRUE' : 'FALSE'; - - $database - ->query('UPDATE `wishes` - SET `title` = "' . $wish_title . '", - `description` = "' . $wish_description . '", - `image` = "' . $wish_image . '", - `url` = "' . $wish_url . '", - `priority` = ' . $wish_priority . ', - `is_purchasable` = ' . $wish_is_purchasable . ' - WHERE `id` = ' . $wish_id . ';'); - - $wish = new Wish($_SESSION['_GET']['id'], false); - $page = new Page(__FILE__, $wish->getTitle()); - $page->messages[] = Page::success(__('Wish successfully updated.'), __('Success')); -} - -if (!$wish->exists) { - $page->errorDocument(404, $wish); -} - -$wishlists = $user->getWishlists($wish->wishlist); - -foreach ($wishlists as $wishlist) { - if ($wish->wishlist === intval($wishlist['id'])) { - $userIsAuthenticated = true; - break; - } -} - -if (!$userIsAuthenticated) { - $page->errorDocument(404, $wish); -} - -$page->header(); -$page->bodyStart(); -$page->navigation(); - -$referer = '/?page=wishlists&id=' . $wish->wishlist; -?> - -
-
-

title ?>

- - messages() ?> - -
-
-
- - image) { ?> - - - -
-
- -
-
- - - - - - - - -
-
-
- -
-
- - - -
- - -
-
- - - - - - - -
-
- -
-
-
- -
-
- - - - - - - - - - -footer(); -$page->bodyEnd(); -?>