Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search(array $params)
 {
     $query = WebNews::find()->byLanguageCode(h::getIso639Code())->joinWith('base');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!$params) {
         return $dataProvider;
     }
     if (!$this->load($params) || !$this->validate()) {
         $this->error = static::ERR_KO;
         return $dataProvider;
     }
     if ($this->tagId) {
         $query->byTagId($this->tagId, false);
     }
     if (trim($this->title)) {
         $query->titleContains($this->title);
     }
     if (trim($this->body)) {
         $query->bodyContains($this->body);
     }
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * @return string
  */
 public function run()
 {
     return $this->render($this->view, ['models' => WebNews::find()->lastNews($this->count)->all(), 'maxLength' => $this->maxLength, 'suffix' => $this->suffix]);
 }
Beispiel #3
0
 /**
  * Renvoie l'actualité immédiatement postérieure à $this
  *
  * @param boolean $onlyActive true => seules les news actives sont renvoyées
  * @return WebNews
  */
 public function getNext($onlyActive = true)
 {
     $next = $this->base->getNext($onlyActive);
     if ($next) {
         return WebNews::find()->byBaseNewsId($next->id)->byLanguageId($this->language_id)->one();
     }
     return null;
 }
Beispiel #4
0
 /**
  * Renvoie la liste des WebNews ayant $this comme tag
  *
  * @return array WebNews[]
  */
 public function getReferers()
 {
     return WebNews::find()->byTagId($this->id)->all();
 }
 /**
  * Lists all WebNews models.
  * @return mixed
  */
 public function actionIndex()
 {
     return $this->render('index', ['dataProvider' => new ActiveDataProvider(['query' => WebNews::find()->joinWith(['base', 'language'], true)->orderBy('base_news.event_date DESC')]), 'emptyBaseNews' => BaseNews::find()->withoutWebNews()->all()]);
 }