Beispiel #1
0
 public function actionIndex()
 {
     $model = new News('search');
     $model->unsetAttributes();
     if (isset($_GET['News'])) {
         $model->setAttributes($_GET['News']);
     }
     $dataProvider = $model->search();
     $this->render('//news/index', array('dataProvider' => $dataProvider, 'model' => $model));
 }
 public function actionList()
 {
     $this->breadcrumbs[] = array('title' => "Новости", 'url' => $this->createUrl("list"));
     $this->Title = "Новости";
     $model = new News("search");
     if (!empty($_GET['filter'])) {
         $model->attributes = $_GET['filter'];
     }
     $dataProvider = $model->search();
     $this->render("list", ["dP" => $dataProvider]);
 }
Beispiel #3
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $this->pageTitle = Yii::t('titles', 'NEWS_NEWS');
     $model = new News('search');
     $model->unsetAttributes();
     $this->render('index', array('dataProvider' => $model->search()));
 }
Beispiel #4
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new News('search');
     $model->unsetAttributes();
     $this->render('index', array('dataProvider' => $model->search()));
 }
Beispiel #5
0
 /**
  * @test
  */
 public function search()
 {
     $model = new News('search');
     $model->unsetAttributes();
     // recherche par date
     $model->unsetAttributes();
     $model->event_date = "01/06/2013";
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     $this->assertEquals($this->news('n1')->id, $data[0]->id);
     // recherche par statut
     $model->unsetAttributes();
     $model->enabled = 0;
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     // recherche par catégorie
     $model->unsetAttributes();
     $categoryId = 1;
     // la plupart des news sont de cette catégorie
     $model->category_id = $categoryId;
     $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar();
     $this->assertEquals($count, count($model->search()->data));
     $model->unsetAttributes();
     $categoryId = 2;
     // il y a quelques news de cette catégorie
     $model->category_id = $categoryId;
     $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar();
     $this->assertEquals($count, count($model->search()->data));
     $model->unsetAttributes();
     $categoryId = 99;
     // aucune news de cette catégorie
     $model->category_id = $categoryId;
     $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar();
     $this->assertEquals($count, count($model->search()->data));
 }