/**
  * @return null|string
  */
 public function run()
 {
     $model = $this->findModel();
     if (isset($model)) {
         return $this->render($this->detailTemplate, ['model' => $model, 'class' => $this->class]);
     } else {
         $models = GalleryModel::find()->where(['active' => 1])->orderby(['position' => SORT_ASC])->all();
         return $this->render($this->template, ['models' => $models, 'class' => $this->class]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Gallery::find()->joinWith(['translations'])->where(['language' => Yii::$app->language]);
     $query->orderBy('position');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => false, 'pagination' => ['pageSize' => 50]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     // Convert date to Unix timestamp
     if (!empty($params[StringHelper::basename(self::className())]['date'])) {
         $query->andFilterWhere(['date' => strtotime($params[StringHelper::basename(self::className())]['date'])]);
     }
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'translations.name', $this->name]);
     return $dataProvider;
 }