コード例 #1
0
ファイル: SiteController.php プロジェクト: phuongitvn/vdh
 public function actionIndex()
 {
     $c = array('conditions' => array('status' => array('==' => 1)));
     $total = WebArticlesModel::model()->count($c);
     $pager = new CPagination($total);
     $itemOnPaging = 5;
     $pager->pageSize = 10;
     $curr_page = $pager->getCurrentPage();
     $limit = $pager->getLimit();
     $offset = $pager->getOffset();
     $c = array('conditions' => array('status' => array('==' => 1)), 'sort' => array('_id' => EMongoCriteria::SORT_DESC), 'limit' => $limit, 'offset' => $offset);
     $data = FeedModel::model()->findAll($c);
     $this->render('index', compact('data', 'pager', 'itemOnPaging'));
 }
コード例 #2
0
ファイル: PostController.php プロジェクト: phuongitvn/vdh
 /**
  * Displays a particular model.
  */
 public function actionView()
 {
     $id = Yii::app()->request->getParam('id');
     $genre = Yii::app()->request->getParam('url_key_cat1');
     $this->activemenu = $genre;
     $article = WebArticlesModel::model()->model()->findByPk(new MongoId($id));
     if (!$article) {
         throw new CHttpException(404, "There is not found!");
     }
     $limit = 10;
     $offset = 0;
     $c = array('conditions' => array('status' => array('==' => 1)), 'sort' => array('_id' => EMongoCriteria::SORT_DESC), 'limit' => $limit, 'offset' => $offset);
     $data = FeedModel::model()->findAll($c);
     $this->render('view', array('article' => $article, 'data' => $data));
 }
コード例 #3
0
ファイル: SearchController.php プロジェクト: phuongitvn/vdh
 public function actionIndex()
 {
     $keyword = Yii::app()->request->getParam('keyword', '');
     $page = Yii::app()->request->getParam('page', 1);
     // Find all records witch have first name starring on a, b and c, case insensitive search
     $keyRegexPattern = self::formatKeywordsPatternSearch($keyword);
     if (empty($keyRegexPattern)) {
         $data = null;
     } else {
         $regexObj = new MongoRegex($keyRegexPattern);
         $c = array('conditions' => array('status' => array('==' => 1), 'title' => array('==' => $regexObj)));
         $total = WebArticlesModel::model()->count($c);
         $pager = new CPagination($total);
         $itemOnPaging = 5;
         $pager->pageSize = 10;
         $curr_page = $pager->getCurrentPage();
         $limit = $pager->getLimit();
         $offset = $pager->getOffset();
         $c = array('conditions' => array('status' => array('==' => 1), 'title' => array('==' => $regexObj)), 'limit' => $limit, 'offset' => $offset);
         $data = WebArticlesModel::model()->findAll($c);
     }
     $this->render('index', compact('data', 'pager', 'itemOnPaging', 'keyword', 'limit'));
 }
コード例 #4
0
 public function run()
 {
     $data = WebArticlesModel::model()->getMostPopular();
     $this->render('list', compact('data'));
 }