NewsController::actionIndex PHP Method

actionIndex() public method

public actionIndex ( )
    public function actionIndex()
    {
        $dbCriteria = new CDbCriteria(['condition' => 't.status = :status', 'params' => [':status' => News::STATUS_PUBLISHED], 'order' => 't.date DESC', 'with' => ['user']]);
        if (!Yii::app()->getUser()->isAuthenticated()) {
            $dbCriteria->mergeWith(['condition' => 'is_protected = :is_protected', 'params' => [':is_protected' => News::PROTECTED_NO]]);
        }
        if ($this->isMultilang()) {
            $dbCriteria->mergeWith(['condition' => 't.lang = :lang', 'params' => [':lang' => Yii::app()->getLanguage()]]);
        }
        $dataProvider = new CActiveDataProvider('News', ['criteria' => $dbCriteria, 'pagination' => ['pageSize' => (int) $this->getModule()->perPage]]);
        $this->render('index', ['dataProvider' => $dataProvider]);
    }