コード例 #1
0
ファイル: LastNewsWidget.php プロジェクト: xPashaNx/diet
 public function run()
 {
     $limit = NewsConfig::model()->findByPk(1, array('select' => 'widget_count'));
     $limit = $limit->widget_count;
     $criteria = new CDbCriteria();
     $criteria->compare('public', 1);
     $criteria->limit = $limit;
     $criteria->order = 'date DESC';
     $news = News::model()->findAll($criteria);
     $this->render('lastnews', array('news' => $news));
     return parent::run();
 }
コード例 #2
0
ファイル: ConfigController.php プロジェクト: xPashaNx/diet
 /**
  * view all models.
  */
 public function actionIndex()
 {
     $model = NewsConfig::model()->find();
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     if (isset($_POST['NewsConfig'])) {
         $model->attributes = $_POST['NewsConfig'];
         if ($model->save()) {
             Yii::app()->user->setFlash('newsConfig', 'Данные успешно изменены.');
         } else {
             Yii::app()->user->setFlash('newsConfig', 'Ошибка изменения данных!!!.');
         }
         $this->refresh();
     }
     $this->render('index', array('model' => $model));
 }
コード例 #3
0
ファイル: DefaultController.php プロジェクト: xPashaNx/diet
 public function init()
 {
     $this->config = NewsConfig::model()->find();
 }
コード例 #4
0
ファイル: DefaultController.php プロジェクト: xPashaNx/diet
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $dataProvider = new CActiveDataProvider('News', array('criteria' => array('condition' => 'public=1', 'order' => 'date DESC'), 'pagination' => array('pageSize' => NewsConfig::model()->findByPk(1)->view_count)));
     $this->render('index', array('dataProvider' => $dataProvider, 'titleListNews' => $this->config->title, 'folder_upload' => News::FOLDER_UPLOAD));
 }