コード例 #1
0
 /**
  * Deletes an existing AboutCategory model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $aboutAbout = About::find()->andWhere(['category_id' => $id])->one();
     if (null === $aboutAbout) {
         $this->findAbout($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 about #' . $aboutAbout->id . ' before delete.'), 'options' => ['class' => 'alert-error']]);
     }
     return $this->redirect(['index']);
 }
コード例 #2
0
ファイル: AboutSearch.php プロジェクト: Hranto/hemon
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = About::find();
     $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;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'description_en', $this->description_en])->andFilterWhere(['like', 'description_ru', $this->description_ru])->andFilterWhere(['like', 'description_am', $this->description_am]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: AboutSearch.php プロジェクト: allhaze/renault
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = About::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     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, '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', 'price', $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;
 }
コード例 #4
0
 /**
  * Lists all AboutPage models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new AboutPageSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->sort = ['defaultOrder' => ['published_at' => SORT_DESC]];
     $dataProvider->query->andFilterWhere(['locale' => Yii::$app->language]);
     if (Yii::$app->request->get('mid')) {
         $parentModel = About::find(['id' => Yii::$app->request->get('mid')])->one();
         $parentModel = About::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA', 'locale_group_id' => $parentModel->locale_group_id])->one();
         $models = AboutPage::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA', 'about_id' => $parentModel->id])->all();
     } else {
         $models = AboutPage::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA'])->all();
     }
     $list = \yii\helpers\ArrayHelper::map($models, 'locale_group_id', 'title');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'list' => $list]);
 }
コード例 #5
0
ファイル: AboutController.php プロジェクト: allhaze/renault
 /**
  * Creates a new About model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     foreach (Yii::$app->params['availableLocales'] as $key => $value) {
         $currentAbout = About::getLocaleInstance($key);
         $currentAbout->locale = $key;
         if (Yii::$app->request->get('scenario')) {
             $currentAbout->on_scenario = Yii::$app->request->get('scenario');
         }
         $abouts[$key] = $currentAbout;
     }
     //set data from default about
     if (Yii::$app->request->get('locale_group_id')) {
         $defaultDomainAbouts = About::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale_group_id' => Yii::$app->request->get('locale_group_id')])->all();
         foreach ($defaultDomainAbouts as $key => $value) {
             if (!in_array($value->locale, array_keys(Yii::$app->params['availableLocales']))) {
                 continue;
             }
             $abouts[$value->locale]->slug = $value->slug;
             $abouts[$value->locale]->title = $value->title;
             $abouts[$value->locale]->head = $value->head;
             $abouts[$value->locale]->body = $value->body;
             $abouts[$value->locale]->price = $value->price;
             $abouts[$value->locale]->description = $value->description;
             $abouts[$value->locale]->thumbnail = $value->thumbnail;
             $abouts[$value->locale]->before_body = $value->before_body;
             $abouts[$value->locale]->after_body = $value->after_body;
         }
     }
     $about = new MultiModel(['models' => $abouts]);
     if ($about->load(Yii::$app->request->post()) && About::multiSave($about)) {
         return $this->redirect(['index']);
     } else {
         switch (Yii::$app->request->get('scenario')) {
             case 'extend':
                 $viewName = 'extend';
                 break;
             default:
                 $viewName = 'create';
         }
         return $this->render($viewName, ['model' => $about, 'categories' => AboutCategory::find()->active()->all(), 'domains' => array_combine(explode(',', Yii::getAlias('@frontendUrls')), explode(',', Yii::getAlias('@frontendUrls')))]);
     }
 }
コード例 #6
0
ファイル: HemController.php プロジェクト: Hranto/hemon
 public function actionAbout()
 {
     $about = About::find()->one();
     //var_dump($about); exit;
     return $this->render('about', ['about' => $about]);
 }
コード例 #7
0
ファイル: About.php プロジェクト: allhaze/renault
 public function afterDelete()
 {
     $about = About::find()->andWhere(['locale_group_id' => $this->locale_group_id, 'domain_id' => Yii::$app->user->identity->domain_id])->one();
     if ($about) {
         $about->delete();
     }
     return parent::afterDelete();
 }