当前位置: 首页>>代码示例>>PHP>>正文


PHP CPagination::setCurrentPage方法代码示例

本文整理汇总了PHP中CPagination::setCurrentPage方法的典型用法代码示例。如果您正苦于以下问题:PHP CPagination::setCurrentPage方法的具体用法?PHP CPagination::setCurrentPage怎么用?PHP CPagination::setCurrentPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPagination的用法示例。


在下文中一共展示了CPagination::setCurrentPage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionList

 public function actionList()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $list = array();
     $criteria = new CDbCriteria();
     $criteria->select = 'sid,name';
     $criteria->order = 'sid ASC';
     $request = Yii::app()->getRequest();
     $id = trim($request->getParam("id"));
     if ($id) {
         $criteria->addCondition("sid = {$id}");
     }
     $sites = new Site();
     $count = $sites->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['postsPerPage'];
     $pager->setCurrentPage($page - 1);
     $pager->applyLimit($criteria);
     $list = $sites->findAll($criteria);
     $res = new Seo();
     $seo = array();
     foreach ($list as $key => $site) {
         $row = $res->find('sid=:sid', array(':sid' => $site->sid));
         $seo[$key] = $row;
     }
     $this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list, 'seo' => $seo));
 }
开发者ID:humor-zo,项目名称:woc-yii,代码行数:27,代码来源:SeoController.php

示例2: actionList

 public function actionList()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $list = array();
     $criteria = new CDbCriteria(array('order' => 'sid ASC'));
     $request = Yii::app()->getRequest();
     $id = trim($request->getParam("id"));
     if ($id) {
         $criteria->addCondition("sid = {$id}");
     }
     $sites = new Site();
     $count = $sites->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['postsPerPage'];
     $pager->setCurrentPage($page - 1);
     $pager->applyLimit($criteria);
     $list = $sites->findAll($criteria);
     $mynum = $mynum2 = array();
     $rnum = new Rnum();
     foreach ($list as $key => $site) {
         $row = $rnum->find('sname=:sname', array(':sname' => $site->name));
         $mynum[$key] = $row->onum;
         $mynum2[$key] = $row->cnum;
     }
     $this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list, 'mynum' => $mynum, 'mynum2' => $mynum2));
 }
开发者ID:humor-zo,项目名称:woc-yii,代码行数:26,代码来源:SiteController.php

示例3: getList

 /**
  * 获取所有统计记录
  */
 public function getList($param, $page = -1, $pageSize = 15)
 {
     $ids = array();
     $pages = null;
     $criteria = new CDbCriteria();
     if (!empty($param['username'])) {
         $userbehavior = new UserBehavior();
         $username = $userbehavior->getUserByLoginName($param['username']);
         if (!empty($username)) {
             foreach ($username as $key => $user) {
                 $ids[] = $user['id'];
             }
         }
         $criteria->addInCondition("user_id", $ids);
     }
     $criteria->order = "ctime DESC";
     $criteria->addColumnCondition(array('is_deleted' => 0));
     if (!empty($param['page'])) {
         $page = $param['page'];
     }
     $count = Stats::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->setCurrentPage(0);
     $pages->pageSize = $pageSize;
     $pages->applyLimit($criteria);
     $stats = Stats::model()->findAll($criteria);
     foreach ($stats as $key => $stat) {
         $userbehavior = new UserBehavior();
         $username = $userbehavior->getUserById($stat['user_id']);
         $result[$key]['user'] = $username;
         $result[$key]['stat'] = $stat;
     }
     return compact('pages', 'result');
 }
开发者ID:zt123,项目名称:Base-System,代码行数:37,代码来源:StatBehavior.php

示例4: actionList

 public function actionList()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $list = array();
     $criteria = new CDbCriteria(array('order' => 'id ASC'));
     $types = new Type();
     $count = $types->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['postsPerPage'];
     $pager->setCurrentPage($page - 1);
     $pager->applyLimit($criteria);
     $list = $types->findAll($criteria);
     $this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list));
 }
开发者ID:humor-zo,项目名称:woc-yii,代码行数:14,代码来源:TypeController.php

示例5: actionShow

 /**
  * Shows a particular model.
  */
 public function actionShow()
 {
     $model = $this->loadPageSlug();
     $this->pageTitle = $model->title;
     if (isset($_GET['page'])) {
         $section = $_GET['page'];
     } else {
         $section = 1;
     }
     $leaves = array();
     $leaves = explode('<!--leaf-->', $model->content);
     $sections = new CPagination(sizeof($leaves));
     $sections->pageSize = 1;
     $sections->applyLimit($criteria = new CDbCriteria());
     $sections->setCurrentPage($section - 1);
     $this->render('show', array('model' => $model, 'pages' => $sections));
 }
开发者ID:smoothcoder,项目名称:DISCARDEDYiiblog,代码行数:20,代码来源:PageController.php

示例6: actionList

 public function actionList()
 {
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $list = array();
     $criteria = new CDbCriteria(array('order' => 'id ASC'));
     $request = Yii::app()->getRequest();
     $id = trim($request->getParam("id"));
     if ($id) {
         $criteria->addCondition("id = {$id}");
     }
     $domains = new Domain();
     $count = $domains->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['postsPerPage'];
     $pager->setCurrentPage($page - 1);
     $pager->applyLimit($criteria);
     $list = $domains->findAll($criteria);
     $this->render('list', array('r' => Yii::app()->request->baseUrl . '/', 'pages' => $pager, 'list' => $list));
 }
开发者ID:humor-zo,项目名称:woc-yii,代码行数:19,代码来源:DomainController.php

示例7: actionManage

 /**
  * Displayes the authitem manage page
  */
 public function actionManage()
 {
     $this->processAdminCommand();
     $page = Yii::app()->getRequest()->getParam("page", "");
     if (Yii::app()->request->isAjaxRequest || $page != "") {
         $selectedType = Yii::app()->request->getParam('selectedType', Yii::app()->user->getState("selectedType"));
     } else {
         $selectedType = "";
     }
     Yii::app()->user->setState("selectedType", $selectedType);
     $criteria = new CDbCriteria();
     if ($selectedType != "") {
         $criteria->condition = "type = " . $selectedType;
     }
     if (!Yii::app()->request->isAjaxRequest) {
         Yii::app()->user->setState("currentPage", Yii::app()->request->getParam('page', 0) - 1);
     }
     $pages = new CPagination(AuthItem::model()->count($criteria));
     $pages->route = "manage";
     $pages->pageSize = $this->module->pageSize;
     $pages->applyLimit($criteria);
     $pages->setCurrentPage(Yii::app()->user->getState('currentPage'));
     $sort = new CSort('AuthItem');
     $sort->applyOrder($criteria);
     $models = AuthItem::model()->findAll($criteria);
     $full = Yii::app()->request->getParam("full");
     if (Yii::app()->request->isAjaxRequest && !$full) {
         $this->renderPartial('manage/list', array('models' => $models, 'pages' => $pages, 'sort' => $sort, 'full' => $full), false, true);
     } else {
         if (Yii::app()->request->isAjaxRequest && $full) {
             $this->renderPartial('manage/manage', array('models' => $models, 'pages' => $pages, 'sort' => $sort, 'full' => $full), false, true);
         } else {
             $this->render('manage/manage', array('models' => $models, 'pages' => $pages, 'sort' => $sort, 'full' => $full));
         }
     }
 }
开发者ID:yunsite,项目名称:my-advertise,代码行数:39,代码来源:AuthitemController.php

示例8: managers

 public function managers($filter = array())
 {
     $result = array();
     $managers = array();
     $criteria = new CDbCriteria();
     $criteria->addColumnCondition(array('is_deleted' => 0));
     $count = $this->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 20;
     if (!empty($filter['pageSzie'])) {
         $pages->pageSize = $filter['pageSzie'];
     }
     if (!empty($filter['current_page'])) {
         $pages->setCurrentPage($filter['current_page']);
     }
     $pages->applyLimit($criteria);
     $objects = $this->findAll($criteria);
     if (!empty($objects)) {
         foreach ($objects as $obj) {
             $item = $obj->attributes;
             if (!empty($item['sp'])) {
                 $item['sp'] = CJSON::decode($item['sp']);
             }
             $managers[] = $item;
         }
     }
     $result = array('managers' => $managers, 'pages' => $pages);
     return $result;
 }
开发者ID:zt123,项目名称:Base-System,代码行数:29,代码来源:Manager.php

示例9: actionSearch


//.........这里部分代码省略.........
             }
             if (!empty($price) && !empty($price['min'])) {
                 $criteria->condition .= ' AND price >= ' . $price["min"];
             }
             if (!empty($price) && !empty($price['max'])) {
                 $criteria->condition .= ' AND price <= ' . $price["max"];
             }
             $criteria->join = 'left join good_attr_val v ON v.good_id=t.id';
             if ($attr->type == '1') {
                 $values = array();
                 foreach ($feature as $key => $value) {
                     if ($value == '1') {
                         $values[] = $key;
                     }
                 }
                 $criteria->compare('v.attr_value_id', $values);
             }
             if ($attr->type == '2') {
                 $criteria->condition .= ' AND v.value=' . $feature . ' and v.attr_id=' . $attr->id;
             }
             if ($attr->type == '3') {
                 if (!empty($feature['min']) && !empty($feature['max'])) {
                     $criteria->condition .= ' AND v.value>=' . $feature['min'] . ' AND v.value<=' . $feature['max'] . ' AND v.attr_id =' . $attr->id;
                 } elseif (!empty($feature['min']) && empty($feature['max'])) {
                     $criteria->condition .= ' AND v.value>=' . $feature['min'] . ' AND v.attr_id =' . $attr->id;
                 } elseif (empty($feature['min']) && !empty($feature['max'])) {
                     $criteria->condition .= ' AND v.value<=' . $feature['max'] . ' AND v.attr_id =' . $attr->id;
                 }
             }
             $goods = Good::model()->with(array('goodImages'))->findAll($criteria);
             $good_ids = array();
             foreach ($goods as $good) {
                 $good_ids[] = $good->id;
             }
             //echo 'id=' . $featureId . '<br>';
             if (empty($res) && $first_step) {
                 //print_r($good_ids);echo '<br>';
                 $res = $good_ids;
                 if (empty($res) && !$first_step) {
                     echo 'Ничего не найдено по этим критериям';
                     return;
                 }
                 $first_step = FALSE;
                 continue;
             }
             if (empty($good_ids)) {
                 echo 'Ничего не найдено по этим критериям';
                 return;
             }
             foreach ($res as $good_id) {
                 if (!in_array($good_id, $good_ids)) {
                     unset($res[array_search($good_id, $res)]);
                 }
             }
         }
     }
     if ($first_step) {
         $criteria = new CDbCriteria();
         $criteria->compare('category_id', $catId, false);
         if (!empty($brands)) {
             $criteria->compare('brand_id', $brands, false);
         }
         if (!empty($price) && !empty($price['min'])) {
             $criteria->condition .= ' AND price >= ' . $price["min"];
         }
         if (!empty($price) && !empty($price['max'])) {
             $criteria->condition .= ' AND price <= ' . $price["max"];
         }
         if (!empty($_POST['order'])) {
             $criteria->order = $_POST['order'] . ' ';
         }
         $count = Good::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = 10;
         $pages->setCurrentPage($_POST['page']);
         $pages->applyLimit($criteria);
         $goods = Good::model()->with(array('goodImages'))->findAll($criteria);
     } else {
         if (count($res) == 0) {
             echo 'Ничего не найдено по этим критериям';
             return;
         }
         $new_res = array();
         foreach ($res as $value) {
             $new_res[] = $value;
         }
         $count = count($new_res);
         $criteria = new CDbCriteria();
         $pages = new CPagination($count);
         $pages->pageSize = 10;
         $pages->setCurrentPage($_POST['page']);
         $pages->applyLimit($criteria);
         $criteria->compare('id', $new_res);
         if (!empty($_POST['order'])) {
             $criteria->order = $_POST['order'] . ' ';
         }
         $goods = Good::model()->with(array('goodImages'))->findAll($criteria);
     }
     $this->renderPartial('search-result', array('goods' => $goods, 'pages' => $pages, 'count' => $count));
 }
开发者ID:rahmanjis,项目名称:yii-catalog,代码行数:101,代码来源:CatalogController.php

示例10: actionCreatePager

 public function actionCreatePager($total, $noLink, $page)
 {
     $pages = new CPagination($total);
     $pages->setPageSize($noLink);
     $pages->setCurrentPage($page - 1);
     ob_start();
     $this->widget('CLinkPager', array('header' => '', 'firstPageLabel' => ' First &lt;&lt;', 'prevPageLabel' => '&lt; Previous', 'nextPageLabel' => 'Next &gt;', 'lastPageLabel' => ' Last &lt;&lt;', 'pages' => $pages, 'htmlOptions' => array('class' => 'pagination')));
     $str = ob_get_clean();
     return $str;
 }
开发者ID:bhaiyyalal,项目名称:testcode,代码行数:10,代码来源:TicketController.php

示例11: setPages

 public static function setPages($content, $pageSize, $page)
 {
     $contentLength = strlen($content);
     $pageCount = ceil($contentLength / $pageSize);
     $pages = new CPagination($pageCount);
     $pages->setPageSize($pageSize);
     $pages->setCurrentPage(0);
     $data = array();
     for ($i = 0; $i < $pageCount; $i++) {
         $data[$i] = substr($content, $i * $pageSize, ($i + 1) * $pageSize);
     }
     return array("data" => $data[$page - 1], "pages" => $pages);
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:13,代码来源:ICOfficialdoc.php

示例12: actionImportoutexcel

 public function actionImportoutexcel()
 {
     $objectPHPExcel = new PHPExcel();
     $objectPHPExcel->setActiveSheetIndex(0);
     //当期查询出的数据
     //$page = isset($_GET['User_page']) ? intval($_GET['User_page']) : 1;
     $page = Yii::app()->session['page'];
     $user = Yii::app()->session['user'];
     $username = isset($user['username']) ? trim($user['username']) : null;
     $email = isset($user['email']) ? trim($user['email']) : null;
     $identity = isset($user['identity']) ? $user['identity'] : null;
     $phone = isset($user['phone']) ? trim($user['phone']) : null;
     $freeze = isset($user['freeze']) ? trim($user['freeze']) : null;
     $state = isset($user['Province']) ? trim($user['Province']) : null;
     $city = isset($user['City']) ? trim($user['City']) : null;
     $district = isset($user['Area']) ? trim($user['Area']) : null;
     $page_size = 10;
     $sql = "select a.username,a.email,a.identity,a.create_at,b.truename,\n    \t\t  b.phone,b.usertype,b.freeze\n    \t\t from tbl_user a,tbl_profiles b where b.user_id=a.id and b.Status=0 and b.isblack=0";
     if ($username) {
         $sql .= " and a.username like '%{$username}%'";
     }
     if ($email) {
         $sql .= " and a.email like '%{$email}%'";
     }
     if ($identity) {
         $sql .= " and a.identity='{$identity}'";
     }
     if ($phone) {
         $sql .= " and b.phone like '%{$phone}%'";
     }
     if ($freeze) {
         $sql .= " and b.freeze ='{$freeze}'";
     }
     if ($state) {
         $sql .= " and b.state='{$state}' and b.city='{$city}' and b.district='{$district}' ";
     }
     $sql .= " order by create_at desc";
     $model = Yii::app()->db->CreateCommand($sql)->queryAll();
     $count = count($model);
     $pages = new CPagination(count($model));
     $pages->pageSize = 10;
     $pages->setCurrentPage($page - 1);
     //$pages->applylimit($criteria);
     $model = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $model->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $model->bindValue(':limit', $pages->pageSize);
     $model = $model->queryAll();
     $page_count = (int) ($count / $page_size) + 1;
     $n = 0;
     foreach ($model as $list) {
         if ($n % $page_size === 0) {
             //报表头的输出
             $objectPHPExcel->getActiveSheet()->mergeCells('B1:G1');
             $objectPHPExcel->getActiveSheet()->setCellValue('B1', '会员信息表');
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', '会员信息表');
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', '会员信息表');
             $objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getFont()->setSize(24);
             $objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', '日期:' . date("Y年m月j日"));
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E2', '第' . $page . '/' . $page_count . '页');
             $objectPHPExcel->setActiveSheetIndex(0)->getStyle('E2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             //表格头的输出
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B3', '用户名称');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C3', '创建时间');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D3', '邮箱');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E3', '机构');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F3', '真实姓名');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G3', '会员类型');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H3', '手机号');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(22);
             $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I3', '是否冻结');
             $objectPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(22);
             $objectPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(32);
             //设置居中
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             //设置边框
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             //设置颜色
             $objectPHPExcel->getActiveSheet()->getStyle('B3:I3')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FF66CCCC');
         }
         //明细的输出
         $objectPHPExcel->getActiveSheet()->setCellValue('B' . ($n + 4), $list['username']);
         $objectPHPExcel->getActiveSheet()->setCellValue('C' . ($n + 4), $list['create_at']);
         $objectPHPExcel->getActiveSheet()->setCellValue('D' . ($n + 4), $list['email']);
         switch ($list['identity']) {
//.........这里部分代码省略.........
开发者ID:zwq,项目名称:unpei,代码行数:101,代码来源:AdminController.php

示例13: ActionPicture

 /**
  * @uses 根据参数查询图片信息。
  * 1:如果国家信息不为空,无城市参数,获取国家全部城市列表。
  * 2:如果国家信息为空,则以城市信息为准获取图片数据。
  * @link http://brs.baicheng.com/index.php?r=Api/Picture/picture
  * $json_params包含如下参数
  * country_id 国家id 【可选】 默认为:0 。
  * city_ids 城市id串 【可选】默认为空 例如:123,234,122。
  * cate_id 图片类型id 【可选】 默认为:0
  * page_size 分页大小 【可选】 默认为:20
  * page 页码 【可选】默认为:1
  * @return bool 返回数据,如果参数错误返回false,如果参数正确并获取到数据,则返回对应的json数据
  */
 public function ActionPicture()
 {
     $json_params = Yii::app()->request->getParam('json_params');
     if (!empty($json_params)) {
         $params_arr = json_decode($json_params, true);
         //大洲
         if (isset($params_arr['country_id']) && !empty($params_arr['country_id'])) {
             $country_id = $params_arr['country_id'];
         } else {
             $country_id = 0;
         }
         //城市
         if (isset($params_arr['city_ids']) && !empty($params_arr['city_ids'])) {
             $city_ids = $params_arr['city_ids'];
         } else {
             $city_ids = "";
         }
         //类型
         if (isset($params_arr['cate_id']) && !empty($params_arr['cate_id'])) {
             $cate_id = $params_arr['cate_id'];
         } else {
             $cate_id = 0;
         }
         //分页大小
         if (isset($params_arr['page_size']) && !empty($params_arr['page_size'])) {
             $page_size = $params_arr['page_size'];
         } else {
             $page_size = 20;
         }
         //页码
         if (isset($params_arr['page']) && !empty($params_arr['page'])) {
             $page = $params_arr['page'];
         } else {
             $page = 1;
         }
         if (empty($country_id) && empty($city_ids) || $page < 1 || $page_size < 1) {
             //参数错误
             return false;
         } else {
             if (!empty($country_id) && empty($city_ids)) {
                 //如果有国家id,无城市ids,将获取国家下的所有城市。
                 $country_cities = City::model()->findAllByAttributes(array('CountryID' => $country_id));
                 $country_cities_arr = array();
                 foreach ($country_cities as $cc) {
                     $country_cities_arr[] = $cc['ID'];
                 }
                 array_unique($country_cities_arr);
                 $city_ids = implode(",", $country_cities_arr);
                 //该国家所有的城市id串
             }
             $cities_arr = explode(",", $city_ids);
             //城市id串
             $pictures_arr = array();
             //返回的数组
             //分页获取图片信息
             $pic_condition = new CDbCriteria();
             $pic_condition->addInCondition('CityId', $cities_arr);
             $pic_condition->addColumnCondition(array('Valid' => 0));
             if (!empty($cate_id)) {
                 $pic_condition->addColumnCondition(array('CategoryId' => $cate_id));
             }
             $pic_condition->order = 'ID ASC';
             $count = Picture::model()->count($pic_condition);
             $pager = new CPagination($count);
             $pager->pageSize = $page_size;
             $pager->setCurrentPage($page - 1);
             $pager->applyLimit($pic_condition);
             $picture_list = Picture::model()->findAll($pic_condition);
             //返回数组中分页信息
             $pictures_arr['PageCount'] = $count;
             $pictures_arr['PageSize'] = $page_size;
             $pictures_arr['Page'] = $page;
             //封装返回数据
             foreach ($picture_list as $key => $val) {
                 $pictures_arr['PictureList'][$key]['ID'] = $val['ID'];
                 $pictures_arr['PictureList'][$key]['CityId'] = $val['CityId'];
                 $pictures_arr['PictureList'][$key]['CategoryId'] = $val['CategoryId'];
                 $pictures_arr['PictureList'][$key]['PictureCategoryName'] = $val->picture_category['PictureCategoryName'];
                 $pictures_arr['PictureList'][$key]['Name'] = $val['Name'];
                 $pictures_arr['PictureList'][$key]['Title'] = $val['Title'];
                 $pictures_arr['PictureList'][$key]['Description'] = $val['Description'];
                 foreach ($val->picture_source as $v) {
                     if ($v['SizeType'] == 0) {
                         $pictures_arr['PictureList'][$key]['PicSrcBig'] = str_replace("uploads/", "", $v['PicSrc']);
                     } elseif ($v['SizeType'] == 1) {
                         $pictures_arr['PictureList'][$key]['PicSrcMiddle'] = str_replace("uploads/", "", $v['PicSrc']);
                     } elseif ($v['SizeType'] == 2) {
//.........这里部分代码省略.........
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:101,代码来源:PictureController.php


注:本文中的CPagination::setCurrentPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。