diff --git a/backend/controllers/SlideController.php b/backend/controllers/SlideController.php new file mode 100755 index 0000000..6ff1fae --- /dev/null +++ b/backend/controllers/SlideController.php @@ -0,0 +1,217 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all Slide models. + * + * @param int $slider_id + * + * @return mixed + */ + public function actionIndex($slider_id) + { + $slider = $this->findSlider($slider_id); + $searchModel = new SlideSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $slider); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'slider' => $slider, + ] + ); + } + + /** + * Displays a single Slide model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new Slide model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @param int $slider_id + * + * @return mixed + */ + public function actionCreate(int $slider_id) + { + $slider = $this->findSlider($slider_id); + + $model = new Slide(); + $model->generateLangs(); + + if ($model->loadWithLangs(\Yii::$app->request)) { + if ($model->saveWithLangs()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'slider' => $slider, + ] + ); + } + + /** + * Updates an existing Slide model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + + $slider = $this->findSlider($model->slider_id); + + if ($model->loadWithLangs(\Yii::$app->request)) { + if ($model->saveWithLangs()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'slider' => $slider, + ] + ); + } + + /** + * Deletes an existing Slide model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $model = $this->findModel($id); + + $slider_id = $model->slider_id; + $model->delete(); + return $this->redirect( + [ + 'index', + 'slider_id' => $slider_id, + ] + ); + } + + /** + * Finds the Slide model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Slide the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = Slide::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + /** + * Finds the Slider model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Slider the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findSlider($id) + { + if (( $model = Slider::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/backend/controllers/SliderController.php b/backend/controllers/SliderController.php new file mode 100755 index 0000000..5f3a4ba --- /dev/null +++ b/backend/controllers/SliderController.php @@ -0,0 +1,174 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all Slider models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new SliderSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single Slider model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new Slider model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new Slider(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } else { + return $this->render( + 'create', + [ + 'model' => $model, + ] + ); + } + } + + /** + * Updates an existing Slider model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } else { + return $this->render( + 'update', + [ + 'model' => $model, + ] + ); + } + } + + /** + * Deletes an existing Slider model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the Slider model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Slider the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = Slider::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/backend/views/layouts/menu_items.php b/backend/views/layouts/menu_items.php index 93a0522..95170ff 100755 --- a/backend/views/layouts/menu_items.php +++ b/backend/views/layouts/menu_items.php @@ -149,6 +149,11 @@ ], ], [ + 'label' => \Yii::t('core', 'Slider'), + 'url' => [ '/slider' ], + 'icon' => 'image', + ], + [ 'label' => \Yii::t('order', 'Order'), 'url' => '#', 'icon' => 'archive', diff --git a/backend/views/slide/_form.php b/backend/views/slide/_form.php new file mode 100755 index 0000000..d5deba2 --- /dev/null +++ b/backend/views/slide/_form.php @@ -0,0 +1,52 @@ + + +
diff --git a/backend/views/slide/_form_language.php b/backend/views/slide/_form_language.php new file mode 100755 index 0000000..0e8c46c --- /dev/null +++ b/backend/views/slide/_form_language.php @@ -0,0 +1,30 @@ +field($model_lang, '[' . $language->id . ']image_id') + ->widget( + ImageManagerInputWidget::className(), + [ + 'aspectRatio' => ( 16 / 9 ), + //set the aspect ratio + 'showPreview' => true, + //false to hide the preview + 'showDeletePickedImageConfirm' => false, + //on true show warning before detach image + ] + ); + echo $form->field($model_lang, '[' . $language->id . ']title') + ->textInput([ 'maxlength' => true ]); + echo $form->field($model_lang, '[' . $language->id . ']link') + ->textInput([ 'maxlength' => true ]); +?> \ No newline at end of file diff --git a/backend/views/slide/_search.php b/backend/views/slide/_search.php new file mode 100755 index 0000000..004b118 --- /dev/null +++ b/backend/views/slide/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/views/slide/create.php b/backend/views/slide/create.php new file mode 100755 index 0000000..b0a65b1 --- /dev/null +++ b/backend/views/slide/create.php @@ -0,0 +1,36 @@ +title = Yii::t('core', 'Create Slide'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Slides'), + 'url' => [ + 'index', + 'slider_id' => $slider->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + diff --git a/backend/views/slide/index.php b/backend/views/slide/index.php new file mode 100755 index 0000000..6c35b5e --- /dev/null +++ b/backend/views/slide/index.php @@ -0,0 +1,60 @@ +title = Yii::t('core', 'Slides'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + diff --git a/backend/views/slide/update.php b/backend/views/slide/update.php new file mode 100755 index 0000000..a889880 --- /dev/null +++ b/backend/views/slide/update.php @@ -0,0 +1,49 @@ +title = Yii::t( + 'core', + 'Update {modelClass}: ', + [ + 'modelClass' => 'Slide', + ] + ) . $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Slides'), + 'url' => [ + 'index', + 'slider_id' => $slider->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->id, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); +?> + diff --git a/backend/views/slide/view.php b/backend/views/slide/view.php new file mode 100755 index 0000000..bfc20f4 --- /dev/null +++ b/backend/views/slide/view.php @@ -0,0 +1,61 @@ +title = $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Slides'), + 'url' => [ + 'index', + 'slider_id' => $model->slider_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + diff --git a/backend/views/slider/_form.php b/backend/views/slider/_form.php new file mode 100755 index 0000000..a8bb67b --- /dev/null +++ b/backend/views/slider/_form.php @@ -0,0 +1,33 @@ + + + diff --git a/backend/views/slider/_search.php b/backend/views/slider/_search.php new file mode 100755 index 0000000..6242edc --- /dev/null +++ b/backend/views/slider/_search.php @@ -0,0 +1,35 @@ + + + diff --git a/backend/views/slider/create.php b/backend/views/slider/create.php new file mode 100755 index 0000000..e1c7385 --- /dev/null +++ b/backend/views/slider/create.php @@ -0,0 +1,27 @@ +title = Yii::t('core', 'Create Slider'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Sliders'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + diff --git a/backend/views/slider/index.php b/backend/views/slider/index.php new file mode 100755 index 0000000..2efc8a6 --- /dev/null +++ b/backend/views/slider/index.php @@ -0,0 +1,68 @@ +title = Yii::t('core', 'Sliders'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + diff --git a/backend/views/slider/update.php b/backend/views/slider/update.php new file mode 100755 index 0000000..2485a80 --- /dev/null +++ b/backend/views/slider/update.php @@ -0,0 +1,40 @@ +title = Yii::t( + 'core', + 'Update {modelClass}: ', + [ + 'modelClass' => 'Slider', + ] + ) . $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Sliders'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->id, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); +?> + diff --git a/backend/views/slider/view.php b/backend/views/slider/view.php new file mode 100755 index 0000000..310962d --- /dev/null +++ b/backend/views/slider/view.php @@ -0,0 +1,57 @@ +title = $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Sliders'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 5771895..c750ce5 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -7,6 +7,7 @@ use artbox\catalog\models\Product; use artbox\core\models\DummyAlias; use artbox\core\models\Feedback; + use artbox\core\models\Slide; use artbox\order\models\LoginForm; use artbox\order\models\PasswordResetRequestForm; use artbox\order\models\ResetPasswordForm; @@ -117,6 +118,7 @@ ) ->limit(4) ->all(); + $slider = Slide::find()->with('lang.image')->where(['status' => true])->orderBy('sort')->all(); return $this->render( 'index', [ @@ -128,6 +130,7 @@ 'brandCount' => $brandCount, 'brands' => $brands, 'articles' => $articles, + 'slider' => $slider ] ); } diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php index c6aef63..1f02684 100755 --- a/frontend/views/site/index.php +++ b/frontend/views/site/index.php @@ -48,15 +48,11 @@ _________________________________________________________ --> -- libgit2 0.21.4