Esempio n. 1
0
 public function loginAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     $userModel = new UserTableModel();
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $userModel->setTable('user');
         $userModel->setData();
         $userModel->login();
         $redirect = Helper::getRedirect();
         if (is_array($redirect) && !empty($redirect['url'])) {
             $redirect = implode('#', $redirect);
             header('Location: ' . $redirect);
             exit;
         }
         if ($fc->getAction() !== 'loginAction') {
             header('Location: ' . $_SERVER['REQUEST_URI']);
         } else {
             header('Location: ' . '/');
         }
         exit;
     } else {
         if ($_SESSION['user_id']) {
             header('Location: /');
         }
         $output = $model->render('../views/user/login.php', 'withoutSliderAndSidebar');
         $fc->setPage($output);
     }
 }
 function viewAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     $id = filter_var($fc->getParams()['id'], FILTER_SANITIZE_NUMBER_INT);
     if (!$id) {
         header('Location: /admin/notFound');
         exit;
     }
     $productModel = new ProductTableModel();
     $productModel->setId($id);
     $productModel->setTable('product');
     $ImageModel = new ImageTableModel();
     $ImageModel->setId($id);
     $ImageModel->setTable('image');
     $images = $ImageModel->readRecordsById('product_id', '*', 'ORDER BY main');
     $product = $productModel->readRecordsById()[0];
     $categoryModel = new CategoryTableModel();
     $product['category'] = $categoryModel->getCategoryById($product['category_id'])['category_name'];
     $product['subCategory'] = $categoryModel->getSubCategoryById($product['subcategory_id'])['subcategory_name'];
     if (!$product) {
         header('Location: /admin/notFound');
         exit;
     }
     $recProducts = (new IndexWidgets())->recAndPopProductsWidget('recommended');
     $model->setData(['product' => $product, 'images' => $images, 'recommendedProducts' => Generator::recommendedProducts($recProducts)]);
     $output = $model->render('../views/product/product.php', 'withoutSlider');
     $fc->setPage($output);
 }
Esempio n. 3
0
 function indexAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     $popProducts = (new IndexWidgets())->recAndPopProductsWidget('popular', 6);
     $recProducts = (new IndexWidgets())->recAndPopProductsWidget('recommended');
     $model->setData(['slides' => IndexWidgets::getSliderWidget(), 'currentCategory' => (new IndexWidgets())->currentCategoryWidget(Helper::getSiteConfig()->currentCategoryWidget), 'popularProducts' => Generator::popularProducts($popProducts, 6), 'recommendedProducts' => Generator::recommendedProducts($recProducts)]);
     $output = $model->render('../views/index.php', 'main');
     $fc->setPage($output);
 }
 public function indexAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         Mailer::setData($_POST);
         if (Mailer::emailHandler()) {
             Session::setUserMsg('Ваше сообщение успешно отправлено. Мы свяжемся с вами в ближайшее время', 'success');
             header('Location: ' . $_SERVER['REQUEST_URI']);
             exit;
         }
     } else {
         $output = $model->render('../views/contacts/contacts.php', 'withoutSliderAndSidebar');
         $fc->setPage($output);
     }
 }
Esempio n. 5
0
 public function checkoutAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $orderModel = new OrderTableModel();
         $orderModel->setData();
         $orderModel->addRecord();
         Basket::deleteBasket();
         \app\services\Session::setMsg('Ваш заказ принят. Наш менеджер свяжется с вами в ближайшее время', 'success');
         header('Location: /');
         exit;
     } else {
         $output = $model->render('../views/order/order.php', 'withoutSliderAndSidebar');
         $fc->setPage($output);
     }
 }
Esempio n. 6
0
 public function viewAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     $articleModel = new ArticleTableModel();
     $userModel = new UserTableModel();
     $id = filter_var($fc->getParams()['id'], FILTER_SANITIZE_NUMBER_INT);
     if (!$id) {
         header('Location: /admin/notFound');
         exit;
     }
     $articleModel->setId($id);
     $articleModel->setTable('article');
     $article = $articleModel->readRecordsById();
     $userModel->setId($article[0]['author']);
     $userModel->setTable('user');
     $model->setData(['article' => $article, 'author' => $userModel->readRecordsById('id', 'id, username')]);
     $output = $model->render('../views/blog/view.php', 'withoutSlider');
     $fc->setPage($output);
 }