diff --git a/backend/controllers/ArticlesController.php b/backend/controllers/ArticlesController.php index 18d0a67..aaf9835 100644 --- a/backend/controllers/ArticlesController.php +++ b/backend/controllers/ArticlesController.php @@ -86,17 +86,7 @@ $model_langs = $model->generateLangs(); if($model->load(Yii::$app->request->post())) { $model->loadLangs(\Yii::$app->request, $model_langs); - if(( $image = UploadedFile::getInstance($model, 'image') )) { - $model->image = $image->name; - } - $imgDir = Yii::getAlias('@storage/articles/'); - if(!is_dir($imgDir)) { - mkdir($imgDir, 0755, true); - } if($model->save()) { - if($image) { - $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name)); - } if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return $this->redirect([ 'view', @@ -130,17 +120,7 @@ $model_langs = $model->generateLangs(); if($model->load(Yii::$app->request->post())) { $model->loadLangs(\Yii::$app->request, $model_langs); - if(( $image = UploadedFile::getInstance($model, 'image') )) { - $model->image = $image->name; - } - $imgDir = Yii::getAlias('@storage/articles/'); - if(!is_dir($imgDir)) { - mkdir($imgDir, 0755, true); - } if($model->save()) { - if($image) { - $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name)); - } if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return $this->redirect([ 'view', diff --git a/backend/controllers/BannerController.php b/backend/controllers/BannerController.php index b20f9ad..c58fba4 100644 --- a/backend/controllers/BannerController.php +++ b/backend/controllers/BannerController.php @@ -2,7 +2,6 @@ namespace backend\controllers; - use common\modules\file\widgets\ImageUploader; use Yii; use common\models\Banner; use common\models\BannerSearch; diff --git a/backend/controllers/BgController.php b/backend/controllers/BgController.php index 894d2c4..589c5fe 100644 --- a/backend/controllers/BgController.php +++ b/backend/controllers/BgController.php @@ -119,7 +119,7 @@ $model_langs = $model->generateLangs(); if($model->load(Yii::$app->request->post()) && $model->save()) { - $model->loadLangs(\Yii::$app->request); + $model->loadLangs(\Yii::$app->request, $model_langs); if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return $this->redirect([ 'view', diff --git a/backend/controllers/BrandController.php b/backend/controllers/BrandController.php index 1915924..f105d03 100644 --- a/backend/controllers/BrandController.php +++ b/backend/controllers/BrandController.php @@ -9,7 +9,6 @@ use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii\filters\AccessControl; - use yii\web\UploadedFile; /** * BrandController implements the CRUD actions for Brand model. diff --git a/backend/controllers/CategoryController.php b/backend/controllers/CategoryController.php index c3dd0ef..3d2a8d5 100644 --- a/backend/controllers/CategoryController.php +++ b/backend/controllers/CategoryController.php @@ -88,14 +88,8 @@ if($model->load(Yii::$app->request->post())) { $model->loadLangs(\Yii::$app->request, $model_langs); - if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) { - $model->image = $image->name; - } if($model->save()) { - if($image) { - $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name)); - } if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ @@ -117,7 +111,7 @@ 'model' => $model, 'model_langs' => $model_langs, 'categories' => ArtboxTreeHelper::treeMap(Category::find() - ->getTree(), 'category_id', 'name', '.'), + ->getTree(), 'category_id', 'category_id', '.'), ]); } @@ -136,14 +130,8 @@ $model_langs = $model->generateLangs(); if($model->load(Yii::$app->request->post())) { - if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) { - $model->image = $image->name; - } $model->loadLangs(\Yii::$app->request, $model_langs); if($model->save()) { - if($image) { - $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name)); - } if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return $this->redirect([ 'view', @@ -156,7 +144,7 @@ 'model' => $model, 'model_langs' => $model_langs, 'categories' => ArtboxTreeHelper::treeMap(Category::find() - ->getTree(), 'category_id', 'name', '.'), + ->getTree(), 'category_id', 'category_id', '.'), ]); } diff --git a/backend/controllers/EventController.php b/backend/controllers/EventController.php index 4e3b0d6..dece42b 100644 --- a/backend/controllers/EventController.php +++ b/backend/controllers/EventController.php @@ -9,7 +9,6 @@ use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use developeruz\db_rbac\behaviors\AccessBehavior; - use yii\web\UploadedFile; /** * EventController implements the CRUD actions for Event model. @@ -89,14 +88,7 @@ $model->loadLangs(\Yii::$app->request, $model_langs); - if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) { - $model->image = $image->name; - } - if($model->save()) { - if($image) { - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name)); - } if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return $this->redirect([ 'view', @@ -133,14 +125,7 @@ $model->loadLangs(\Yii::$app->request, $model_langs); - if(( $image = UploadedFile::getInstance($model, 'imageUpload') )) { - $model->image = $image->name; - } - if($model->save()) { - if($image) { - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name)); - } if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return $this->redirect([ 'view', diff --git a/backend/controllers/ProjectController.php b/backend/controllers/ProjectController.php index fc963cb..20380b8 100644 --- a/backend/controllers/ProjectController.php +++ b/backend/controllers/ProjectController.php @@ -201,8 +201,9 @@ $project = $this->findModel($id); $model = new ProductToProject(); $products = Product::find() + ->distinct() ->select([ - 'product.name', + 'product.product_id', 'product.product_id', ]) ->joinWith('variants', true, 'INNER JOIN') @@ -221,7 +222,6 @@ if(!empty( $model->product_id ) && !empty( $products[ $model->product_id ] )) { $variants = ProductVariant::find() ->select([ - 'name', 'product_variant_id', ]) ->where([ 'product_id' => $model->product_id ]) @@ -261,7 +261,7 @@ } $products = Product::find() ->select([ - 'product.name', + 'product.product_id', 'product.product_id', ]) ->joinWith('variants', true, 'INNER JOIN') @@ -272,7 +272,6 @@ if(!empty( $model->product_id ) && !empty( $products[ $model->product_id ] )) { $variants = ProductVariant::find() ->select([ - 'name', 'product_variant_id', ]) ->where([ 'product_id' => $model->product_id ]) diff --git a/backend/controllers/SliderImageController.php b/backend/controllers/SliderImageController.php index 675daa1..6a792c8 100644 --- a/backend/controllers/SliderImageController.php +++ b/backend/controllers/SliderImageController.php @@ -10,7 +10,6 @@ use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; - use yii\web\UploadedFile; /** * SliderImageController implements the CRUD actions for SliderImage model. @@ -97,38 +96,29 @@ if($model->load(Yii::$app->request->post())) { $model->loadLangs(\Yii::$app->request, $model_langs); $model->slider_id = $slider_id; - if(( $image = UploadedFile::getInstance($model, 'image') )) { - $model->image = $image->name; - } - if($model->save() && $image) { - $imgDir = Yii::getAlias('@storage/slider/'); - if(!is_dir($imgDir)) { - mkdir($imgDir, 0755, true); + if($model->save()) { + if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { + return $this->redirect([ + 'view', + 'slider_id' => $slider_id, + 'id' => $model->slider_image_id, + ]); + } else { + return $this->redirect([ + 'update', + 'slider_id' => $slider_id, + 'id' => $model->slider_image_id, + ]); } - $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name)); - } - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { - return $this->redirect([ - 'view', - 'slider_id' => $slider_id, - 'id' => $model->slider_image_id, - ]); - } else { - return $this->redirect([ - 'update', - 'slider_id' => $slider_id, - 'id' => $model->slider_image_id, - ]); } - } else { - $slider = Slider::findOne($slider_id); - return $this->render('create', [ - 'slider_id' => $slider_id, - 'model' => $model, - 'model_langs' => $model_langs, - 'slider' => $slider, - ]); } + $slider = Slider::findOne($slider_id); + return $this->render('create', [ + 'slider_id' => $slider_id, + 'model' => $model, + 'model_langs' => $model_langs, + 'slider' => $slider, + ]); } /** @@ -146,20 +136,7 @@ $model_langs = $model->generateLangs(); if($model->load(Yii::$app->request->post())) { $model->loadLangs(\Yii::$app->request, $model_langs); - if(( $image = UploadedFile::getInstance($model, 'image') )) { - $model->image = $image->name; - } - if(!$model->image) { - $model->image = $model->getOldAttribute('image'); - } - if($model->save() && $image) { - $imgDir = Yii::getAlias('@storage/slider/'); - if(!is_dir($imgDir)) { - mkdir($imgDir, 0755, true); - } - $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name)); - } - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { + if($model->save() && $model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return $this->redirect([ 'view', 'slider_id' => $slider_id, diff --git a/backend/models/Label.php b/backend/models/Label.php index bcf0b24..98d0d73 100644 --- a/backend/models/Label.php +++ b/backend/models/Label.php @@ -11,9 +11,9 @@ use yii\web\Request; * Class Label * * * From language behavior * - * @property {TableLang} $lang - * @property {TableLang}[] $langs - * @property {TableLang} $object_lang + * @property OrdersLabelLang $lang + * @property OrdersLabelLang[] $langs + * @property OrdersLabelLang $object_lang * @property string $ownerKey * @property string $langKey * @method string getOwnerKey() @@ -22,7 +22,7 @@ use yii\web\Request; * @method void setLangKey(string $value) * @method ActiveQuery getLangs() * @method ActiveQuery getLang( integer $language_id ) - * @method {TableLang}[] generateLangs() + * @method OrdersLabelLang[] generateLangs() * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) * @method bool linkLangs(ActiveRecord[] $model_langs) * @method bool saveLangs(ActiveRecord[] $model_langs) @@ -44,8 +44,4 @@ class Label extends \yii\db\ActiveRecord ], ]; } - - public function getNl(){ - return $this->name; - } } diff --git a/backend/views/articles/_form.php b/backend/views/articles/_form.php index b615fbb..07698f5 100644 --- a/backend/views/articles/_form.php +++ b/backend/views/articles/_form.php @@ -29,31 +29,9 @@ ->widget(DatePicker::className(), [ 'dateFormat' => 'dd-MM-yyyy', ]) ?> - = $form->field($model, 'title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'body') - ->widget(CKEditor::className(), [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ - 'preset' => 'full', - 'inline' => false, - 'filebrowserUploadUrl' => Yii::$app->getUrlManager() - ->createUrl('file/uploader/images-upload'), - ]), - ]) ?> - - = $form->field($model, 'body_preview') - ->widget(CKEditor::className(), [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ - 'preset' => 'full', - 'inline' => false, - 'filebrowserUploadUrl' => Yii::$app->getUrlManager() - ->createUrl('file/uploader/images-upload'), - ]), - ]) ?> = $form->field($model, 'image') - ->widget(\kartik\file\FileInput::classname(), [ + ->widget(\kartik\file\FileInput::className(), [ 'language' => 'ru', 'options' => [ 'accept' => 'image/*', @@ -73,24 +51,6 @@ ], ]); ?> - = $form->field($model, 'translit') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta_title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta_keywords') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta_description') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'seo_text') - ->textarea([ 'rows' => 6 ]) ?> - - = $form->field($model, 'h1') - ->textInput([ 'maxlength' => true ]) ?> - $model_langs, diff --git a/backend/views/articles/_form_language.php b/backend/views/articles/_form_language.php index 9f280fa..8ad752c 100644 --- a/backend/views/articles/_form_language.php +++ b/backend/views/articles/_form_language.php @@ -15,6 +15,8 @@ ?> = $form->field($model_lang, '[' . $language->language_id . ']title') ->textInput([ 'maxlength' => true ]); ?> += $form->field($model_lang, '[' . $language->language_id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> = $form->field($model_lang, '[' . $language->language_id . ']body') ->widget(CKEditor::className(), [ 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ diff --git a/backend/views/articles/create.php b/backend/views/articles/create.php index 33777c0..2e4d10e 100644 --- a/backend/views/articles/create.php +++ b/backend/views/articles/create.php @@ -9,9 +9,9 @@ * @var Articles $model * @var ArticlesLang[] $model_langs */ - $this->title = 'Create Articles'; + $this->title = \Yii::t('app', 'Create Articles'); $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Articles', + 'label' => \Yii::t('app', 'Articles'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = $this->title; diff --git a/backend/views/articles/index.php b/backend/views/articles/index.php index f97b4d3..7d2856a 100644 --- a/backend/views/articles/index.php +++ b/backend/views/articles/index.php @@ -7,34 +7,22 @@ use yii\grid\GridView; /* @var $searchModel common\models\ArticlesSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ -$this->title = 'Articles'; +$this->title = \Yii::t('app', 'Articles'); $this->params['breadcrumbs'][] = $this->title; ?> -
- = Html::a('Create Articles', ['create'], ['class' => 'btn btn-success']) ?> + = Html::a(\Yii::t('app', 'Create Articles'), ['create'], ['class' => 'btn btn-success']) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'id', 'date', - 'title', - 'image', - // 'translit', - // 'meta_title', - // 'meta_keywords', - // 'meta_description', - // 'seo_text:ntext', - // 'h1', - + 'imageUrl:image', ['class' => 'yii\grid\ActionColumn'], ], ]); ?> diff --git a/backend/views/articles/update.php b/backend/views/articles/update.php index 5c7a71c..20b26de 100644 --- a/backend/views/articles/update.php +++ b/backend/views/articles/update.php @@ -9,19 +9,19 @@ * @var Articles $model * @var ArticlesLang[] $model_langs */ - $this->title = 'Update Articles: ' . $model->title; + $this->title = \Yii::t('app', 'Update Articles').': ' . $model->id; $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Articles', + 'label' => \Yii::t('app', 'Articles'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->title, + 'label' => $model->id, 'url' => [ 'view', 'id' => $model->id, ], ]; - $this->params[ 'breadcrumbs' ][] = 'Update'; + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Update'); ?>- = Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> - = Html::a('Delete', ['delete', 'id' => $model->id], [ + = Html::a(\Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> + = Html::a(\Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [ 'class' => 'btn btn-danger', 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', + 'confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post', ], ]) ?>
- = DetailView::widget([ 'model' => $model, 'attributes' => [ 'id', 'date', - 'title', - 'translit', - 'meta_title', - 'meta_keywords', - 'meta_description', - 'h1', ], ]) ?> -- = Html::a(Yii::t('app', 'Create Banner'), ['create'], ['class' => 'btn btn-success']) ?> + = Html::a(Yii::t('app', 'Create Banner'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], 'banner_id', - 'image', - 'alt', - 'title', - // 'url:url', - // 'status', - - ['class' => 'yii\grid\ActionColumn'], + 'url', + 'status', + [ 'class' => 'yii\grid\ActionColumn' ], ], ]); ?>- = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->banner_id], ['class' => 'btn btn-primary']) ?> - = Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->banner_id], [ + = Html::a(Yii::t('app', 'Update'), [ + 'update', + 'id' => $model->banner_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(Yii::t('app', 'Delete'), [ + 'delete', + 'id' => $model->banner_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?>
- + = DetailView::widget([ 'model' => $model, 'attributes' => [ 'banner_id', - 'image', - 'alt', - 'title', - 'url:url', + 'url', 'status', ], ]) ?> diff --git a/backend/views/bg/_form.php b/backend/views/bg/_form.php index a3b4080..13eeadb 100644 --- a/backend/views/bg/_form.php +++ b/backend/views/bg/_form.php @@ -17,16 +17,37 @@- = Html::a('Create Bg', ['create'], ['class' => 'btn btn-success']) ?> + = Html::a(\Yii::t('app', 'Create Bg'), ['create'], ['class' => 'btn btn-success']) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'id', - 'title', - 'url:url', - 'image', - + 'url', + 'imageUrl:image', ['class' => 'yii\grid\ActionColumn'], ], ]); ?> diff --git a/backend/views/bg/update.php b/backend/views/bg/update.php index e0ac501..8f919d8 100644 --- a/backend/views/bg/update.php +++ b/backend/views/bg/update.php @@ -11,19 +11,19 @@ * @var BgLang[] $model_langs */ - $this->title = 'Update Bg: ' . $model->title; + $this->title = \Yii::t('app', 'Update Bg: ') . $model->id; $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Bgs', + 'label' => \Yii::t('app', 'Bgs'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->title, + 'label' => $model->id, 'url' => [ 'view', 'id' => $model->id, ], ]; - $this->params[ 'breadcrumbs' ][] = 'Update'; + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Update'); ?>- = Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> - = Html::a('Delete', ['delete', 'id' => $model->id], [ + = Html::a(\Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> + = Html::a(\Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [ 'class' => 'btn btn-danger', 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', + 'confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post', ], ]) ?> @@ -29,9 +29,8 @@ $this->params['breadcrumbs'][] = $this->title; 'model' => $model, 'attributes' => [ 'id', - 'title', - 'url:url', - 'image', + 'url', + 'imageUrl:image', ], ]) ?> diff --git a/backend/views/brand/_form.php b/backend/views/brand/_form.php index 599b346..d41f39d 100644 --- a/backend/views/brand/_form.php +++ b/backend/views/brand/_form.php @@ -22,14 +22,8 @@ 'options' => [ 'enctype' => 'multipart/form-data' ], ]); ?> - = $form->field($model, 'name') - ->textInput() ?> - - = $form->field($model, 'alias') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'image') - ->widget(\kartik\file\FileInput::classname(), [ + ->widget(\kartik\file\FileInput::className(), [ 'language' => 'ru', 'options' => [ 'accept' => 'image/*', @@ -49,18 +43,6 @@ ], ]); ?> - = $form->field($model, 'meta_title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta_desc') - ->textarea([ 'rows' => 6 ]) ?> - - = $form->field($model, 'meta_robots') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'seo_text') - ->textarea([ 'rows' => 6 ]) ?> - = LanguageForm::widget([ 'model_langs' => $model_langs, 'formView' => '@backend/views/brand/_form_language', diff --git a/backend/views/brand/_form_language.php b/backend/views/brand/_form_language.php index a4ba5e9..6447ba1 100644 --- a/backend/views/brand/_form_language.php +++ b/backend/views/brand/_form_language.php @@ -14,6 +14,9 @@ = $form->field($model_lang, '[' . $language->language_id . ']name') ->textInput([ 'maxlength' => true ]); ?> += $form->field($model_lang, '[' . $language->language_id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> + = $form->field($model_lang, '[' . $language->language_id . ']meta_title') ->textInput([ 'maxlength' => true ]) ?> diff --git a/backend/views/brand/index.php b/backend/views/brand/index.php index d1295f1..fa911f5 100644 --- a/backend/views/brand/index.php +++ b/backend/views/brand/index.php @@ -13,27 +13,16 @@ $this->params['breadcrumbs'][] = $this->title;
= Html::a(Yii::t('product', 'Create Brand'), ['create'], ['class' => 'btn btn-success']) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, -// 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - - 'name', - 'alias', - [ - 'attribute' => 'title', - 'format' => 'html', - 'value' => function($data) { - return Html::img($data->imageUrl, ['width'=>'100']); - }, - ], - + 'brand_id', + 'imageUrl:image', ['class' => 'yii\grid\ActionColumn'], ], ]); ?> diff --git a/backend/views/brand/view.php b/backend/views/brand/view.php index 083cb2e..e73e094 100644 --- a/backend/views/brand/view.php +++ b/backend/views/brand/view.php @@ -29,12 +29,7 @@ $this->params['breadcrumbs'][] = $this->title; 'model' => $model, 'attributes' => [ 'brand_id', - 'alias', 'imageUrl:image', - 'meta_title', - 'meta_desc:ntext', - 'meta_robots', - 'seo_text:ntext', ], ]) ?> diff --git a/backend/views/category/_form.php b/backend/views/category/_form.php index 596d70a..973ecb8 100644 --- a/backend/views/category/_form.php +++ b/backend/views/category/_form.php @@ -6,8 +6,6 @@ use yii\helpers\Html; use yii\web\View; use yii\widgets\ActiveForm; - use mihaildev\ckeditor\CKEditor; - use mihaildev\elfinder\ElFinder; /** * @var View $this @@ -25,12 +23,6 @@ 'options' => [ 'enctype' => 'multipart/form-data' ], ]); ?> - = $form->field($model, 'name') - ->textInput() ?> - - = $form->field($model, 'alias') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'parent_id') ->dropDownList($categories, [ 'prompt' => Yii::t('rubrication', 'Root category'), @@ -40,26 +32,8 @@ ]) ->label(Yii::t('product', 'Parent category')) ?> - - = $form->field($model, 'taxGroup')->widget(Select2::className(), [ - 'data' => \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'), - 'language' => 'ru', - 'options' => [ - 'placeholder' => 'Linked options', - 'multiple' => true, - ], - 'pluginOptions' => [ - 'allowClear' => true - ], - ] - ) ?> - */ - ?> - - = $form->field($model, 'imageUpload') - ->widget(\kartik\file\FileInput::classname(), [ + = $form->field($model, 'image') + ->widget(\kartik\file\FileInput::className(), [ 'language' => 'ru', 'options' => [ 'accept' => 'image/*', @@ -80,30 +54,6 @@ ]) ->hint('Для корректного отображения на сайте, размер изображения должен быть 262x144 либо соблюдать соотношение сторон примерно 2:1'); ?> - = $form->field($model, 'meta_title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta_desc') - ->textarea([ 'rows' => 6 ]) ?> - - = $form->field($model, 'meta_robots') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'h1') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'seo_text') - ->widget(CKEditor::className(), [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ - 'preset' => 'full', - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать - 'inline' => false, - //по умолчанию false]), - 'filebrowserUploadUrl' => Yii::$app->getUrlManager() - ->createUrl('file/uploader/images-upload'), - ]), - ]) ?> - = LanguageForm::widget([ 'model_langs' => $model_langs, 'formView' => '@backend/views/category/_form_language', diff --git a/backend/views/category/_form_language.php b/backend/views/category/_form_language.php index 9087fb8..9e0c533 100644 --- a/backend/views/category/_form_language.php +++ b/backend/views/category/_form_language.php @@ -14,6 +14,9 @@ = $form->field($model_lang, '[' . $language->language_id . ']name') ->textInput([ 'maxlength' => true ]); ?> += $form->field($model_lang, '[' . $language->language_id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> + = $form->field($model_lang, '[' . $language->language_id . ']meta_title') ->textInput([ 'maxlength' => true ]) ?> diff --git a/backend/views/category/index.php b/backend/views/category/index.php index b93a275..dbf9a38 100644 --- a/backend/views/category/index.php +++ b/backend/views/category/index.php @@ -1,5 +1,6 @@ Yii::t('product', 'Name'), 'content' => function($data) { + /** + * @var Category $data + */ $op = []; foreach($data->getParents() ->all() as $parent) { - $op[] = $parent->name; + $op[] = $parent->category_id; } - $op[] = $data->name; + $op[] = $data->category_id; return implode(' → ', $op); }, ], diff --git a/backend/views/category/update.php b/backend/views/category/update.php index e951b6d..f0a8b77 100644 --- a/backend/views/category/update.php +++ b/backend/views/category/update.php @@ -14,13 +14,13 @@ $this->title = Yii::t('product', 'Update {modelClass}: ', [ 'modelClass' => 'Category', - ]) . ' ' . $model->name; + ]) . ' ' . $model->category_id; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('product', 'Categories'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->name, + 'label' => $model->category_id, 'url' => [ 'view', 'id' => $model->category_id, diff --git a/backend/views/category/view.php b/backend/views/category/view.php index 643c0e9..cf76c6b 100644 --- a/backend/views/category/view.php +++ b/backend/views/category/view.php @@ -6,7 +6,7 @@ use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model common\modules\product\models\Category */ -$this->title = $model->name; +$this->title = $model->category_id; $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Categories'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> @@ -25,7 +25,7 @@ $this->params['breadcrumbs'][] = $this->title; ]) ?> = Html::a(Yii::t('product', 'Create Category'), ['category/create'], ['class' => 'btn btn-success']) ?> parent_id)) :?> - = Html::a(Yii::t('product', 'Create category By {name}', ['name' => $model->parent->name]), ['category/create?parent='. $model->parent->category_id], ['class' => 'btn btn-success']) ?> + = Html::a(Yii::t('product', 'Create category By {name}', ['name' => $model->parent->category_id]), ['category/create?parent='. $model->parent->category_id], ['class' => 'btn btn-success']) ?> @@ -37,13 +37,7 @@ $this->params['breadcrumbs'][] = $this->title; 'path', 'depth', 'imageUrl:image', - 'meta_title', - 'meta_desc:ntext', - 'meta_robots', - 'h1', - 'seo_text:ntext', 'product_unit_id', - 'alias', ], ]) ?> diff --git a/backend/views/event/_form.php b/backend/views/event/_form.php index 764fd36..472c404 100644 --- a/backend/views/event/_form.php +++ b/backend/views/event/_form.php @@ -25,25 +25,6 @@ 'options' => [ 'enctype' => 'multipart/form-data' ], ]); ?> - = $form->field($model, 'name') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'alias') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'body') - ->widget(CKEditor::className(), [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ - 'preset' => 'full', - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать - 'inline' => false, - //по умолчанию false]), - 'filebrowserUploadUrl' => Yii::$app->getUrlManager() - ->createUrl('file/uploader/images-upload'), - ]), - ]) ?> - - = $form->field($model, 'end_at') ->widget(DatePicker::className(), [ 'pluginOptions' => [ @@ -53,7 +34,7 @@ ]) ?> - = $form->field($model, 'imageUpload') + = $form->field($model, 'image') ->widget(\kartik\file\FileInput::className(), [ 'language' => 'ru', 'options' => [ @@ -74,18 +55,6 @@ ], ]); ?> - = $form->field($model, 'meta_title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'description') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'h1') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'seo_text') - ->textarea([ 'rows' => 6 ]) ?> - = LanguageForm::widget([ 'model_langs' => $model_langs, 'formView' => '@backend/views/event/_form_language', diff --git a/backend/views/event/_form_language.php b/backend/views/event/_form_language.php index 0b4257d..42e7a78 100644 --- a/backend/views/event/_form_language.php +++ b/backend/views/event/_form_language.php @@ -15,6 +15,10 @@ ?> = $form->field($model_lang, '[' . $language->language_id . ']name') ->textInput([ 'maxlength' => true ]); ?> + += $form->field($model_lang, '[' . $language->language_id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> + = $form->field($model_lang, '[' . $language->language_id . ']body') ->widget(CKEditor::className(), [ 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ diff --git a/backend/views/event/index.php b/backend/views/event/index.php index b87b7b9..a227ed0 100644 --- a/backend/views/event/index.php +++ b/backend/views/event/index.php @@ -1,45 +1,31 @@ title = Yii::t('app', 'Events'); -$this->params['breadcrumbs'][] = $this->title; + + use yii\helpers\Html; + use yii\grid\GridView; + + /* @var $this yii\web\View */ + /* @var $searchModel common\models\EventSearch */ + /* @var $dataProvider yii\data\ActiveDataProvider */ + + $this->title = Yii::t('app', 'Events'); + $this->params[ 'breadcrumbs' ][] = $this->title; ?>- = Html::a(Yii::t('app', 'Create Event'), ['create'], ['class' => 'btn btn-success']) ?> + = Html::a(Yii::t('app', 'Create Event'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], 'event_id', - 'name', - 'alias', - [ - 'format' => 'image', - 'attribute'=>'image', - ], - // 'meta_title', - // 'description', - // 'h1', - // 'seo_text:ntext', - // 'created_at', - // 'updated_at', - // 'end_at', - - ['class' => 'yii\grid\ActionColumn'], + 'imageUrl:image', + [ 'class' => 'yii\grid\ActionColumn' ], ], ]); ?>- = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->event_id], ['class' => 'btn btn-primary']) ?> - = Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->event_id], [ + = Html::a(Yii::t('app', 'Update'), [ + 'update', + 'id' => $model->event_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(Yii::t('app', 'Delete'), [ + 'delete', + 'id' => $model->event_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?>
- + = DetailView::widget([ 'model' => $model, 'attributes' => [ 'event_id', - 'name', - 'alias', - 'meta_title', - 'description', - 'h1', + 'imageUrl:image', ], ]) ?> diff --git a/backend/views/page/_form.php b/backend/views/page/_form.php index 773723a..95f9c0c 100644 --- a/backend/views/page/_form.php +++ b/backend/views/page/_form.php @@ -6,8 +6,6 @@ use yii\helpers\Html; use yii\web\View; use yii\widgets\ActiveForm; - use mihaildev\ckeditor\CKEditor; - use mihaildev\elfinder\ElFinder; /** * @var View $this @@ -21,49 +19,15 @@ - = $form->field($model, 'title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'translit') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'body') - ->widget(CKEditor::className(), [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ - 'preset' => 'full', - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать - 'inline' => false, - //по умолчанию false]), - 'allowedContent' => true, - 'filebrowserUploadUrl' => Yii::$app->getUrlManager() - ->createUrl('file/uploader/images-upload'), - ]), - ]) ?> - - = $form->field($model, 'meta_title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta_keywords') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta_description') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'seo_text') - ->textarea([ 'rows' => 6 ]) ?> - - = $form->field($model, 'h1') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'in_menu') - ->checkbox() ?> - = LanguageForm::widget([ 'model_langs' => $model_langs, 'formView' => '@backend/views/page/_form_language', 'form' => $form, ]) ?> + = $form->field($model, 'in_menu') + ->checkbox() ?> +- = Html::a('Create Page', ['create'], ['class' => 'btn btn-success']) ?> + = Html::a(\Yii::t('app', 'Create Page'), ['create'], ['class' => 'btn btn-success']) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'id', - 'translit', - 'title', - 'meta_title', - // 'meta_keywords', - // 'meta_description', - // 'seo_text:ntext', - // 'h1', - ['class' => 'yii\grid\ActionColumn'], ], ]); ?> diff --git a/backend/views/page/update.php b/backend/views/page/update.php index 53ea7c8..20ef6bb 100644 --- a/backend/views/page/update.php +++ b/backend/views/page/update.php @@ -11,19 +11,19 @@ * @var PageLang[] $model_langs */ - $this->title = 'Update Page: ' . $model->title; + $this->title = \Yii::t('app', 'Update Page').': ' . $model->id; $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Pages', + 'label' => \Yii::t('app', 'Pages'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->title, + 'label' => $model->id, 'url' => [ 'view', 'id' => $model->id, ], ]; - $this->params[ 'breadcrumbs' ][] = 'Update'; + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Update'); ?>- = Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> - = Html::a('Delete', ['delete', 'id' => $model->id], [ + = Html::a(\Yii::t('app', 'Update'), [ + 'update', + 'id' => $model->id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(\Yii::t('app', 'Delete'), [ + 'delete', + 'id' => $model->id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', + 'data' => [ + 'confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'), + 'method' => 'post', ], ]) ?>
- + = DetailView::widget([ 'model' => $model, 'attributes' => [ 'id', - 'translit', - 'title', - 'body:ntext', - 'meta_title', - 'meta_keywords', - 'meta_description', - 'seo_text:ntext', - 'h1', ], ]) ?> diff --git a/backend/views/project/_form.php b/backend/views/project/_form.php index 0e6b09a..6c9bb52 100644 --- a/backend/views/project/_form.php +++ b/backend/views/project/_form.php @@ -6,8 +6,6 @@ use yii\helpers\Html; use yii\web\View; use yii\widgets\ActiveForm; - use mihaildev\ckeditor\CKEditor; - use mihaildev\elfinder\ElFinder; use yii\jui\DatePicker; /** @@ -30,24 +28,6 @@ 'dateFormat' => 'dd-MM-yyyy', ]) ?> - = $form->field($model, 'title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'link') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'description') - ->widget(CKEditor::className(), [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ - 'preset' => 'full', - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать - 'inline' => false, - //по умолчанию false]), - 'filebrowserUploadUrl' => Yii::$app->getUrlManager() - ->createUrl('file/uploader/images-upload'), - ]), - ]) ?> - = $form->field($model, 'imagesUpload[]') ->widget(\kartik\file\FileInput::className(), [ 'language' => 'ru', @@ -78,7 +58,7 @@ ]) ?>- = Html::a('Create Project', ['create'], ['class' => 'btn btn-success']) ?> + = Html::a(\Yii::t('app', 'Create Project'), ['create'], ['class' => 'btn btn-success']) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, @@ -24,8 +24,6 @@ $this->params['breadcrumbs'][] = $this->title; ['class' => 'yii\grid\SerialColumn'], 'project_id', 'date_add:date', - 'title', - [ 'class' => 'yii\grid\ActionColumn', 'buttons' => [ diff --git a/backend/views/project/product-create.php b/backend/views/project/product-create.php index 6118ab6..6cd5f76 100644 --- a/backend/views/project/product-create.php +++ b/backend/views/project/product-create.php @@ -14,9 +14,9 @@ * @var ProductToProject $model * @var array $variants */ - $this->title = 'Create product to project'; + $this->title = \Yii::t('app', 'Create product to project'); $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Products to project', + 'label' => \Yii::t('app', 'Products to project'), 'url' => [ 'product', 'id' => $project->project_id, @@ -29,30 +29,28 @@ field($model, 'product_id') - ->dropDownList($products, [ 'prompt' => 'Выберите коллекцию' ]); + ->dropDownList($products, [ 'prompt' => \Yii::t('app', 'Выберите коллекцию')]); ?>- = Html::a('Product to project', [ + = Html::a(\Yii::t('app', 'Product to project'), [ 'product-create', 'id' => $project->project_id, ], [ 'class' => 'btn btn-success' ]) ?> @@ -34,8 +34,8 @@ 'filterModel' => $searchModel, 'columns' => [ [ 'class' => 'yii\grid\SerialColumn' ], - 'product.name', - 'productVariant.name', + 'product_variant_id', + 'project_id', [ 'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}', @@ -62,8 +62,8 @@ 'project/product-delete', 'product_to_project_id' => $model->product_to_project_id, ]), [ - 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', - 'title' => 'Удалить', + 'data-confirm' => \Yii::t('app', 'Вы уверены, что хотите удалить этот элемент?'), + 'title' => \Yii::t('app', 'Удалить'), 'data-method' => 'post', 'data-pjax' => 0, ]); diff --git a/backend/views/project/update.php b/backend/views/project/update.php index 1f45b53..221ccaf 100644 --- a/backend/views/project/update.php +++ b/backend/views/project/update.php @@ -10,19 +10,19 @@ * @var Project $model * @var ProjectLang $model_langs */ - $this->title = 'Update Project: ' . $model->title; + $this->title = \Yii::t('app', 'Update Project').': ' . $model->project_id; $this->params[ 'breadcrumbs' ][] = [ - 'label' => 'Project', + 'label' => \Yii::t('app', 'Project'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->title, + 'label' => $model->project_id, 'url' => [ 'view', 'id' => $model->project_id, ], ]; - $this->params[ 'breadcrumbs' ][] = 'Update'; + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Update'); ?>
- = Html::a('Update', ['update', 'id' => $model->project_id], ['class' => 'btn btn-primary']) ?> - = Html::a('Delete', ['delete', 'id' => $model->project_id], [ + = Html::a(\Yii::t('app', 'Update'), ['update', 'id' => $model->project_id], ['class' => 'btn btn-primary']) ?> + = Html::a(\Yii::t('app', 'Delete'), ['delete', 'id' => $model->project_id], [ 'class' => 'btn btn-danger', 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', + 'confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post', ], ]) ?> @@ -30,7 +30,6 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'project_id', 'date_add:date', - 'title', ], ]) ?> diff --git a/backend/views/seo-category/_form.php b/backend/views/seo-category/_form.php index 00dc571..9b33ed4 100644 --- a/backend/views/seo-category/_form.php +++ b/backend/views/seo-category/_form.php @@ -19,9 +19,6 @@ - = $form->field($model, 'name') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'controller') ->textInput([ 'maxlength' => true ]) ?> diff --git a/backend/views/seo-category/index.php b/backend/views/seo-category/index.php index 9e6bda0..c4dd174 100644 --- a/backend/views/seo-category/index.php +++ b/backend/views/seo-category/index.php @@ -24,12 +24,9 @@ $this->params['breadcrumbs'][] = $this->title; 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'seo_category_id', - 'name', 'controller', 'status', - [ 'class' => 'yii\grid\ActionColumn', 'template' => '{update} {image} {delete}', diff --git a/backend/views/seo-category/update.php b/backend/views/seo-category/update.php index e832b95..5a8ccc9 100644 --- a/backend/views/seo-category/update.php +++ b/backend/views/seo-category/update.php @@ -13,13 +13,13 @@ $this->title = Yii::t('app', 'Update {modelClass}: ', [ 'modelClass' => 'Seo Category', - ]) . $model->name; + ]) . $model->seo_category_id; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('app', 'Seo Categories'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->name, + 'label' => $model->seo_category_id, 'url' => [ 'view', 'id' => $model->seo_category_id, diff --git a/backend/views/seo-category/view.php b/backend/views/seo-category/view.php index 842e78b..3411d25 100644 --- a/backend/views/seo-category/view.php +++ b/backend/views/seo-category/view.php @@ -1,35 +1,43 @@ title = $model->name; -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Categories'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use yii\helpers\Html; + use yii\widgets\DetailView; + + /* @var $this yii\web\View */ + /* @var $model common\models\SeoCategory */ + + $this->title = $model->seo_category_id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('app', 'Seo Categories'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->seo_category_id], ['class' => 'btn btn-primary']) ?> - = Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->seo_category_id], [ + = Html::a(Yii::t('app', 'Update'), [ + 'update', + 'id' => $model->seo_category_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(Yii::t('app', 'Delete'), [ + 'delete', + 'id' => $model->seo_category_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?>
- + = DetailView::widget([ 'model' => $model, 'attributes' => [ 'seo_category_id', - 'name', 'controller', 'status', ], diff --git a/backend/views/seo-dynamic/_form.php b/backend/views/seo-dynamic/_form.php index b0486a8..39ef1c8 100644 --- a/backend/views/seo-dynamic/_form.php +++ b/backend/views/seo-dynamic/_form.php @@ -24,36 +24,15 @@ - = $form->field($model, 'name') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'action') ->textInput([ 'maxlength' => true ]) ?> = $form->field($model, 'param') ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'key') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'fields') ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'h1') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'description') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'seo_text') - ->textarea([ 'rows' => 6 ]) ?> - = $form->field($model, 'status') ->textInput() ?> diff --git a/backend/views/seo-dynamic/index.php b/backend/views/seo-dynamic/index.php index 20b9167..d546768 100644 --- a/backend/views/seo-dynamic/index.php +++ b/backend/views/seo-dynamic/index.php @@ -1,74 +1,70 @@ title = Yii::t('app', 'Seo Dynamics'); -$this->params['breadcrumbs'][] = $this->title; + + use yii\helpers\Html; + use yii\grid\GridView; + use yii\helpers\Url; + + /* @var $this yii\web\View */ + /* @var $searchModel common\models\SeoDynamicSearch */ + /* @var $dataProvider yii\data\ActiveDataProvider */ + + $this->title = Yii::t('app', 'Seo Dynamics'); + $this->params[ 'breadcrumbs' ][] = $this->title; ?>- = Html::a(Yii::t('app', 'Create Seo Dynamic'), Url::toRoute(['create','seo_category_id'=>$seo_category_id]), ['class' => 'btn btn-success']) ?> + = Html::a(Yii::t('app', 'Create Seo Dynamic'), Url::toRoute([ + 'create', + 'seo_category_id' => $seo_category_id, + ]), [ 'class' => 'btn btn-success' ]) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], 'seo_dynamic_id', 'seo_category_id', - 'name', 'action', 'fields', - 'meta', - // 'title', - // 'h1', - // 'description', - // 'seo_text:ntext', - // 'status', - + 'status', [ - 'class' => 'yii\grid\ActionColumn', - 'buttons' => [ - 'view' => function ($url, $model) - { - return Html::a ( - '', - Url::toRoute(['view','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]), - [ + 'class' => 'yii\grid\ActionColumn', + 'buttons' => [ + 'view' => function($url, $model) { + return Html::a('', Url::toRoute([ + 'view', + 'seo_category_id' => $model->seo_category_id, + 'id' => $model->seo_dynamic_id, + ]), [ 'title' => "Просмотр", - ] - ); + ]); }, - 'update' => function ($url, $model) - { - return Html::a ( - '', - Url::toRoute(['update','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]), - [ + 'update' => function($url, $model) { + return Html::a('', Url::toRoute([ + 'update', + 'seo_category_id' => $model->seo_category_id, + 'id' => $model->seo_dynamic_id, + ]), [ 'title' => "Редактировать", - ] - ); + ]); }, - 'delete' => function ($url, $model) - { - - return Html::a('', Url::toRoute(['delete','seo_category_id'=> $model->seo_category_id, 'id' => $model->seo_dynamic_id]), [ - 'title' => Yii::t('yii', 'Delete'), + 'delete' => function($url, $model) { + + return Html::a('', Url::toRoute([ + 'delete', + 'seo_category_id' => $model->seo_category_id, + 'id' => $model->seo_dynamic_id, + ]), [ + 'title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), - 'data-method' => 'post', + 'data-method' => 'post', ]); - + }, ], ], diff --git a/backend/views/seo-dynamic/update.php b/backend/views/seo-dynamic/update.php index 951606f..10eeb11 100644 --- a/backend/views/seo-dynamic/update.php +++ b/backend/views/seo-dynamic/update.php @@ -15,7 +15,7 @@ $this->title = Yii::t('app', 'Update {modelClass}: ', [ 'modelClass' => 'Seo Dynamic', - ]) . $model->name; + ]) . $model->seo_dynamic_id; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('app', 'Seo Dynamics'), 'url' => Url::toRoute([ @@ -24,7 +24,7 @@ ]), ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->name, + 'label' => $model->seo_dynamic_id, 'url' => Url::toRoute([ 'view', 'seo_category_id' => $seo_category_id, diff --git a/backend/views/seo-dynamic/view.php b/backend/views/seo-dynamic/view.php index 36429f0..6505c0d 100644 --- a/backend/views/seo-dynamic/view.php +++ b/backend/views/seo-dynamic/view.php @@ -1,43 +1,46 @@ title = $model->name; -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seo Dynamics'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use yii\helpers\Html; + use yii\widgets\DetailView; + + /* @var $this yii\web\View */ + /* @var $model common\models\SeoDynamic */ + + $this->title = $model->seo_dynamic_id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('app', 'Seo Dynamics'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>- = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->seo_dynamic_id], ['class' => 'btn btn-primary']) ?> - = Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->seo_dynamic_id], [ + = Html::a(Yii::t('app', 'Update'), [ + 'update', + 'id' => $model->seo_dynamic_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(Yii::t('app', 'Delete'), [ + 'delete', + 'id' => $model->seo_dynamic_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?>
- + = DetailView::widget([ 'model' => $model, 'attributes' => [ 'seo_dynamic_id', 'seo_category_id', - 'name', 'action', 'fields', - 'title', - 'meta', - 'h1', - 'description', - 'seo_text:ntext', 'status', ], ]) ?> diff --git a/backend/views/seo/_form.php b/backend/views/seo/_form.php index c3b7ba0..6dde164 100644 --- a/backend/views/seo/_form.php +++ b/backend/views/seo/_form.php @@ -6,8 +6,6 @@ use yii\helpers\Html; use yii\web\View; use yii\widgets\ActiveForm; - use mihaildev\ckeditor\CKEditor; - use mihaildev\elfinder\ElFinder; /** * @var View $this @@ -24,29 +22,6 @@ = $form->field($model, 'url') ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'title') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'meta') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'description') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'h1') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'seo_text') - ->widget(CKEditor::className(), [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ - 'preset' => 'full', - //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать - 'inline' => false, - //по умолчанию false]), - 'filebrowserUploadUrl' => Yii::$app->getUrlManager() - ->createUrl('file/uploader/images-upload'), - ]), - ]) ?> - = LanguageForm::widget([ 'model_langs' => $model_langs, 'formView' => '@backend/views/seo/_form_language', diff --git a/backend/views/seo/_form_language.php b/backend/views/seo/_form_language.php index 6b88aa1..67ee2bd 100644 --- a/backend/views/seo/_form_language.php +++ b/backend/views/seo/_form_language.php @@ -7,14 +7,15 @@ use yii\widgets\ActiveForm; /** - * @var SeoLang $model_lang - * @var Language $language - * @var ActiveForm $form - * @var View $this + * @var SeoLang $model_lang + * @var Language $language + * @var ActiveForm $form + * @var View $this */ ?> = $form->field($model_lang, '[' . $language->language_id . ']title') ->textInput([ 'maxlength' => true ]); ?> + = $form->field($model_lang, '[' . $language->language_id . ']description') ->widget(CKEditor::className(), [ 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ diff --git a/backend/views/seo/index.php b/backend/views/seo/index.php index 1118984..efe65d6 100644 --- a/backend/views/seo/index.php +++ b/backend/views/seo/index.php @@ -23,13 +23,8 @@ $this->params['breadcrumbs'][] = $this->title; 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'seo_id', - 'url:url', - 'meta', - 'h1', - // 'seo_text:ntext', - + 'url', ['class' => 'yii\grid\ActionColumn'], ], ]); ?> diff --git a/backend/views/seo/update.php b/backend/views/seo/update.php index 9e3d5ef..f916983 100644 --- a/backend/views/seo/update.php +++ b/backend/views/seo/update.php @@ -19,7 +19,7 @@ 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->title, + 'label' => $model->seo_id, 'url' => [ 'view', 'id' => $model->seo_id, diff --git a/backend/views/seo/view.php b/backend/views/seo/view.php index fa1330f..47f01af 100644 --- a/backend/views/seo/view.php +++ b/backend/views/seo/view.php @@ -6,7 +6,7 @@ use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model common\models\Seo */ -$this->title = $model->title; +$this->title = $model->seo_id; $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Seos'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> @@ -29,12 +29,7 @@ $this->params['breadcrumbs'][] = $this->title; 'model' => $model, 'attributes' => [ 'seo_id', - 'url:url', - 'title', - 'meta', - 'description', - 'h1', - 'seo_text:ntext', + 'url', ], ]) ?> diff --git a/backend/views/service/_form.php b/backend/views/service/_form.php index 977fb2a..b9cd52a 100644 --- a/backend/views/service/_form.php +++ b/backend/views/service/_form.php @@ -6,8 +6,6 @@ use yii\helpers\Html; use yii\web\View; use yii\widgets\ActiveForm; - use mihaildev\ckeditor\CKEditor; - use mihaildev\elfinder\ElFinder; /** * @var View $this @@ -19,56 +17,32 @@- = Html::a(Yii::t('app', 'Create Service'), ['create'], ['class' => 'btn btn-success']) ?> + = Html::a(Yii::t('app', 'Create Service'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], + 'service_id', - 'name', - 'alias', - [ - 'format' => 'image', - 'attribute'=>'image', - ], - // 'meta_title', - // 'description', - // 'h1', - // 'seo_text:ntext', - // 'created_at', - // 'updated_at', - - ['class' => 'yii\grid\ActionColumn'], + 'imageUrl:image', + 'created_at:date', + + [ 'class' => 'yii\grid\ActionColumn' ], ], ]); ?>- = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->service_id], ['class' => 'btn btn-primary']) ?> - = Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->service_id], [ + = Html::a(Yii::t('app', 'Update'), [ + 'update', + 'id' => $model->service_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(Yii::t('app', 'Delete'), [ + 'delete', + 'id' => $model->service_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?>
- + = DetailView::widget([ 'model' => $model, 'attributes' => [ 'service_id', - 'name', - 'alias', - [ - 'format' => 'image', - 'attribute'=>'image', - ], - 'meta_title', - 'description', - 'h1', - 'seo_text:ntext', - 'created_at', - 'updated_at', + 'imageUrl:image', + 'created_at:date', ], ]) ?> diff --git a/backend/views/slider-image/_form.php b/backend/views/slider-image/_form.php index 5dde8b3..d1320f6 100644 --- a/backend/views/slider-image/_form.php +++ b/backend/views/slider-image/_form.php @@ -44,13 +44,6 @@ ], ]); ?> - - = $form->field($model, 'alt') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'title') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'url') ->textInput([ 'maxlength' => true ]) ?> @@ -59,8 +52,8 @@ 'name' => 'status', 'hideSearch' => true, 'data' => [ - 1 => 'Active', - 2 => 'Inactive', + 1 => \Yii::t('app', 'Active'), + 2 => \Yii::t('app', 'Inactive'), ], 'options' => [ 'placeholder' => 'Select status...' ], 'pluginOptions' => [ diff --git a/backend/views/slider-image/index.php b/backend/views/slider-image/index.php index b70e57a..a5b97bf 100644 --- a/backend/views/slider-image/index.php +++ b/backend/views/slider-image/index.php @@ -27,13 +27,9 @@ $this->params['breadcrumbs'][] = $this->title; 'slider_image_id', 'slider_id', - 'image', - 'alt', - 'title', - // 'url:url', - // 'status', - // 'sort', - + 'imageUrl:image', + 'url', + 'status', [ 'class' => 'yii\grid\ActionColumn', 'buttons' => [ diff --git a/backend/views/slider-image/view.php b/backend/views/slider-image/view.php index acb5d99..34f4a06 100644 --- a/backend/views/slider-image/view.php +++ b/backend/views/slider-image/view.php @@ -31,10 +31,8 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'slider_image_id', 'slider_id', - 'image', - 'alt', - 'title', - 'url:url', + 'imageUrl:image', + 'url', 'status', 'sort', ], diff --git a/common/behaviors/SaveImgBehavior.php b/common/behaviors/SaveImgBehavior.php index 89b0dbe..8b16a06 100644 --- a/common/behaviors/SaveImgBehavior.php +++ b/common/behaviors/SaveImgBehavior.php @@ -40,7 +40,7 @@ if(empty($image) && $event->name == ActiveRecord::EVENT_BEFORE_UPDATE) { $this->owner->$field_name = $this->owner->getOldAttribute($field_name); - } else { + } elseif(!empty($image)) { $imgDir = \Yii::getAlias('@storage/'.$field['directory'].'/'); if(!is_dir($imgDir)) { diff --git a/common/behaviors/Slug.php b/common/behaviors/Slug.php index 214f701..01abbb0 100644 --- a/common/behaviors/Slug.php +++ b/common/behaviors/Slug.php @@ -1,79 +1,83 @@ 'getSlug', - ActiveRecord::EVENT_BEFORE_UPDATE=> 'getSlug' - ]; - } - - public function getSlug( $event ) - { - if(!empty($this->owner->{$this->in_attribute})){ - if ( empty( $this->owner->{$this->out_attribute} ) ) { - $this->owner->{$this->out_attribute} = $this->generateSlug( $this->owner->{$this->in_attribute} ); + + public $in_attribute = 'name'; + + public $out_attribute = 'slug'; + + public $translit = true; + + public function events() + { + return [ + ActiveRecord::EVENT_BEFORE_INSERT => 'getSlug', + ActiveRecord::EVENT_BEFORE_UPDATE => 'getSlug', + ]; + } + + public function getSlug($event) + { + if(!empty( $this->owner->{$this->in_attribute} )) { + if(empty( $this->owner->{$this->out_attribute} )) { + $this->owner->{$this->out_attribute} = $this->generateSlug($this->owner->{$this->in_attribute}); + } else { + $this->owner->{$this->out_attribute} = $this->generateSlug($this->owner->{$this->out_attribute}); + } + } + + } + + private function generateSlug($slug) + { + $slug = $this->slugify($slug); + if($this->checkUniqueSlug($slug)) { + return $slug; } else { - $this->owner->{$this->out_attribute} = $this->generateSlug( $this->owner->{$this->out_attribute} ); + for($suffix = 2; !$this->checkUniqueSlug($new_slug = $slug . '-' . $suffix); $suffix++) { + } + return $new_slug; } } - - } - - private function generateSlug( $slug ) - { - $slug = $this->slugify( $slug ); - if ( $this->checkUniqueSlug( $slug ) ) { - return $slug; - } else { - for ( $suffix = 2; !$this->checkUniqueSlug( $new_slug = $slug . '-' . $suffix ); $suffix++ ) {} - return $new_slug; + + private function slugify($slug) + { + if($this->translit) { + return yii\helpers\Inflector::slug(TransliteratorHelper::process($slug), '-', true); + } else { + return $this->slug($slug, '-', true); + } } - } - - private function slugify( $slug ) - { - if ( $this->translit ) { - return yii\helpers\Inflector::slug( TransliteratorHelper::process( $slug ), '-', true ); - } else { - return $this->slug( $slug, '-', true ); + + private function slug($string, $replacement = '-', $lowercase = true) + { + $string = preg_replace('/[^\p{L}\p{Nd}]+/u', $replacement, $string); + $string = trim($string, $replacement); + return $lowercase ? strtolower($string) : $string; } - } - - private function slug( $string, $replacement = '-', $lowercase = true ) - { - $string = preg_replace( '/[^\p{L}\p{Nd}]+/u', $replacement, $string ); - $string = trim( $string, $replacement ); - return $lowercase ? strtolower( $string ) : $string; - } - - private function checkUniqueSlug( $slug ) - { - $pk = $this->owner->primaryKey(); - $pk = $pk[0]; - - $condition = $this->out_attribute . ' = :out_attribute'; - $params = [ ':out_attribute' => $slug ]; - if ( !$this->owner->isNewRecord ) { - $condition .= ' and ' . $pk . ' != :pk'; - $params[':pk'] = $this->owner->{$pk}; + + private function checkUniqueSlug($slug) + { + $pk = $this->owner->primaryKey(); + $pk = $pk[ 0 ]; + + $condition = $this->out_attribute . ' = :out_attribute'; + $params = [ ':out_attribute' => $slug ]; + if(!$this->owner->isNewRecord) { + $condition .= ' and ' . $pk . ' != :pk'; + $params[ ':pk' ] = $this->owner->{$pk}; + } + return !$this->owner->find() + ->where($condition, $params) + ->one(); } - - return !$this->owner->find() - ->where( $condition, $params ) - ->one(); - } - -} \ No newline at end of file + + } \ No newline at end of file diff --git a/common/models/Articles.php b/common/models/Articles.php index 10388d0..af4263e 100644 --- a/common/models/Articles.php +++ b/common/models/Articles.php @@ -14,16 +14,7 @@ * This is the model class for table "articles". * @property integer $id * @property integer $date - * @property string $title - * @property string $body * @property string $image - * @property string $translit - * @property string $meta_title - * @property string $meta_keywords - * @property string $meta_description - * @property string $seo_text - * @property string $h1 - * @property string $body_preview * * From language behavior * * @property ArticlesLang $lang * @property ArticlesLang[] $langs @@ -60,14 +51,14 @@ public function behaviors() { return [ - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'title', - 'out_attribute' => 'translit', - 'translit' => true, - ], [ 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'articles', + ] + ], ], 'language' => [ 'class' => LanguageBehavior::className(), @@ -94,28 +85,7 @@ ], [ [ - 'title', - 'body', - ], - 'required', - ], - [ - [ - 'body', - 'body_preview', - 'seo_text', - ], - 'string', - ], - [ - [ - 'title', 'image', - 'translit', - 'meta_title', - 'meta_keywords', - 'meta_description', - 'h1', ], 'string', 'max' => 255, @@ -145,19 +115,10 @@ public function attributeLabels() { return [ - 'id' => 'ID', - 'date' => 'Date', - 'title' => 'Title', - 'body' => 'Body', - 'body_preview' => 'Body preview', - 'image' => 'Image', + 'id' => Yii::t('app', 'ID'), + 'date' => Yii::t('app', 'Date'), + 'image' => Yii::t('app', 'Image'), 'imageUrl' => Yii::t('app', 'Image'), - 'translit' => 'Translit', - 'meta_title' => 'Meta Title', - 'meta_keywords' => 'Meta Keywords', - 'meta_description' => 'Meta Description', - 'seo_text' => 'Seo Text', - 'h1' => 'H1', ]; } diff --git a/common/models/ArticlesLang.php b/common/models/ArticlesLang.php index c394983..3207706 100644 --- a/common/models/ArticlesLang.php +++ b/common/models/ArticlesLang.php @@ -18,6 +18,7 @@ use Yii; * @property string $seo_text * @property string $h1 * @property string $body_preview + * @property string $alias * * @property Articles $articles * @property Language $language @@ -40,6 +41,18 @@ class ArticlesLang extends \yii\db\ActiveRecord return 'articles_lang'; } + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'title', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + /** * @inheritdoc */ @@ -47,7 +60,7 @@ class ArticlesLang extends \yii\db\ActiveRecord { return [ [['title', 'body'], 'required'], - [['body', 'seo_text', 'body_preview'], 'string'], + [['body', 'seo_text', 'body_preview', 'alias'], 'string'], [['title', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255], [['articles_id', 'language_id'], 'unique', 'targetAttribute' => ['articles_id', 'language_id'], 'message' => 'The combination of Articles ID and Language ID has already been taken.'], [['articles_id'], 'exist', 'skipOnError' => true, 'targetClass' => Articles::className(), 'targetAttribute' => ['articles_id' => 'id']], diff --git a/common/models/ArticlesSearch.php b/common/models/ArticlesSearch.php index 096fa9e..964cd28 100644 --- a/common/models/ArticlesSearch.php +++ b/common/models/ArticlesSearch.php @@ -2,10 +2,8 @@ namespace common\models; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use common\models\Articles; /** * ArticlesSearch represents the model behind the search form about `common\models\Articles`. @@ -19,7 +17,6 @@ class ArticlesSearch extends Articles { return [ [['id'], 'integer'], - [['title', 'body', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'], ]; } @@ -67,15 +64,6 @@ class ArticlesSearch extends Articles 'id' => $this->id, ]); - $query->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'body', $this->body]) - ->andFilterWhere(['like', 'translit', $this->translit]) - ->andFilterWhere(['like', 'meta_title', $this->meta_title]) - ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords]) - ->andFilterWhere(['like', 'meta_description', $this->meta_description]) - ->andFilterWhere(['like', 'seo_text', $this->seo_text]) - ->andFilterWhere(['like', 'h1', $this->h1]); - return $dataProvider; } } diff --git a/common/models/Banner.php b/common/models/Banner.php index f8c29dc..c3cd6ef 100644 --- a/common/models/Banner.php +++ b/common/models/Banner.php @@ -12,9 +12,6 @@ use yii\web\Request; * This is the model class for table "banner". * * @property integer $banner_id - * @property string $image - * @property string $alt - * @property string $title * @property string $url * @property integer $status * * From language behavior * @@ -61,10 +58,7 @@ class Banner extends \yii\db\ActiveRecord { return [ [['status'], 'integer'], - [['image', 'alt', 'title', 'url'], 'string', 'max' => 255], - ['title', 'unique', 'targetClass' => '\common\models\Slider', 'message' => Yii::t('app','message',[ - 'field' => 'Title' - ])], + [['url'], 'string', 'max' => 255], ]; } @@ -74,10 +68,7 @@ class Banner extends \yii\db\ActiveRecord public function attributeLabels() { return [ - 'banner_id' => Yii::t('app', 'status'), - 'image' => Yii::t('app', 'image'), - 'alt' => Yii::t('app', 'alt'), - 'title' => Yii::t('app', 'title'), + 'banner_id' => Yii::t('app', 'banner_id'), 'url' => Yii::t('app', 'url'), 'status' => Yii::t('app', 'status'), ]; diff --git a/common/models/BannerSearch.php b/common/models/BannerSearch.php index a6fa15a..5ecd823 100644 --- a/common/models/BannerSearch.php +++ b/common/models/BannerSearch.php @@ -1,78 +1,87 @@ $query, - ]); - - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'banner_id', + 'status', + ], + 'integer', + ], + [ + [ 'url' ], + 'safe', + ], + ]; + } + + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Banner::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if(!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'banner_id' => $this->banner_id, + 'status' => $this->status, + ]); + + $query->andFilterWhere([ + 'like', + 'url', + $this->url, + ]); + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'banner_id' => $this->banner_id, - 'status' => $this->status, - ]); - - $query->andFilterWhere(['like', 'image', $this->image]) - ->andFilterWhere(['like', 'alt', $this->alt]) - ->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'url', $this->url]); - - return $dataProvider; } -} diff --git a/common/models/Bg.php b/common/models/Bg.php index e6c3ad7..6ee2a00 100644 --- a/common/models/Bg.php +++ b/common/models/Bg.php @@ -1,83 +1,75 @@ [ - 'class' => LanguageBehavior::className(), - ], - ]; - } + namespace common\models; - public function rules() - { - return [ - [['title'], 'required'], - [['old_image','url'], 'safe'], - [['image'], 'file', 'extensions'=>'jpg, gif, png', 'skipOnEmpty'=>true], - - ]; - } - - public function attributeLabels() - { - return [ - 'title'=>'Название', - 'body'=>'Описание', - 'date'=>'Дата', - 'image'=>'Изображения', - ]; - } + use common\behaviors\SaveImgBehavior; + use common\modules\language\behaviors\LanguageBehavior; + use yii\db\ActiveQuery; + use yii\db\ActiveRecord; + use yii\web\Request; + + /** + * Class Bg + * * From language behavior * + * @property BgLang $lang + * @property BgLang[] $langs + * @property BgLang $object_lang + * @property string $ownerKey + * @property string $langKey + * @method string getOwnerKey() + * @method void setOwnerKey( string $value ) + * @method string getLangKey() + * @method void setLangKey( string $value ) + * @method ActiveQuery getLangs() + * @method ActiveQuery getLang( integer $language_id ) + * @method BgLang[] generateLangs() + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) + * @method bool linkLangs( ActiveRecord[] $model_langs ) + * @method bool saveLangs( ActiveRecord[] $model_langs ) + * * End language behavior * + */ + class Bg extends \yii\db\ActiveRecord + { - + public static function tableName() + { + return 'bg'; + } - public function beforeDelete() { - $this->deleteImage($this->image); - return parent::beforeDelete(); - } - - public function deleteImage($file){ - if(!empty($file)){ - @unlink('upload/bg/'.$file); - } - } - - -} + public function behaviors() + { + return [ + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'bg', + ], + ], + ], + 'language' => [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + public function rules() + { + return [ + [ + [ 'url' ], + 'string', + ], + ]; + } + + public function attributeLabels() + { + return [ + 'image' => \Yii::t('app', 'Image'), + 'url' => \Yii::t('app', 'Url'), + ]; + } + } diff --git a/common/models/BgSearch.php b/common/models/BgSearch.php index 44577a1..2558885 100644 --- a/common/models/BgSearch.php +++ b/common/models/BgSearch.php @@ -1,76 +1,83 @@ $query, - ]); - - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'id' ], + 'integer', + ], + [ + [ 'url' ], + 'safe', + ], + ]; + } + + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Bg::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if(!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + ]); + + $query->andFilterWhere([ + 'like', + 'url', + $this->url, + ]); + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'id' => $this->id, - ]); - - $query->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'url', $this->url]) - ->andFilterWhere(['like', 'image', $this->image]); - - return $dataProvider; } -} diff --git a/common/models/Delivery.php b/common/models/Delivery.php index 04f1ce0..b99b63e 100644 --- a/common/models/Delivery.php +++ b/common/models/Delivery.php @@ -1,48 +1,47 @@ [ - 'class' => LanguageBehavior::className(), - ], - ]; - } + namespace common\models; - public static function tableName() - { - return 'orders_delivery'; - } + use common\modules\language\behaviors\LanguageBehavior; + use yii\db\ActiveQuery; + use yii\db\ActiveRecord; + use yii\web\Request; -} \ No newline at end of file + /** + * Class Delivery + * * From language behavior * + * @property OrdersDeliveryLang $lang + * @property OrdersDeliveryLang[] $langs + * @property OrdersDeliveryLang $object_lang + * @property string $ownerKey + * @property string $langKey + * @method string getOwnerKey() + * @method void setOwnerKey( string $value ) + * @method string getLangKey() + * @method void setLangKey( string $value ) + * @method ActiveQuery getLangs() + * @method ActiveQuery getLang( integer $language_id ) + * @method OrdersDeliveryLang[] generateLangs() + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) + * @method bool linkLangs( ActiveRecord[] $model_langs ) + * @method bool saveLangs( ActiveRecord[] $model_langs ) + * * End language behavior * + */ + class Delivery extends \yii\db\ActiveRecord + { + + public function behaviors() + { + return [ + 'language' => [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + public static function tableName() + { + return 'orders_delivery'; + } + + } \ No newline at end of file diff --git a/common/models/Event.php b/common/models/Event.php index 1c2bb5a..7e39a8a 100644 --- a/common/models/Event.php +++ b/common/models/Event.php @@ -2,6 +2,7 @@ namespace common\models; +use common\behaviors\SaveImgBehavior; use common\modules\language\behaviors\LanguageBehavior; use Yii; use yii\behaviors\TimestampBehavior; @@ -13,14 +14,7 @@ use yii\web\Request; * This is the model class for table "event". * * @property integer $event_id - * @property string $name - * @property string $alias - * @property string $body * @property string $image - * @property string $meta_title - * @property string $description - * @property string $h1 - * @property string $seo_text * @property integer $created_at * @property integer $updated_at * @property integer $end_at @@ -45,8 +39,6 @@ use yii\web\Request; */ class Event extends \yii\db\ActiveRecord { - public $imageUpload; - /** * @inheritdoc */ @@ -62,18 +54,21 @@ class Event extends \yii\db\ActiveRecord { return [ TimestampBehavior::className(), - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true - ], [ 'class' => 'common\behaviors\ShowImage', ], 'language' => [ 'class' => LanguageBehavior::className(), ], + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'event', + ], + ], + ], ]; } @@ -99,12 +94,8 @@ class Event extends \yii\db\ActiveRecord public function rules() { return [ - [['body', 'seo_text'], 'string'], [['created_at', 'updated_at' ], 'integer'], - [['name', 'alias', 'image', 'meta_title', 'description', 'h1','end_at'], 'string', 'max' => 255], - [['name','body'], 'required'], - [['imageUpload'], 'safe'], - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], + [['end_at'], 'string', 'max' => 255], ]; } @@ -115,27 +106,10 @@ class Event extends \yii\db\ActiveRecord { return [ 'event_id' => Yii::t('app', 'event_id'), - 'name' => Yii::t('app', 'name'), - 'alias' => Yii::t('app', 'alias'), - 'body' => Yii::t('app', 'body'), 'image' => Yii::t('app', 'image'), - 'meta_title' => Yii::t('app', 'meta_title'), - 'description' => Yii::t('app', 'description'), - 'h1' => Yii::t('app', 'h1'), - 'seo_text' => Yii::t('app', 'seo_text'), 'created_at' => Yii::t('app', 'created_at'), 'updated_at' => Yii::t('app', 'updated_at'), 'end_at' => Yii::t('app', 'end_at'), ]; } - - - public function getImageFile() { - return empty($this->image) ? null : Yii::getAlias('@imagesDir/articles/'. $this->image); - } - - public function getImageUrl() - { - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/articles/' . $this->image); - } } diff --git a/common/models/EventLang.php b/common/models/EventLang.php index f76afca..4c91758 100644 --- a/common/models/EventLang.php +++ b/common/models/EventLang.php @@ -1,89 +1,145 @@ 255], - [['event_id', 'language_id'], 'unique', 'targetAttribute' => ['event_id', 'language_id'], 'message' => 'The combination of Event ID and Language ID has already been taken.'], - [['event_id'], 'exist', 'skipOnError' => true, 'targetClass' => Event::className(), 'targetAttribute' => ['event_id' => 'event_id']], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'event_id' => Yii::t('app', 'Event ID'), - 'language_id' => Yii::t('app', 'Language ID'), - 'name' => Yii::t('app', 'Name'), - 'body' => Yii::t('app', 'Body'), - 'meta_title' => Yii::t('app', 'Meta Title'), - 'description' => Yii::t('app', 'Description'), - 'seo_text' => Yii::t('app', 'Seo Text'), - 'h1' => Yii::t('app', 'H1'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getEvent() - { - return $this->hasOne(Event::className(), ['event_id' => 'event_id']); - } - - /** - * @return \yii\db\ActiveQuery + * This is the model class for table "event_lang". + * @property integer $event_id + * @property integer $language_id + * @property string $name + * @property string $body + * @property string $meta_title + * @property string $description + * @property string $seo_text + * @property string $h1 + * @property string $alias + * @property Event $event + * @property Language $language */ - public function getLanguage() + class EventLang extends \yii\db\ActiveRecord { - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); + + public static function primaryKey() + { + return [ + 'event_id', + 'language_id', + ]; + } + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'event_lang'; + } + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'name', + 'body', + ], + 'required', + ], + [ + [ + 'body', + 'seo_text', + ], + 'string', + ], + [ + [ + 'name', + 'meta_title', + 'description', + 'h1', + 'alias', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'event_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'event_id', + 'language_id', + ], + 'message' => 'The combination of Event ID and Language ID has already been taken.', + ], + [ + [ 'event_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Event::className(), + 'targetAttribute' => [ 'event_id' => 'event_id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'language_id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'event_id' => Yii::t('app', 'Event ID'), + 'language_id' => Yii::t('app', 'Language ID'), + 'name' => Yii::t('app', 'Name'), + 'body' => Yii::t('app', 'Body'), + 'meta_title' => Yii::t('app', 'Meta Title'), + 'description' => Yii::t('app', 'Description'), + 'seo_text' => Yii::t('app', 'Seo Text'), + 'h1' => Yii::t('app', 'H1'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getEvent() + { + return $this->hasOne(Event::className(), [ 'event_id' => 'event_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]); + } } -} diff --git a/common/models/EventSearch.php b/common/models/EventSearch.php index a6fa7e9..9c7be65 100644 --- a/common/models/EventSearch.php +++ b/common/models/EventSearch.php @@ -17,7 +17,6 @@ class EventSearch extends Event { return [ [['event_id', 'created_at', 'updated_at', 'end_at'], 'integer'], - [['name', 'alias', 'body', 'image', 'meta_title', 'description', 'h1', 'seo_text'], 'safe'], ]; } @@ -70,15 +69,6 @@ class EventSearch extends Event 'end_at' => $this->end_at, ]); - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'alias', $this->alias]) - ->andFilterWhere(['like', 'body', $this->body]) - ->andFilterWhere(['like', 'image', $this->image]) - ->andFilterWhere(['like', 'meta_title', $this->meta_title]) - ->andFilterWhere(['like', 'description', $this->description]) - ->andFilterWhere(['like', 'h1', $this->h1]) - ->andFilterWhere(['like', 'seo_text', $this->seo_text]); - return $dataProvider; } } diff --git a/common/models/OrdersDeliveryLang.php b/common/models/OrdersDeliveryLang.php index c53e93f..a879a5a 100644 --- a/common/models/OrdersDeliveryLang.php +++ b/common/models/OrdersDeliveryLang.php @@ -46,7 +46,7 @@ class OrdersDeliveryLang extends \yii\db\ActiveRecord [['title'], 'string', 'max' => 255], [['orders_delivery_id', 'language_id'], 'unique', 'targetAttribute' => ['orders_delivery_id', 'language_id'], 'message' => 'The combination of Orders Delivery ID and Language ID has already been taken.'], [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], - [['orders_delivery_id'], 'exist', 'skipOnError' => true, 'targetClass' => OrdersDelivery::className(), 'targetAttribute' => ['orders_delivery_id' => 'id']], + [['orders_delivery_id'], 'exist', 'skipOnError' => true, 'targetClass' => Delivery::className(), 'targetAttribute' => ['orders_delivery_id' => 'id']], ]; } diff --git a/common/models/Page.php b/common/models/Page.php index bb0315f..650e268 100644 --- a/common/models/Page.php +++ b/common/models/Page.php @@ -9,14 +9,6 @@ /** * This is the model class for table "page". * @property integer $id - * @property string $translit - * @property string $title - * @property string $body - * @property string $meta_title - * @property string $meta_keywords - * @property string $meta_description - * @property string $seo_text - * @property string $h1 * @property bool $in_menu * * From language behavior * * @property PageLang $lang @@ -53,12 +45,6 @@ public function behaviors() { return [ - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'title', - 'out_attribute' => 'translit', - 'translit' => true, - ], 'language' => [ 'class' => LanguageBehavior::className(), ], @@ -73,25 +59,6 @@ return [ [ [ - 'body', - 'seo_text', - ], - 'string', - ], - [ - [ - 'translit', - 'title', - 'meta_title', - 'meta_keywords', - 'meta_description', - 'h1', - ], - 'string', - 'max' => 255, - ], - [ - [ 'in_menu', ], 'boolean', @@ -99,14 +66,6 @@ ]; } - public function getPageTranslit($page) - { - return self::find() - ->where([ 'translit' => $page ]) - ->one(); - - } - /** * @inheritdoc */ @@ -114,14 +73,6 @@ { return [ 'id' => 'ID', - 'translit' => 'Translit', - 'title' => 'Title', - 'body' => 'Body', - 'meta_title' => 'Meta Title', - 'meta_keywords' => 'Meta Keywords', - 'meta_description' => 'Meta Description', - 'seo_text' => 'Seo Text', - 'h1' => 'H1', 'in_menu' => 'Show in menu', ]; } diff --git a/common/models/PageLang.php b/common/models/PageLang.php index 702427b..8790090 100644 --- a/common/models/PageLang.php +++ b/common/models/PageLang.php @@ -1,91 +1,149 @@ 255], - [['page_id', 'language_id'], 'unique', 'targetAttribute' => ['page_id', 'language_id'], 'message' => 'The combination of Page ID and Language ID has already been taken.'], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], - [['page_id'], 'exist', 'skipOnError' => true, 'targetClass' => Page::className(), 'targetAttribute' => ['page_id' => 'id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'page_id' => Yii::t('app', 'Page ID'), - 'language_id' => Yii::t('app', 'Language ID'), - 'title' => Yii::t('app', 'Title'), - 'body' => Yii::t('app', 'Body'), - 'meta_title' => Yii::t('app', 'Meta Title'), - 'meta_keywords' => Yii::t('app', 'Meta Keywords'), - 'meta_description' => Yii::t('app', 'Meta Description'), - 'seo_text' => Yii::t('app', 'Seo Text'), - 'h1' => Yii::t('app', 'H1'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLanguage() - { - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); - } - - /** - * @return \yii\db\ActiveQuery + * This is the model class for table "page_lang". + * @property integer $page_id + * @property integer $language_id + * @property string $title + * @property string $body + * @property string $meta_title + * @property string $meta_keywords + * @property string $meta_description + * @property string $seo_text + * @property string $h1 + * @property string $alias + * @property Language $language + * @property Page $page */ - public function getPage() + class PageLang extends \yii\db\ActiveRecord { - return $this->hasOne(Page::className(), ['id' => 'page_id']); + + public static function primaryKey() + { + return [ + 'page_id', + 'language_id', + ]; + } + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'page_lang'; + } + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'title', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'title', + 'body', + ], + 'required', + ], + [ + [ + 'body', + 'seo_text', + ], + 'string', + ], + [ + [ + 'title', + 'meta_title', + 'meta_keywords', + 'meta_description', + 'h1', + 'alias', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'page_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'page_id', + 'language_id', + ], + 'message' => 'The combination of Page ID and Language ID has already been taken.', + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'language_id' ], + ], + [ + [ 'page_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Page::className(), + 'targetAttribute' => [ 'page_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'page_id' => Yii::t('app', 'Page ID'), + 'language_id' => Yii::t('app', 'Language ID'), + 'title' => Yii::t('app', 'Title'), + 'body' => Yii::t('app', 'Body'), + 'meta_title' => Yii::t('app', 'Meta Title'), + 'meta_keywords' => Yii::t('app', 'Meta Keywords'), + 'meta_description' => Yii::t('app', 'Meta Description'), + 'seo_text' => Yii::t('app', 'Seo Text'), + 'h1' => Yii::t('app', 'H1'), + 'alias' => Yii::t('app', 'Alias'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPage() + { + return $this->hasOne(Page::className(), [ 'id' => 'page_id' ]); + } } -} diff --git a/common/models/PageSearch.php b/common/models/PageSearch.php index 39fa69c..de22f25 100644 --- a/common/models/PageSearch.php +++ b/common/models/PageSearch.php @@ -17,7 +17,6 @@ class PageSearch extends Page { return [ [['id'], 'integer'], - [['translit', 'title', 'body', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'], ]; } @@ -65,15 +64,6 @@ class PageSearch extends Page 'id' => $this->id, ]); - $query->andFilterWhere(['like', 'translit', $this->translit]) - ->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'body', $this->body]) - ->andFilterWhere(['like', 'meta_title', $this->meta_title]) - ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords]) - ->andFilterWhere(['like', 'meta_description', $this->meta_description]) - ->andFilterWhere(['like', 'seo_text', $this->seo_text]) - ->andFilterWhere(['like', 'h1', $this->h1]); - return $dataProvider; } } diff --git a/common/models/ProductSpec.php b/common/models/ProductSpec.php index 41479cc..30b662a 100644 --- a/common/models/ProductSpec.php +++ b/common/models/ProductSpec.php @@ -13,10 +13,8 @@ * This is the model class for table "product_spec". * @property integer $product_spec_id * @property integer $product_id - * @property string $tech_spec_text * @property string $tech_spec_link * @property string $tech_char_link - * @property string $instruction * @property Product $product * * * From language behavior * @@ -75,13 +73,6 @@ return [ [ [ - 'tech_spec_text', - 'instruction', - ], - 'string', - ], - [ - [ 'techSpecFile', 'techCharFile', ], @@ -99,10 +90,8 @@ return [ 'product_spec_id' => 'Product Spec ID', 'product_id' => 'Product ID', - 'tech_spec_text' => 'Tech Spec Text', 'tech_spec_link' => 'Tech Spec Link', 'tech_char_link' => 'Tech Char Link', - 'instruction' => 'Instruction', 'techSpecFile' => 'techSpecFile', 'techCharFile' => 'techCharFile', ]; diff --git a/common/models/Project.php b/common/models/Project.php index 9524646..a039078 100644 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -11,9 +11,6 @@ /** * This is the model class for table "project". * @property integer $project_id - * @property string $title - * @property string $link - * @property string $description * @property integer $date_add * @property ProjectImage[] $images * @property ProjectImage $image @@ -57,12 +54,6 @@ public function behaviors() { return [ - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'title', - 'out_attribute' => 'link', - 'translit' => true, - ], 'language' => [ 'class' => LanguageBehavior::className(), ], @@ -83,14 +74,6 @@ }, ], [ - [ 'title' ], - 'required', - ], - [ - [ 'description' ], - 'string', - ], - [ [ 'date_add', 'imagesUpload', diff --git a/common/models/ProjectLang.php b/common/models/ProjectLang.php index 37bafe7..302551f 100644 --- a/common/models/ProjectLang.php +++ b/common/models/ProjectLang.php @@ -1,81 +1,129 @@ 255], - [['project_id', 'language_id'], 'unique', 'targetAttribute' => ['project_id', 'language_id'], 'message' => 'The combination of Project ID and Language ID has already been taken.'], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], - [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'project_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'project_id' => Yii::t('app', 'Project ID'), - 'language_id' => Yii::t('app', 'Language ID'), - 'title' => Yii::t('app', 'Title'), - 'description' => Yii::t('app', 'Description'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLanguage() - { - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); - } - - /** - * @return \yii\db\ActiveQuery + * This is the model class for table "project_lang". + * @property integer $project_id + * @property integer $language_id + * @property string $title + * @property string $description + * @property string $alias + * @property Language $language + * @property Project $project */ - public function getProject() + class ProjectLang extends \yii\db\ActiveRecord { - return $this->hasOne(Project::className(), ['project_id' => 'project_id']); + + public static function primaryKey() + { + return [ + 'project_id', + 'language_id', + ]; + } + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'project_lang'; + } + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'title', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'title' ], + 'required', + ], + [ + [ 'description' ], + 'string', + ], + [ + [ + 'title', + 'alias', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'project_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'project_id', + 'language_id', + ], + 'message' => 'The combination of Project ID and Language ID has already been taken.', + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'language_id' ], + ], + [ + [ 'project_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Project::className(), + 'targetAttribute' => [ 'project_id' => 'project_id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'project_id' => Yii::t('app', 'Project ID'), + 'language_id' => Yii::t('app', 'Language ID'), + 'title' => Yii::t('app', 'Title'), + 'description' => Yii::t('app', 'Description'), + 'alias' => Yii::t('app', 'Alias'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProject() + { + return $this->hasOne(Project::className(), [ 'project_id' => 'project_id' ]); + } } -} diff --git a/common/models/ProjectSearch.php b/common/models/ProjectSearch.php index e2ec7cf..94e4fdc 100644 --- a/common/models/ProjectSearch.php +++ b/common/models/ProjectSearch.php @@ -23,7 +23,6 @@ class ProjectSearch extends Project { return [ [['project_id', 'date_add'], 'integer'], - [['title', 'link', 'description'], 'safe'], ]; } @@ -67,10 +66,6 @@ class ProjectSearch extends Project 'date_add' => $this->date_add, ]); - $query->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'link', $this->link]) - ->andFilterWhere(['like', 'description', $this->description]); - return $dataProvider; } } diff --git a/common/models/Seo.php b/common/models/Seo.php index 68fdceb..0136cfa 100644 --- a/common/models/Seo.php +++ b/common/models/Seo.php @@ -13,11 +13,6 @@ use yii\web\Request; * * @property integer $seo_id * @property string $url - * @property string $title - * @property string $meta - * @property string $description - * @property string $h1 - * @property string $seo_text * * * From language behavior * * @property SeoLang $lang @@ -63,8 +58,7 @@ class Seo extends \yii\db\ActiveRecord { return [ [['url'], 'required'], - [['seo_text'], 'string'], - [['url', 'title', 'meta', 'description', 'h1'], 'string', 'max' => 255], + [['url'], 'string', 'max' => 255], ]; } @@ -76,11 +70,6 @@ class Seo extends \yii\db\ActiveRecord return [ 'seo_id' => Yii::t('app', 'seo_id'), 'url' => Yii::t('app', 'url'), - 'title' => Yii::t('app', 'title'), - 'meta' => Yii::t('app', 'meta_title'), - 'description' => Yii::t('app', 'description'), - 'h1' => Yii::t('app', 'h1'), - 'seo_text' => Yii::t('app', 'seo_text'), ]; } } diff --git a/common/models/SeoCategory.php b/common/models/SeoCategory.php index bca8edf..2e19821 100644 --- a/common/models/SeoCategory.php +++ b/common/models/SeoCategory.php @@ -12,7 +12,6 @@ use yii\web\Request; * This is the model class for table "seo_category". * * @property integer $seo_category_id - * @property string $name * @property string $controller * @property integer $status * @@ -62,7 +61,6 @@ class SeoCategory extends \yii\db\ActiveRecord { return [ [['status'], 'integer'], - [['name'], 'string', 'max' => 255], [['controller'], 'string', 'max' => 100], ]; } @@ -74,7 +72,6 @@ class SeoCategory extends \yii\db\ActiveRecord { return [ 'seo_category_id' => Yii::t('app', 'seo_category_id'), - 'name' => Yii::t('app', 'name'), 'controller' => Yii::t('app', 'controller'), 'status' => Yii::t('app', 'status'), ]; diff --git a/common/models/SeoCategorySearch.php b/common/models/SeoCategorySearch.php index bfdab8d..2c5ae57 100644 --- a/common/models/SeoCategorySearch.php +++ b/common/models/SeoCategorySearch.php @@ -1,77 +1,88 @@ $query, - ]); - - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); + + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'seo_category_id', + 'status', + ], + 'integer', + ], + [ + [ 'controller' ], + 'safe', + ], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = SeoCategory::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if(!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'seo_category_id' => $this->seo_category_id, + 'status' => $this->status, + ]); + + $query->andFilterWhere([ + 'like', + 'controller', + $this->controller, + ]); + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'seo_category_id' => $this->seo_category_id, - 'status' => $this->status, - ]); - - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'controller', $this->controller]); - - return $dataProvider; } -} diff --git a/common/models/SeoDynamic.php b/common/models/SeoDynamic.php index c427dde..0757fa7 100644 --- a/common/models/SeoDynamic.php +++ b/common/models/SeoDynamic.php @@ -1,107 +1,118 @@ [ - 'class' => LanguageBehavior::className(), - ], - ]; - } + namespace common\models; + + use common\modules\language\behaviors\LanguageBehavior; + use Yii; + use yii\db\ActiveQuery; + use yii\db\ActiveRecord; + use yii\web\Request; /** - * @inheritdoc - */ - public function rules() - { - return [ - [['seo_category_id', 'status'], 'integer'], - [['seo_text'], 'string'], - [['name', 'action'], 'string', 'max' => 200], - [['fields', 'title', 'meta', 'h1', 'description', 'param', 'key'], 'string', 'max' => 255], - [['seo_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoCategory::className(), 'targetAttribute' => ['seo_category_id' => 'seo_category_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'), - 'seo_category_id' => Yii::t('app', 'seo_category_id'), - 'name' => Yii::t('app', 'name'), - 'action' => Yii::t('app', 'action'), - 'fields' => Yii::t('app', 'fields'), - 'title' => Yii::t('app', 'title'), - 'meta' => Yii::t('app', 'meta'), - 'h1' => Yii::t('app', 'h1'), - 'description' => Yii::t('app', 'description'), - 'seo_text' => Yii::t('app', 'seo_text'), - 'status' => Yii::t('app', 'status'), - 'param' => Yii::t('app', 'param'), - 'key' => Yii::t('app', 'key'), - ]; - } - - /** - * @return \yii\db\ActiveQuery + * This is the model class for table "seo_dynamic". + * @property integer $seo_dynamic_id + * @property integer $seo_category_id + * @property string $action + * @property string $fields + * @property integer $status + * @property string $param + * * From language behavior * + * @property SeoDynamicLang $lang + * @property SeoDynamicLang[] $langs + * @property SeoDynamicLang $object_lang + * @property string $ownerKey + * @property string $langKey + * @method string getOwnerKey() + * @method void setOwnerKey( string $value ) + * @method string getLangKey() + * @method void setLangKey( string $value ) + * @method ActiveQuery getLangs() + * @method ActiveQuery getLang( integer $language_id ) + * @method SeoDynamicLang[] generateLangs() + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) + * @method bool linkLangs( ActiveRecord[] $model_langs ) + * @method bool saveLangs( ActiveRecord[] $model_langs ) + * * End language behavior * + * @property SeoCategory $seoCategory */ - public function getSeoCategory() + class SeoDynamic extends \yii\db\ActiveRecord { - return $this->hasOne(SeoCategory::className(), ['seo_category_id' => 'seo_category_id']); + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'seo_dynamic'; + } + + public function behaviors() + { + return [ + 'language' => [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'seo_category_id', + 'status', + ], + 'integer', + ], + [ + [ + 'action', + ], + 'string', + 'max' => 200, + ], + [ + [ + 'fields', + 'param', + ], + 'string', + 'max' => 255, + ], + [ + [ 'seo_category_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => SeoCategory::className(), + 'targetAttribute' => [ 'seo_category_id' => 'seo_category_id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'), + 'seo_category_id' => Yii::t('app', 'seo_category_id'), + 'action' => Yii::t('app', 'action'), + 'fields' => Yii::t('app', 'fields'), + 'status' => Yii::t('app', 'status'), + 'param' => Yii::t('app', 'param'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSeoCategory() + { + return $this->hasOne(SeoCategory::className(), [ 'seo_category_id' => 'seo_category_id' ]); + } } -} diff --git a/common/models/SeoDynamicSearch.php b/common/models/SeoDynamicSearch.php index 6b02e4c..feffc02 100644 --- a/common/models/SeoDynamicSearch.php +++ b/common/models/SeoDynamicSearch.php @@ -1,84 +1,98 @@ $query, - ]); - - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); + + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'seo_dynamic_id', + 'seo_category_id', + 'status', + ], + 'integer', + ], + [ + [ + 'action', + 'fields', + ], + 'safe', + ], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($seo_category_id, $params) + { + $query = SeoDynamic::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if(!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'seo_dynamic_id' => $this->seo_dynamic_id, + 'seo_category_id' => $seo_category_id, + 'status' => $this->status, + ]); + + $query->andFilterWhere([ + 'like', + 'action', + $this->action, + ]) + ->andFilterWhere([ + 'like', + 'fields', + $this->fields, + ]); + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'seo_dynamic_id' => $this->seo_dynamic_id, - 'seo_category_id' => $seo_category_id, - 'status' => $this->status, - ]); - - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'action', $this->action]) - ->andFilterWhere(['like', 'fields', $this->fields]) - ->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'meta', $this->title]) - ->andFilterWhere(['like', 'h1', $this->h1]) - ->andFilterWhere(['like', 'description', $this->description]) - ->andFilterWhere(['like', 'seo_text', $this->seo_text]); - - return $dataProvider; } -} diff --git a/common/models/SeoSearch.php b/common/models/SeoSearch.php index 3b1266c..33d8fa6 100644 --- a/common/models/SeoSearch.php +++ b/common/models/SeoSearch.php @@ -2,10 +2,8 @@ namespace common\models; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use common\models\Seo; /** * SeoSearch represents the model behind the search form about `common\models\Seo`. @@ -25,7 +23,7 @@ class SeoSearch extends Seo { return [ [['seo_id'], 'integer'], - [['url', 'title', 'meta', 'description', 'h1', 'seo_text'], 'safe'], + [['url'], 'safe'], ]; } @@ -68,12 +66,7 @@ class SeoSearch extends Seo 'seo_id' => $this->seo_id, ]); - $query->andFilterWhere(['like', 'url', $this->url]) - ->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'meta', $this->meta]) - ->andFilterWhere(['like', 'description', $this->description]) - ->andFilterWhere(['like', 'h1', $this->h1]) - ->andFilterWhere(['like', 'seo_text', $this->seo_text]); + $query->andFilterWhere(['like', 'url', $this->url]); return $dataProvider; } diff --git a/common/models/Service.php b/common/models/Service.php index 0a72cec..cdae8e3 100644 --- a/common/models/Service.php +++ b/common/models/Service.php @@ -1,107 +1,101 @@ 255], - ]; - } - /** - * @inheritdoc - */ - public function behaviors() - { - return [ - TimestampBehavior::className(), - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true - ], - [ - 'class' => 'common\behaviors\ShowImage', - ], - 'language' => [ - 'class' => LanguageBehavior::className(), - ], - ]; - } - /** - * @inheritdoc + * This is the model class for table "service". + * @property integer $service_id + * @property string $image + * @property integer $created_at + * @property integer $updated_at + * * From language behavior * + * @property ServiceLang $lang + * @property ServiceLang[] $langs + * @property ServiceLang $object_lang + * @property string $ownerKey + * @property string $langKey + * @method string getOwnerKey() + * @method void setOwnerKey( string $value ) + * @method string getLangKey() + * @method void setLangKey( string $value ) + * @method ActiveQuery getLangs() + * @method ActiveQuery getLang( integer $language_id ) + * @method ServiceLang[] generateLangs() + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) + * @method bool linkLangs( ActiveRecord[] $model_langs ) + * @method bool saveLangs( ActiveRecord[] $model_langs ) + * * End language behavior * */ - public function attributeLabels() + class Service extends \yii\db\ActiveRecord { - return [ - 'service_id' => Yii::t('app', 'service_id'), - 'name' => Yii::t('app', 'name'), - 'alias' => Yii::t('app', 'alias'), - 'body' => Yii::t('app', 'body'), - 'image' => Yii::t('app', 'image'), - 'meta_title' => Yii::t('app', 'meta_title'), - 'description' => Yii::t('app', 'description'), - 'h1' => Yii::t('app', 'h1'), - 'seo_text' => Yii::t('app', 'seo_text'), - 'created_at' => Yii::t('app', 'created_at'), - 'updated_at' => Yii::t('app', 'updated_at'), - ]; + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'service'; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'created_at', + 'updated_at', + ], + 'integer', + ], + ]; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'service', + ], + ], + ], + TimestampBehavior::className(), + [ + 'class' => 'common\behaviors\ShowImage', + ], + 'language' => [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'service_id' => Yii::t('app', 'service_id'), + 'image' => Yii::t('app', 'image'), + 'created_at' => Yii::t('app', 'created_at'), + 'updated_at' => Yii::t('app', 'updated_at'), + ]; + } } -} diff --git a/common/models/ServiceLang.php b/common/models/ServiceLang.php index 99e6541..5821b30 100644 --- a/common/models/ServiceLang.php +++ b/common/models/ServiceLang.php @@ -20,7 +20,7 @@ */ class ServiceLang extends \yii\db\ActiveRecord { - + public static function primaryKey() { return [ @@ -37,6 +37,18 @@ return 'service_lang'; } + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + /** * @inheritdoc */ diff --git a/common/models/ServiceSearch.php b/common/models/ServiceSearch.php index ea16c41..e4ca391 100644 --- a/common/models/ServiceSearch.php +++ b/common/models/ServiceSearch.php @@ -1,84 +1,79 @@ $query, - ]); - - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); + + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'service_id', + 'created_at', + 'updated_at', + ], + 'integer', + ], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Service::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if(!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'service_id' => $this->service_id, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'service_id' => $this->service_id, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, - ]); - - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'alias', $this->alias]) - ->andFilterWhere(['like', 'body', $this->body]) - ->andFilterWhere(['like', 'image', $this->image]) - ->andFilterWhere(['like', 'meta_title', $this->meta_title]) - ->andFilterWhere(['like', 'description', $this->description]) - ->andFilterWhere(['like', 'h1', $this->h1]) - ->andFilterWhere(['like', 'seo_text', $this->seo_text]); - - return $dataProvider; } -} diff --git a/common/models/SliderImage.php b/common/models/SliderImage.php index c9dc95e..e41224a 100644 --- a/common/models/SliderImage.php +++ b/common/models/SliderImage.php @@ -2,6 +2,7 @@ namespace common\models; + use common\behaviors\SaveImgBehavior; use common\modules\language\behaviors\LanguageBehavior; use Yii; use yii\db\ActiveQuery; @@ -13,8 +14,6 @@ * @property integer $slider_image_id * @property integer $slider_id * @property string $image - * @property string $alt - * @property string $title * @property string $url * @property integer $status * @property integer $sort @@ -64,9 +63,6 @@ ], [ [ - 'image', - 'alt', - 'title', 'url', ], 'string', @@ -88,6 +84,15 @@ 'language' => [ 'class' => LanguageBehavior::className(), ], + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'slider', + ], + ], + ], ]; } @@ -100,8 +105,6 @@ 'slider_image_id' => Yii::t('app', 'slider_image_id'), 'slider_id' => Yii::t('app', 'slider_id'), 'image' => Yii::t('app', 'image'), - 'alt' => Yii::t('app', 'alt'), - 'title' => Yii::t('app', 'title'), 'url' => Yii::t('app', 'url'), 'status' => Yii::t('app', 'status'), 'sort' => Yii::t('app', 'sort'), @@ -116,14 +119,4 @@ return $this->hasOne(Slider::className(), [ 'slider_id' => 'slider_id' ]); } - public function getImageFile() - { - return empty( $this->image ) ? NULL : '/storage/slider/' . $this->image; - } - - public function getImageUrl() - { - return empty( $this->image ) ? NULL : '/storage/slider/' . $this->image; - } - } diff --git a/common/models/SliderImageSearch.php b/common/models/SliderImageSearch.php index 9bd5da8..d292a77 100644 --- a/common/models/SliderImageSearch.php +++ b/common/models/SliderImageSearch.php @@ -34,9 +34,6 @@ ], [ [ - 'image', - 'alt', - 'title', 'url', ], 'safe', @@ -88,25 +85,10 @@ ]); $query->andFilterWhere([ - 'like', - 'image', - $this->image, - ]) - ->andFilterWhere([ - 'like', - 'alt', - $this->alt, - ]) - ->andFilterWhere([ - 'like', - 'title', - $this->title, - ]) - ->andFilterWhere([ - 'like', - 'url', - $this->url, - ]); + 'like', + 'url', + $this->url, + ]); return $dataProvider; } diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php index c7d9191..37a8b16 100644 --- a/common/modules/product/models/Brand.php +++ b/common/modules/product/models/Brand.php @@ -1,122 +1,98 @@ [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true - ], - [ - 'class' => SaveImgBehavior::className(), - 'fields' => [ - [ - 'name' => 'image', - 'directory' => 'brand', + + public $_items_count = 0; + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'brand'; + } + + public function behaviors() + { + return [ + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'brand', + ], ], ], - ], - 'language' => [ - 'class' => LanguageBehavior::className(), - ], - ]; - } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['name'], 'string'], - [['meta_desc', 'seo_text'], 'string'], - [['alias', 'name'], 'string', 'max' => 250], - [['meta_title', 'image'], 'string', 'max' => 255], - [['meta_robots'], 'string', 'max' => 50], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'name' => Yii::t('product', 'Name of the brand'), - 'brand_id' => Yii::t('product', 'Brand ID'), - 'alias' => Yii::t('product', 'Alias'), - 'image' => Yii::t('product', 'Image'), - 'imageUrl' => Yii::t('product', 'Image'), - 'meta_title' => Yii::t('product', 'Meta Title'), - 'meta_desc' => Yii::t('product', 'Meta Desc'), - 'meta_robots' => Yii::t('product', 'Meta Robots'), - 'seo_text' => Yii::t('product', 'Seo Text'), - ]; - } - - - - /** - * @return \yii\db\ActiveQuery - */ - public function getProducts() - { - return $this->hasMany(Product::className(), ['brand_id' => 'brand_id']); + 'language' => [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'in_menu' ], + 'boolean', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'brand_id' => Yii::t('product', 'Brand ID'), + 'image' => Yii::t('product', 'Image'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProducts() + { + return $this->hasMany(Product::className(), [ 'brand_id' => 'brand_id' ]); + } } -} diff --git a/common/modules/product/models/BrandLang.php b/common/modules/product/models/BrandLang.php index c529e48..29080b5 100644 --- a/common/modules/product/models/BrandLang.php +++ b/common/modules/product/models/BrandLang.php @@ -1,87 +1,138 @@ 255], - [['brand_id', 'language_id'], 'unique', 'targetAttribute' => ['brand_id', 'language_id'], 'message' => 'The combination of Brand ID and Language ID has already been taken.'], - [['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => Brand::className(), 'targetAttribute' => ['brand_id' => 'brand_id']], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'brand_id' => Yii::t('app', 'Brand ID'), - 'language_id' => Yii::t('app', 'Language ID'), - 'name' => Yii::t('app', 'Name'), - 'meta_title' => Yii::t('app', 'Meta Title'), - 'meta_robots' => Yii::t('app', 'Meta Robots'), - 'meta_desc' => Yii::t('app', 'Meta Desc'), - 'seo_text' => Yii::t('app', 'Seo Text'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBrand() - { - return $this->hasOne(Brand::className(), ['brand_id' => 'brand_id']); - } - - /** - * @return \yii\db\ActiveQuery + * This is the model class for table "brand_lang". + * @property integer $brand_id + * @property integer $language_id + * @property string $name + * @property string $meta_title + * @property string $meta_robots + * @property string $meta_desc + * @property string $seo_text + * @property string $alias + * @property Brand $brand + * @property Language $language */ - public function getLanguage() + class BrandLang extends \yii\db\ActiveRecord { - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); + + public static function primaryKey() + { + return [ + 'brand_id', + 'language_id', + ]; + } + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'brand_lang'; + } + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'name' ], + 'required', + ], + [ + [ 'seo_text' ], + 'string', + ], + [ + [ + 'name', + 'meta_title', + 'meta_robots', + 'meta_desc', + 'alias', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'brand_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'brand_id', + 'language_id', + ], + 'message' => 'The combination of Brand ID and Language ID has already been taken.', + ], + [ + [ 'brand_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Brand::className(), + 'targetAttribute' => [ 'brand_id' => 'brand_id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'language_id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'brand_id' => Yii::t('app', 'Brand ID'), + 'language_id' => Yii::t('app', 'Language ID'), + 'name' => Yii::t('app', 'Name'), + 'meta_title' => Yii::t('app', 'Meta Title'), + 'meta_robots' => Yii::t('app', 'Meta Robots'), + 'meta_desc' => Yii::t('app', 'Meta Desc'), + 'seo_text' => Yii::t('app', 'Seo Text'), + 'alias' => Yii::t('app', 'Alias'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getBrand() + { + return $this->hasOne(Brand::className(), [ 'brand_id' => 'brand_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]); + } } -} diff --git a/common/modules/product/models/BrandSearch.php b/common/modules/product/models/BrandSearch.php index 64ef3a7..c5f9974 100644 --- a/common/modules/product/models/BrandSearch.php +++ b/common/modules/product/models/BrandSearch.php @@ -5,7 +5,6 @@ namespace common\modules\product\models; use yii\base\Model; use yii\data\ActiveDataProvider; use yii\db\ActiveQuery; -use yii\web\NotFoundHttpException; /** * BrandSearch represents the model behind the search form about `common\modules\product\models\Brand`. @@ -20,7 +19,6 @@ class BrandSearch extends Brand { return [ [['brand_id'], 'integer'], - [['alias', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'brand_name'], 'safe'], ]; } @@ -66,8 +64,7 @@ class BrandSearch extends Brand $dataProvider->setSort([ 'attributes' => [ 'brand_name', - 'alias' - ] + ], ]); // grid filtering conditions @@ -75,17 +72,6 @@ class BrandSearch extends Brand 'brand_id' => $this->brand_id, ]); - - $query->andFilterWhere(['ilike', 'alias', $this->alias]) - ->andFilterWhere(['ilike', 'image', $this->image]) - ->andFilterWhere(['ilike', 'meta_title', $this->meta_title]) - ->andFilterWhere(['ilike', 'meta_desc', $this->meta_desc]) - ->andFilterWhere(['ilike', 'meta_robots', $this->meta_robots]) - ->andFilterWhere(['ilike', 'seo_text', $this->seo_text]); - if (!empty($this->brand_name)) { - $query->andFilterWhere(['ilike', 'name', $this->brand_name]); - } - $query->orderBy(['brand_id' => SORT_ASC]); return $dataProvider; @@ -119,15 +105,4 @@ class BrandSearch extends Brand return $query; } - - public static function findByAlias($alias) { - /** @var CategoryQuery $query */ - $query = Brand::find() - ->andFilterWhere(['alias' => $alias]); - if (($model = $query->one()) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } } diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php index eccffc5..e278bbd 100644 --- a/common/modules/product/models/Category.php +++ b/common/modules/product/models/Category.php @@ -2,6 +2,7 @@ namespace common\modules\product\models; + use common\behaviors\SaveImgBehavior; use common\components\artboxtree\ArtboxTreeBehavior; use common\components\artboxtree\ArtboxTreeHelper; use common\modules\language\behaviors\LanguageBehavior; @@ -20,13 +21,7 @@ * @property string $path * @property integer $depth * @property string $image - * @property string $meta_title - * @property string $meta_desc - * @property string $meta_robots - * @property string $seo_text * @property integer $product_unit_id - * @property string $alias - * @property boolean $name * * From language behavior * * @property CategoryLang $lang * @property CategoryLang[] $langs @@ -51,8 +46,6 @@ class Category extends \yii\db\ActiveRecord { - public $imageUpload; - public function behaviors() { return [ @@ -61,15 +54,18 @@ 'keyNameGroup' => NULL, 'keyNamePath' => 'path', ], - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true, - ], 'language' => [ 'class' => LanguageBehavior::className(), ], + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'brand', + ], + ], + ], ]; } @@ -88,10 +84,6 @@ { return [ [ - [ 'name' ], - 'string', - ], - [ [ 'parent_id', 'depth', @@ -102,42 +94,9 @@ [ [ 'path', - 'meta_desc', - 'h1', - 'seo_text', ], 'string', ], - [ - [ - 'meta_title', - 'image', - ], - 'string', - 'max' => 255, - ], - [ - [ 'meta_robots' ], - 'string', - 'max' => 50, - ], - [ - [ - 'alias', - 'name', - ], - 'string', - 'max' => 250, - ], - [ - [ 'imageUpload' ], - 'safe', - ], - [ - [ 'imageUpload' ], - 'file', - 'extensions' => 'jpg, gif, png', - ], ]; } @@ -153,14 +112,7 @@ 'depth' => Yii::t('product', 'Depth'), 'image' => Yii::t('product', 'Image'), 'imageUrl' => Yii::t('product', 'Image'), - 'meta_title' => Yii::t('product', 'Meta Title'), - 'meta_desc' => Yii::t('product', 'Meta Desc'), - 'meta_robots' => Yii::t('product', 'Meta Robots'), - 'h1' => Yii::t('product', 'h1'), - 'seo_text' => Yii::t('product', 'Seo Text'), 'product_unit_id' => Yii::t('product', 'Product Unit ID'), - 'alias' => Yii::t('product', 'Alias'), - 'name' => Yii::t('product', 'Name'), 'remote_id' => Yii::t('product', 'Remote ID'), ]; } @@ -220,16 +172,6 @@ } } - public function getImageFile() - { - return empty( $this->image ) ? '/images/no_photo.png' : Yii::getAlias('@imagesDir/categories/' . $this->image); - } - - public function getImageUrl() - { - return empty( $this->image ) ? '/images/no_photo.png' : Yii::getAlias('@imagesUrl/categories/' . $this->image); - } - public function beforeSave($insert) { if(parent::beforeSave($insert)) { diff --git a/common/modules/product/models/CategoryLang.php b/common/modules/product/models/CategoryLang.php index 4226466..36d8a46 100644 --- a/common/modules/product/models/CategoryLang.php +++ b/common/modules/product/models/CategoryLang.php @@ -38,6 +38,18 @@ class CategoryLang extends \yii\db\ActiveRecord return 'category_lang'; } + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + /** * @inheritdoc */ diff --git a/common/modules/product/models/CategorySearch.php b/common/modules/product/models/CategorySearch.php index c3eaedd..c307786 100644 --- a/common/modules/product/models/CategorySearch.php +++ b/common/modules/product/models/CategorySearch.php @@ -5,7 +5,6 @@ namespace common\modules\product\models; use common\components\artboxtree\ArtboxTreeHelper; use yii\base\Model; use yii\data\ActiveDataProvider; -use yii\web\NotFoundHttpException; /** * CategorySearch represents the model behind the search form about `common\modules\product\models\Category`. @@ -24,7 +23,6 @@ class CategorySearch extends Category { return [ [['category_id', 'parent_id', 'depth', 'product_unit_id'], 'integer'], - [['path', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'alias'], 'safe'], ]; } @@ -68,25 +66,12 @@ class CategorySearch extends Category 'category.parent_id' => $this->parent_id, 'category.product_unit_id' => $this->product_unit_id, ]); - - $query->andFilterWhere(['like', 'category.alias', $this->alias]); - + $query->orderBy(['category.path' => SORT_ASC, 'category.depth' => SORT_ASC, 'category.category_id' => SORT_ASC]); return $dataProvider; } - public static function findByAlias($alias) { - /** @var CategoryQuery $query */ - $query = Category::find() - ->andFilterWhere(['alias' => $alias]); - if (($model = $query->one()) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } - public static function findByRemoteID($id) { /** @var CategoryQuery $query */ $query = Category::find() diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index b52d53b..8b5904b 100644 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -2,7 +2,6 @@ namespace common\modules\product\models; - use common\behaviors\Slug; use common\models\ProductCertificate; use common\models\ProductSpec; use common\models\ProductToRating; @@ -19,27 +18,24 @@ /** * This is the model class for table "{{%product}}". - * @property string $name * @property integer $brand_id * @property integer $product_id * @property Category $category - * @property array $categories - * @property array of ProductVariant $variants + * @property Category[] $categories + * @property ProductVariant[] $variants * @property ProductVariant $variant * @property ProductImage $image - * @property array $images + * @property ProductImage[] $images * @property boolean $is_top * @property boolean $is_new * @property boolean $akciya * @property ProductToRating $averageRating * @property array $properties * @property ProductVariant $enabledVariant - * @property array $enabledVariants + * @property ProductVariant[] $enabledVariants * @property string $video - * @property string $description * @property TaxOption[] $options * @property Brand $brand - * @property ProductVariant[] $variants * @property ProductSpec $productSpec * @property ProductCertificate[] $productCertificates * * From language behavior * @@ -80,12 +76,6 @@ [ 'class' => FilterBehavior::className(), ], - [ - 'class' => Slug::className(), - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true, - ], 'language' => [ 'class' => LanguageBehavior::className(), ], @@ -111,16 +101,6 @@ 'integer', ], [ - [ 'name' ], - 'string', - 'max' => 150, - ], - [ - [ 'alias' ], - 'string', - 'max' => 250, - ], - [ [ 'categories', 'variants', @@ -132,7 +112,6 @@ ], [ [ - 'description', 'video', ], 'safe', @@ -154,29 +133,22 @@ public function attributeLabels() { return [ - 'product_id' => Yii::t('product', 'ID'), - 'name' => Yii::t('product', 'Name'), - 'brand_id' => Yii::t('product', 'Brand'), - 'categories' => Yii::t('product', 'Categories'), + 'product_id' => Yii::t('product', 'ID'), + 'brand_id' => Yii::t('product', 'Brand'), + 'categories' => Yii::t('product', 'Categories'), // relation behavior field - 'category' => Yii::t('product', 'Category'), + 'category' => Yii::t('product', 'Category'), // relation behavior field - 'image' => Yii::t('product', 'Image'), - 'images' => Yii::t('product', 'Images'), - 'description' => Yii::t('product', 'Description'), - 'video' => Yii::t('product', 'Video embeded'), - 'variants' => Yii::t('product', 'Variants'), - 'is_top' => Yii::t('product', 'Is top'), - 'is_new' => Yii::t('product', 'Is new'), - 'akciya' => Yii::t('product', 'Is promo'), + 'image' => Yii::t('product', 'Image'), + 'images' => Yii::t('product', 'Images'), + 'video' => Yii::t('product', 'Video embeded'), + 'variants' => Yii::t('product', 'Variants'), + 'is_top' => Yii::t('product', 'Is top'), + 'is_new' => Yii::t('product', 'Is new'), + 'akciya' => Yii::t('product', 'Is promo'), ]; } - public function getUrl() - { - return '/product/' . $this->alias; - } - /** * @return \yii\db\ActiveQuery */ @@ -269,7 +241,7 @@ public function getFullName() { - return empty( $this->brand ) ? $this->name : $this->brand->name . ' ' . $this->name; + return empty( $this->brand ) ? $this->lang->name : $this->brand->lang->name . ' ' . $this->lang->name; } public function getCategories() @@ -288,7 +260,7 @@ { $result = []; foreach($this->categories as $category) { - $result[] = $category->name; + $result[] = $category->lang->name; } return $result; } diff --git a/common/modules/product/models/ProductLang.php b/common/modules/product/models/ProductLang.php index a4a40b8..0597fb3 100644 --- a/common/modules/product/models/ProductLang.php +++ b/common/modules/product/models/ProductLang.php @@ -2,6 +2,7 @@ namespace common\modules\product\models; +use common\behaviors\Slug; use common\modules\language\models\Language; use Yii; @@ -12,6 +13,7 @@ use Yii; * @property integer $language_id * @property string $name * @property string $description + * @property string $alias * * @property Language $language * @property Product $product @@ -35,6 +37,18 @@ class ProductLang extends \yii\db\ActiveRecord return 'product_lang'; } + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + /** * @inheritdoc */ @@ -43,7 +57,7 @@ class ProductLang extends \yii\db\ActiveRecord return [ [['name'], 'required'], [['description'], 'string'], - [['name'], 'string', 'max' => 255], + [['name', 'alias'], 'string', 'max' => 255], [['product_id', 'language_id'], 'unique', 'targetAttribute' => ['product_id', 'language_id'], 'message' => 'The combination of Product ID and Language ID has already been taken.'], [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], @@ -60,6 +74,7 @@ class ProductLang extends \yii\db\ActiveRecord 'language_id' => Yii::t('app', 'Language ID'), 'name' => Yii::t('app', 'Name'), 'description' => Yii::t('app', 'Description'), + 'alias' => Yii::t('app', 'Alias'), ]; } diff --git a/common/modules/product/models/ProductSearch.php b/common/modules/product/models/ProductSearch.php index a51e1a3..a3fc817 100644 --- a/common/modules/product/models/ProductSearch.php +++ b/common/modules/product/models/ProductSearch.php @@ -4,8 +4,6 @@ namespace common\modules\product\models; use yii\base\Model; use yii\data\ActiveDataProvider; -use yii\db\ActiveQuery; -use yii\web\NotFoundHttpException; /** * ProductSearch represents the model behind the search form about `common\modules\product\models\Product`. @@ -33,7 +31,7 @@ class ProductSearch extends Product public function rules() { return [ - [['name', 'brand_name', 'brand_id', 'category_id', 'category_name', 'variant_sku'], 'safe'], + [['brand_name', 'brand_id', 'category_id', 'category_name', 'variant_sku'], 'safe'], [['brand_id', 'product_id'], 'integer'], [['is_top', 'is_new', 'akciya'], 'boolean'], ]; @@ -60,7 +58,7 @@ class ProductSearch extends Product $query = Product::find(); - $query->joinWith(['brand', 'categories', 'variant']); +// $query->joinWith(['brand', 'categories', 'variant']); $query->groupBy(['product.product_id']); @@ -72,19 +70,18 @@ class ProductSearch extends Product return $dataProvider; } - $dataProvider->setSort([ - 'attributes' => [ - 'name', - 'brand_name' => [ - 'asc' => ['brand.name' => SORT_ASC], - 'desc' => ['brand.name' => SORT_DESC], - 'default' => SORT_DESC, - 'label' => 'Brand name', - ], - 'category_name', - 'variant_sku', - ] - ]); +// $dataProvider->setSort([ +// 'attributes' => [ +// 'brand_name' => [ +// 'asc' => ['brand.name' => SORT_ASC], +// 'desc' => ['brand.name' => SORT_DESC], +// 'default' => SORT_DESC, +// 'label' => 'Brand name', +// ], +// 'category_name', +// 'variant_sku', +// ] +// ]); if (isset($this->is_top)) { $query->andFilterWhere([ @@ -104,28 +101,16 @@ class ProductSearch extends Product $query->andFilterWhere([ 'product.brand_id' => $this->brand_id, 'product.product_id' => $this->product_id, - 'product_category.category_id' => $this->category_id +// 'product_category.category_id' => $this->category_id ]); - $query->andFilterWhere(['ilike', 'product.name', $this->name]); - $query->andFilterWhere(['ilike', 'brand.name', $this->brand_name]); - $query->andFilterWhere(['ilike', 'category.name', $this->category_name]); - $query->andFilterWhere(['ilike', 'product_variant.sku', $this->variant_sku]); +// $query->andFilterWhere(['ilike', 'brand.name', $this->brand_name]); +// $query->andFilterWhere(['ilike', 'category.name', $this->category_name]); +// $query->andFilterWhere(['ilike', 'product_variant.sku', $this->variant_sku]); return $dataProvider; } - public static function findByAlias($alias) { - /** @var ActiveQuery $query */ - $query = Product::find(); - $query->andFilterWhere(['alias' => $alias]); - if (($model = $query->one()) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested product does not exist.'); - } - } - public static function findByRemoteID($id) { /** @var CategoryQuery $query */ $query = Product::find() diff --git a/common/modules/product/models/ProductUnit.php b/common/modules/product/models/ProductUnit.php index a8ddccd..38bd6d1 100644 --- a/common/modules/product/models/ProductUnit.php +++ b/common/modules/product/models/ProductUnit.php @@ -12,8 +12,6 @@ use yii\web\Request; * This is the model class for table "product_unit". * * @property integer $product_unit_id - * @property string $name - * @property string $code * @property boolean $is_default * * @property Category[] $categories @@ -62,10 +60,7 @@ class ProductUnit extends \yii\db\ActiveRecord public function rules() { return [ - [['name', 'code'], 'required'], [['is_default'], 'boolean'], - [['name'], 'string', 'max' => 255], - [['code'], 'string', 'max' => 50], ]; } @@ -76,8 +71,6 @@ class ProductUnit extends \yii\db\ActiveRecord { return [ 'product_unit_id' => Yii::t('product', 'Product Unit ID'), - 'name' => Yii::t('product', 'Name'), - 'code' => Yii::t('product', 'Code'), 'is_default' => Yii::t('product', 'Is Default'), ]; } diff --git a/common/modules/product/models/ProductUnitSearch.php b/common/modules/product/models/ProductUnitSearch.php index 271b0fb..4ccadee 100644 --- a/common/modules/product/models/ProductUnitSearch.php +++ b/common/modules/product/models/ProductUnitSearch.php @@ -23,7 +23,6 @@ class ProductUnitSearch extends ProductUnit { return [ [['product_unit_id'], 'integer'], - [['name', 'code'], 'safe'], [['is_default'], 'boolean'], ]; } @@ -68,9 +67,6 @@ class ProductUnitSearch extends ProductUnit 'is_default' => $this->is_default, ]); - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'code', $this->code]); - return $dataProvider; } } diff --git a/common/modules/product/models/ProductVariant.php b/common/modules/product/models/ProductVariant.php index 0c2f907..00972ff 100644 --- a/common/modules/product/models/ProductVariant.php +++ b/common/modules/product/models/ProductVariant.php @@ -15,7 +15,6 @@ * This is the model class for table "product_variant". * @property integer $product_variant_id * @property integer $product_id - * @property string $name * @property string $remote_id * @property string $sku * @property double $price @@ -26,6 +25,7 @@ * @property array $images * @property TaxOption[] $options * @property ProductUnit $productUnit + * @property Product $product * * From language behavior * * @property ProductVariantLang $lang * @property ProductVariantLang[] $langs @@ -47,20 +47,10 @@ class ProductVariant extends \yii\db\ActiveRecord { - /**just for rukzachok**/ - public $count; - public $sum_cost; public $product_name; - //public $image; - public $translit; - - public $translit_rubric; - - private $data; - /** @var array $_images */ public $imagesUpload = ''; @@ -111,7 +101,6 @@ ], [ [ - 'name', 'sku', ], 'string', @@ -147,7 +136,6 @@ return [ 'product_variant_id' => Yii::t('product', 'Product Variant ID'), 'product_id' => Yii::t('product', 'Product ID'), - 'name' => Yii::t('product', 'Name'), 'sku' => Yii::t('product', 'Sku'), 'price' => Yii::t('product', 'Price'), 'price_old' => Yii::t('product', 'Price Old'), @@ -234,7 +222,7 @@ public function getFullname() { - return empty( $this->product ) ? NULL : ( $this->product->name . ( empty( $this->name ) ? '' : ' ' . $this->name ) ); + return empty( $this->product ) ? NULL : ( $this->product->lang->name . ( empty( $this->lang->name ) ? '' : ' ' . $this->lang->name ) ); } public function getImagesHTML() diff --git a/common/modules/product/models/ProductVariantListSearch.php b/common/modules/product/models/ProductVariantListSearch.php index c723e99..87590c8 100644 --- a/common/modules/product/models/ProductVariantListSearch.php +++ b/common/modules/product/models/ProductVariantListSearch.php @@ -1,85 +1,114 @@ $query, - ]); - - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); - return $dataProvider; + + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'product_variant_id', + 'product_id', + 'product_unit_id', + ], + 'integer', + ], + [ + [ + 'sku', + 'remote_id', + ], + 'safe', + ], + [ + [ + 'price', + 'price_old', + 'stock', + ], + 'number', + ], + ]; } - - if($product_id){ + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params, $product_id = false) + { + $query = ProductVariant::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if(!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + if($product_id) { + $query->andFilterWhere([ + 'product_id' => $product_id, + ]); + } + + // grid filtering conditions $query->andFilterWhere([ - 'product_id' => $product_id, + 'product_variant_id' => $this->product_variant_id, + 'price' => $this->price, + 'price_old' => $this->price_old, + 'stock' => $this->stock, + 'product_unit_id' => $this->product_unit_id, ]); + + $query->andFilterWhere([ + 'like', + 'sku', + $this->sku, + ]) + ->andFilterWhere([ + 'like', + 'remote_id', + $this->remote_id, + ]); + + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'product_variant_id' => $this->product_variant_id, - 'price' => $this->price, - 'price_old' => $this->price_old, - 'stock' => $this->stock, - 'product_unit_id' => $this->product_unit_id, - ]); - - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'sku', $this->sku]) - ->andFilterWhere(['like', 'remote_id', $this->remote_id]); - - return $dataProvider; } -} diff --git a/common/modules/product/views/manage/_form.php b/common/modules/product/views/manage/_form.php index f0c97ce..4981eca 100644 --- a/common/modules/product/views/manage/_form.php +++ b/common/modules/product/views/manage/_form.php @@ -29,9 +29,6 @@ 'options' => [ 'enctype' => 'multipart/form-data' ], ]); ?> - = $form->field($model, 'name') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'is_top') ->checkbox([ 'label' => 'ТОП' ]) ?> = $form->field($model, 'is_new') @@ -39,25 +36,18 @@ = $form->field($model, 'akciya') ->checkbox([ 'label' => 'Акционный' ]) ?> - = $form->field($model, 'description') - ->widget(\mihaildev\ckeditor\CKEditor::className(), [ - 'editorOptions' => [ - 'preset' => 'full', - 'inline' => false, - ], - ]); ?> = $form->field($model, 'video') ->textarea(); ?> = $form->field($model, 'brand_id') ->dropDownList(ArrayHelper::map(ProductHelper::getBrands() - ->all(), 'brand_id', 'name'), [ + ->all(), 'brand_id', 'brand_id'), [ 'prompt' => Yii::t('product', 'Select brand'), ]) ?> = $form->field($model, 'categories') ->widget(Select2::className(), [ - 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), + 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'category_id'), 'language' => 'ru', 'options' => [ 'placeholder' => Yii::t('product', 'Select categories'), @@ -123,25 +113,17 @@ all() as $group) : ?> = $form->field($model, 'options') - ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'value'), [ + ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'tax_option_id'), [ 'multiple' => true, 'unselect' => NULL, ]) - ->label($group->name); ?> + ->label($group->tax_group_id); ?>= Html::a(Yii::t('product', 'Create Product'), ['create'], ['class' => 'btn btn-success']) ?> @@ -27,63 +26,63 @@ $this->params['breadcrumbs'][] = $this->title; 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'name', - [ - 'label' => Yii::t('product', 'Brand'), - 'attribute' => 'brand_name', - 'value' => 'brand.name', - 'format' => 'raw', - 'filter' => Select2::widget([ - 'model' => $searchModel, - 'attribute' => 'brand_id', - 'data' => ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'), - 'language' => 'ru', - 'options' => [ - 'placeholder' => Yii::t('product', 'Select brand'), - 'multiple' => false, - ], - 'pluginOptions' => [ - 'allowClear' => true - ], - ]) - ], - [ - 'label' => Yii::t('product', 'Category'), - 'attribute' => 'category_name', - 'value' => function($model) { - $categories = []; - foreach ($model->categories as $category) { - $categories[] = $category->name; - } - return implode(", ", $categories); - }, - 'format' => 'raw', - 'filter' => Select2::widget([ - 'model' => $searchModel, - 'attribute' => 'category_id', - 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), - 'language' => 'ru', - 'options' => [ - 'placeholder' => Yii::t('product', 'Select category'), - 'multiple' => false, - ], - 'pluginOptions' => [ - 'allowClear' => true - ], - ]) - ], - [ - 'label' => Yii::t('product', 'SKU'), - 'attribute' => 'variant_sku', - 'value' => 'variant.sku', - ], - 'variant.price', - 'variant.price_old', - [ - 'label' => Yii::t('product', 'Stock'), - 'attribute' => 'variant_stock', - 'value' => 'variant.stock_caption', - ], + 'product_id', +// [ +// 'label' => Yii::t('product', 'Brand'), +// 'attribute' => 'brand_name', +// 'value' => 'brand.name', +// 'format' => 'raw', +// 'filter' => Select2::widget([ +// 'model' => $searchModel, +// 'attribute' => 'brand_id', +// 'data' => ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'), +// 'language' => 'ru', +// 'options' => [ +// 'placeholder' => Yii::t('product', 'Select brand'), +// 'multiple' => false, +// ], +// 'pluginOptions' => [ +// 'allowClear' => true +// ], +// ]) +// ], +// [ +// 'label' => Yii::t('product', 'Category'), +// 'attribute' => 'category_name', +// 'value' => function($model) { +// $categories = []; +// foreach ($model->categories as $category) { +// $categories[] = $category->name; +// } +// return implode(", ", $categories); +// }, +// 'format' => 'raw', +// 'filter' => Select2::widget([ +// 'model' => $searchModel, +// 'attribute' => 'category_id', +// 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), +// 'language' => 'ru', +// 'options' => [ +// 'placeholder' => Yii::t('product', 'Select category'), +// 'multiple' => false, +// ], +// 'pluginOptions' => [ +// 'allowClear' => true +// ], +// ]) +// ], +// [ +// 'label' => Yii::t('product', 'SKU'), +// 'attribute' => 'variant_sku', +// 'value' => 'variant.sku', +// ], +// 'variant.price', +// 'variant.price_old', +// [ +// 'label' => Yii::t('product', 'Stock'), +// 'attribute' => 'variant_stock', +// 'value' => 'variant.stock_caption', +// ], [ 'class' => 'yii\grid\ActionColumn', 'template' => '{items} {view} |{is_top} {is_new} {akciya} | {update} {delete}', diff --git a/common/modules/product/views/manage/update.php b/common/modules/product/views/manage/update.php index 84f3ce5..827f779 100644 --- a/common/modules/product/views/manage/update.php +++ b/common/modules/product/views/manage/update.php @@ -8,22 +8,22 @@ use yii\web\View; /** - * @var View $this - * @var Product $model - * @var ProductLang[] $model_langs - * @var ProductSpec $product_spec + * @var View $this + * @var Product $model + * @var ProductLang[] $model_langs + * @var ProductSpec $product_spec * @var ProductSpecLang[] $product_spec_langs */ $this->title = Yii::t('product', 'Update {modelClass}: ', [ 'modelClass' => 'Product', - ]) . ' ' . $model->name; + ]) . ' ' . $model->product_id; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('product', 'Products'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->name, + 'label' => $model->product_id, 'url' => [ 'view', 'id' => $model->product_id, @@ -36,10 +36,10 @@
- = Html::a(Yii::t('product', 'Create Product Unit'), ['create'], ['class' => 'btn btn-success']) ?> + = Html::a(Yii::t('product', 'Create Product Unit'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
= GridView::widget([ 'dataProvider' => $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'name', - 'code:html', + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], + 'product_unit_id', 'is_default:boolean', - - ['class' => 'yii\grid\ActionColumn'], + [ 'class' => 'yii\grid\ActionColumn' ], ], ]); ?>- = Html::a(Yii::t('product', 'Update'), ['update', 'id' => $model->product_unit_id], ['class' => 'btn btn-primary']) ?> - = Html::a(Yii::t('product', 'Delete'), ['delete', 'id' => $model->product_unit_id], [ + = Html::a(Yii::t('product', 'Update'), [ + 'update', + 'id' => $model->product_unit_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(Yii::t('product', 'Delete'), [ + 'delete', + 'id' => $model->product_unit_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?>
- + = DetailView::widget([ - 'model' => $model, + 'model' => $model, 'attributes' => [ 'product_unit_id', - 'name', - 'code', 'is_default:boolean', ], ]) ?> diff --git a/common/modules/product/views/variant/_form.php b/common/modules/product/views/variant/_form.php index 8885754..065e4f8 100644 --- a/common/modules/product/views/variant/_form.php +++ b/common/modules/product/views/variant/_form.php @@ -21,14 +21,6 @@ */ $js = ' -$(".dynamicform_wrapper").on("beforeInsert", function(e, item) { - console.log("beforeInsert"); -}); - -$(".dynamicform_wrapper").on("afterInsert", function(e, item) { - console.log("afterInsert"); -}); - $(".dynamicform_wrapper").on("beforeDelete", function(e, item) { if (! confirm("Are you sure you want to delete this item?")) { return false; @@ -36,10 +28,6 @@ $(".dynamicform_wrapper").on("beforeDelete", function(e, item) { return true; }); -$(".dynamicform_wrapper").on("afterDelete", function(e) { - console.log("Deleted item!"); -}); - $(".dynamicform_wrapper").on("limitReached", function(e, item) { alert("Limit reached"); }); @@ -54,9 +42,6 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { 'options' => [ 'enctype' => 'multipart/form-data' ], ]); ?> - = $form->field($model, 'name') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'product_id') ->hiddenInput() ->label(false); ?> @@ -161,7 +146,7 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { = $form->field($model, 'product_unit_id') ->dropDownList(ArrayHelper::map(\common\modules\product\models\ProductUnit::find() - ->all(), 'product_unit_id', 'name'), [ + ->all(), 'product_unit_id', 'product_unit_id'), [ 'prompt' => Yii::t('product', 'Unit'), ]) ->label(Yii::t('product', 'Unit')) ?> @@ -169,11 +154,11 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { all() as $group) : ?> = $form->field($model, 'options') - ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'value'), [ + ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'tax_option_id'), [ 'multiple' => true, 'unselect' => NULL, ]) - ->label($group->name); ?> + ->label($group->tax_group_id); ?> diff --git a/common/modules/product/views/variant/index.php b/common/modules/product/views/variant/index.php index 4355909..6907964 100644 --- a/common/modules/product/views/variant/index.php +++ b/common/modules/product/views/variant/index.php @@ -22,7 +22,6 @@ if (!empty($product)) {= Html::a(Yii::t('product', 'Create Variant'), Url::toRoute(['create','product_id'=> $product_id]), ['class' => 'btn btn-success']) ?> @@ -32,7 +31,6 @@ if (!empty($product)) { 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - [ 'attribute' => 'product_id', 'value' => 'fullname', @@ -40,7 +38,7 @@ if (!empty($product)) { 'filter' => \kartik\select2\Select2::widget([ 'model' => $searchModel, 'attribute' => 'product_id', - 'data' => \yii\helpers\ArrayHelper::map(\common\modules\product\models\Product::find()->orderBy(['name' => 'ASC'])->all(), 'product_id', 'name'), +// 'data' => \yii\helpers\ArrayHelper::map(\common\modules\product\models\Product::find()->orderBy(['name' => 'ASC'])->all(), 'product_id', 'name'), 'language' => 'ru', 'options' => [ 'placeholder' => Yii::t('product', 'Select product'), @@ -55,7 +53,6 @@ if (!empty($product)) { 'price', 'price_old', 'stock', - [ 'class' => 'yii\grid\ActionColumn', 'buttons' => [ diff --git a/common/modules/product/views/variant/update.php b/common/modules/product/views/variant/update.php index 536797a..aa0a70a 100644 --- a/common/modules/product/views/variant/update.php +++ b/common/modules/product/views/variant/update.php @@ -17,13 +17,13 @@ */ $this->title = Yii::t('product', 'Update {modelClass}: ', [ 'modelClass' => 'Product', - ]) . ' ' . $model->name; + ]) . ' ' . $model->product_variant_id; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('product', 'Products'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->product->name, + 'label' => $model->product->product_id, 'url' => [ 'view', 'id' => $model->product->product_id, diff --git a/common/modules/product/views/variant/view.php b/common/modules/product/views/variant/view.php index 5eaecd8..fc40bfb 100644 --- a/common/modules/product/views/variant/view.php +++ b/common/modules/product/views/variant/view.php @@ -4,11 +4,11 @@ use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ -/* @var $model common\modules\product\models\Product */ +/* @var $model common\modules\product\models\ProductVariant */ -$this->title = $model->name; +$this->title = $model->product_variant_id; $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->product->name, 'url' => ['view', 'id' => $model->product->product_id]]; +$this->params['breadcrumbs'][] = ['label' => $model->product->lang->name, 'url' => ['view', 'id' => $model->product->product_id]]; $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Variants'), 'url' => ['/product/variant?product_id='. $model->product->product_id]]; $this->params['breadcrumbs'][] = $this->title; ?> @@ -31,10 +31,7 @@ $this->params['breadcrumbs'][] = $this->title; 'model' => $model, 'attributes' => [ 'product_id', - 'name', 'fullname', - 'brand.name', - 'category.name', 'image.imageUrl:image' ], ]) ?> diff --git a/common/modules/rubrication/controllers/TaxOptionController.php b/common/modules/rubrication/controllers/TaxOptionController.php index b2bb1c3..cf7a3c1 100644 --- a/common/modules/rubrication/controllers/TaxOptionController.php +++ b/common/modules/rubrication/controllers/TaxOptionController.php @@ -9,7 +9,6 @@ use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; - use yii\web\UploadedFile; /** * TaxOptionController implements the CRUD actions for TaxOption model. @@ -78,23 +77,8 @@ $model_langs = $model->generateLangs(); $group = TaxGroup::findOne(Yii::$app->request->queryParams[ 'group' ]); - if($model->load(Yii::$app->request->post())) { + if($model->load(Yii::$app->request->post()) && $model->save()) { $model->loadLangs(\Yii::$app->request, $model_langs); - if(( $image = UploadedFile::getInstance($model, 'image') )) { - $model->image = $image->name; - } - if($model->save() && $image) { - - $imgDir = Yii::getAlias('@storage/tax_option/'); - - if(!is_dir($imgDir)) { - mkdir($imgDir, 0755, true); - } - - $image->saveAs(Yii::getAlias('@storage/tax_option/' . $image->name)); - } - - $model->save(); if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ @@ -108,17 +92,16 @@ ]); } - } else { - $model->tax_group_id = $group->tax_group_id; - if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) { - $model->parent_id = Yii::$app->request->queryParams[ 'parent' ]; - } - return $this->render('create', [ - 'model' => $model, - 'model_langs' => $model_langs, - 'group' => $group, - ]); } + $model->tax_group_id = $group->tax_group_id; + if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) { + $model->parent_id = Yii::$app->request->queryParams[ 'parent' ]; + } + return $this->render('create', [ + 'model' => $model, + 'model_langs' => $model_langs, + 'group' => $group, + ]); } /** @@ -135,21 +118,8 @@ $model_langs = $model->generateLangs(); $group = TaxGroup::findOne($model->tax_group_id); - if($model->load(Yii::$app->request->post())) { + if($model->load(Yii::$app->request->post()) && $model->save()) { $model->loadLangs(\Yii::$app->request, $model_langs); - if(( $image = UploadedFile::getInstance($model, 'image') )) { - $model->image = $image->name; - } - if($model->save() && $image) { - - $imgDir = Yii::getAlias('@storage/tax_option/'); - - if(!is_dir($imgDir)) { - mkdir($imgDir, 0755, true); - } - - $image->saveAs(Yii::getAlias('@storage/tax_option/' . $image->name)); - } TaxOption::find() ->rebuildMP($model->tax_group_id); diff --git a/common/modules/rubrication/models/TaxGroup.php b/common/modules/rubrication/models/TaxGroup.php index 6adf067..da9ca02 100644 --- a/common/modules/rubrication/models/TaxGroup.php +++ b/common/modules/rubrication/models/TaxGroup.php @@ -7,43 +7,39 @@ use yii\db\ActiveQuery; use yii\db\ActiveRecord; use yii\web\Request; - + /** * This is the model class for table "{{%tax_group}}". - * @property integer $tax_group_id - * @property string $alias - * @property string $name - * @property string $description - * @property boolean $is_filter - * @property integer $level - * @property integer $sort - * @property boolean $display - * @property boolean $is_menu - * @property TaxOption[] $taxOptions - * @property Category[] $categories - * @property TaxOption[] $options - * + * @property integer $tax_group_id + * @property boolean $is_filter + * @property integer $level + * @property integer $sort + * @property boolean $display + * @property boolean $is_menu + * @property TaxOption[] $taxOptions + * @property Category[] $categories + * @property TaxOption[] $options * * From language behavior * - * @property TaxGroupLang $lang - * @property TaxGroupLang[] $langs - * @property TaxGroupLang $object_lang + * @property TaxGroupLang $lang + * @property TaxGroupLang[] $langs + * @property TaxGroupLang $object_lang * @property string $ownerKey * @property string $langKey * @method string getOwnerKey() - * @method void setOwnerKey(string $value) + * @method void setOwnerKey( string $value ) * @method string getLangKey() - * @method void setLangKey(string $value) + * @method void setLangKey( string $value ) * @method ActiveQuery getLangs() * @method ActiveQuery getLang( integer $language_id ) * @method TaxGroupLang[] generateLangs() - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) - * @method bool linkLangs(ActiveRecord[] $model_langs) - * @method bool saveLangs(ActiveRecord[] $model_langs) + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) + * @method bool linkLangs( ActiveRecord[] $model_langs ) + * @method bool saveLangs( ActiveRecord[] $model_langs ) * * End language behavior * */ class TaxGroup extends \yii\db\ActiveRecord { - + /** * @var TaxOption[] $_options */ @@ -55,12 +51,6 @@ public function behaviors() { return [ - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true, - ], 'language' => [ 'class' => LanguageBehavior::className(), ], @@ -83,18 +73,6 @@ return [ [ [ - 'name', - ], - 'required', - ], - [ - [ - 'description', - ], - 'string', - ], - [ - [ 'is_filter', 'display', 'is_menu', @@ -109,18 +87,6 @@ 'integer', ], [ - [ - 'alias', - ], - 'string', - 'max' => 50, - ], - [ - [ 'name' ], - 'string', - 'max' => 255, - ], - [ [ 'categories' ], 'safe', ], @@ -134,9 +100,6 @@ { return [ 'tax_group_id' => 'Tax Group ID', - 'alias' => 'Alias', - 'name' => 'Name', - 'description' => 'Description', 'is_filter' => 'Use in filter', 'sort' => 'Sort', 'display' => 'Display', diff --git a/common/modules/rubrication/models/TaxGroupLang.php b/common/modules/rubrication/models/TaxGroupLang.php index 932ed16..5a7b324 100644 --- a/common/modules/rubrication/models/TaxGroupLang.php +++ b/common/modules/rubrication/models/TaxGroupLang.php @@ -1,81 +1,129 @@ 255], - [['tax_group_id', 'language_id'], 'unique', 'targetAttribute' => ['tax_group_id', 'language_id'], 'message' => 'The combination of Tax Group ID and Language ID has already been taken.'], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], - [['tax_group_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxGroup::className(), 'targetAttribute' => ['tax_group_id' => 'tax_group_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'tax_group_id' => Yii::t('app', 'Tax Group ID'), - 'language_id' => Yii::t('app', 'Language ID'), - 'name' => Yii::t('app', 'Name'), - 'description' => Yii::t('app', 'Description'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLanguage() - { - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); - } - - /** - * @return \yii\db\ActiveQuery + * This is the model class for table "tax_group_lang". + * @property integer $tax_group_id + * @property integer $language_id + * @property string $name + * @property string $alias + * @property string $description + * @property Language $language + * @property TaxGroup $taxGroup */ - public function getTaxGroup() + class TaxGroupLang extends \yii\db\ActiveRecord { - return $this->hasOne(TaxGroup::className(), ['tax_group_id' => 'tax_group_id']); + + public static function primaryKey() + { + return [ + 'tax_group_id', + 'language_id', + ]; + } + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'tax_group_lang'; + } + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'name' ], + 'required', + ], + [ + [ 'description' ], + 'string', + ], + [ + [ + 'name', + 'alias', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'tax_group_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'tax_group_id', + 'language_id', + ], + 'message' => 'The combination of Tax Group ID and Language ID has already been taken.', + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'language_id' ], + ], + [ + [ 'tax_group_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => TaxGroup::className(), + 'targetAttribute' => [ 'tax_group_id' => 'tax_group_id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'tax_group_id' => Yii::t('app', 'Tax Group ID'), + 'language_id' => Yii::t('app', 'Language ID'), + 'name' => Yii::t('app', 'Name'), + 'description' => Yii::t('app', 'Description'), + 'alias' => Yii::t('app', 'Alias'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getTaxGroup() + { + return $this->hasOne(TaxGroup::className(), [ 'tax_group_id' => 'tax_group_id' ]); + } } -} diff --git a/common/modules/rubrication/models/TaxOption.php b/common/modules/rubrication/models/TaxOption.php index 23af484..b3e7126 100644 --- a/common/modules/rubrication/models/TaxOption.php +++ b/common/modules/rubrication/models/TaxOption.php @@ -2,6 +2,7 @@ namespace common\modules\rubrication\models; + use common\behaviors\SaveImgBehavior; use common\modules\language\behaviors\LanguageBehavior; use common\modules\product\models\Product; use Yii; @@ -9,40 +10,37 @@ use yii\db\ActiveQuery; use yii\db\ActiveRecord; use yii\web\Request; - + /** * This is the model class for table "{{%tax_option}}". - * @property string $tax_option_id - * @property integer $tax_group_id - * @property integer $parent_id - * @property integer $tree - * @property string $path_int - * @property integer $depth - * @property string $alias - * @property integer $sort - * @property integer $value - * @property array $image - * @property TaxGroup $taxGroup - * @property TaxOption $parent - * @property TaxOption[] $taxOptions - * @property Product[] $products - * + * @property string $tax_option_id + * @property integer $tax_group_id + * @property integer $parent_id + * @property integer $tree + * @property string $path_int + * @property integer $depth + * @property integer $sort + * @property string $image + * @property TaxGroup $taxGroup + * @property TaxOption $parent + * @property TaxOption[] $taxOptions + * @property Product[] $products * * From language behavior * - * @property TaxOptionLang $lang - * @property TaxOptionLang[] $langs - * @property TaxOptionLang $object_lang - * @property string $ownerKey - * @property string $langKey + * @property TaxOptionLang $lang + * @property TaxOptionLang[] $langs + * @property TaxOptionLang $object_lang + * @property string $ownerKey + * @property string $langKey * @method string getOwnerKey() - * @method void setOwnerKey(string $value) + * @method void setOwnerKey( string $value ) * @method string getLangKey() - * @method void setLangKey(string $value) + * @method void setLangKey( string $value ) * @method ActiveQuery getLangs() * @method ActiveQuery getLang( integer $language_id ) * @method TaxOptionLang[] generateLangs() - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) - * @method bool linkLangs(ActiveRecord[] $model_langs) - * @method bool saveLangs(ActiveRecord[] $model_langs) + * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) + * @method bool linkLangs( ActiveRecord[] $model_langs ) + * @method bool saveLangs( ActiveRecord[] $model_langs ) * * End language behavior * */ class TaxOption extends \yii\db\ActiveRecord @@ -56,17 +54,20 @@ public function behaviors() { return [ + [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'tax_option', + ], + ], + ], 'artboxtree' => [ 'class' => ArtboxTreeBehavior::className(), 'keyNameGroup' => 'tax_group_id', ], - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'value', - 'out_attribute' => 'alias', - 'translit' => true, - ], - 'language' => [ + 'language' => [ 'class' => LanguageBehavior::className(), ], ]; @@ -89,7 +90,6 @@ [ [ 'tax_group_id', - 'value', ], 'required', ], @@ -102,15 +102,6 @@ 'integer', ], [ - [ - 'image', - 'alias', - 'value', - ], - 'string', - 'max' => 255, - ], - [ [ 'tax_group_id' ], 'exist', 'skipOnError' => true, @@ -129,7 +120,6 @@ 'tax_option_id' => Yii::t('app', 'Tax Option ID'), 'tax_group_id' => Yii::t('app', 'Tax Group ID'), 'parent_id' => Yii::t('app', 'Parent ID'), - 'alias' => Yii::t('app', 'Alias'), 'sort' => Yii::t('app', 'Sort'), 'image' => Yii::t('product', 'Image'), ]; @@ -177,16 +167,6 @@ return false; } - public function getImageFile() - { - return empty( $this->image ) ? NULL : Yii::getAlias('@imagesDir/tax_option/' . $this->image); - } - - public function getImageUrl() - { - return empty( $this->image ) ? NULL : Yii::getAlias('@imagesUrl/tax_option/' . $this->image); - } - public function getProducts() { return $this->hasMany(Product::className(), [ 'product_id' => 'product_id' ]) diff --git a/common/modules/rubrication/models/TaxOptionLang.php b/common/modules/rubrication/models/TaxOptionLang.php index 2199401..bcb08cd 100644 --- a/common/modules/rubrication/models/TaxOptionLang.php +++ b/common/modules/rubrication/models/TaxOptionLang.php @@ -1,78 +1,123 @@ 255], - [['tax_option_id', 'language_id'], 'unique', 'targetAttribute' => ['tax_option_id', 'language_id'], 'message' => 'The combination of Tax Option ID and Language ID has already been taken.'], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], - [['tax_option_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxOption::className(), 'targetAttribute' => ['tax_option_id' => 'tax_option_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'tax_option_id' => Yii::t('app', 'Tax Option ID'), - 'language_id' => Yii::t('app', 'Language ID'), - 'value' => Yii::t('app', 'Value'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLanguage() - { - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); - } - - /** - * @return \yii\db\ActiveQuery + * This is the model class for table "tax_option_lang". + * @property integer $tax_option_id + * @property integer $language_id + * @property string $value + * @property string $alias + * @property Language $language + * @property TaxOption $taxOption */ - public function getTaxOption() + class TaxOptionLang extends \yii\db\ActiveRecord { - return $this->hasOne(TaxOption::className(), ['tax_option_id' => 'tax_option_id']); + + public static function primaryKey() + { + return [ + 'tax_option_id', + 'language_id', + ]; + } + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'tax_option_lang'; + } + + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'value', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'value' ], + 'required', + ], + [ + [ + 'value', + 'alias', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'tax_option_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'tax_option_id', + 'language_id', + ], + 'message' => 'The combination of Tax Option ID and Language ID has already been taken.', + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'language_id' ], + ], + [ + [ 'tax_option_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => TaxOption::className(), + 'targetAttribute' => [ 'tax_option_id' => 'tax_option_id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'tax_option_id' => Yii::t('app', 'Tax Option ID'), + 'language_id' => Yii::t('app', 'Language ID'), + 'value' => Yii::t('app', 'Value'), + 'alias' => Yii::t('app', 'Alias'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getTaxOption() + { + return $this->hasOne(TaxOption::className(), [ 'tax_option_id' => 'tax_option_id' ]); + } } -} diff --git a/common/modules/rubrication/models/TaxOptionSearch.php b/common/modules/rubrication/models/TaxOptionSearch.php index 31d246b..7d5e52d 100644 --- a/common/modules/rubrication/models/TaxOptionSearch.php +++ b/common/modules/rubrication/models/TaxOptionSearch.php @@ -27,7 +27,6 @@ class TaxOptionSearch extends TaxOption { return [ [['tax_option_id', 'tax_group_id', 'parent_id', 'sort'], 'integer'], - [['alias', 'value'], 'safe'], ]; } @@ -73,9 +72,7 @@ class TaxOptionSearch extends TaxOption 'parent_id' => $this->parent_id, 'sort' => $this->sort, ]); - - $query->andFilterWhere(['like', 'alias', $this->alias]); - + $query->orderBy(['path_int' => SORT_ASC, 'depth' => SORT_ASC, 'sort' => SORT_ASC]); return $dataProvider; diff --git a/common/modules/rubrication/views/tax-group/_form.php b/common/modules/rubrication/views/tax-group/_form.php index 5b7f20c..8801508 100644 --- a/common/modules/rubrication/views/tax-group/_form.php +++ b/common/modules/rubrication/views/tax-group/_form.php @@ -21,17 +21,8 @@ [ 'enctype' => 'multipart/form-data' ] ]); ?> - = $form->field($model, 'name') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'alias') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'description') - ->textarea([ 'rows' => 6 ]) ?> - = $form->field($model, 'categories') - ->dropDownList(ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'), [ + ->dropDownList(ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'category_id'), [ 'multiple' => true, ]) ->label('Use in the following categories') ?> diff --git a/common/modules/rubrication/views/tax-group/_form_language.php b/common/modules/rubrication/views/tax-group/_form_language.php index 00be83b..9c52182 100644 --- a/common/modules/rubrication/views/tax-group/_form_language.php +++ b/common/modules/rubrication/views/tax-group/_form_language.php @@ -13,5 +13,7 @@ ?> = $form->field($model_lang, '[' . $language->language_id . ']name') ->textInput([ 'maxlength' => true ]); ?> += $form->field($model_lang, '[' . $language->language_id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> = $form->field($model_lang, '[' . $language->language_id . ']description') ->textarea([ 'rows' => 6 ]) ?> \ No newline at end of file diff --git a/common/modules/rubrication/views/tax-group/index.php b/common/modules/rubrication/views/tax-group/index.php index 5da36a4..f9110ed 100644 --- a/common/modules/rubrication/views/tax-group/index.php +++ b/common/modules/rubrication/views/tax-group/index.php @@ -1,71 +1,80 @@ title = Yii::t('rubrication', 'Groups'); -$this->params['breadcrumbs'][] = $this->title; + use yii\helpers\Html; + use yii\grid\GridView; + use yii\helpers\Url; + + /* @var $this yii\web\View */ + /* @var $level integer + /* @var $dataProvider yii\data\ActiveDataProvider */ + + $this->title = Yii::t('rubrication', 'Groups'); + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- = Html::a(Yii::t('rubrication', 'Create Group'), Url::to(['/rubrication/tax-group/create', 'level'=> $level]), ['class' => 'btn btn-success']) ?> + = Html::a(Yii::t('rubrication', 'Create Group'), Url::to([ + '/rubrication/tax-group/create', + 'level' => $level, + ]), [ 'class' => 'btn btn-success' ]) ?>
- + = GridView::widget([ 'dataProvider' => $dataProvider, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'name', - 'alias', - 'description:ntext', - 'is_filter:boolean', - + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], + 'tax_group_id', + 'is_filter:boolean', + [ - 'class' => 'yii\grid\ActionColumn', - 'template' => '{update} {options} {relations} {delete} {rebuild}', - 'buttons' => [ - 'options' => function ($url, $model) { + 'class' => 'yii\grid\ActionColumn', + 'template' => '{update} {options} {relations} {delete} {rebuild}', + 'buttons' => [ + 'options' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('rubrication', 'Options'), ]); }, - 'relations' => function ($url, $model) { + 'relations' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('rubrication', 'Relations'), ]); }, - 'rebuild' => function ($url, $model) { + 'rebuild' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('rubrication', 'Rebuild cache'), ]); - } + }, ], - 'urlCreator' => function ($action, $model, $key, $index) use ($level) { - if ($action === 'options') { - $url ='/admin/rubrication/tax-option?group='.$model->tax_group_id; + 'urlCreator' => function($action, $model, $key, $index) use ($level) { + if($action === 'options') { + $url = '/admin/rubrication/tax-option?group=' . $model->tax_group_id; return $url; - } elseif ($action === 'relations') { - $url ='/admin/rubrication/tax-group/relation&id='.$model->tax_group_id; + } elseif($action === 'relations') { + $url = '/admin/rubrication/tax-group/relation&id=' . $model->tax_group_id; return $url; - } elseif ($action === 'update') { - $url =Url::to(['/rubrication/tax-group/update', 'level'=> $level,'id' =>$model->tax_group_id]); + } elseif($action === 'update') { + $url = Url::to([ + '/rubrication/tax-group/update', + 'level' => $level, + 'id' => $model->tax_group_id, + ]); return $url; - } elseif ($action === 'delete') { - $url =Url::to(['/rubrication/tax-group/delete', 'level'=> $level,'id' =>$model->tax_group_id]); + } elseif($action === 'delete') { + $url = Url::to([ + '/rubrication/tax-group/delete', + 'level' => $level, + 'id' => $model->tax_group_id, + ]); return $url; - } elseif ($action === 'rebuild') { - $url ='/admin/rubrication/tax-group/rebuild?id='.$model->tax_group_id; + } elseif($action === 'rebuild') { + $url = '/admin/rubrication/tax-group/rebuild?id=' . $model->tax_group_id; return $url; } - } + return ''; + }, ], ], ]); ?> diff --git a/common/modules/rubrication/views/tax-group/update.php b/common/modules/rubrication/views/tax-group/update.php index 32e358d..47eefa0 100644 --- a/common/modules/rubrication/views/tax-group/update.php +++ b/common/modules/rubrication/views/tax-group/update.php @@ -13,13 +13,13 @@ $this->title = Yii::t('rubrication', 'Update {modelClass}: ', [ 'modelClass' => 'Tax Group', - ]) . ' ' . $model->name; + ]) . ' ' . $model->tax_group_id; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('rubrication', 'Groups'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->name, + 'label' => $model->tax_group_id, 'url' => [ 'view', 'id' => $model->tax_group_id, diff --git a/common/modules/rubrication/views/tax-group/view.php b/common/modules/rubrication/views/tax-group/view.php index 00be9e5..ceaafcc 100644 --- a/common/modules/rubrication/views/tax-group/view.php +++ b/common/modules/rubrication/views/tax-group/view.php @@ -1,38 +1,44 @@ title = $model->name; -$this->params['breadcrumbs'][] = ['label' => Yii::t('rubrication', 'Tax Groups'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; + + use yii\helpers\Html; + use yii\widgets\DetailView; + + /* @var $this yii\web\View */ + /* @var $model common\modules\rubrication\models\TaxGroup */ + + $this->title = $model->tax_group_id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('rubrication', 'Tax Groups'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>- = Html::a(Yii::t('rubrication', 'Update'), ['update', 'id' => $model->tax_group_id], ['class' => 'btn btn-primary']) ?> - = Html::a(Yii::t('rubrication', 'Delete'), ['delete', 'id' => $model->tax_group_id], [ + = Html::a(Yii::t('rubrication', 'Update'), [ + 'update', + 'id' => $model->tax_group_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(Yii::t('rubrication', 'Delete'), [ + 'delete', + 'id' => $model->tax_group_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('rubrication', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?> - = Html::a(Yii::t('rubrication', 'Create Option'), ['tax-option/create?group='. $model->tax_group_id], ['class' => 'btn btn-success']) ?> + = Html::a(Yii::t('rubrication', 'Create Option'), [ 'tax-option/create?group=' . $model->tax_group_id ], [ 'class' => 'btn btn-success' ]) ?>
- + = DetailView::widget([ 'model' => $model, 'attributes' => [ 'tax_group_id', - 'alias', - 'name', - 'description:ntext', 'is_filter:boolean', ], ]) ?> diff --git a/common/modules/rubrication/views/tax-option/_form.php b/common/modules/rubrication/views/tax-option/_form.php index 306ff19..855de92 100644 --- a/common/modules/rubrication/views/tax-option/_form.php +++ b/common/modules/rubrication/views/tax-option/_form.php @@ -24,7 +24,7 @@ tax_group_id )) : ?> = $form->field($model, 'tax_group_id') ->dropDownList(ArrayHelper::map(TaxOption::find() - ->all(), 'tax_group_id', 'value'), [ + ->all(), 'tax_group_id', 'tax_group_id'), [ 'prompt' => Yii::t('rubrication', 'Select group'), ]) ?> @@ -33,15 +33,8 @@ ->label('') ?> - - = $form->field($model, 'value') - ->textInput([ 'maxlength' => true ]) ?> - - = $form->field($model, 'alias') - ->textInput([ 'maxlength' => true ]) ?> - = $form->field($model, 'image') - ->widget(\kartik\file\FileInput::classname(), [ + ->widget(\kartik\file\FileInput::className(), [ 'language' => 'ru', 'options' => [ 'accept' => 'image/*', diff --git a/common/modules/rubrication/views/tax-option/_form_language.php b/common/modules/rubrication/views/tax-option/_form_language.php index 1472fb3..28ef000 100644 --- a/common/modules/rubrication/views/tax-option/_form_language.php +++ b/common/modules/rubrication/views/tax-option/_form_language.php @@ -12,4 +12,6 @@ */ ?> = $form->field($model_lang, '[' . $language->language_id . ']value') - ->textInput([ 'maxlength' => true ]); ?> \ No newline at end of file + ->textInput([ 'maxlength' => true ]); ?> += $form->field($model_lang, '[' . $language->language_id . ']alias') + ->textInput([ 'maxlength' => true ]); ?> diff --git a/common/modules/rubrication/views/tax-option/create.php b/common/modules/rubrication/views/tax-option/create.php index 297654d..f23688c 100644 --- a/common/modules/rubrication/views/tax-option/create.php +++ b/common/modules/rubrication/views/tax-option/create.php @@ -16,14 +16,14 @@ 'url' => [ 'tax-group/index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => Yii::t('rubrication', $group->name), + 'label' => Yii::t('rubrication', $group->tax_group_id), 'url' => [ 'index', 'group' => $group->tax_group_id, ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->name ])), + 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->tax_group_id ])), 'url' => [ 'index', 'group' => $group->tax_group_id, diff --git a/common/modules/rubrication/views/tax-option/index.php b/common/modules/rubrication/views/tax-option/index.php index a5dd6c6..a1a7350 100644 --- a/common/modules/rubrication/views/tax-option/index.php +++ b/common/modules/rubrication/views/tax-option/index.php @@ -11,7 +11,7 @@ * @var TaxGroup $group */ - $this->title = Yii::t('rubrication', 'Options for group "{group}"', [ 'group' => $group->name ]); + $this->title = Yii::t('rubrication', 'Options for group "{group}"', [ 'group' => $group->tax_group_id ]); $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('rubrication', 'Groups'), 'url' => [ 'tax-group/index' ], @@ -30,8 +30,7 @@ 'dataProvider' => $dataProvider, 'columns' => [ [ 'class' => 'yii\grid\SerialColumn' ], - 'value', - 'alias', + 'tax_option_id', [ 'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}', diff --git a/common/modules/rubrication/views/tax-option/update.php b/common/modules/rubrication/views/tax-option/update.php index 148060a..e2b28f5 100644 --- a/common/modules/rubrication/views/tax-option/update.php +++ b/common/modules/rubrication/views/tax-option/update.php @@ -18,14 +18,14 @@ 'url' => [ 'tax-group/index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $group->name, + 'label' => $group->tax_group_id, 'url' => [ 'view', 'id' => $group->tax_group_id, ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->name ])), + 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->tax_group_id ])), 'url' => [ 'index', 'group' => $group->tax_group_id, diff --git a/common/modules/rubrication/views/tax-option/view.php b/common/modules/rubrication/views/tax-option/view.php index 425ad73..1f9f428 100644 --- a/common/modules/rubrication/views/tax-option/view.php +++ b/common/modules/rubrication/views/tax-option/view.php @@ -1,44 +1,63 @@ title = $model->value; -$this->params['breadcrumbs'][] = ['label' => Yii::t('rubrication', 'Groups'), 'url' => ['tax-group/index']]; -$this->params['breadcrumbs'][] = ['label' => Yii::t('rubrication', $group->name), 'url' => ['index', 'group' => $group->tax_group_id]]; -$this->params['breadcrumbs'][] = ['label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', ['name' => $group->name])), 'url' => ['index', 'group' => $group->tax_group_id]]; -$this->params['breadcrumbs'][] = $this->title; + + use yii\helpers\Html; + use yii\widgets\DetailView; + + /* @var $this yii\web\View */ + /* @var $model common\modules\rubrication\models\TaxOption */ + + $this->title = $model->tax_option_id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('rubrication', 'Groups'), + 'url' => [ 'tax-group/index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('rubrication', $group->tax_group_id), + 'url' => [ + 'index', + 'group' => $group->tax_group_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->tax_group_id ])), + 'url' => [ + 'index', + 'group' => $group->tax_group_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>- = Html::a(Yii::t('rubrication', 'Update'), ['update', 'id' => $model->tax_option_id], ['class' => 'btn btn-primary']) ?> - = Html::a(Yii::t('rubrication', 'Delete'), ['delete', 'id' => $model->tax_option_id], [ + = Html::a(Yii::t('rubrication', 'Update'), [ + 'update', + 'id' => $model->tax_option_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + = Html::a(Yii::t('rubrication', 'Delete'), [ + 'delete', + 'id' => $model->tax_option_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('rubrication', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?> - = Html::a(Yii::t('rubrication', 'Create Option'), ['tax-option/create?group='. $model->tax_group_id], ['class' => 'btn btn-success']) ?> - parent_id)) :?> - = Html::a(Yii::t('rubrication', 'Create Option By {name}', ['name' => $model->parent->value]), ['tax-option/create?group='. $model->tax_group_id .'&parent='. $model->parent->tax_option_id], ['class' => 'btn btn-success']) ?> - + = Html::a(Yii::t('rubrication', 'Create Option'), [ 'tax-option/create?group=' . $model->tax_group_id ], [ 'class' => 'btn btn-success' ]) ?> + parent_id )) : ?> + = Html::a(Yii::t('rubrication', 'Create Option By {name}', [ 'name' => $model->parent->tax_option_id ]), [ 'tax-option/create?group=' . $model->tax_group_id . '&parent=' . $model->parent->tax_option_id ], [ 'class' => 'btn btn-success' ]) ?> +
- + = DetailView::widget([ 'model' => $model, 'attributes' => [ 'tax_option_id', - 'value', - 'alias', - 'parent.value', - 'group.name', + 'parent.tax_option_id', + 'group.tax_group_id', 'sort', ], ]) ?> diff --git a/console/migrations/m161004_102751_add_lang_column.php b/console/migrations/m161004_102751_add_lang_column.php new file mode 100644 index 0000000..63006ec --- /dev/null +++ b/console/migrations/m161004_102751_add_lang_column.php @@ -0,0 +1,55 @@ +addColumn('articles_lang', 'alias', $this->string(255)); + $this->addColumn('brand_lang', 'alias', $this->string(255)); + $this->addColumn('category_lang', 'alias', $this->string(255)); + $this->addColumn('event_lang', 'alias', $this->string(255)); + $this->addColumn('page_lang', 'alias', $this->string(255)); + $this->addColumn('product_lang', 'alias', $this->string(255)); + $this->addColumn('project_lang', 'alias', $this->string(255)); + $this->addColumn('service_lang', 'alias', $this->string(255)); + $this->addColumn('tax_group_lang', 'alias', $this->string(255)); + $this->addColumn('tax_option_lang', 'alias', $this->string(255)); + $this->createIndex('articles_lang_alias', 'articles_lang', 'alias', true); + $this->createIndex('brand_lang_alias', 'brand_lang', 'alias', true); + $this->createIndex('category_lang_alias', 'category_lang', 'alias', true); + $this->createIndex('event_lang_alias', 'event_lang', 'alias', true); + $this->createIndex('page_lang_alias', 'page_lang', 'alias', true); + $this->createIndex('product_lang_alias', 'product_lang', 'alias', true); + $this->createIndex('project_lang_alias', 'project_lang', 'alias', true); + $this->createIndex('service_lang_alias', 'service_lang', 'alias', true); + $this->createIndex('tax_group_lang_alias', 'tax_group_lang', 'alias', true); + $this->createIndex('tax_option_lang_alias', 'tax_option_lang', 'alias', true); + } + + public function down() + { + $this->dropIndex('articles_lang_alias', 'articles_lang'); + $this->dropIndex('brand_lang_alias', 'brand_lang'); + $this->dropIndex('category_lang_alias', 'category_lang'); + $this->dropIndex('event_lang_alias', 'event_lang'); + $this->dropIndex('page_lang_alias', 'page_lang'); + $this->dropIndex('product_lang_alias', 'product_lang'); + $this->dropIndex('project_lang_alias', 'project_lang'); + $this->dropIndex('service_lang_alias', 'service_lang'); + $this->dropIndex('tax_group_lang_alias', 'tax_group_lang'); + $this->dropIndex('tax_option_lang_alias', 'tax_option_lang'); + $this->dropColumn('articles_lang', 'alias'); + $this->dropColumn('brand_lang', 'alias'); + $this->dropColumn('category_lang', 'alias'); + $this->dropColumn('event_lang', 'alias'); + $this->dropColumn('page_lang', 'alias'); + $this->dropColumn('product_lang', 'alias'); + $this->dropColumn('project_lang', 'alias'); + $this->dropColumn('service_lang', 'alias'); + $this->dropColumn('tax_group_lang', 'alias'); + $this->dropColumn('tax_option_lang', 'alias'); + } + } diff --git a/todo b/todo index b18ef70..951ea93 100644 --- a/todo +++ b/todo @@ -1,10 +1,78 @@ -1. OrdersDelivery - добавить возможность добавления. -2. Переименовать все id в table_id. -3. Переименовать все table!s! в table. -4. Пересмотреть структура таблицы orders_products. -5. Посмотреть разницу ProductVariantSearch и ProductVariantListSearch. -6. Wishlist -7. Lookbook (типа коллекций)? +1. Написать стандарты. +1.1. Таблицы и колонки. (0.25 час Ярик, Виталик) +1.2. Классы. (0.25 час Ярик, Виталик) (http://svyatoslav.biz/misc/psr_translation/) +1.3. Написать как пользоваться GIT. (1 час Виталик) +1.4. Стандарты по JS (pure, jQuery). (1 час Ярик) (https://learn.javascript.ru/coding-style) + +2. База данных. +2.1. Удалить поля, которые перешли в мультиязычность. (1 час Ярик) +2.2. Привести наименование колонок и таблиц к одному стилю. (1 час Ярик) +2.3. Написать миграциию. (15 мин на таблицу 71 таблица) (20 часа Женя, 1 час Ярик) + +3. Классы +3.1. Пофиксить после изменений в базе + формы. (8 часов Ярик) +3.2. SlugBeahvior перенести на классы языков где требуется. (1 час Ярик) + +4. Админка +4.1. Почистить админку. +4.2. Перевести все поля. (3 час Женя) +4.3. Пофиксить крошки и другие баги. (3 часа Леша) +4.4. Настроить везде одинаковую загрузку картинок (1 час Ярик) +4.4.1. Написать behavior для множественной загрузки картинок. (4 час Виталик) +4.5. Добавить страницы добавления OrdersDelivery, OrdersLabel. (2 час Леша) +4.6. Вывод информации на главную страницу админки. (∞ Леша) + +5. Подготовка под Composer (∞) (https://github.com/yiisoft/yii2/blob/master/docs/guide-ru/structure-extensions.md#Создание-расширений-) +5.1. Свести все зависимости в одну директорию. +5.2. Свести все ключевые правки в один проект. +5.2.1. Импорт с линии света (∞ Виталик) +5.2.2. Акции с рюкзака (1 час Виталик) +5.2.3. Мультиязычность с витекса (1 часа Ярик) +5.2.4. Блог на бакаре (Леша) +5.2.5. Загрузка картинок с витекса (0.25 часа Ярик) + +6. Модуль заказов +6.1. Доставка +6.1.1. Бесплатная +6.1.2. Доставка новая почта +6.2. Оплата онлайн + +7. Wishlist + 8. Compare -9. Tags для блога -10. Social integration \ No newline at end of file + +9. Blog (Леша делает) +9.1. Рубрики +9.2. Теги + +10. Сторонние сервисы +10.1. Доставка +10.2. Оплата +10.3. Интеграция с 1С (baucenter) (3 часа Виталик) + +11. Базовая верстка + +12. Фильтры (8 часа Ярик, Виталик) +12.1. Чтобы исчезали + +13. Пофиксить Product Stock (1 час Ярик) + +14. Настройка продакшн сервера (2 часа Виталик, Леша) + +15. Узнать о снижении цены + +16. Блок просмотренные товары + +17. Блок похожие товары + +18. Валюты + +19. Промокоды + +Осталось Ярик: +- Посмотреть разницу ProductVariantSearch и ProductVariantListSearch. +- Social integration + +Fix по существующему: +1. Product - разобратсья с картинками +2. Product->getCategories = Product->getCategoriesWithNames -- libgit2 0.21.4