コード例 #1
0
ファイル: SiteController.php プロジェクト: jessesiu/GigaDBV3
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     #if (Yii::app()->user->isGuest) {
     #    $this->render('index');
     #} else {
     #    if (Yii::app()->user->checkAccess('admin')) {
     #        $this->redirect(array('admin/index'));
     #    } else {
     #        $this->redirect(array('user/accountBalance', 'id'=>Yii::app()->user->_id));
     #    }
     #}
     $form = new SearchForm();
     // Use for Form
     $dataset = new Dataset();
     // Use for auto suggestion
     $datasetModel = $this->getDatasetByType(0);
     // Use for image slider content
     $publicIds = Yii::app()->db->createCommand()->select("id")->from("dataset")->where("upload_status = 'Published'")->queryAll();
     $datasettypes_hints = Type::model()->findAll(array('order' => 'name ASC'));
     $news = News::model()->findAll("start_date<=current_date AND end_date>=current_date");
     $criteria = new CDbCriteria();
     $criteria->limit = 10;
     $criteria->condition = "upload_status = 'Published'";
     #$criteria->order = "id DESC";
     $criteria->order = 'publication_date DESC';
     $latest_datasets = Dataset::model()->findAll($criteria);
     $criteria->condition = null;
     $criteria->order = 'publication_date DESC';
     $latest_messages = RssMessage::model()->findAll($criteria);
     $rss_arr = array_merge($latest_datasets, $latest_messages);
     $this->sortRssArray($rss_arr);
     $this->render('index', array('datasets' => $datasetModel, 'form' => $form, 'dataset' => $dataset, 'news' => $news, 'dataset_hint' => $datasettypes_hints, 'rss_arr' => $rss_arr, 'count' => count($publicIds), 'latest_datasets' => $latest_datasets));
 }
コード例 #2
0
ファイル: RssController.php プロジェクト: jessesiu/GigaDBV3
 public function actionLatest()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = $this->numberOfLatestDataset;
     $criteria->condition = "upload_status = 'Published'";
     #$criteria->order = "id DESC";
     $criteria->order = 'publication_date DESC';
     $datasets = Dataset::model()->findAll($criteria);
     $criteria->condition = null;
     $criteria->order = 'publication_date DESC';
     $latest_messages = RssMessage::model()->findAll($criteria);
     $rss_arr = array_merge($datasets, $latest_messages);
     $this->sortRssArray($rss_arr);
     $this->generateFeed($rss_arr);
 }
コード例 #3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = RssMessage::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }