Esempio n. 1
0
 public function actionDescription()
 {
     if (Yii::$app->user->isGuest) {
         $this->redirect(Yii::$app->user->loginUrl);
     }
     $model = BMainpageMasters::find()->where(['site' => 1])->one();
     if (!$model) {
         $model = new BMainpageMasters();
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $model->site = 1;
             $model->save();
             return $this->render('description', ['model' => $model, 'success' => true]);
         }
     }
     return $this->render('description', ['model' => $model]);
 }
Esempio n. 2
0
 public function actionMasters()
 {
     $getName = $_GET['name'];
     if (!$getName) {
         $query = BMasters::find();
         $countQuery = clone $query;
         $model = BMasters::find()->orderBy('sort ASC')->all();
         $BMainpageMasters = BMainpageMasters::find()->where(['site' => 1])->one();
         return $this->render('masters', ['model' => $model, 'description' => $BMainpageMasters->text]);
     } else {
         $model = BMasters::find()->where(['translate' => $getName])->one();
         $allmodel = BMasters::find()->count();
         if ($model->sort == $allmodel) {
             $nextmaster = 1;
             $prevmaster = $model->sort - 1;
         } else {
             if ($model->sort == 1) {
                 $nextmaster = $model->sort + 1;
                 $prevmaster = $allmodel;
             } else {
                 $nextmaster = $model->sort + 1;
                 $prevmaster = $model->sort - 1;
             }
         }
         $nextmastertranslate = BMasters::find()->where(['sort' => $nextmaster])->one();
         $prevmastertranslate = BMasters::find()->where(['sort' => $prevmaster])->one();
         $reviews = BReviews::find()->where('section = "masters" AND translate = "' . $getName . '" AND moderate = 1')->orderBy('id DESC')->all();
         if (!$model) {
             return $this->render('error', ['name' => 'Not Found (#404)', 'message' => 'Страница не найдена']);
         }
         if (Yii::$app->getSession()->getFlash('captcha')) {
             $captcha = false;
         } else {
             $captcha = true;
         }
         if (Yii::$app->getSession()->getFlash('save')) {
             $save = true;
         } else {
             $save = false;
         }
         return $this->render('masters_detail', ['model' => $model, 'nextmastertranslate' => $nextmastertranslate, 'prevmastertranslate' => $prevmastertranslate, 'reviews' => $reviews, 'captcha' => $captcha, 'save' => $save]);
     }
 }