Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public function beforeAction($event)
 {
     if (\Yii::$app->session->has('_language')) {
     } else {
         \Yii::$app->language = 'ar';
     }
     return parent::beforeAction($event);
 }
Exemplo 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);
 }
Exemplo n.º 4
0
 static function pagination($limit = 10, $page = 1, array $options = [])
 {
     $p = $page;
     if (!$options['num']) {
         $aw = new AdminWidgets();
         $num = $aw->getNum($options['table']);
     } else {
         $num = $options['num'];
     }
     $pages = round($num / $limit);
     if ($page == 0) {
         $page = 1;
     }
     if ($page == 1) {
         $disabledP = 'disabled';
     } else {
         if ($page == $pages) {
             $disabledN = 'disabled';
         } else {
             $disabled = '';
         }
     }
     $fc = FrontController::getInstance();
     $controller = $fc->getClearController();
     $action = $fc->getClearAction();
     $link = "/{$controller}/{$action}";
     if (!empty($options)) {
         foreach ($options as $key => $value) {
             if (!empty($value)) {
                 $link .= "/{$key}/{$value}";
             }
         }
     }
     $output = '';
     $output .= '<ul class="pagination">' . "\n";
     $output .= '<li class="' . $disabledP . '" id="previous">' . "\n";
     $output .= '<a href="' . $link . '/page/' . --$p . '" aria-controls="pgn" data-dt-idx="0" tabindex="0">&laquo;</a>' . "\n";
     $output .= '</li>' . "\n";
     for ($i = 1; $i <= $pages; $i++) {
         if ($page == $i) {
             $active = 'active';
         } else {
             $active = '';
         }
         $output .= '<li class="paginate_button ' . $active . '">' . "\n";
         $output .= '<a href="' . $link . '/page/' . $i . '" aria-controls="pgn" data-dt-idx="' . $i . '" tabindex="0">' . $i . '</a>' . "\n";
         $output .= '</li>' . "\n";
     }
     $output .= '<li class="paginate_button next ' . $disabledN . '" id="next">' . "\n";
     $output .= '<a href="' . $link . '/page/' . ++$page . '" aria-controls="pgn" data-dt-idx="' . ++$page . '" tabindex="0">&raquo;</a>' . "\n";
     $output .= '</li>' . "\n";
     $output .= '</ul>' . "\n";
     return $output;
 }
Exemplo n.º 5
0
 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);
     }
 }
Exemplo n.º 6
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);
     }
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
0
 public function breadCrumbs()
 {
     $pages = ['profile' => 'Профиль пользователя', 'add' => 'Добавление новых товаров', 'allProducts' => 'Все товары', 'page' => 'Страница', 'view' => 'Просмотр', 'product' => 'Товар'];
     $output = '';
     $link = '';
     $fc = FrontController::getInstance();
     $action = $fc->getAction();
     $action = $fc->getClearAction();
     $params = $fc->getParams() ? array_diff($fc->getParams(), ['']) : [];
     $output = '<ol class = "breadcrumb">';
     if (!(empty($action) || $action === 'index')) {
         $output .= '<li><a href = "/admin"><i class = ""></i> Главная </a></li>';
     }
     $output .= '<li><a href = "/admin/' . $action . '"><i class = ""></i>' . $pages[$action] . '</a></li>';
     foreach ($params as $key => $value) {
         $link .= '/' . $value;
         $output .= '<li><a href = "/admin/' . $action . '/' . $key . '/' . $value . '"><i class = ""></i> ' . $pages[$key] . ' ' . $value . ' </a></li>';
     }
     $output .= '</ol >';
     return $output;
 }
Exemplo n.º 9
0
            <div class="error-content">
              <h3><i class="fa fa-warning text-yellow"></i> Страница не найдена</h3>
              <p>
                Сожалеем, но запрашиваемая страница не найдена.
              </p>
              <form class="search-form">
                <div class="input-group">
                  <input type="text" name="search" class="form-control" placeholder="Поиск">
                  <div class="input-group-btn">
                    <button type="submit" name="submit" class="btn btn-warning btn-flat"><i class="fa fa-search"></i></button>
                  </div>
                </div><!-- /.input-group -->
              </form>
              <br>
              <a href="../<?php 
echo FrontController::getInstance()->getClearController();
?>
" class="btn btn-warning">На главную</a>
            </div><!-- /.error-content -->
          </div><!-- /.error-page -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->

      <!-- Add the sidebar's background. This div must be placed
           immediately after the control sidebar -->
      <div class="control-sidebar-bg"></div>
    </div><!-- ./wrapper -->

  </body>
</html>
Exemplo n.º 10
0
 public function validateAction()
 {
     $fc = FrontController::getInstance();
     $model = new UserTableModel();
     $model->setTable('user');
     if (empty($fc->getParams()['email']) && empty($fc->getParams()['key'])) {
         header('Location: /');
         exit;
     }
     $model->setValidateUserData($fc->getParams());
     if ($model->checkValidKey()) {
         $output = $model->render('../views/user/validate.php', 'withoutSliderAndSidebarAndFooter');
         $fc->setPage($output);
     } else {
         Session::setMsg('Невозможно активировать данный аккаунт. Пожалуйста зарегистрируйтесь заново', 'warning');
         header('Location: /user/login');
         exit;
     }
 }
Exemplo n.º 11
0
<?php

use app\controllers\FrontController;
use app\helpers\Basket;
use app\services\Session;
/* Пути по-умолчанию для поиска файлов */
set_include_path(get_include_path() . PATH_SEPARATOR . 'app/controllers' . PATH_SEPARATOR . 'app/models' . PATH_SEPARATOR . 'app/services' . PATH_SEPARATOR . 'app/helpers' . PATH_SEPARATOR . 'app/tests' . PATH_SEPARATOR . 'app/widgets' . PATH_SEPARATOR . 'app/dataContainers');
/* Автозагрузчик классов */
spl_autoload_register(function ($class) {
    require_once $class . '.class.php';
});
//классы composer
require_once '/app/extensions/vendor/autoload.php';
Session::init();
Basket::init();
/* Инициализация и запуск FrontController */
$controller = FrontController::getInstance();
$controller->route();
/* Вывод данных */
echo $controller->getPage();
Exemplo n.º 12
0
 public function newSubCatAction()
 {
     $fc = FrontController::getInstance();
     $model = new SubCategoryTableModel();
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $model->setTable('subcategory');
         $model->setData();
         $model->addRecord();
     }
     //         header('Location: ' . $_SERVER['HTTP_REFERER']);
     //         exit;
 }