public function show($wishListId) { if (!Wish_list::listBelongsToUser($wishListId)) { $this->redirect_to('wish_lists'); break; } #TODO add a method of properly sorting wish lists by the date each product was added. $wishList = Wish_list::findById($wishListId); $listOfWishLists = Wish_list::findByUserId($_SESSION['user_id']); if (isset($wishList['listInfo'])) { $listInfo = $wishList['listInfo']; unset($wishList['listInfo']); } else { $listInfo = ['wish_list_id' => $wishList[0]['wish_list_id'], 'fk_wish_list_user' => $wishList[0]['fk_wish_list_user'], 'wish_list_name' => $wishList[0]['wish_list_name']]; } $view = new View('wish_lists/show'); $view->set_title('Wish List - ' . $listInfo['wish_list_name']); $view->pass_data('listInfo', $listInfo); $view->pass_data('wishList', $wishList); $view->pass_data('listOfWishLists', $listOfWishLists); $view->load_page(); }
public function item($id = '') { require_once '../app/models/Product.php'; $product = Product::findByProductVersionId($id); if ($product) { $catagory = ucfirst($product['product_catagory']); require_once '../app/models/' . $catagory . '.php'; $model = new $catagory(); $product = $model->splitListsToArray($product); $productVersions = Product::findProductVersions($product['base_product_id']); require_once '../app/models/Wish_list.php'; $view = new View('products/item'); $view->set_title($product['product_name']); session_start(); if (isset($_SESSION['user_id'])) { $wishLists = Wish_list::findByUserId($_SESSION['user_id']); $view->pass_data('wishLists', $wishLists); } $view->pass_data('product', $product); $view->pass_data('productVersions', $productVersions); } else { $view = new View('products/not_found'); $view->set_title('Product not found'); } $view->load_page(); }