From aee73024e7bc8ae82b15390c309258d4247ad7c8 Mon Sep 17 00:00:00 2001 From: Yarik Date: Mon, 29 May 2017 19:06:13 +0300 Subject: [PATCH] Artbox great prepairings --- backend/config/main.php | 29 +++++++++++++++-------------- backend/controllers/SitemapController.php | 269 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- common/components/Sitemap.php | 149 ----------------------------------------------------------------------------------------------------------------------------------------------------- common/models/LoginForm.php | 106 ---------------------------------------------------------------------------------------------------------- common/models/PasswordResetRequestForm.php | 78 ------------------------------------------------------------------------------ common/models/ResetPasswordForm.php | 72 ------------------------------------------------------------------------ common/models/SignupForm.php | 99 --------------------------------------------------------------------------------------------------- common/models/SitemapDynamic.php | 120 ------------------------------------------------------------------------------------------------------------------------ common/models/SitemapStatic.php | 105 --------------------------------------------------------------------------------------------------------- console/controllers/CheckController.php | 2 -- frontend/assets/AppAsset.php | 1 - frontend/controllers/AccountController.php | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------- frontend/controllers/PageController.php | 12 +++++++++--- frontend/controllers/ProductController.php | 30 +++++++++++++++++++++--------- frontend/controllers/SiteController.php | 8 ++++---- frontend/views/layouts/main.php | 2 +- frontend/web/css/perfect-scrollbar.min.css | 0 frontend/web/js/perfect-scrollbar.min.js | 0 frontend/web/sitemap.xml | 22 +++++++++++++++++++++- 19 files changed, 144 insertions(+), 1044 deletions(-) delete mode 100755 backend/controllers/SitemapController.php delete mode 100755 common/components/Sitemap.php delete mode 100755 common/models/LoginForm.php delete mode 100755 common/models/PasswordResetRequestForm.php delete mode 100755 common/models/ResetPasswordForm.php delete mode 100755 common/models/SignupForm.php delete mode 100755 common/models/SitemapDynamic.php delete mode 100755 common/models/SitemapStatic.php mode change 100644 => 100755 frontend/web/css/perfect-scrollbar.min.css mode change 100644 => 100755 frontend/web/js/perfect-scrollbar.min.js diff --git a/backend/config/main.php b/backend/config/main.php index 0e70445..7af9726 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -1,7 +1,7 @@ 'backend\controllers', 'bootstrap' => [ 'log' ], 'controllerMap' => [ - 'profile' => 'artbox\core\controllers\ProfileController', - 'page' => 'artbox\core\controllers\PageController', - 'alias' => 'artbox\core\controllers\AliasController', + 'profile' => 'artbox\core\controllers\ProfileController', + 'page' => 'artbox\core\controllers\PageController', + 'alias' => 'artbox\core\controllers\AliasController', 'seo' => 'artbox\core\controllers\SeoController', 'feedback' => 'artbox\core\controllers\FeedbackController', 'weblog-article' => 'artbox\weblog\controllers\ArticleController', @@ -35,16 +35,17 @@ 'variant-option-complementary' => 'artbox\catalog\controllers\VariantOptionComplController', 'variant-option-exclusion' => 'artbox\catalog\controllers\VariantOptionExclController', 'product-option-complementary' => 'artbox\catalog\controllers\ProductOptionComplController', - 'product-option-exclusion' => 'artbox\catalog\controllers\ProductOptionExclController', - 'import' => 'artbox\catalog\controllers\ImportController', - 'blog-article' => 'artbox\weblog\controllers\ArticleController', - 'blog-category' => 'artbox\weblog\controllers\CategoryController', - 'blog-tag' => 'artbox\weblog\controllers\TagController', - 'order' => 'artbox\order\controllers\OrderController', - 'order-product' => 'artbox\order\controllers\OrderProductController', - 'label' => 'artbox\order\controllers\LabelController', - 'delivery' => 'artbox\order\controllers\DeliveryController', - 'payment' => 'artbox\order\controllers\PaymentController', + 'product-option-exclusion' => 'artbox\catalog\controllers\ProductOptionExclController', + 'import' => 'artbox\catalog\controllers\ImportController', + 'blog-article' => 'artbox\weblog\controllers\ArticleController', + 'blog-category' => 'artbox\weblog\controllers\CategoryController', + 'blog-tag' => 'artbox\weblog\controllers\TagController', + 'order' => 'artbox\order\controllers\OrderController', + 'order-product' => 'artbox\order\controllers\OrderProductController', + 'label' => 'artbox\order\controllers\LabelController', + 'delivery' => 'artbox\order\controllers\DeliveryController', + 'payment' => 'artbox\order\controllers\PaymentController', + 'sitemap' => 'artbox\core\controllers\SitemapController', ], 'components' => [ 'assetManager' => [ diff --git a/backend/controllers/SitemapController.php b/backend/controllers/SitemapController.php deleted file mode 100755 index caa6afc..0000000 --- a/backend/controllers/SitemapController.php +++ /dev/null @@ -1,269 +0,0 @@ - [ - 'class' => AccessControl::className(), - 'rules' => [ - [ - 'actions' => [ - 'login', - 'error', - ], - 'allow' => true, - ], - [ - 'allow' => true, - 'roles' => [ '@' ], - ], - ], - ], - ]; - } - - /** - * Action to configure sitemap of the website - * - * @return string - */ - public function actionIndex() - { - return $this->render('index'); - } - - /** - * Action to configure sitemap of the website - * - * @return string - */ - public function actionUpdate() - { - /** - * @var Sitemap $sitemap - */ - $request = \Yii::$app->request; - // ***** Generate SitemapDynamic models for every entity in Sitemap component - $sitemap = \Yii::$app->get('sitemap'); - $entities = $sitemap->entities; - /** - * @var SitemapDynamic[] $entity_models - */ - $entity_models = []; - foreach ($entities as $entity) { - $entity_model = new SitemapDynamic(); - $entity_model->entity = $entity[ 'class' ]; - $entity_model->status = SitemapDynamic::STATUS_DISABLED; - $entity_models[] = $entity_model; - } - // ***** <<< End - if ($request->isPost) { - $success = false; - // ***** Create SitemapStatic models from POST and delete existing - $models = []; - $index = 1; - foreach ($request->post('SitemapStatic') as $item) { - $model = new SitemapStatic(); - if ($model->load($item, '') && $model->validate()) { - $model->id = $index++; - $models[] = $model; - } - } - if (!empty( $models )) { - $old = SitemapStatic::find() - ->all(); - foreach ($old as $item) { - $item->delete(); - } - foreach ($models as $model) { - $model->save(false); - $success = true; - } - } - // ***** <<< End - // ***** Create SitemapDynamic models from POST and delete existing - - /** - * @var SitemapDynamic[] $old_entity_models - */ - $old_entity_models = SitemapDynamic::find() - ->all(); - foreach ($old_entity_models as $old_entity_model) { - $old_entity_model->delete(); - } - $index = 1; - $entity_models = []; - foreach ($request->post('SitemapDynamic') as $item) { - $entity = new SitemapDynamic(); - if ($entity->load($item, '') && $entity->validate()) { - $entity->id = $index++; - $entity->save(false); - $entity_models[] = $entity; - $success = true; - } - } - if ($success) { - if ($request->post('action', '') == 'generate') { - if ($sitemap->generateXML()) { - \Yii::$app->session->setFlash( - 'success', - \Yii::t( - 'core', - 'Карта сайта сгенерированна в ' . \Yii::getAlias( - $sitemap->path . '.' - ) - ) - ); - } - } - return $this->redirect([ 'index' ]); - } - // ***** <<< End - } else { - // ***** Find existing SitemapStatic models - $models = SitemapStatic::find() - ->all(); - if (empty( $models )) { - $models = [ new SitemapStatic() ]; - } - // ***** <<< End - // ***** Fill SitemapDynamic models from Sitemap component with existing models - /** - * @var SitemapDynamic[] $old_entity_models - */ - $old_entity_models = SitemapDynamic::find() - ->indexBy('entity') - ->all(); - foreach ($entity_models as $index => $entity_model) { - if (isset( $old_entity_models[ $entity_model->entity ] )) { - $entity_model->status = $old_entity_models[ $entity_model->entity ]->status; - $entity_model->priority = $old_entity_models[ $entity_model->entity ]->priority; - $entity_model->frequency = $old_entity_models[ $entity_model->entity ]->frequency; - } - } - // ***** <<< End - } - return $this->render( - 'update', - [ - 'models' => $models, - 'entity_models' => $entity_models, - ] - ); - } - - /** - * Create activeField for static sitemap - * - * @return string - */ - public function actionCreateStatic() - { - $content = ''; - $request = \Yii::$app->request; - $formId = $request->get('formId'); - $count = $request->get('count'); - if (empty( $formId ) || empty( $count )) { - return $this->renderContent($content); - } - $model = new SitemapStatic(); - $form = new ActiveForm(); - $content .= $form->field( - $model, - "[$count]url", - [ - 'options' => [ - 'class' => 'form-group col-xs-5 col-sm-6', - ], - ] - ) - ->textInput() - ->render(); - $content .= $form->field( - $model, - "[$count]frequency", - [ - 'options' => [ - 'class' => 'form-group col-xs-3 col-sm-3', - ], - ] - ) - ->dropDownList( - [ - 'always' => 'always', - 'hourly' => 'hourly', - 'daily' => 'daily', - 'weekly' => 'weekly', - 'monthly' => 'monthly', - 'yearly' => 'yearly', - 'never' => 'never', - ] - ) - ->render(); - $content .= $form->field( - $model, - "[$count]priority", - [ - 'options' => [ - 'class' => 'form-group col-xs-3 col-sm-2', - ], - ] - ) - ->textInput() - ->render(); - $content .= Html::icon( - 'minus', - [ - 'class' => 'col-xs-1 field-group-remove', - 'onclick' => 'sitemap_remove(this)', - ] - ); - foreach ($form->attributes as $index => $attribute) { - $content .= Html::script("$('#w0').yiiActiveForm('add', " . Json::htmlEncode($attribute) . ");"); - } - $content = Html::tag( - 'div', - $content, - [ - 'class' => 'row field-group', - ] - ); - $this->layout = false; - return $this->renderContent($content); - } - - /** - * Generate sitemap XML to Sitemap::$path - * - * @return bool - */ - public function actionGenerate() - { - $response = \Yii::$app->response; - $response->format = $response::FORMAT_JSON; - /** - * @var Sitemap $sitemap - */ - $sitemap = \Yii::$app->get('sitemap'); - return $sitemap->generateXML(); - } - } - \ No newline at end of file diff --git a/common/components/Sitemap.php b/common/components/Sitemap.php deleted file mode 100755 index a0f67cc..0000000 --- a/common/components/Sitemap.php +++ /dev/null @@ -1,149 +0,0 @@ -get('urlManagerFrontend'); - return $urlManager->createAbsoluteUrl('/' . $this->url); - } - - /** - * Check whether sitemap.xml exist - * - * @return bool - */ - public function checkFileExist(): bool - { - return file_exists(\Yii::getAlias($this->path)); - } - /** - * Generate sitemap XML in $path - * - * @return bool - */ - public function generateXML(): bool - { - return $this->saveXML($this->generateOneShot()); - } - - /** - * Save generated xml to $path file - * - * @param string $xml - * - * @return bool - */ - protected function saveXML(string $xml): bool - { - $realpath = \Yii::getAlias($this->path); - if (file_put_contents($realpath, $xml)) { - return true; - } else { - return false; - } - } - - /** - * Generate xml from configs - * - * @return string - */ - public function generateOneShot(): string - { - /** - * @var UrlManager $urlManager - */ - $urlManager = \Yii::$app->get('urlManagerFrontend'); - $content = ''; - $content .= ''; - /** - * @var SitemapStatic[] $static - */ - // ***** Begin generating static pages - $static = SitemapStatic::find() - ->all(); - foreach ($static as $item) { - $content .= Html::tag( - 'url', - Html::tag('loc', $item->url) . Html::tag('lastmod', date('Y-m-d')) . Html::tag( - 'changefreq', - $item->frequency - ) . Html::tag('priority', $item->priority) - ); - } - // ***** <<< End - /** - * @var SitemapDynamic $dynamic - */ - $dynamic = SitemapDynamic::find() - ->indexBy('entity') - ->where([ 'status' => 1 ]) - ->all(); - $entities = $this->entities; - foreach ($entities as $entity) { - /** - * @var string $class - */ - $class = $entity[ 'class' ]; - /** - * @var ActiveRecord $classInstance - */ - $classInstance = new $class(); - if (is_subclass_of($classInstance, ActiveRecord::className())) { - if (!empty( $dynamic[ $class ] )) { - /** - * @var SitemapDynamic $model - */ - $model = $dynamic[ $class ]; - $query = $classInstance::find(); - if (isset( $entity[ 'conditions' ] )) { - foreach ($entity[ 'conditions' ] as $condition) { - $query->where($condition); - } - } - $result = $query->all(); - foreach ($result as $record) { - $content .= Html::tag( - 'url', - Html::tag( - 'loc', - $urlManager->createAbsoluteUrl( - [ - $entity[ 'url' ], - 'id' => $record->getAttribute('id'), - ] - ) - ) . Html::tag('lastmod', date('Y-m-d')) . Html::tag( - 'changefreq', - $model->frequency - ) . Html::tag('priority', $model->priority) - ); - } - } - } - } - $content .= ''; - return $content; - } - } \ No newline at end of file diff --git a/common/models/LoginForm.php b/common/models/LoginForm.php deleted file mode 100755 index 853f4d0..0000000 --- a/common/models/LoginForm.php +++ /dev/null @@ -1,106 +0,0 @@ -hasErrors()) { - $user = $this->getUser(); - if (!$user || !$user->validatePassword($this->password)) { - $this->addError($attribute, 'Incorrect username or password.'); - } - } - } - - /** - * Logs in a user using the provided username and password. - * - * @return bool whether the user is logged in successfully - */ - public function login() - { - if ($this->validate()) { - return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); - } else { - return false; - } - } - - /** - * Finds user by [[username]] - * - * @return Customer|null - */ - protected function getUser() - { - if ($this->_user === null) { - $this->_user = Customer::findByUsername($this->username); - } - - return $this->_user; - } - - public function attributeLabels() - { - return [ - 'username' => Yii::t('app', 'Логин'), - 'password' => Yii::t('app', 'Пароль'), - 'rememberMe' => Yii::t('app', 'Запомнить'), - ]; - } - } diff --git a/common/models/PasswordResetRequestForm.php b/common/models/PasswordResetRequestForm.php deleted file mode 100755 index f621b3e..0000000 --- a/common/models/PasswordResetRequestForm.php +++ /dev/null @@ -1,78 +0,0 @@ - '\artbox\order\models\Customer', - 'filter' => [ 'status' => Customer::STATUS_ACTIVE ], - 'message' => 'There is no user with this email address.', - ], - ]; - } - /** - * Sends an email with a link, for resetting the password. - * - * @return bool whether the email was send - */ - public function sendEmail() - { - /* @var $user Customer */ - $user = Customer::findOne( - [ - 'status' => Customer::STATUS_ACTIVE, - 'email' => $this->email, - ] - ); - if (!$user) { - return false; - } - - if (!Customer::isPasswordResetTokenValid($user->password_reset_token)) { - $user->generatePasswordResetToken(); - if (!$user->save()) { - return false; - } - } - return Yii::$app->mailer->compose( - [ - 'html' => 'passwordResetToken-html', - 'text' => 'passwordResetToken-text', - ], - [ 'user' => $user ] - ) - ->setFrom([ Yii::$app->params[ 'supportEmail' ] => Yii::$app->name . ' robot' ]) - ->setTo($this->email) - ->setSubject('Password reset for ' . Yii::$app->name) - ->send(); - } - } \ No newline at end of file diff --git a/common/models/ResetPasswordForm.php b/common/models/ResetPasswordForm.php deleted file mode 100755 index 358d36e..0000000 --- a/common/models/ResetPasswordForm.php +++ /dev/null @@ -1,72 +0,0 @@ -_user = Customer::findByPasswordResetToken($token); - if (!$this->_user) { - throw new InvalidParamException('Wrong password reset token.'); - } - parent::__construct($config); - } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [ - 'password', - 'required', - ], - [ - 'password', - 'string', - 'min' => 6, - ], - ]; - } - - /** - * Resets password. - * - * @return bool if password was reset. - */ - public function resetPassword() - { - $user = $this->_user; - $user->setPassword($this->password); - $user->removePasswordResetToken(); - - return $user->save(false); - } - } \ No newline at end of file diff --git a/common/models/SignupForm.php b/common/models/SignupForm.php deleted file mode 100755 index 867fe3d..0000000 --- a/common/models/SignupForm.php +++ /dev/null @@ -1,99 +0,0 @@ - '\artbox\order\models\Customer', - 'message' => 'This username has already been taken.', - ], - [ - 'username', - 'string', - 'min' => 2, - 'max' => 255, - ], - - [ - 'email', - 'trim', - ], - [ - 'email', - 'required', - ], - [ - 'email', - 'email', - ], - [ - 'email', - 'string', - 'max' => 255, - ], - [ - 'email', - 'unique', - 'targetClass' => '\artbox\order\models\Customer', - 'message' => 'This email address has already been taken.', - ], - - [ - 'password', - 'required', - ], - [ - 'password', - 'string', - 'min' => 6, - ], - ]; - } - - /** - * Signs user up. - * - * @return \artbox\order\models\Customer|null the saved model or null if saving fails - */ - public function signup() - { - if (!$this->validate()) { - return null; - } - - $user = new Customer(); - $user->username = $this->username; - $user->email = $this->email; - $user->setPassword($this->password); - $user->generateAuthKey(); - - return $user->save() ? $user : null; - } - } \ No newline at end of file diff --git a/common/models/SitemapDynamic.php b/common/models/SitemapDynamic.php deleted file mode 100755 index 7d01f94..0000000 --- a/common/models/SitemapDynamic.php +++ /dev/null @@ -1,120 +0,0 @@ -get('sitemapdb'); - } - - /** - * @inheritdoc - */ - public function attributes() - { - return [ - 'id', - 'entity', - 'status', - 'priority', - 'frequency', - ]; - } - - /** - * @inheritdoc - */ - public static function primaryKey() - { - return [ 'id' ]; - } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [ - [ - 'entity', - 'status', - 'priority', - 'frequency', - ], - 'required', - ], - [ - [ - 'status', - ], - 'boolean', - ], - [ - [ - 'entity', - 'frequency', - ], - 'string', - ], - [ - [ - 'priority', - ], - 'double', - 'min' => 0, - 'max' => 1, - ], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => Yii::t('core', 'ID'), - 'entity' => Yii::t('core', 'Model'), - 'status' => Yii::t('core', 'Status'), - 'priority' => Yii::t('core', 'Priority'), - 'frequency' => Yii::t('core', 'Frequency'), - ]; - } - - /** - * Find maximum ID value from SitemapStatic models - */ - public static function max(): int - { - $models = self::find() - ->all(); - $array = ArrayHelper::getColumn($models, self::primaryKey()[ 0 ], false); - if (empty( $array )) { - return 0; - } else { - return max($array); - } - } - } \ No newline at end of file diff --git a/common/models/SitemapStatic.php b/common/models/SitemapStatic.php deleted file mode 100755 index 24b3be0..0000000 --- a/common/models/SitemapStatic.php +++ /dev/null @@ -1,105 +0,0 @@ -get('sitemapdb'); - } - - /** - * @inheritdoc - */ - public function attributes() - { - return [ - 'id', - 'url', - 'priority', - 'frequency', - ]; - } - - /** - * @inheritdoc - */ - public static function primaryKey() - { - return [ 'id' ]; - } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [ - [ - 'url', - 'priority', - ], - 'required', - ], - [ - [ - 'priority', - ], - 'double', - 'min' => 0, - 'max' => 1, - ], - [ - [ - 'url', - 'frequency', - ], - 'string', - ], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => Yii::t('core', 'ID'), - 'url' => Yii::t('core', 'Url'), - 'priority' => Yii::t('core', 'Priority'), - 'frequency' => Yii::t('core', 'Frequency'), - ]; - } - - /** - * Find maximum ID value from SitemapStatic models - */ - public static function max(): int - { - $models = self::find() - ->all(); - $array = ArrayHelper::getColumn($models, self::primaryKey()[ 0 ], false); - if (empty( $array )) { - return 0; - } else { - return max($array); - } - } - } \ No newline at end of file diff --git a/console/controllers/CheckController.php b/console/controllers/CheckController.php index efd9c07..6fdce23 100755 --- a/console/controllers/CheckController.php +++ b/console/controllers/CheckController.php @@ -2,9 +2,7 @@ namespace console\controllers; use yii\console\Controller; - use yii\db\Connection; use yii\db\Exception; - use yii\helpers\ArrayHelper; /** * Class CheckController diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index 7ec234f..06f8565 100755 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -14,7 +14,6 @@ public $css = [ 'css/animate.css', 'css/style.css', - // 'css/style.default.css', // - 'css/owl.carousel.css', 'css/owl.theme.css', '//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,500,700,800', diff --git a/frontend/controllers/AccountController.php b/frontend/controllers/AccountController.php index afba717..23490e3 100755 --- a/frontend/controllers/AccountController.php +++ b/frontend/controllers/AccountController.php @@ -8,8 +8,8 @@ use artbox\order\models\Wishlist; use yii\data\ActiveDataProvider; use yii\db\ActiveQuery; + use yii\filters\AccessControl; use yii\web\Controller; - use yii\web\ForbiddenHttpException; use yii\web\NotFoundHttpException; use yii\web\Response; @@ -20,9 +20,35 @@ */ class AccountController extends Controller { + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'access' => [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + ]; + } + + /** + * Account main page with orders + * + * @return string + */ public function actionIndex() { - $user = Customer::findOne(\Yii::$app->user->identity->getId()); + /** + * @var Customer $user + */ + $user = \Yii::$app->user->identity; $orders = $user->getOrders() ->with( @@ -46,12 +72,24 @@ ); } + /** + * Account detail order page + * + * @param $id + * + * @return string + * @throws \yii\web\NotFoundHttpException + */ public function actionOrder($id) { /** + * @var Customer $user + */ + $user = \Yii::$app->user->identity; + /** * @var Order $order */ - $order = Order::find() + $order = $user->getOrders() ->with('orderProducts.variant.product.lang') ->where( [ @@ -62,8 +100,6 @@ if (empty($order)) { throw new NotFoundHttpException(\Yii::t('app', 'Order not found')); - } elseif ($order->user_id !== \Yii::$app->user->identity->getId()) { - throw new ForbiddenHttpException(); } return $this->render( @@ -74,6 +110,11 @@ ); } + /** + * Acount info page + * + * @return string + */ public function actionAccount() { $user = \Yii::$app->user->identity; @@ -86,6 +127,11 @@ ); } + /** + * Account wishlist page + * + * @return string + */ public function actionWishlist() { /** @@ -114,7 +160,7 @@ ], ] ); - + return $this->render( 'wishlist', [ @@ -122,7 +168,12 @@ ] ); } - + + /** + * Account change password action + * + * @return string|\yii\web\Response + */ public function actionChangePassword() { /** @@ -165,6 +216,11 @@ } + /** + * Account change data action + * + * @return string|\yii\web\Response + */ public function actionChangeData() { /** @@ -188,6 +244,11 @@ ); } + /** + * Account delete from wishlist action + * + * @return array + */ public function actionWishlistDelete() { \Yii::$app->response->format = Response::FORMAT_JSON; @@ -201,21 +262,22 @@ ->andWhere( [ 'variant_id' => \Yii::$app->request->post('variant'), - + ] ) ->one(); if (!empty($model) && $model->delete()) { return [ 'success' => true, - 'message' => 'Товар удален из избранного', + 'message' => \Yii::t('app', 'Товар удален из избранного'), ]; } - + return [ 'success' => false, - 'message' => 'Ошибка', + 'message' => \Yii::t('app', 'Ошибка'), ]; } + return []; } } \ No newline at end of file diff --git a/frontend/controllers/PageController.php b/frontend/controllers/PageController.php index 8cd4b40..b0aee82 100755 --- a/frontend/controllers/PageController.php +++ b/frontend/controllers/PageController.php @@ -43,7 +43,13 @@ ] ); } - + + /** + * @param $id + * + * @return \artbox\core\models\Page + * @throws \yii\web\NotFoundHttpException + */ protected function findModel($id) { /** @@ -60,11 +66,11 @@ if (!empty( $model )) { if ($model->lang->alias_id !== Yii::$app->seo->aliasId) { - throw new NotFoundHttpException('Wrong language'); + throw new NotFoundHttpException(\Yii::t('app', 'Wrong language')); } return $model; } else { - throw new NotFoundHttpException('Model not found'); + throw new NotFoundHttpException(\Yii::t('app', 'Model not found')); } } } \ No newline at end of file diff --git a/frontend/controllers/ProductController.php b/frontend/controllers/ProductController.php index 47397cf..5e2121c 100755 --- a/frontend/controllers/ProductController.php +++ b/frontend/controllers/ProductController.php @@ -83,14 +83,19 @@ ->one(); if (!empty($model)) { if ($model->lang->alias_id !== $seo->aliasId) { - throw new NotFoundHttpException('Wrong language'); + throw new NotFoundHttpException(\Yii::t('app', 'Wrong language')); } return $model; } else { - throw new NotFoundHttpException('Model not found'); + throw new NotFoundHttpException(\Yii::t('app', 'Model not found')); } } + /** + * Remove product from wishlist + * + * @return array + */ public function actionWishlistRm() { \Yii::$app->response->format = Response::FORMAT_JSON; @@ -113,7 +118,7 @@ 'button' => Html::button( Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]), [ - 'title' => 'Добавить в избранное', + 'title' => \Yii::t('app', 'Добавить в избранное'), 'data' => [ 'toggle' => 'tooltip', 'placement' => 'top', @@ -125,7 +130,7 @@ 'class' => 'wishlist-add btn btn-success pull-right', ] ), - 'message' => 'Товар убран из избранного', + 'message' => \Yii::t('app', 'Товар убран из избранного'), ]; } @@ -133,7 +138,7 @@ 'button' => Html::button( Html::tag('i', '', [ 'class' => 'fa fa-heart' ]), [ - 'title' => 'Убрать из избранного', + 'title' => \Yii::t('app', 'Убрать из избранного'), 'data' => [ 'toggle' => 'tooltip', 'placement' => 'top', @@ -145,11 +150,17 @@ 'class' => 'wishlist-rm btn btn-success pull-right', ] ), - 'message' => 'Товар не найден', + 'message' => \Yii::t('app', 'Товар не найден'), ]; } + return []; } + /** + * Add product to wishlist + * + * @return array + */ public function actionWishlistAdd() { \Yii::$app->response->format = Response::FORMAT_JSON; @@ -164,7 +175,7 @@ 'button' => Html::button( Html::tag('i', '', [ 'class' => 'fa fa-heart' ]), [ - 'title' => 'Убрать из избранного', + 'title' => \Yii::t('app', 'Убрать из избранного'), 'data' => [ 'toggle' => 'tooltip', 'placement' => 'top', @@ -184,7 +195,7 @@ 'button' => Html::button( Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]), [ - 'title' => 'Добавить в избранное', + 'title' => \Yii::t('app', 'Добавить в избранное'), 'data' => [ 'toggle' => 'tooltip', 'placement' => 'top', @@ -196,8 +207,9 @@ 'class' => 'wishlist-add btn btn-success pull-right', ] ), - 'message' => 'Товар добавить не вышло', + 'message' => \Yii::t('app', 'Товар добавить не вышло'), ]; } + return []; } } \ No newline at end of file diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 1c93637..b1f2b46 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -7,12 +7,12 @@ use artbox\catalog\models\Product; use artbox\core\models\DummyAlias; use artbox\core\models\Feedback; + use artbox\order\models\LoginForm; + use artbox\order\models\PasswordResetRequestForm; + use artbox\order\models\ResetPasswordForm; + use artbox\order\models\SignupForm; use artbox\weblog\models\Article; - use common\models\LoginForm; - use common\models\PasswordResetRequestForm; - use common\models\ResetPasswordForm; use common\models\Settings; - use common\models\SignupForm; use Yii; use yii\base\InvalidParamException; use yii\bootstrap\Html; diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 2c3419d..3b3eb9a 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -11,7 +11,7 @@ use artbox\core\models\Image; use artbox\core\models\Page; use artbox\core\models\User; - use common\models\LoginForm; + use artbox\order\models\LoginForm; use common\models\Newsletter; use common\models\SearchForm; use common\models\Settings; diff --git a/frontend/web/css/perfect-scrollbar.min.css b/frontend/web/css/perfect-scrollbar.min.css old mode 100644 new mode 100755 index 686b6a1..686b6a1 --- a/frontend/web/css/perfect-scrollbar.min.css +++ b/frontend/web/css/perfect-scrollbar.min.css diff --git a/frontend/web/js/perfect-scrollbar.min.js b/frontend/web/js/perfect-scrollbar.min.js old mode 100644 new mode 100755 index ace5733..ace5733 --- a/frontend/web/js/perfect-scrollbar.min.js +++ b/frontend/web/js/perfect-scrollbar.min.js diff --git a/frontend/web/sitemap.xml b/frontend/web/sitemap.xml index 8efe869..421bc0f 100755 --- a/frontend/web/sitemap.xml +++ b/frontend/web/sitemap.xml @@ -1 +1,21 @@ - \ No newline at end of file + + + + artbox.dev + 2017-05-29 + always + 1 + + + http://www.artbox.dev/ru/o-nas + 2017-05-29 + always + 1 + + + http://www.artbox.dev/ru/dostavka-i-oplata + 2017-05-29 + always + 1 + + \ No newline at end of file -- libgit2 0.21.4