/**
  * Deletes an existing AboutPageCategory model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $aboutPageModel = AboutPage::find()->andWhere(['category_id' => $id])->one();
     if (null === $aboutPageModel) {
         $this->findModel($id)->delete();
     } else {
         Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete category #' . $id . '. It used in other table. Change category for aboutPage #' . $aboutPageModel->id . ' before delete.'), 'options' => ['class' => 'alert-error']]);
     }
     return $this->redirect(['index']);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AboutPage::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!empty($params['mid'])) {
         $query->andFilterWhere(['about_id' => intval($params['mid'])]);
     }
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'about_id' => $this->about_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'domain_id' => $this->domain_id]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * Finds the AboutPage model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AboutPage the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AboutPage::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAboutPages()
 {
     return $this->hasMany(AboutPage::className(), ['category_id' => 'id']);
 }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAboutPage()
 {
     return $this->hasOne(AboutPage::className(), ['id' => 'about_page_id']);
 }
Exemplo n.º 6
0
 /**
  * Deletes an existing About model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     //$this->findAbout($id)->delete();
     $aboutPageAbout = AboutPage::find()->andWhere(['about_id' => $id])->one();
     if (null === $aboutPageAbout) {
         $this->findAbout($id)->delete();
     } else {
         Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete about #' . $id . '. It used in other table. Delete aboutPage page #' . $aboutPageAbout->id . ' first.'), 'options' => ['class' => 'alert-error']]);
     }
     return $this->redirect(['index']);
 }
Exemplo n.º 7
0
 public function afterDelete()
 {
     $model = AboutPage::find()->andWhere(['locale_group_id' => $this->locale_group_id, 'domain_id' => Yii::$app->user->identity->domain_id])->one();
     if ($model) {
         $model->delete();
     }
     return parent::afterDelete();
 }
Exemplo n.º 8
0
 private static function isActiveMenuItem($mid, $locale)
 {
     $result = false;
     if (preg_match('/^about-page/', Yii::$app->request->pathinfo)) {
         if ($mid == Yii::$app->request->get('mid')) {
             $result = true;
         }
     }
     if (preg_match('/^about-page\\/update/', Yii::$app->request->pathinfo)) {
         if (Yii::$app->request->get('id')) {
             $model = AboutPage::findOne(['id' => Yii::$app->request->get('id')]);
             $localGroupModel = AboutPage::findOne(['locale_group_id' => $model->locale_group_id, 'locale' => $locale]);
             if ($model and $mid == $model->about_id) {
                 $result = true;
             }
         }
     }
     return $result;
 }