Commit cf67df180a632000f3d350cb74cfbaa2f58f6755
1 parent
cc8a193d
карусель
Showing
27 changed files
with
1403 additions
and
10 deletions
Show diff stats
backend/config/main.php
@@ -27,14 +27,26 @@ | @@ -27,14 +27,26 @@ | ||
27 | 'components' => [ | 27 | 'components' => [ |
28 | 'assetManager' => [ | 28 | 'assetManager' => [ |
29 | 'bundles' => [ | 29 | 'bundles' => [ |
30 | - 'yiister\gentelella\assets\ThemeAsset' => [ | ||
31 | - 'basePath' => '@webroot', | ||
32 | - 'baseUrl' => '@web', | 30 | +// 'yiister\gentelella\assets\ThemeAsset' => [ |
31 | +// 'basePath' => '@webroot', | ||
32 | +// 'baseUrl' => '@web', | ||
33 | +// 'js' => [ | ||
34 | +// 'js/custom.js', | ||
35 | +// ], | ||
36 | +// 'css' => [ | ||
37 | +// 'css/custom.css', | ||
38 | +// ], | ||
39 | +// ], | ||
40 | + 'yiister\gentelella\assets\ThemeSrcAsset' => [ | ||
41 | + 'sourcePath' => null, // не опубликовывать комплект | ||
33 | 'js' => [ | 42 | 'js' => [ |
34 | - 'js/custom.js', | 43 | + 'admin/js/custom.js', |
35 | ], | 44 | ], |
36 | - 'css' => [ | ||
37 | - 'css/custom.css', | 45 | + ], |
46 | + 'yiister\gentelella\assets\ThemeBuildAsset'=> [ | ||
47 | + 'sourcePath' => null, // не опубликовывать комплект | ||
48 | + 'css' => [ | ||
49 | + 'admin/css/custom.css', | ||
38 | ], | 50 | ], |
39 | ], | 51 | ], |
40 | ], | 52 | ], |
1 | +<?php | ||
2 | + namespace backend\controllers; | ||
3 | + | ||
4 | + use artbox\core\controllers\SlideController as ArtboxSlideController; | ||
5 | + use common\models\Slider; | ||
6 | + use common\models\SlideSearch; | ||
7 | + use common\models\Slide; | ||
8 | + use yii\web\NotFoundHttpException; | ||
9 | + use Yii; | ||
10 | + /** | ||
11 | + * Created by PhpStorm. | ||
12 | + * User: timur | ||
13 | + * Date: 24.01.18 | ||
14 | + * Time: 15:09 | ||
15 | + */ | ||
16 | + | ||
17 | + class SlideController extends ArtboxSlideController | ||
18 | + { | ||
19 | + /** | ||
20 | + * Lists all Slide models. | ||
21 | + * | ||
22 | + * @param int $slider_id | ||
23 | + * | ||
24 | + * @return mixed | ||
25 | + */ | ||
26 | + public function actionIndex($slider_id) | ||
27 | + { | ||
28 | + $slider = $this->findSlider($slider_id); | ||
29 | + $searchModel = new SlideSearch(); | ||
30 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $slider); | ||
31 | + | ||
32 | + return $this->render( | ||
33 | + 'index', | ||
34 | + [ | ||
35 | + 'searchModel' => $searchModel, | ||
36 | + 'dataProvider' => $dataProvider, | ||
37 | + 'slider' => $slider, | ||
38 | + ] | ||
39 | + ); | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * Displays a single Slide model. | ||
44 | + * | ||
45 | + * @param integer $id | ||
46 | + * | ||
47 | + * @return mixed | ||
48 | + */ | ||
49 | + public function actionView($id) | ||
50 | + { | ||
51 | + return $this->render( | ||
52 | + 'view', | ||
53 | + [ | ||
54 | + 'model' => $this->findModel($id), | ||
55 | + ] | ||
56 | + ); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a new Slide model. | ||
61 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
62 | + * | ||
63 | + * @param int $slider_id | ||
64 | + * | ||
65 | + * @return mixed | ||
66 | + */ | ||
67 | + public function actionCreate(int $slider_id) | ||
68 | + { | ||
69 | + $slider = $this->findSlider($slider_id); | ||
70 | + | ||
71 | + $model = new Slide(); | ||
72 | + $model->generateLangs(); | ||
73 | + | ||
74 | + if ($model->loadWithLangs(\Yii::$app->request)) { | ||
75 | + if ($model->saveWithLangs()) { | ||
76 | + return $this->redirect( | ||
77 | + [ | ||
78 | + 'view', | ||
79 | + 'id' => $model->id, | ||
80 | + ] | ||
81 | + ); | ||
82 | + } | ||
83 | + } | ||
84 | + return $this->render( | ||
85 | + 'create', | ||
86 | + [ | ||
87 | + 'model' => $model, | ||
88 | + 'modelLangs' => $model->modelLangs, | ||
89 | + 'slider' => $slider, | ||
90 | + ] | ||
91 | + ); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Updates an existing Slide model. | ||
96 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
97 | + * | ||
98 | + * @param integer $id | ||
99 | + * | ||
100 | + * @return mixed | ||
101 | + */ | ||
102 | + public function actionUpdate($id) | ||
103 | + { | ||
104 | + $model = $this->findModel($id); | ||
105 | + $model->generateLangs(); | ||
106 | + | ||
107 | + $slider = $this->findSlider($model->slider_id); | ||
108 | + | ||
109 | + if ($model->loadWithLangs(\Yii::$app->request)) { | ||
110 | + if ($model->saveWithLangs()) { | ||
111 | + return $this->redirect( | ||
112 | + [ | ||
113 | + 'view', | ||
114 | + 'id' => $model->id, | ||
115 | + ] | ||
116 | + ); | ||
117 | + } | ||
118 | + } | ||
119 | + return $this->render( | ||
120 | + 'update', | ||
121 | + [ | ||
122 | + 'model' => $model, | ||
123 | + 'modelLangs' => $model->modelLangs, | ||
124 | + 'slider' => $slider, | ||
125 | + ] | ||
126 | + ); | ||
127 | + } | ||
128 | + | ||
129 | + /** | ||
130 | + * Deletes an existing Slide model. | ||
131 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
132 | + * | ||
133 | + * @param integer $id | ||
134 | + * | ||
135 | + * @return mixed | ||
136 | + */ | ||
137 | + public function actionDelete($id) | ||
138 | + { | ||
139 | + $model = $this->findModel($id); | ||
140 | + | ||
141 | + $slider_id = $model->slider_id; | ||
142 | + $model->delete(); | ||
143 | + return $this->redirect( | ||
144 | + [ | ||
145 | + 'index', | ||
146 | + 'slider_id' => $slider_id, | ||
147 | + ] | ||
148 | + ); | ||
149 | + } | ||
150 | + | ||
151 | + /** | ||
152 | + * Finds the Slide model based on its primary key value. | ||
153 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
154 | + * | ||
155 | + * @param integer $id | ||
156 | + * | ||
157 | + * @return Slide the loaded model | ||
158 | + * @throws NotFoundHttpException if the model cannot be found | ||
159 | + */ | ||
160 | + protected function findModel($id) | ||
161 | + { | ||
162 | + if (( $model = Slide::findOne($id) ) !== null) { | ||
163 | + return $model; | ||
164 | + } else { | ||
165 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
166 | + } | ||
167 | + } | ||
168 | + | ||
169 | + /** | ||
170 | + * Finds the Slider model based on its primary key value. | ||
171 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
172 | + * | ||
173 | + * @param integer $id | ||
174 | + * | ||
175 | + * @return Slider the loaded model | ||
176 | + * @throws NotFoundHttpException if the model cannot be found | ||
177 | + */ | ||
178 | + protected function findSlider($id) | ||
179 | + { | ||
180 | + if (( $model = Slider::findOne($id) ) !== null) { | ||
181 | + return $model; | ||
182 | + } else { | ||
183 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
184 | + } | ||
185 | + } | ||
186 | + } | ||
0 | \ No newline at end of file | 187 | \ No newline at end of file |
1 | +<?php | ||
2 | + namespace backend\controllers; | ||
3 | + | ||
4 | + use \artbox\core\controllers\SliderController as ArtboxSliderController; | ||
5 | + use Yii; | ||
6 | + use yii\helpers\VarDumper; | ||
7 | + use common\models\SliderSearch; | ||
8 | + use common\models\Slider; | ||
9 | + use yii\web\NotFoundHttpException; | ||
10 | + /** | ||
11 | + * Created by PhpStorm. | ||
12 | + * User: timur | ||
13 | + * Date: 24.01.18 | ||
14 | + * Time: 15:07 | ||
15 | + */ | ||
16 | + | ||
17 | + class SliderController extends ArtboxSliderController | ||
18 | + { | ||
19 | + /** | ||
20 | + * Lists all Slider models. | ||
21 | + * | ||
22 | + * @return mixed | ||
23 | + */ | ||
24 | + public function actionIndex() | ||
25 | + { | ||
26 | + $searchModel = new SliderSearch(); | ||
27 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
28 | + | ||
29 | + return $this->render( | ||
30 | + 'index', | ||
31 | + [ | ||
32 | + 'searchModel' => $searchModel, | ||
33 | + 'dataProvider' => $dataProvider, | ||
34 | + ] | ||
35 | + ); | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * Displays a single Slider model. | ||
40 | + * | ||
41 | + * @param integer $id | ||
42 | + * | ||
43 | + * @return mixed | ||
44 | + */ | ||
45 | + public function actionView($id) | ||
46 | + { | ||
47 | + return $this->render( | ||
48 | + 'view', | ||
49 | + [ | ||
50 | + 'model' => $this->findModel($id), | ||
51 | + ] | ||
52 | + ); | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * Creates a new Slider model. | ||
57 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
58 | + * | ||
59 | + * @return mixed | ||
60 | + */ | ||
61 | + public function actionCreate() | ||
62 | + { | ||
63 | + $model = new Slider(); | ||
64 | + | ||
65 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
66 | + return $this->redirect( | ||
67 | + [ | ||
68 | + 'view', | ||
69 | + 'id' => $model->id, | ||
70 | + ] | ||
71 | + ); | ||
72 | + } else { | ||
73 | + return $this->render( | ||
74 | + 'create', | ||
75 | + [ | ||
76 | + 'model' => $model, | ||
77 | + ] | ||
78 | + ); | ||
79 | + } | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * Updates an existing Slider model. | ||
84 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
85 | + * | ||
86 | + * @param integer $id | ||
87 | + * | ||
88 | + * @return mixed | ||
89 | + */ | ||
90 | + public function actionUpdate($id) | ||
91 | + { | ||
92 | + $model = $this->findModel($id); | ||
93 | + | ||
94 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
95 | + return $this->redirect( | ||
96 | + [ | ||
97 | + 'view', | ||
98 | + 'id' => $model->id, | ||
99 | + ] | ||
100 | + ); | ||
101 | + } else { | ||
102 | + return $this->render( | ||
103 | + 'update', | ||
104 | + [ | ||
105 | + 'model' => $model, | ||
106 | + ] | ||
107 | + ); | ||
108 | + } | ||
109 | + } | ||
110 | + | ||
111 | + /** | ||
112 | + * Deletes an existing Slider model. | ||
113 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
114 | + * | ||
115 | + * @param integer $id | ||
116 | + * | ||
117 | + * @return mixed | ||
118 | + */ | ||
119 | + public function actionDelete($id) | ||
120 | + { | ||
121 | + $this->findModel($id) | ||
122 | + ->delete(); | ||
123 | + | ||
124 | + return $this->redirect([ 'index' ]); | ||
125 | + } | ||
126 | + | ||
127 | + /** | ||
128 | + * Finds the Slider model based on its primary key value. | ||
129 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
130 | + * | ||
131 | + * @param integer $id | ||
132 | + * | ||
133 | + * @return Slider the loaded model | ||
134 | + * @throws NotFoundHttpException if the model cannot be found | ||
135 | + */ | ||
136 | + protected function findModel($id) | ||
137 | + { | ||
138 | + if (( $model = Slider::findOne($id) ) !== null) { | ||
139 | + return $model; | ||
140 | + } else { | ||
141 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
142 | + } | ||
143 | + } | ||
144 | + } | ||
0 | \ No newline at end of file | 145 | \ No newline at end of file |
backend/views/layouts/menu_items.php
@@ -78,5 +78,10 @@ | @@ -78,5 +78,10 @@ | ||
78 | 'url' => [ '/imagemanager' ], | 78 | 'url' => [ '/imagemanager' ], |
79 | 'icon' => 'image', | 79 | 'icon' => 'image', |
80 | ], | 80 | ], |
81 | + [ | ||
82 | + 'label' => \Yii::t('core', 'Slider'), | ||
83 | + 'url' => ['/slider/index'], | ||
84 | + 'icon' => 'bolt', | ||
85 | + ], | ||
81 | ] | 86 | ] |
82 | ); | 87 | ); |
83 | \ No newline at end of file | 88 | \ No newline at end of file |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\Slide; | ||
4 | + use artbox\core\widgets\LanguageForm; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\widgets\ActiveForm; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var \yii\web\View $this | ||
10 | + * @var Slide $model | ||
11 | + * @var \artbox\core\models\SlideLang[] $modelLangs | ||
12 | + * @var ActiveForm $form | ||
13 | + * @var \artbox\core\models\Slider $slider | ||
14 | + */ | ||
15 | +?> | ||
16 | + | ||
17 | +<div class="slide-form"> | ||
18 | + | ||
19 | + <?php $form = ActiveForm::begin(); ?> | ||
20 | + | ||
21 | + <?= $form->field($model, 'slider_id') | ||
22 | + ->hiddenInput([ 'value' => $slider->id ]) | ||
23 | + ->label(false) ?> | ||
24 | + | ||
25 | + <?= LanguageForm::widget( | ||
26 | + [ | ||
27 | + 'modelLangs' => $modelLangs, | ||
28 | + 'formView' => '@artbox/core/views/slide/_form_language', | ||
29 | + 'form' => $form, | ||
30 | + ] | ||
31 | + ) ?> | ||
32 | + | ||
33 | + <?= $form->field($model, 'status') | ||
34 | + ->checkbox( | ||
35 | + [ | ||
36 | + 'class' => 'flat', | ||
37 | + ] | ||
38 | + ) ?> | ||
39 | + | ||
40 | + <?= $form->field($model, 'sort') | ||
41 | + ->input('number') ?> | ||
42 | + | ||
43 | + <div class="form-group"> | ||
44 | + <?= Html::submitButton( | ||
45 | + $model->isNewRecord ? Yii::t('core', 'Create') : Yii::t('core', 'Update'), | ||
46 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | ||
47 | + ) ?> | ||
48 | + </div> | ||
49 | + | ||
50 | + <?php ActiveForm::end(); ?> | ||
51 | + | ||
52 | +</div> |
1 | +<?php | ||
2 | + use artbox\core\components\imagemanager\components\ImageManagerInputWidget; | ||
3 | + use artbox\core\models\Language; | ||
4 | + use dosamigos\tinymce\TinyMce; | ||
5 | + use yii\web\View; | ||
6 | + use yii\widgets\ActiveForm; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var \artbox\core\models\SlideLang $model_lang | ||
10 | + * @var Language $language | ||
11 | + * @var ActiveForm $form | ||
12 | + * @var View $this | ||
13 | + */ | ||
14 | + echo $form->field($model_lang, '[' . $language->id . ']image_id') | ||
15 | + ->widget( | ||
16 | + ImageManagerInputWidget::className(), | ||
17 | + [ | ||
18 | + 'aspectRatio' => ( 16 / 9 ), | ||
19 | + //set the aspect ratio | ||
20 | + 'showPreview' => true, | ||
21 | + //false to hide the preview | ||
22 | + 'showDeletePickedImageConfirm' => false, | ||
23 | + //on true show warning before detach image | ||
24 | + ] | ||
25 | + ); | ||
26 | + echo $form->field($model_lang, '[' . $language->id . ']title') | ||
27 | + ->textInput([ 'maxlength' => true ]); | ||
28 | + echo $form->field($model_lang, '[' . $language->id . ']link') | ||
29 | + ->textInput([ 'maxlength' => true ]); | ||
30 | +?> | ||
0 | \ No newline at end of file | 31 | \ No newline at end of file |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\SlideSearch; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\widgets\ActiveForm; | ||
6 | + | ||
7 | + /* @var $this yii\web\View */ | ||
8 | + /* @var $model SlideSearch */ | ||
9 | + /* @var $form yii\widgets\ActiveForm */ | ||
10 | +?> | ||
11 | + | ||
12 | +<div class="slide-search"> | ||
13 | + | ||
14 | + <?php $form = ActiveForm::begin( | ||
15 | + [ | ||
16 | + 'action' => [ 'index' ], | ||
17 | + 'method' => 'get', | ||
18 | + ] | ||
19 | + ); ?> | ||
20 | + | ||
21 | + <?= $form->field($model, 'id') ?> | ||
22 | + | ||
23 | + <?= $form->field($model, 'slider_id') ?> | ||
24 | + | ||
25 | + <?= $form->field($model, 'status') | ||
26 | + ->checkbox() ?> | ||
27 | + | ||
28 | + <?= $form->field($model, 'sort') ?> | ||
29 | + | ||
30 | + <div class="form-group"> | ||
31 | + <?= Html::submitButton(Yii::t('core', 'Search'), [ 'class' => 'btn btn-primary' ]) ?> | ||
32 | + <?= Html::resetButton(Yii::t('core', 'Reset'), [ 'class' => 'btn btn-default' ]) ?> | ||
33 | + </div> | ||
34 | + | ||
35 | + <?php ActiveForm::end(); ?> | ||
36 | + | ||
37 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\Slide; | ||
4 | + use yii\helpers\Html; | ||
5 | + | ||
6 | + /** | ||
7 | + * @var \yii\web\View $this | ||
8 | + * @var Slide $model | ||
9 | + * @var \artbox\core\models\Slider $slider | ||
10 | + * @var \artbox\core\models\SlideLang[] $modelLangs | ||
11 | + */ | ||
12 | + | ||
13 | + $this->title = Yii::t('core', 'Create Slide'); | ||
14 | + $this->params[ 'breadcrumbs' ][] = [ | ||
15 | + 'label' => Yii::t('core', 'Slides'), | ||
16 | + 'url' => [ | ||
17 | + 'index', | ||
18 | + 'slider_id' => $slider->id, | ||
19 | + ], | ||
20 | + ]; | ||
21 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
22 | +?> | ||
23 | +<div class="slide-create"> | ||
24 | + | ||
25 | + <h1><?= Html::encode($this->title) ?></h1> | ||
26 | + | ||
27 | + <?= $this->render( | ||
28 | + '_form', | ||
29 | + [ | ||
30 | + 'model' => $model, | ||
31 | + 'modelLangs' => $modelLangs, | ||
32 | + 'slider' => $slider, | ||
33 | + ] | ||
34 | + ) ?> | ||
35 | + | ||
36 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\SlideSearch; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\grid\GridView; | ||
6 | + | ||
7 | + /* @var $this yii\web\View */ | ||
8 | + /* @var $searchModel SlideSearch */ | ||
9 | + /* @var $dataProvider yii\data\ActiveDataProvider */ | ||
10 | + /* @var \artbox\core\models\Slider $slider */ | ||
11 | + | ||
12 | + $this->title = Yii::t('core', 'Slides'); | ||
13 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
14 | +?> | ||
15 | +<div class="slide-index"> | ||
16 | + | ||
17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
18 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
19 | + | ||
20 | + <p> | ||
21 | + <?= Html::a(Yii::t('core', 'Create Slide'), | ||
22 | + [ | ||
23 | + 'create', | ||
24 | + 'slider_id' => $slider->id, | ||
25 | + ], | ||
26 | + [ 'class' => 'btn btn-success' ] | ||
27 | + ) ?> | ||
28 | + </p> | ||
29 | + <?= GridView::widget( | ||
30 | + [ | ||
31 | + 'dataProvider' => $dataProvider, | ||
32 | + 'filterModel' => $searchModel, | ||
33 | + 'columns' => [ | ||
34 | + [ 'class' => 'yii\grid\SerialColumn' ], | ||
35 | + | ||
36 | + 'id', | ||
37 | + [ | ||
38 | + 'attribute' => 'image_id', | ||
39 | + 'value' => function (\artbox\core\models\Slide $model) { | ||
40 | + if (empty($model->lang->image)) { | ||
41 | + return ''; | ||
42 | + } else { | ||
43 | + return Html::img( | ||
44 | + $model->lang->image->getUrl(), | ||
45 | + [ | ||
46 | + 'width' => '400px', | ||
47 | + ] | ||
48 | + ); | ||
49 | + } | ||
50 | + }, | ||
51 | + 'format' => 'html', | ||
52 | + ], | ||
53 | + 'status:boolean', | ||
54 | + 'sort', | ||
55 | + | ||
56 | + [ 'class' => 'yii\grid\ActionColumn' ], | ||
57 | + ], | ||
58 | + ] | ||
59 | + ); ?> | ||
60 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\Slide; | ||
4 | + use yii\helpers\Html; | ||
5 | + | ||
6 | + /** | ||
7 | + * @var \yii\web\View $this | ||
8 | + * @var Slide $model | ||
9 | + * @var \artbox\core\models\Slider $slider | ||
10 | + * @var \artbox\core\models\SlideLang[] $modelLangs | ||
11 | + */ | ||
12 | + | ||
13 | + $this->title = Yii::t( | ||
14 | + 'core', | ||
15 | + 'Update {modelClass}: ', | ||
16 | + [ | ||
17 | + 'modelClass' => 'Slide', | ||
18 | + ] | ||
19 | + ) . $model->id; | ||
20 | + $this->params[ 'breadcrumbs' ][] = [ | ||
21 | + 'label' => Yii::t('core', 'Slides'), | ||
22 | + 'url' => [ | ||
23 | + 'index', | ||
24 | + 'slider_id' => $slider->id, | ||
25 | + ], | ||
26 | + ]; | ||
27 | + $this->params[ 'breadcrumbs' ][] = [ | ||
28 | + 'label' => $model->id, | ||
29 | + 'url' => [ | ||
30 | + 'view', | ||
31 | + 'id' => $model->id, | ||
32 | + ], | ||
33 | + ]; | ||
34 | + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); | ||
35 | +?> | ||
36 | +<div class="slide-update"> | ||
37 | + | ||
38 | + <h1><?= Html::encode($this->title) ?></h1> | ||
39 | + | ||
40 | + <?= $this->render( | ||
41 | + '_form', | ||
42 | + [ | ||
43 | + 'model' => $model, | ||
44 | + 'modelLangs' => $modelLangs, | ||
45 | + 'slider' => $slider, | ||
46 | + ] | ||
47 | + ) ?> | ||
48 | + | ||
49 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\Slide; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\widgets\DetailView; | ||
6 | + | ||
7 | + /* @var $this yii\web\View */ | ||
8 | + /* @var $model Slide */ | ||
9 | + | ||
10 | + $this->title = $model->id; | ||
11 | + $this->params[ 'breadcrumbs' ][] = [ | ||
12 | + 'label' => Yii::t('core', 'Slides'), | ||
13 | + 'url' => [ | ||
14 | + 'index', | ||
15 | + 'slider_id' => $model->slider_id, | ||
16 | + ], | ||
17 | + ]; | ||
18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
19 | +?> | ||
20 | +<div class="slide-view"> | ||
21 | + | ||
22 | + <h1><?= Html::encode($this->title) ?></h1> | ||
23 | + | ||
24 | + <p> | ||
25 | + <?= Html::a( | ||
26 | + Yii::t('core', 'Update'), | ||
27 | + [ | ||
28 | + 'update', | ||
29 | + 'id' => $model->id, | ||
30 | + ], | ||
31 | + [ 'class' => 'btn btn-primary' ] | ||
32 | + ) ?> | ||
33 | + <?= Html::a( | ||
34 | + Yii::t('core', 'Delete'), | ||
35 | + [ | ||
36 | + 'delete', | ||
37 | + 'id' => $model->id, | ||
38 | + ], | ||
39 | + [ | ||
40 | + 'class' => 'btn btn-danger', | ||
41 | + 'data' => [ | ||
42 | + 'confirm' => Yii::t('core', 'Are you sure you want to delete this item?'), | ||
43 | + 'method' => 'post', | ||
44 | + ], | ||
45 | + ] | ||
46 | + ) ?> | ||
47 | + </p> | ||
48 | + | ||
49 | + <?= DetailView::widget( | ||
50 | + [ | ||
51 | + 'model' => $model, | ||
52 | + 'attributes' => [ | ||
53 | + 'id', | ||
54 | + 'slider_id', | ||
55 | + 'status:boolean', | ||
56 | + 'sort', | ||
57 | + ], | ||
58 | + ] | ||
59 | + ) ?> | ||
60 | + | ||
61 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use backend\models\Slider; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\widgets\ActiveForm; | ||
6 | + | ||
7 | + /* @var $this yii\web\View */ | ||
8 | + /* @var $model Slider */ | ||
9 | + /* @var $form yii\widgets\ActiveForm */ | ||
10 | +?> | ||
11 | + | ||
12 | +<div class="slider-form"> | ||
13 | + | ||
14 | + <?php $form = ActiveForm::begin(); ?> | ||
15 | + | ||
16 | + <?= $form->field($model, 'status') | ||
17 | + ->checkbox([ | ||
18 | + 'class' => 'flat', | ||
19 | + ]) ?> | ||
20 | + | ||
21 | + <?= $form->field($model, 'sort') | ||
22 | + ->input('number') ?> | ||
23 | + | ||
24 | + <?= $form->field($model, 'on_home_page') | ||
25 | + ->checkbox([ | ||
26 | + 'class' => 'flat', | ||
27 | + ]) ?> | ||
28 | + | ||
29 | + <div class="form-group"> | ||
30 | + <?= Html::submitButton( | ||
31 | + $model->isNewRecord ? Yii::t('core', 'Create') : Yii::t('core', 'Update'), | ||
32 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | ||
33 | + ) ?> | ||
34 | + </div> | ||
35 | + | ||
36 | + <?php ActiveForm::end(); ?> | ||
37 | + | ||
38 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\SliderSearch; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\widgets\ActiveForm; | ||
6 | + | ||
7 | + /* @var $this yii\web\View */ | ||
8 | + /* @var $model SliderSearch */ | ||
9 | + /* @var $form yii\widgets\ActiveForm */ | ||
10 | +?> | ||
11 | + | ||
12 | +<div class="slider-search"> | ||
13 | + | ||
14 | + <?php $form = ActiveForm::begin( | ||
15 | + [ | ||
16 | + 'action' => [ 'index' ], | ||
17 | + 'method' => 'get', | ||
18 | + ] | ||
19 | + ); ?> | ||
20 | + | ||
21 | + <?= $form->field($model, 'id') ?> | ||
22 | + | ||
23 | + <?= $form->field($model, 'status') | ||
24 | + ->checkbox() ?> | ||
25 | + | ||
26 | + <?= $form->field($model, 'sort') ?> | ||
27 | + | ||
28 | + <div class="form-group"> | ||
29 | + <?= Html::submitButton(Yii::t('core', 'Search'), [ 'class' => 'btn btn-primary' ]) ?> | ||
30 | + <?= Html::resetButton(Yii::t('core', 'Reset'), [ 'class' => 'btn btn-default' ]) ?> | ||
31 | + </div> | ||
32 | + | ||
33 | + <?php ActiveForm::end(); ?> | ||
34 | + | ||
35 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\Slider; | ||
4 | + use yii\helpers\Html; | ||
5 | + | ||
6 | + /* @var $this yii\web\View */ | ||
7 | + /* @var $model Slider */ | ||
8 | + | ||
9 | + $this->title = Yii::t('core', 'Create Slider'); | ||
10 | + $this->params[ 'breadcrumbs' ][] = [ | ||
11 | + 'label' => Yii::t('core', 'Sliders'), | ||
12 | + 'url' => [ 'index' ], | ||
13 | + ]; | ||
14 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
15 | +?> | ||
16 | +<div class="slider-create"> | ||
17 | + | ||
18 | + <h1><?= Html::encode($this->title) ?></h1> | ||
19 | + | ||
20 | + <?= $this->render( | ||
21 | + '_form', | ||
22 | + [ | ||
23 | + 'model' => $model, | ||
24 | + ] | ||
25 | + ) ?> | ||
26 | + | ||
27 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\SliderSearch; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\grid\GridView; | ||
6 | + | ||
7 | + /* @var $this yii\web\View */ | ||
8 | + /* @var $searchModel SliderSearch */ | ||
9 | + /* @var $dataProvider yii\data\ActiveDataProvider */ | ||
10 | + | ||
11 | + $this->title = Yii::t('core', 'Sliders'); | ||
12 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
13 | +?> | ||
14 | +<div class="slider-index"> | ||
15 | + | ||
16 | + <h1><?= Html::encode($this->title) ?></h1> | ||
17 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
18 | + | ||
19 | + <p> | ||
20 | + <?= Html::a(Yii::t('core', 'Create Slider'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
21 | + </p> | ||
22 | + <?= GridView::widget( | ||
23 | + [ | ||
24 | + 'dataProvider' => $dataProvider, | ||
25 | + 'filterModel' => $searchModel, | ||
26 | + 'columns' => [ | ||
27 | + [ 'class' => 'yii\grid\SerialColumn' ], | ||
28 | + | ||
29 | + 'id', | ||
30 | + 'status:boolean', | ||
31 | + [ | ||
32 | + 'attribute' => 'sort', | ||
33 | + 'filter' => false, | ||
34 | + ], | ||
35 | + [ | ||
36 | + 'class' => 'yii\grid\ActionColumn', | ||
37 | + 'buttons' => [ | ||
38 | + 'slides' => function ($url, $model, $key) { | ||
39 | + /** | ||
40 | + * @var \artbox\core\models\Slider $model | ||
41 | + */ | ||
42 | + return Html::a( | ||
43 | + Html::tag( | ||
44 | + 'i', | ||
45 | + '', | ||
46 | + [ | ||
47 | + 'class' => 'glyphicon glyphicon-picture', | ||
48 | + ] | ||
49 | + ), | ||
50 | + [ | ||
51 | + 'slide/index', | ||
52 | + 'slider_id' => $model->id, | ||
53 | + ], | ||
54 | + [ | ||
55 | + 'title' => \Yii::t('core', 'Slides'), | ||
56 | + 'data' => [ | ||
57 | + 'pjax' => 0, | ||
58 | + ], | ||
59 | + ] | ||
60 | + ); | ||
61 | + }, | ||
62 | + ], | ||
63 | + 'template' => '{slides} {view} {update} {delete}', | ||
64 | + ], | ||
65 | + ], | ||
66 | + ] | ||
67 | + ); ?> | ||
68 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\Slider; | ||
4 | + use yii\helpers\Html; | ||
5 | + | ||
6 | + /* @var $this yii\web\View */ | ||
7 | + /* @var $model Slider */ | ||
8 | + | ||
9 | + $this->title = Yii::t( | ||
10 | + 'core', | ||
11 | + 'Update {modelClass}: ', | ||
12 | + [ | ||
13 | + 'modelClass' => 'Slider', | ||
14 | + ] | ||
15 | + ) . $model->id; | ||
16 | + $this->params[ 'breadcrumbs' ][] = [ | ||
17 | + 'label' => Yii::t('core', 'Sliders'), | ||
18 | + 'url' => [ 'index' ], | ||
19 | + ]; | ||
20 | + $this->params[ 'breadcrumbs' ][] = [ | ||
21 | + 'label' => $model->id, | ||
22 | + 'url' => [ | ||
23 | + 'view', | ||
24 | + 'id' => $model->id, | ||
25 | + ], | ||
26 | + ]; | ||
27 | + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); | ||
28 | +?> | ||
29 | +<div class="slider-update"> | ||
30 | + | ||
31 | + <h1><?= Html::encode($this->title) ?></h1> | ||
32 | + | ||
33 | + <?= $this->render( | ||
34 | + '_form', | ||
35 | + [ | ||
36 | + 'model' => $model, | ||
37 | + ] | ||
38 | + ) ?> | ||
39 | + | ||
40 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use artbox\core\models\Slider; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\widgets\DetailView; | ||
6 | + | ||
7 | + /* @var $this yii\web\View */ | ||
8 | + /* @var $model Slider */ | ||
9 | + | ||
10 | + $this->title = $model->id; | ||
11 | + $this->params[ 'breadcrumbs' ][] = [ | ||
12 | + 'label' => Yii::t('core', 'Sliders'), | ||
13 | + 'url' => [ 'index' ], | ||
14 | + ]; | ||
15 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
16 | +?> | ||
17 | +<div class="slider-view"> | ||
18 | + | ||
19 | + <h1><?= Html::encode($this->title) ?></h1> | ||
20 | + | ||
21 | + <p> | ||
22 | + <?= Html::a( | ||
23 | + Yii::t('core', 'Update'), | ||
24 | + [ | ||
25 | + 'update', | ||
26 | + 'id' => $model->id, | ||
27 | + ], | ||
28 | + [ 'class' => 'btn btn-primary' ] | ||
29 | + ) ?> | ||
30 | + <?= Html::a( | ||
31 | + Yii::t('core', 'Delete'), | ||
32 | + [ | ||
33 | + 'delete', | ||
34 | + 'id' => $model->id, | ||
35 | + ], | ||
36 | + [ | ||
37 | + 'class' => 'btn btn-danger', | ||
38 | + 'data' => [ | ||
39 | + 'confirm' => Yii::t('core', 'Are you sure you want to delete this item?'), | ||
40 | + 'method' => 'post', | ||
41 | + ], | ||
42 | + ] | ||
43 | + ) ?> | ||
44 | + </p> | ||
45 | + | ||
46 | + <?= DetailView::widget( | ||
47 | + [ | ||
48 | + 'model' => $model, | ||
49 | + 'attributes' => [ | ||
50 | + 'id', | ||
51 | + 'status:boolean', | ||
52 | + 'sort', | ||
53 | + ], | ||
54 | + ] | ||
55 | + ) ?> | ||
56 | + | ||
57 | +</div> |
common/messages/ru/app.php
@@ -121,4 +121,5 @@ return [ | @@ -121,4 +121,5 @@ return [ | ||
121 | 'sect3_21' => 'Обратиться к нам и', | 121 | 'sect3_21' => 'Обратиться к нам и', |
122 | 'Office {office}' => 'Офис {office}', | 122 | 'Office {office}' => 'Офис {office}', |
123 | 'Contact us' => 'Связаться с нами', | 123 | 'Contact us' => 'Связаться с нами', |
124 | + "Show on home page" => "Показать на главной странице", | ||
124 | ]; | 125 | ]; |
125 | \ No newline at end of file | 126 | \ No newline at end of file |
1 | +<?php | ||
2 | + | ||
3 | + namespace common\models; | ||
4 | + | ||
5 | + use artbox\core\behaviors\LanguageBehavior; | ||
6 | + use Yii; | ||
7 | + use yii\db\ActiveQuery; | ||
8 | + use artbox\core\models\Slide as ArtboxSlide; | ||
9 | + use yii\web\Request; | ||
10 | + use artbox\core\models\PageLang; | ||
11 | + | ||
12 | + /** | ||
13 | + * This is the model class for table "slide". | ||
14 | + * | ||
15 | + * @property integer $id | ||
16 | + * @property integer $slider_id | ||
17 | + * @property boolean $status | ||
18 | + * @property integer $sort | ||
19 | + * @property Slider $slider | ||
20 | + * @property SlideLang[] $slideLangs | ||
21 | + * * From language behavior * | ||
22 | + * @property SlideLang $lang | ||
23 | + * @property SlideLang[] $langs | ||
24 | + * @property PageLang $objectLang | ||
25 | + * @property string $ownerKey | ||
26 | + * @property string $langKey | ||
27 | + * @property PageLang[] $modelLangs | ||
28 | + * @property bool $transactionStatus | ||
29 | + * @method string getOwnerKey() | ||
30 | + * @method void setOwnerKey( string $value ) | ||
31 | + * @method string getLangKey() | ||
32 | + * @method void setLangKey( string $value ) | ||
33 | + * @method ActiveQuery getLangs() | ||
34 | + * @method ActiveQuery getLang( integer $language_id ) | ||
35 | + * @method PageLang[] generateLangs() | ||
36 | + * @method void loadLangs( Request $request ) | ||
37 | + * @method bool linkLangs() | ||
38 | + * @method bool saveLangs() | ||
39 | + * @method bool getTransactionStatus() | ||
40 | + * @method bool loadWithLangs( Request $request ) | ||
41 | + * @method bool saveWithLangs() | ||
42 | + * * End language behavior * | ||
43 | + * @see LanguageBehavior | ||
44 | + */ | ||
45 | + class Slide extends ArtboxSlide | ||
46 | + { | ||
47 | + /** | ||
48 | + * @inheritdoc | ||
49 | + */ | ||
50 | + public static function tableName() | ||
51 | + { | ||
52 | + return 'slide'; | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * @inheritdoc | ||
57 | + */ | ||
58 | + public function behaviors() | ||
59 | + { | ||
60 | + return [ | ||
61 | + 'language' => [ | ||
62 | + 'class' => LanguageBehavior::className(), | ||
63 | + ], | ||
64 | + ]; | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * @inheritdoc | ||
69 | + */ | ||
70 | + public function rules() | ||
71 | + { | ||
72 | + return [ | ||
73 | + [ | ||
74 | + [ 'slider_id' ], | ||
75 | + 'required', | ||
76 | + ], | ||
77 | + [ | ||
78 | + [ | ||
79 | + 'slider_id', | ||
80 | + 'sort', | ||
81 | + ], | ||
82 | + 'integer', | ||
83 | + ], | ||
84 | + [ | ||
85 | + [ 'status' ], | ||
86 | + 'boolean', | ||
87 | + ], | ||
88 | + [ | ||
89 | + [ 'slider_id' ], | ||
90 | + 'exist', | ||
91 | + 'skipOnError' => true, | ||
92 | + 'targetClass' => Slider::className(), | ||
93 | + 'targetAttribute' => [ 'slider_id' => 'id' ], | ||
94 | + ], | ||
95 | + ]; | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * @inheritdoc | ||
100 | + */ | ||
101 | + public function attributeLabels() | ||
102 | + { | ||
103 | + return [ | ||
104 | + 'id' => Yii::t('core', 'ID'), | ||
105 | + 'slider_id' => Yii::t('core', 'Slider ID'), | ||
106 | + 'status' => Yii::t('core', 'Status'), | ||
107 | + 'sort' => Yii::t('core', 'Sort'), | ||
108 | + ]; | ||
109 | + } | ||
110 | + | ||
111 | + /** | ||
112 | + * @return \yii\db\ActiveQuery | ||
113 | + */ | ||
114 | + public function getSlider() | ||
115 | + { | ||
116 | + return $this->hasOne(Slider::className(), [ 'id' => 'slider_id' ]) | ||
117 | + ->inverseOf('slides'); | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
121 | + * @return \yii\db\ActiveQuery | ||
122 | + */ | ||
123 | + public function getSlideLangs() | ||
124 | + { | ||
125 | + return $this->hasMany(SlideLang::className(), [ 'slide_id' => 'id' ]) | ||
126 | + ->inverseOf('slide'); | ||
127 | + } | ||
128 | + } |
1 | +<?php | ||
2 | + | ||
3 | + namespace common\models; | ||
4 | + | ||
5 | + use yii\base\Model; | ||
6 | + use yii\data\ActiveDataProvider; | ||
7 | + | ||
8 | + /** | ||
9 | + * SlideSearch represents the model behind the search form about `common\models\Slide`. | ||
10 | + */ | ||
11 | + class SlideSearch extends Slide | ||
12 | + { | ||
13 | + /** | ||
14 | + * @inheritdoc | ||
15 | + */ | ||
16 | + public function rules() | ||
17 | + { | ||
18 | + return [ | ||
19 | + [ | ||
20 | + [ | ||
21 | + 'id', | ||
22 | + 'slider_id', | ||
23 | + 'sort', | ||
24 | + ], | ||
25 | + 'integer', | ||
26 | + ], | ||
27 | + [ | ||
28 | + [ 'status' ], | ||
29 | + 'boolean', | ||
30 | + ], | ||
31 | + ]; | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * @inheritdoc | ||
36 | + */ | ||
37 | + public function behaviors() | ||
38 | + { | ||
39 | + return []; | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * @inheritdoc | ||
44 | + */ | ||
45 | + public function scenarios() | ||
46 | + { | ||
47 | + // bypass scenarios() implementation in the parent class | ||
48 | + return Model::scenarios(); | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * Creates data provider instance with search query applied | ||
53 | + * | ||
54 | + * @param array $params | ||
55 | + * @param \artbox\core\models\Slider $slider | ||
56 | + * | ||
57 | + * @return \yii\data\ActiveDataProvider | ||
58 | + */ | ||
59 | + public function search($params, Slider $slider) | ||
60 | + { | ||
61 | + $query = Slide::find(); | ||
62 | + | ||
63 | + // add conditions that should always apply here | ||
64 | + $query->where([ 'slider_id' => $slider->id ]); | ||
65 | + | ||
66 | + $dataProvider = new ActiveDataProvider( | ||
67 | + [ | ||
68 | + 'query' => $query, | ||
69 | + ] | ||
70 | + ); | ||
71 | + | ||
72 | + $this->load($params); | ||
73 | + | ||
74 | + if (!$this->validate()) { | ||
75 | + // uncomment the following line if you do not want to return any records when validation fails | ||
76 | + // $query->where('0=1'); | ||
77 | + return $dataProvider; | ||
78 | + } | ||
79 | + | ||
80 | + // grid filtering conditions | ||
81 | + $query->andFilterWhere( | ||
82 | + [ | ||
83 | + 'id' => $this->id, | ||
84 | + 'slider_id' => $this->slider_id, | ||
85 | + 'status' => $this->status, | ||
86 | + 'sort' => $this->sort, | ||
87 | + ] | ||
88 | + ); | ||
89 | + | ||
90 | + return $dataProvider; | ||
91 | + } | ||
92 | + } |
1 | +<?php | ||
2 | + | ||
3 | + namespace common\models; | ||
4 | + | ||
5 | + use Yii; | ||
6 | + use artbox\core\models\Slider as ArtboxSlider; | ||
7 | + | ||
8 | + /** | ||
9 | + * This is the model class for table "slider". | ||
10 | + * | ||
11 | + * @property integer $id | ||
12 | + * @property boolean $status | ||
13 | + * @property integer $sort | ||
14 | + * @property Slide[] $slides | ||
15 | + */ | ||
16 | + class Slider extends ArtboxSlider | ||
17 | + { | ||
18 | + | ||
19 | + /** | ||
20 | + * @inheritdoc | ||
21 | + */ | ||
22 | + public function rules() | ||
23 | + { | ||
24 | + return [ | ||
25 | + [ | ||
26 | + [ | ||
27 | + 'status', | ||
28 | + 'on_home_page', | ||
29 | + ], | ||
30 | + 'boolean', | ||
31 | + ], | ||
32 | + [ | ||
33 | + [ 'sort' ], | ||
34 | + 'integer', | ||
35 | + ], | ||
36 | + ]; | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * @inheritdoc | ||
41 | + */ | ||
42 | + public function attributeLabels() | ||
43 | + { | ||
44 | + return [ | ||
45 | + 'id' => Yii::t('core', 'ID'), | ||
46 | + 'status' => Yii::t('core', 'Status'), | ||
47 | + 'sort' => Yii::t('core', 'Sort'), | ||
48 | + 'on_home_page' => Yii::t('app', "Show on home page"), | ||
49 | + ]; | ||
50 | + } | ||
51 | + | ||
52 | +// /** | ||
53 | +// * @return \yii\db\ActiveQuery | ||
54 | +// */ | ||
55 | +// public function getSlides() | ||
56 | +// { | ||
57 | +// return $this->hasMany(Slide::className(), [ 'slider_id' => 'id' ]) | ||
58 | +// ->inverseOf('slider'); | ||
59 | +// } | ||
60 | + } |
1 | +<?php | ||
2 | + | ||
3 | + namespace common\models; | ||
4 | + | ||
5 | + use yii\base\Model; | ||
6 | + use yii\data\ActiveDataProvider; | ||
7 | + | ||
8 | + /** | ||
9 | + * SliderSearch represents the model behind the search form about `common\models\Slider`. | ||
10 | + */ | ||
11 | + class SliderSearch extends Slider | ||
12 | + { | ||
13 | + /** | ||
14 | + * @inheritdoc | ||
15 | + */ | ||
16 | + public function rules() | ||
17 | + { | ||
18 | + return [ | ||
19 | + [ | ||
20 | + [ | ||
21 | + 'id', | ||
22 | + 'sort', | ||
23 | + ], | ||
24 | + 'integer', | ||
25 | + ], | ||
26 | + [ | ||
27 | + [ 'status' ], | ||
28 | + 'boolean', | ||
29 | + ], | ||
30 | + ]; | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * @inheritdoc | ||
35 | + */ | ||
36 | + public function scenarios() | ||
37 | + { | ||
38 | + // bypass scenarios() implementation in the parent class | ||
39 | + return Model::scenarios(); | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * Creates data provider instance with search query applied | ||
44 | + * | ||
45 | + * @param array $params | ||
46 | + * | ||
47 | + * @return ActiveDataProvider | ||
48 | + */ | ||
49 | + public function search($params) | ||
50 | + { | ||
51 | + $query = Slider::find(); | ||
52 | + | ||
53 | + // add conditions that should always apply here | ||
54 | + | ||
55 | + $dataProvider = new ActiveDataProvider( | ||
56 | + [ | ||
57 | + 'query' => $query, | ||
58 | + ] | ||
59 | + ); | ||
60 | + | ||
61 | + $this->load($params); | ||
62 | + | ||
63 | + if (!$this->validate()) { | ||
64 | + // uncomment the following line if you do not want to return any records when validation fails | ||
65 | + // $query->where('0=1'); | ||
66 | + return $dataProvider; | ||
67 | + } | ||
68 | + | ||
69 | + // grid filtering conditions | ||
70 | + $query->andFilterWhere( | ||
71 | + [ | ||
72 | + 'id' => $this->id, | ||
73 | + 'status' => $this->status, | ||
74 | + 'sort' => $this->sort, | ||
75 | + ] | ||
76 | + ); | ||
77 | + | ||
78 | + return $dataProvider; | ||
79 | + } | ||
80 | + } |
console/migrations/m180124_130301_add_on_home_page_column_to_slider_table.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\db\Migration; | ||
4 | + | ||
5 | +/** | ||
6 | + * Handles adding on_home_page to table `slider`. | ||
7 | + */ | ||
8 | +class m180124_130301_add_on_home_page_column_to_slider_table extends Migration | ||
9 | +{ | ||
10 | + /** | ||
11 | + * @inheritdoc | ||
12 | + */ | ||
13 | + public function up() | ||
14 | + { | ||
15 | + $this->addColumn('slider', 'on_home_page', $this->boolean()); | ||
16 | + } | ||
17 | + | ||
18 | + /** | ||
19 | + * @inheritdoc | ||
20 | + */ | ||
21 | + public function down() | ||
22 | + { | ||
23 | + $this->dropColumn('slider', 'on_home_page'); | ||
24 | + } | ||
25 | +} |
frontend/controllers/SiteController.php
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | 3 | ||
4 | use artbox\core\models\Feedback; | 4 | use artbox\core\models\Feedback; |
5 | use common\models\Settings; | 5 | use common\models\Settings; |
6 | + use common\models\Slider; | ||
6 | use Yii; | 7 | use Yii; |
7 | use yii\filters\VerbFilter; | 8 | use yii\filters\VerbFilter; |
8 | use yii\swiftmailer\Mailer; | 9 | use yii\swiftmailer\Mailer; |
@@ -49,7 +50,16 @@ | @@ -49,7 +50,16 @@ | ||
49 | */ | 50 | */ |
50 | public function actionIndex() | 51 | public function actionIndex() |
51 | { | 52 | { |
52 | - return $this->render('index'); | 53 | + |
54 | + $slider = Slider::find()->with("slides.lang.image") | ||
55 | + ->where(['on_home_page'=>true])->one(); | ||
56 | + | ||
57 | + return $this->render( | ||
58 | + 'index', | ||
59 | + [ | ||
60 | + 'slider' => $slider, | ||
61 | + ] | ||
62 | + ); | ||
53 | } | 63 | } |
54 | 64 | ||
55 | /** | 65 | /** |
frontend/views/site/index.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | -/* @var $this yii\web\View */ | ||
4 | - | 2 | + |
3 | + /** | ||
4 | + * @var $this yii\web\View | ||
5 | + * @var $slider \common\models\Slider | ||
6 | + */ | ||
7 | + | ||
5 | use common\models\Settings; | 8 | use common\models\Settings; |
6 | use frontend\assets\MapAsset; | 9 | use frontend\assets\MapAsset; |
7 | use yii\web\View; | 10 | use yii\web\View; |
@@ -20,6 +23,53 @@ $this->registerJs($js, View::POS_END); | @@ -20,6 +23,53 @@ $this->registerJs($js, View::POS_END); | ||
20 | 23 | ||
21 | <div id="main-page"> | 24 | <div id="main-page"> |
22 | <section class="no-mb main-slider"> | 25 | <section class="no-mb main-slider"> |
26 | + | ||
27 | + <div id="carouselExampleControls" class="carousel slide" data-ride="carousel"> | ||
28 | + <div class="carousel-inner"> | ||
29 | + <?php | ||
30 | + /** | ||
31 | + * @var $slide \common\models\Slide | ||
32 | + */ | ||
33 | + foreach ($slider->slides as $slide){ | ||
34 | + echo '<div class="carousel-item">'; | ||
35 | + echo $slide->lang->image->getImg( | ||
36 | + [ | ||
37 | + 'class' => "d-block w-100" | ||
38 | + ] | ||
39 | + ); | ||
40 | + echo "</div>"; | ||
41 | + | ||
42 | + ?> | ||
43 | + | ||
44 | + | ||
45 | + | ||
46 | +<!-- <div class="carousel-item active">--> | ||
47 | +<!-- <img class="d-block w-100" src="..." alt="First slide">--> | ||
48 | +<!-- </div>--> | ||
49 | +<!-- <div class="carousel-item">--> | ||
50 | +<!-- <img class="d-block w-100" src="..." alt="Second slide">--> | ||
51 | +<!-- </div>--> | ||
52 | +<!-- <div class="carousel-item">--> | ||
53 | +<!-- <img class="d-block w-100" src="..." alt="Third slide">--> | ||
54 | +<!-- </div>--> | ||
55 | + | ||
56 | + | ||
57 | + | ||
58 | + <?php | ||
59 | + | ||
60 | + } | ||
61 | + ?> | ||
62 | + | ||
63 | + </div> | ||
64 | + <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev"> | ||
65 | + <span class="carousel-control-prev-icon" aria-hidden="true"></span> | ||
66 | + <span class="sr-only">Previous</span> | ||
67 | + </a> | ||
68 | + <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next"> | ||
69 | + <span class="carousel-control-next-icon" aria-hidden="true"></span> | ||
70 | + <span class="sr-only">Next</span> | ||
71 | + </a> | ||
72 | + </div> | ||
23 | <!-- тут место для слайдера --> | 73 | <!-- тут место для слайдера --> |
24 | </section> | 74 | </section> |
25 | 75 |