/**
  * This function generates the products grid
  * based on the criteria. It also generates the
  * pagination object need for the users to navigate
  * through products.
  *
  * @return void
  */
 public function generateProductGrid()
 {
     $this->_numberOfRecords = Product::model()->count($this->_productGridCriteria);
     $this->_pages = new CPagination($this->_numberOfRecords);
     $this->_pages->setPageSize(CPropertyValue::ensureInteger(Yii::app()->params['PRODUCTS_PER_PAGE']));
     $this->_pages->applyLimit($this->_productGridCriteria);
     $this->_productsGrid = self::createBookends(Product::model()->findAll($this->_productGridCriteria));
 }
Beispiel #2
0
 public function actionPosts($name)
 {
     $tag = urldecode($name);
     $this->setSiteTitle(t('tag_posts', 'main', array('{name}' => $tag)));
     // @todo 关键字的描述没有指定
     $this->setPageKeyWords($tag);
     $this->setPageDescription(t('tag_posts_page_description', 'main', array('{name}' => $tag)));
     cs()->registerMetaTag('all', 'robots');
     $cmd = app()->getDb()->createCommand()->select('p.id')->from(TABLE_TAG . ' t')->where('t.name = :tagname', array(':tagname' => $tag))->join(TABLE_POST_TAG . ' pt', 'pt.tag_id = t.id')->join(TABLE_POST . ' p', 'p.id = pt.post_id');
     $ids = $cmd->queryColumn();
     if (count($ids) > 0) {
         $criteria = new CDbCriteria();
         if (param('post_list_type') == POST_LIST_TYPE_TITLE) {
             $criteria->select = array('t.id', 't.title', 't.visit_nums', 't.comment_nums', 't.create_time');
         }
         $criteria->order = 't.istop, t.create_time desc, t.id desc';
         $criteria->addInCondition('t.id', $ids)->addCondition('t.state = :state');
         $criteria->params += array(':state' => POST_STATE_ENABLED);
         $count = Post::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->setPageSize(param('postCountOfTitleListPage'));
         $pages->applyLimit($criteria);
         $posts = Post::model()->findAll($criteria);
     }
     $listType = param('post_list_type');
     $view = $listType == POST_LIST_TYPE_SUMMARY ? '/post/_summary_list' : '/post/_title_list';
     $blockTitle = t('tag_posts', 'main', array('{name}' => $tag));
     $data = array('blockTitle' => $blockTitle, 'posts' => $posts, 'pages' => $pages);
     $postListHtml = $this->renderPartial($view, $data, true);
     $this->render('posts', array('postListHtml' => $postListHtml));
 }
 public function actionPersonnel()
 {
     if (isset($_GET['id'])) {
         $model = $this->loadPersonnelModel($_GET['id']);
         $this->render('personnel_detail', array('model' => $model));
     } else {
         if (isset($_GET['type_id'])) {
             $type_id = $_GET['type_id'];
             $type = PersonnelType::model()->findByPk($_GET['type_id']);
             $criteria = new CDbCriteria();
             $criteria->condition = 'status = 1 AND personnel_type_id =' . $type_id;
             $criteria->order = 'sort_order';
             $total = Personnel::model()->count($criteria);
             $pages = new CPagination($total);
             $pages->setPageSize(10);
             $pages->applyLimit($criteria);
             $model = Personnel::model()->findAll($criteria);
             $this->render('personnel', array('model' => $model, 'type' => $type, 'pages' => $pages));
         } else {
             $criteria = new CDbCriteria();
             $criteria->select = '*';
             $criteria->condition = 'status = 1';
             $criteria->order = 'sort_order';
             $total = Personnel::model()->count($criteria);
             $pages = new CPagination($total);
             $pages->setPageSize(10);
             $pages->applyLimit($criteria);
             $model = Personnel::model()->findAll($criteria);
             $this->render('personnel', array('model' => $model, 'pages' => $pages));
         }
     }
 }
 public function actioncxIndex()
 {
     //print_r( ucfirst($this->getId() ) );
     //$this->actionId     = $this->getAction()->getId();
     $controllerId = $this->controllerId;
     $criteria = new CDbCriteria();
     if (isset($_GET['keyword']) || !empty($_GET['keyword']) || strlen($_GET['keyword']) > 0) {
         $keyword = trim($_GET['keyword']);
         $criteria->condition = 'title like :keyword ';
         $criteria->params = array(':keyword' => "%{$keyword}%");
         $is_partial = true;
     }
     $imodel = new $controllerId();
     $item_count = call_user_func(array($imodel, 'count'), $criteria);
     $page_size = 10;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = $page_size;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $select_pagination->header = '跳转到:';
     $select_pagination->htmlOptions['onchange'] = "";
     $select_pagination->setPages($pages);
     $select_pagination->init();
     $list = call_user_func(array($imodel, 'findAll'), $criteria);
     if ($is_partial) {
         $this->renderPartial('_index', array('list' => $list, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
     } else {
         $this->render('index', array('list' => $list, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
     }
 }
 public function actionIndex($id = null)
 {
     if (!empty($this->arrSystem)) {
         $this->pageTitle = "Hình ảnh - " . $this->arrSystem->title;
     }
     $criteria = new CDBCriteria();
     $title = "";
     if ($id == null) {
         $criteria->addCondition("is_product = 1");
         $title = "Hình ảnh hoạt động";
     } else {
         if ($id == 2) {
             $criteria->addCondition("is_product = 2");
             $title = "Sản phẩm mới";
         } else {
             throw new CHttpException(404, 'Không tìm thấy trang!.');
         }
     }
     $countItem = Slides::model()->count($criteria);
     $pages = new CPagination($countItem);
     $pages->setPageSize(12);
     $pages->applyLimit($criteria);
     $arrNew = Slides::model()->findAll($criteria);
     $arrImage = Slides::model()->findALl($criteria);
     $this->render("index", array('arrImage' => $arrImage, 'item_count' => $countItem, 'page_size' => 12, 'pages' => $pages, 'title' => $title));
 }
 public function actionList()
 {
     $_default_item_perpage = 10;
     if (isset($_GET['limit']) && (int) $_GET['limit'] > 0) {
         Yii::app()->session['current'] = $_GET['limit'];
         $_default_item_perpage = Yii::app()->session['current'];
     } else {
         if (isset(Yii::app()->session['current'])) {
             $_default_item_perpage = Yii::app()->session['current'];
         } else {
             Yii::app()->session['current'] = $_default_item_perpage;
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition('current=1 AND web=1');
     $q = Yii::app()->getRequest()->getQuery('q');
     if ($q) {
         $criteria->addCondition('`title` LIKE "%' . $q . '%" OR `code` LIKE "%' . $q . '%" OR `description_short` LIKE "%' . $q . '%"');
     }
     $criteria->order = _xls_get_sort_order();
     $item_count = Product::model()->count($criteria);
     $pages = new CPagination($item_count);
     $pages->setPageSize($_default_item_perpage);
     $pages->applyLimit($criteria);
     $model = Product::model()->findAll($criteria);
     $this->render('list', array('model' => $model, 'item_count' => $item_count, 'page_size' => $_default_item_perpage, 'items_count' => $item_count, 'pages' => $pages));
 }
Beispiel #7
0
 /**
  * Action for the members section of the directory
  *
  * @todo Dont pass lucene hits to view, build user array inside of action
  */
 public function actionMembers()
 {
     $details = Yii::app()->db->createCommand()->select('companyname, username, firstname, lastname, title, guid')->from('user, profile')->where('user.id=profile.user_id and group_id=3')->order('companyname')->queryAll();
     $companycount = Yii::app()->db->createCommand()->select('count(distinct(companyname)) as count')->from('profile')->where('companyname not like \'student\'')->order('companyname')->queryAll();
     $item_count = (int) $companycount[0]["count"];
     $page_size = (int) $companycount[0]["count"];
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $end = $pages->offset + $pages->limit <= $item_count ? $pages->offset + $pages->limit : $item_count;
     $sample = array();
     $y = "";
     $i = 0;
     $j = 0;
     foreach ($details as $x) {
         if ($x["companyname"] != $y) {
             $sample[$i++] = array('cname' => $x["companyname"], 'detail' => array());
             $j = 0;
         }
         $sample[$i - 1]["detail"][$j++] = $x;
         $y = $x["companyname"];
     }
     $pg_content = array();
     for ($i = $pages->offset; $i < $end; $i++) {
         $pg_content[$i] = $sample[$i];
     }
     $this->render('members', array('item_count' => $item_count, 'page_size' => $page_size, 'items_count' => $item_count, 'pages' => $pages, 'sample' => $pg_content));
 }
Beispiel #8
0
 public function actionPickAtt()
 {
     $return_id = $_GET['return_id'];
     $rtype = $_GET['rtype'];
     $criteria = new CDbCriteria();
     if (isset($_GET['keyword'])) {
         $screen_name = trim($_GET['keyword']);
         $criteria->condition = 'screen_name like :screen_name';
         $criteria->params = array(':screen_name' => "%{$screen_name}%");
         $partial_tpl = '_att';
         //$atts = Attachment::model()->findAll($criteria);
         //$this->renderPartial('_att',array('return_id' => $return_id,'atts' => $atts,'rtype' => $rtype ),false,true);
     } else {
         $partial_tpl = 'pickatt';
         //$atts = Attachment::model()->findAll();
         //$this->renderPartial('pickatt',array('return_id' => $return_id,'atts' => $atts ,'rtype' => $rtype ),false,true);
     }
     $item_count = Attachment::model()->count($criteria);
     $page_size = 10;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = $page_size;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $select_pagination->htmlOptions['onchange'] = "";
     $select_pagination->setPages($pages);
     $select_pagination->init();
     $atts = Attachment::model()->findAll($criteria);
     $this->renderPartial($partial_tpl, array('return_id' => $return_id, 'atts' => $atts, 'rtype' => $rtype, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
 }
 public function actionIndex()
 {
     if (isset($_GET['type_id'])) {
         $criteria = new CDbCriteria();
         $criteria->select = '*';
         $criteria->condition = 'status = 1 AND report_type_id =' . $_GET['type_id'];
         $criteria->order = 'sort_order';
         $total = Report::model()->count($criteria);
         $pages = new CPagination($total);
         $pages->setPageSize(20);
         $pages->applyLimit($criteria);
         $model = Report::model()->findAll($criteria);
         $type = ReportType::model()->findByPK($_GET['type_id']);
         $this->render('index', array('model' => $model, 'type' => $type, 'pages' => $pages));
     } else {
         if (isset($_GET['id'])) {
             $model = Report::model()->findByPk($_GET['id']);
             $this->render('detail', array('model' => $model));
         } else {
             $criteria = new CDbCriteria();
             $criteria->select = '*';
             $criteria->condition = 'status = 1';
             $criteria->order = 'sort_order';
             $total = Report::model()->count($criteria);
             $pages = new CPagination($total);
             $pages->setPageSize(20);
             $pages->applyLimit($criteria);
             $model = Report::model()->findAll($criteria);
             $this->render('index', array('model' => $model, 'pages' => $pages));
         }
     }
 }
Beispiel #10
0
 public function actionTag()
 {
     $data = array();
     $alias = urlGETParams('alias');
     $query = "SELECT * FROM tbl_tags_youtube WHERE alias = :alias";
     $values = array(':alias' => $alias);
     $row = $this->db->createCommand($query)->bindValues($values)->queryRow();
     if (empty($row)) {
         $this->redirect($this->createUrl('video/index'));
     }
     $data['row'] = $row;
     $tag_id = $row['id'];
     $where = " AND tags LIKE '%," . $tag_id . ",%' ";
     $query_count = "SELECT COUNT(id) FROM tbl_youtube WHERE 1 " . $where;
     $item_count = $this->db->createCommand($query_count)->queryScalar();
     $pages = new CPagination($item_count);
     $perPage = 30;
     $pages->setPageSize($perPage);
     $page = isset($_GET['page']) ? intval($_GET['page']) : 0;
     if ($page <= 0) {
         $page = 1;
     }
     $offset = ($page - 1) * $perPage;
     $query = "SELECT * FROM tbl_youtube WHERE 1 " . $where . " " . " ORDER BY id DESC " . "LIMIT " . $offset . "," . $perPage;
     $data['listVideo'] = $this->db->createCommand($query)->queryAll();
     $title = $data['row']['name'] . ' videos';
     if ($page > 1) {
         $title .= ' - page ' . $page;
     }
     $this->_meta = array('title' => $title . ' - Techz24', 'description' => 'All videos in topic . ' . $data['row']['name'] . ' on Techz24');
     $this->_style_class = 'page right-sidebar singular fade-imgs-in-appear one-side-wide both-sidebars archive-page';
     $this->render('tag', array('data' => $data, 'item_count' => $item_count, 'page_size' => $perPage, 'pages' => $pages));
 }
 public function search($begin, $end)
 {
     $condition = 'time>=:begin AND time<=:end';
     $params = ['begin' => $begin, 'end' => $end];
     $model = Logging::model();
     $pager = new CPagination($model->count($condition, $params));
     $pager->setPageSize(100);
     $logging = $model->findAll(['condition' => $condition, 'params' => $params, 'offset' => $pager->getOffset(), 'limit' => $pager->getLimit(), 'order' => 'time desc']);
     $this->render('index', ['logging' => new RedArrayDataProvider($logging), 'pager' => $pager]);
 }
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     if ($_GET['find']) {
         if ($_GET['activity_type'] != NULL and $_GET['start_date'] == NULL and $_GET['end_date'] == NULL) {
             $type = $_GET['activity_type'];
             $criteria->condition = 'activity_type LIKE :type';
             $criteria->params[':type'] = $type;
         } elseif ($_GET['activity_type'] == NULL and $_GET['start_date'] != NULL and $_GET['end_date'] != NULL) {
             $start_date = date('Y-m-d', strtotime($_GET['start_date']));
             $end_date = date('Y-m-d', strtotime($_GET['end_date']));
             if ($start_date == $end_date) {
                 $criteria->condition = 'DATE(activity_time) LIKE :date';
                 $criteria->params[':date'] = $start_date;
             } else {
                 $criteria->condition = 'DATE(activity_time) BETWEEN :start_date AND :end_date';
                 $criteria->params[':start_date'] = $start_date;
                 $criteria->params[':end_date'] = $end_date;
             }
         } elseif ($_GET['activity_type'] == NULL and $_GET['start_date'] != NULL and $_GET['end_date'] == NULL) {
             $start_date = date('Y-m-d', strtotime($_GET['start_date']));
             $criteria->condition = 'DATE(activity_time) >= :date';
             $criteria->params[':date'] = $start_date;
         } elseif ($_GET['activity_type'] == NULL and $_GET['start_date'] == NULL and $_GET['end_date'] != NULL) {
             $end_date = date('Y-m-d', strtotime($_GET['end_date']));
             $criteria->condition = 'DATE(activity_time) <= :date';
             $criteria->params[':date'] = $end_date;
         } elseif ($_GET['activity_type'] != NULL and $_GET['start_date'] != NULL and $_GET['end_date'] != NULL) {
             $type = $_GET['activity_type'];
             $start_date = date('Y-m-d', strtotime($_GET['start_date']));
             $end_date = date('Y-m-d', strtotime($_GET['end_date']));
             $criteria->condition = 'activity_type LIKE :type';
             $criteria->params[':type'] = $type;
             if ($start_date == $end_date) {
                 $criteria->condition = $criteria->condition . ' AND DATE(activity_time) LIKE :date';
                 $criteria->params[':date'] = $start_date;
             } else {
                 $criteria->condition = $criteria->condition . ' AND DATE(activity_time) BETWEEN :start_date AND :end_date';
                 $criteria->params[':start_date'] = $start_date;
                 $criteria->params[':end_date'] = $end_date;
             }
         }
     }
     $total = ActivityFeed::model()->count($criteria);
     // Count feeds
     $pages = new CPagination($total);
     $pages->setPageSize(Yii::app()->params['listPerPage']);
     $pages->applyLimit($criteria);
     $feeds = ActivityFeed::model()->findAll($criteria);
     // Get feeds
     /*echo $pages->getCurrentPage().'-'.$pages->getPageCount().'---'.count($feeds).'....';
     		echo $total;exit;*/
     $this->render('index', array('feeds' => $feeds, 'type' => $type, 'start_date' => $_GET['start_date'], 'end_date' => $_GET['end_date'], 'pages' => $pages, 'criteria' => $criteria));
 }
 public function actionHlist()
 {
     $this->layout = '//layouts/blank';
     $criteria = Advertisement::model()->setFetchCondition();
     $count = Advertisement::model()->count($criteria);
     $pagination = new CPagination($count);
     $pagination->setPageSize(15);
     $pagination->applyLimit($criteria);
     $dataProvider = Advertisement::model()->findAll($criteria);
     $this->render('hlist', array('model' => $model, 'dataProvider' => $dataProvider, 'pagination' => $pagination));
 }
 public function actionBasicPager()
 {
     $item_count = 32;
     $page_size = 5;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     // simulate the effect of LIMIT in a sql query
     $end = $pages->offset + $pages->limit <= $item_count ? $pages->offset + $pages->limit : $item_count;
     $sample = range($pages->offset + 1, $end);
     $this->render('basic_pager', array('item_count' => $item_count, 'page_size' => $page_size, 'items_count' => $item_count, 'pages' => $pages, 'sample' => $sample));
 }
 /**
  * Constructor.
  * @param CDataProvider $dataProvider the data provider to iterate over
  * @param integer       $pageSize     pageSize to use for iteration. This is the number of objects loaded into memory at the same time.
  */
 public function __construct(CDataProvider $dataProvider, $pageSize = null)
 {
     $this->_dataProvider = $dataProvider;
     $this->_totalItemCount = $dataProvider->getTotalItemCount();
     if (($pagination = $this->_dataProvider->getPagination()) === false) {
         $this->_dataProvider->setPagination($pagination = new CPagination());
     }
     if ($pageSize !== null) {
         $pagination->setPageSize($pageSize);
     }
 }
 /**
  * Page which shows all people
  */
 public function actionPeople()
 {
     $criteria = new CDbCriteria();
     //$criteria->condition = 'visibility != '.Space::VISIBILITY_NONE;
     $criteria->order = 'firstname ASC';
     $userCount = User::model()->count($criteria);
     $pages = new CPagination($userCount);
     $pages->setPageSize(HSetting::Get('paginationSize'));
     $pages->applyLimit($criteria);
     // the trick is here!
     $users = User::model()->findAll($criteria);
     $this->render('people', array('users' => $users, 'pages' => $pages, 'userCount' => $userCount, 'pageSize' => HSetting::Get('paginationSize')));
 }
Beispiel #17
0
 private static function fetchTopicPosts($tid)
 {
     $criteria = new CDbCriteria();
     $criteria->order = 't.state desc, t.create_time desc, t.id desc';
     $criteria->limit = param('postCountOfPage');
     $criteria->addColumnCondition(array('topic_id' => $tid))->addCondition('t.state != :state');
     $count = Post::model()->count($criteria, array(':state' => Post::STATE_DISABLED));
     $pages = new CPagination($count);
     $pages->setPageSize(param('postCountOfPage'));
     $pages->applyLimit($criteria);
     $posts = Post::model()->with('category', 'topic')->findAll($criteria, array(':state' => Post::STATE_DISABLED));
     return array('posts' => $posts, 'pages' => $pages);
 }
 public function actionGroup3()
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->condition = 'status = 1 AND know_group=3';
     $criteria->order = 'sort_order';
     $total = Knowledge::model()->count($criteria);
     $pages = new CPagination($total);
     $pages->setPageSize(20);
     $pages->applyLimit($criteria);
     $model = Knowledge::model()->findAll($criteria);
     $this->render('index', array('model' => $model, 'pages' => $pages));
 }
 private function view()
 {
     $query = $this->request->getPost('Setting', []);
     $model = Setting::model();
     $model->attributes = $query;
     $condition = $this->createSearchCriteria($query);
     $pager = new CPagination($model->count($condition));
     $pager->setPageSize(20);
     $condition['offset'] = $pager->getOffset();
     $condition['limit'] = $pager->getLimit();
     $data = $model->findAll($condition);
     $this->render('setting', ['data' => new RedArrayDataProvider($data), 'pager' => $pager, 'model' => $model]);
 }
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect('/');
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'update_time DESC';
     $item_count = SupportTicket::model()->count($criteria);
     $pages = new CPagination($item_count);
     $pages->setPageSize(Yii::app()->params['defaultListPerPage']);
     $pages->applyLimit($criteria);
     // the trick is here!
     $this->render('index', array('model' => SupportTicket::model()->findAll($criteria), 'item_count' => $item_count, 'page_size' => Yii::app()->params['defaultListPerPage'], 'items_count' => $item_count, 'pages' => $pages));
 }
Beispiel #21
0
 public function actionBilling()
 {
     $query = ['uid' => $this->user->getId()];
     $model = Traffic::model();
     $model->attributes = $query;
     $condition = ['condition' => 'uid=:uid', 'params' => ['uid' => $query['uid']]];
     $pager = new CPagination($model->count($condition));
     $pager->setPageSize(20);
     $condition['offset'] = $pager->getOffset();
     $condition['limit'] = $pager->getLimit();
     $condition['order'] = 'date desc';
     $data = $model->findAll($condition);
     $this->render('billing', ['data' => new RedArrayDataProvider($data), 'pager' => $pager]);
 }
Beispiel #22
0
 public function run()
 {
     $query = $this->request->getQuery('Service', []);
     $model = Service::model();
     $model->attributes = $query;
     $condition = $this->createSearchCriteria($query);
     $pager = new CPagination($model->count($condition));
     $pager->setPageSize(20);
     $condition['offset'] = $pager->getOffset();
     $condition['limit'] = $pager->getLimit();
     $condition['order'] = 'status asc, uid asc';
     $data = $model->findAll($condition);
     $this->render('pac', ['data' => new RedArrayDataProvider($data), 'pager' => $pager, 'model' => $model]);
 }
Beispiel #23
0
 public function fetchAllByPage($condition, $pageSize = 0)
 {
     $conditionArray = array("condition" => $condition, "order" => "addtime DESC");
     $criteria = new CDbCriteria();
     foreach ($conditionArray as $key => $value) {
         $criteria->{$key} = $value;
     }
     $count = $this->count($criteria);
     $pagination = new CPagination($count);
     $everyPage = empty($pageSize) ? Ibos::app()->params["basePerPage"] : $pageSize;
     $pagination->setPageSize(intval($everyPage));
     $pagination->applyLimit($criteria);
     $reportList = $this->fetchAll($criteria);
     return array("pagination" => $pagination, "data" => $reportList);
 }
 public function actionIndex()
 {
     $pageSize = 10;
     $criteria = new CDbCriteria();
     //$criteria->condition = 'collumnName1 = :id';
     $criteria->order = 'id DESC';
     //$criteria->params = array(':id' => $id);
     $itemCount = Logging::model()->count($criteria);
     $pagination = new CPagination($itemCount);
     $pagination->setPageSize($pageSize);
     $pagination->applyLimit($criteria);
     // the trick is here!
     $logEntries = Logging::model()->findAll($criteria);
     $this->render('index', array('entries' => $logEntries, 'itemCount' => $itemCount, 'pageSize' => $pageSize, 'pagination' => $pagination));
 }
Beispiel #25
0
 public function fetchAllAndPage($conditions = "", $pageSize = null)
 {
     $conditionArray = array("condition" => $conditions, "order" => "istop DESC,toptime ASC,addtime DESC");
     $criteria = new CDbCriteria();
     foreach ($conditionArray as $key => $value) {
         $criteria->{$key} = $value;
     }
     $count = $this->count($criteria);
     $pages = new CPagination($count);
     $everyPage = is_null($pageSize) ? Yii::app()->params["basePerPage"] : $pageSize;
     $pages->setPageSize(intval($everyPage));
     $pages->applyLimit($criteria);
     $datas = $this->fetchAll($criteria);
     return array("pages" => $pages, "datas" => $datas);
 }
 private static function fetchCategoryPosts($id)
 {
     $criteria = new CDbCriteria();
     if (param('post_list_type') == POST_LIST_TYPE_TITLE) {
         $criteria->select = array('t.id', 't.title', 't.visit_nums', 't.comment_nums', 't.create_time');
     }
     $criteria->order = 't.istop, t.create_time desc, t.id desc';
     $criteria->addColumnCondition(array('category_id' => $id))->addCondition('t.state = :state');
     $criteria->params += array(':state' => POST_STATE_ENABLED);
     $count = Post::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->setPageSize(param('postCountOfTitleListPage'));
     $pages->applyLimit($criteria);
     $posts = Post::model()->findAll($criteria);
     return array('posts' => $posts, 'pages' => $pages);
 }
Beispiel #27
0
 public function actionIndex()
 {
     $data = array();
     $alias = urlGETParams('alias');
     $query = "SELECT * FROM tbl_tags WHERE alias = :alias";
     $values = array(':alias' => $alias);
     $row = $this->db->createCommand($query)->bindValues($values)->queryRow();
     if (empty($row)) {
         $this->redirect($this->createUrl('index/index'));
     }
     $data['row'] = $row;
     $tag_id = $row['id'];
     $where = " AND tags LIKE '%," . $tag_id . ",%' ";
     $query_count = "SELECT COUNT(id) FROM tbl_archive WHERE 1 " . $where;
     $item_count = $this->db->createCommand($query_count)->queryScalar();
     $pages = new CPagination($item_count);
     $perPage = 20;
     $pages->setPageSize($perPage);
     $page = isset($_GET['page']) ? intval($_GET['page']) : 0;
     if ($page <= 0) {
         $page = 1;
     }
     $offset = ($page - 1) * $perPage;
     $query = "SELECT id, cate_id, title, alias, thumbnail,short_text,created,tags FROM tbl_archive WHERE 1 " . $where . " " . " ORDER BY id DESC " . "LIMIT " . $offset . "," . $perPage;
     $data['newpost'] = $this->db->createCommand($query)->queryAll();
     $tags = array();
     if (!empty($data['newpost'])) {
         foreach ($data['newpost'] as $item) {
             $arr = explode(',', trim($item['tags'], ','));
             if (!empty($arr)) {
                 foreach ($arr as $t) {
                     $tags[] = $t;
                 }
             }
         }
         $tags = array_unique($tags);
         $data['tags'] = $this->getListTags($tags);
     }
     $data['category'] = $this->getListCategory();
     $title = $data['row']['name'] . ' News';
     if ($page > 1) {
         $title .= ' - page ' . $page;
     }
     $this->_meta = array('title' => $title . ' - Techz24', 'description' => 'Techz24 news editors and reporters provide top ' . $data['row']['name'] . ' news, with in-depth coverage of issues and events.');
     $this->_style_class = 'page right-sidebar singular fade-imgs-in-appear one-side-wide both-sidebars archive-page';
     $this->render('index', array('data' => $data, 'item_count' => $item_count, 'page_size' => $perPage, 'pages' => $pages));
 }
 public function actionJob()
 {
     if (isset($_GET['id'])) {
         $model = News::model()->findByPk($_GET['id']);
         $this->render('detail', array('model' => $model));
     } else {
         $news_criteria = new CDbCriteria();
         $news_criteria->condition = "status = 1 AND news_type_id = 3";
         $news_criteria->order = "create_date desc,news_id desc";
         $news_total = News::model()->count($news_criteria);
         $pages = new CPagination($news_total);
         $pages->setPageSize(20);
         $pages->applyLimit($news_criteria);
         $news = News::model()->findAll($news_criteria);
         $this->render('job', array('news' => $news, 'pages' => $pages));
     }
 }
Beispiel #29
0
 public function actionGridProduct()
 {
     $search = null;
     $criteria = new CDbCriteria();
     if (!empty($_POST)) {
         $search = Util::input($_POST['search']);
         $criteria->condition = "\n        product_code LIKE(:search)\n        OR product_name LIKE(:search)\n      ";
         $criteria->params = array('search' => '%' . $search . '%');
     }
     $product = new Product();
     $model = new CActiveDataProvider($product, array('sort' => array('defaultOrder' => 'product_id DESC')));
     $pagination = new CPagination();
     $pagination->setPageSize(40);
     $model->setPagination($pagination);
     $model->setCriteria($criteria);
     $this->render('//Dialog/GridProduct', array('model' => $model));
 }
Beispiel #30
0
 /**
  * Lists all models.
  */
 public function actionIndex($opt = null)
 {
     $controllerId = strlen($opt['controllerId']) > 0 ? $opt['controllerId'] : $this->controllerId;
     if (!is_array($opt)) {
         $criteria = new CDbCriteria();
         $keyword = trim($_GET['keyword']);
     } else {
         extract($opt);
     }
     $imodel = new $controllerId();
     $item_count = call_user_func(array($imodel, 'count'), $criteria);
     $page_size = strlen($opt['page_size']) > 0 ? $opt['page_size'] : 10;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = $page_size;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $select_pagination->header = Yii::t('cp', 'Go to:');
     $select_pagination->htmlOptions['onchange'] = "";
     $select_pagination->setPages($pages);
     $select_pagination->init();
     $list = call_user_func(array($imodel, 'findAll'), $criteria);
     if (!is_array($opt['tpl_params'])) {
         $opt['tpl_params'] = array();
     }
     $opt['tpl_params']['list'] = $list;
     $opt['tpl_params']['pagination'] = $pagination;
     $opt['tpl_params']['select_pagination'] = $select_pagination;
     // echo Chtml::listBox('category_id',1,$leafs)
     //print_r($opt['tpl_params']);
     if ($is_partial) {
         $this->renderPartial('_index', $opt['tpl_params'], false, true);
     } else {
         $tpl = strlen($opt['tpl']) > 0 ? $opt['tpl'] : 'index';
         if ($_GET['ajax'] == 'ajax') {
             $this->renderPartial($tpl, $opt['tpl_params'], false, true);
         } else {
             $this->render($tpl, $opt['tpl_params'], false, true);
         }
     }
 }