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


PHP CPagination::getCurrentPage方法代码示例

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


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

示例1: run

 /**
  * Executes the widget.
  */
 public function run()
 {
     if ($this->pagination->getPageCount() == $this->pagination->getCurrentPage() + 1) {
         return;
     }
     $showMoreUrl = CHtml::normalizeUrl(Yii::app()->createUrl('comment/comment/show', array('contentModel' => get_class($this->object), 'contentId' => $this->object->getPrimaryKey(), 'page' => $this->pagination->getCurrentPage() + 2)));
     $moreCount = $this->pagination->getPageSize();
     if ($this->pagination->getPageCount() == $this->pagination->getCurrentPage() + 2) {
         $moreCount = $this->pagination->getItemCount() - $this->pagination->getPageSize() - $this->pagination->getOffset();
     }
     $this->render('showMore', array('object' => $this->object, 'pagination' => $this->pagination, 'id' => get_class($this->object) . "_" . $this->object->getPrimaryKey(), 'showMoreUrl' => $showMoreUrl, 'moreCount' => $moreCount));
 }
开发者ID:skapl,项目名称:design,代码行数:15,代码来源:CommentsShowMoreWidget.php

示例2: actionIndex

 /**
  * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
  * Requests come in, are verified, and then pulled from the database dynamically
  * Shows all blog posts for a particular category_id
  * @param $id	- The content ID that we want to pull from the database
  * @return $this->render() - Render of page that we want to display
  **/
 public function actionIndex($id = NULL)
 {
     // Run a pre check of our data
     $this->beforeCiiAction($id);
     // Retrieve the data
     $category = Categories::model()->findByPk($id);
     $this->breadcrumbs = Categories::model()->getParentCategories($id);
     // Parse Metadata
     $meta = Categories::model()->parseMeta($category->metadata);
     $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => $category->name)));
     $layout = isset($meta['layout']) ? $meta['layout']['value'] : 'default';
     // Set the layout
     $this->setLayout($layout);
     $data = array();
     $pages = array();
     $itemCount = 0;
     $pageSize = Cii::getConfig('categoryPaginationSize', 10);
     $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition("category_id = " . $id)->addCondition('password = ""');
     $criteria->limit = $pageSize;
     $criteria->order = 'created DESC';
     $itemCount = Content::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = $pageSize;
     $criteria->offset = $criteria->limit * $pages->getCurrentPage();
     $data = Content::model()->findAll($criteria);
     $pages->applyLimit($criteria);
     $this->render('index', array('id' => $id, 'category' => $category, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages, 'meta' => array('description' => $category->getDescription())));
 }
开发者ID:fandikurnia,项目名称:CiiMS,代码行数:35,代码来源:CategoriesController.php

示例3: actionShow

 public function actionShow()
 {
     $uid = Ibos::app()->user->uid;
     $docid = EnvUtil::getRequest("id");
     $version = EnvUtil::getRequest("version");
     if (empty($docid)) {
         $this->ajaxReturn("", "JSONP");
     }
     $officialDocEntity = new ICOfficialdoc($docid);
     $officialDoc = $officialDocEntity->getAttributes();
     if ($version) {
         $versionData = OfficialdocVersion::model()->fetchByAttributes(array("docid" => $docid, "version" => $version));
         $officialDoc = array_merge($officialDoc, $versionData);
     }
     if (!empty($officialDoc)) {
         if (!OfficialdocUtil::checkReadScope($uid, $officialDoc)) {
             $this->error(Ibos::lang("You do not have permission to read the officialdoc"), $this->createUrl("default/index"));
         }
         $data = ICOfficialdoc::getShowData($officialDoc);
         OfficialdocReader::model()->addReader($docid, $uid);
         Officialdoc::model()->updateClickCount($docid, $data["clickcount"]);
         $page = EnvUtil::getRequest("page");
         $criteria = new CDbCriteria();
         $pages = new CPagination(OfficialdocUtil::getCharacterLength($data["content"]));
         $pages->pageSize = 2000;
         $pages->applyLimit($criteria);
         $tmpContent = OfficialdocUtil::subHtml($data["content"], $pages->getCurrentPage() * $pages->getPageSize(), ($pages->getCurrentPage() + 1) * $pages->getPageSize());
         $data["content"] = $tmpContent;
         if (!empty($page) && $page != 1) {
             $data["content"] = "<div><div style=\"border-bottom:4px solid #e26f50;margin-top:60px;\"></div><div style=\"border-top:1px solid #e26f50;margin-top:4px;\"><div><p style=\"text-align:center;\"></p><div id=\"original-content\" style=\"min-height:400px;font:16px/2 fangsong,simsun;color:#666;\"><table cellspacing=\"0\" cellpadding=\"0\" width=\"95%\" align=\"center\"><tbody><tr><td class=\"p1\"><span><p>" . $tmpContent . "</p>";
             $data["content"] = OfficialdocUtil::subHtml($data["content"], 0, $pages->pageSize * 2);
         }
         $params = array("data" => $data, "pages" => $pages, "dashboardConfig" => Yii::app()->setting->get("setting/docconfig"));
         if ($data["rcid"]) {
             $params["rcType"] = RcType::model()->fetchByPk($data["rcid"]);
         }
     } else {
         $params = "";
     }
     $this->ajaxReturn($params, "JSONP");
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:41,代码来源:DocsController.php

示例4: actionList

 /**
  * 部门列表
  */
 public function actionList($page = 1)
 {
     $count = IMDepartment::model()->count();
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['perPage'];
     if (empty($page)) {
         $pager->currentPage = 1;
     }
     $list = IMDepartment::model()->findAll(array('order' => 'id DESC', 'offset' => $pager->getCurrentPage() * $pager->getPageSize(), 'limit' => $pager->pageSize));
     foreach ($list as $v) {
         $data[] = $v->attributes;
     }
     $this->render('list', array('list' => $data, 'pager' => $pager));
 }
开发者ID:tihualong,项目名称:TTPHPServer,代码行数:17,代码来源:ConfigController.php

示例5: actionIndex

 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'));
 }
开发者ID:phuongitvn,项目名称:vdh,代码行数:14,代码来源:SiteController.php

示例6: actionIndex

 public function actionIndex()
 {
     $criteria = new EMongoCriteria();
     #$criteria->order = 'username desc'; //按什么字段来排序
     $model = Admin::model();
     $count = $model->count($criteria);
     //count() 函数计算数组中的单元数目或对象中的属性个数。
     $pager = new CPagination($count);
     $pager->pageSize = 12;
     //每页显示的行数
     $criteria->limit($pager->pageSize);
     $criteria->offset($pager->getCurrentPage() * $pager->pageSize);
     $list = $model->findAll($criteria);
     //查询所有的数据
     $this->render('index', array('list' => $list, 'pages' => $pager));
 }
开发者ID:bo369,项目名称:novel,代码行数:16,代码来源:UserController.php

示例7: actionView

 public function actionView()
 {
     $playlistId = Yii::app()->request->getParam('id');
     $playlist = WapPlaylistModel::model()->published()->findByPk($playlistId);
     $user_msisdn = $playlist->msisdn;
     if (!$playlist) {
         $this->forward("/site/error", true);
     }
     $songsOfPlaylist = WapPlaylistModel::model()->getSongs($playlistId);
     //samge user
     $countPlSameUser = WapPlaylistModel::model()->countPlaylistByPhone($this->userPhone);
     $playlistPages = new CPagination($countPlSameUser);
     $pageSize = Yii::app()->params['pageSize'];
     $playlistPages->setPageSize($pageSize);
     $currentPage = $playlistPages->getCurrentPage();
     $playlistsSameUser = WapPlaylistModel::model()->getSamePlaylistByPhone($playlist->id, $this->userPhone, $currentPage * $pageSize, $pageSize);
     $errorCode = 'success';
     $errorDescription = '';
     //for show price
     $checkPlay = WapUserTransactionModel::model()->checkCharging24h($this->userPhone, $this->userPhone, $playlistId, 'play_album');
     $userSub = $this->userSub;
     //WapUserSubscribeModel::model()->getUserSubscribe($phone);
     if ($checkPlay) {
         $playPrice = 0;
     } else {
         if ($userSub) {
             $playPrice = 0;
         }
     }
     if ($checkPlay) {
         $playPrice = 0;
     }
     // 		$registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT');
     $this->itemName = $playlist->name;
     $this->artist = "Chacha";
     //$playlist->username;
     $this->thumb = UserModel::model()->getThumbnailUrl('s1', $playlist->user_id);
     $this->url = URLHelper::buildFriendlyURL("playlist", $playlist->id, Common::makeFriendlyUrl($playlist->name));
     $this->description = $playlist->name;
     $this->render('view', array('playlist' => $playlist, 'songsOfPlaylist' => $songsOfPlaylist, 'playlistsSameUser' => $playlistsSameUser, 'playlistPages' => $playlistPages, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'userSub' => $userSub, 'user_msisdn' => $user_msisdn));
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:41,代码来源:PlaylistController.php

示例8: fetchAllArray

 public static function fetchAllArray($limit = 20)
 {
     $limit = (int) $limit;
     $cmd = app()->getDb()->createCommand()->select('count(*)')->from(TABLE_FILTER_KEYWORD);
     $count = (int) $cmd->queryScalar();
     if ($count == 0) {
         return array();
     }
     $cmd = app()->getDb()->createCommand()->from(TABLE_FILTER_KEYWORD)->order('id asc');
     if ($limit > 0) {
         $cmd->limit($limit);
     }
     $pages = new CPagination($count);
     $pages->setPageSize($limit);
     $page = $pages->getCurrentPage();
     $offset = $page * $limit;
     if ($offset >= 0) {
         $cmd->offset($offset);
     }
     $rows = $cmd->queryAll();
     return array('rows' => $rows, 'pages' => $pages);
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:22,代码来源:FilterKeyword.php

示例9: actionIndex

 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'));
 }
开发者ID:phuongitvn,项目名称:vdh,代码行数:23,代码来源:SearchController.php

示例10: actionGridData


//.........这里部分代码省略.........
             $criteria->condition = '(' . $field[$jqGrid['searchField']] . ' ' . $operation[$jqGrid['searchOper']] . ' :keyword)';
             $criteria->params = array(':keyword' => str_replace('keyword', $jqGrid['searchString'], $keywordFormula[$jqGrid['searchOper']]));
             // search by special field types
             if ($jqGrid['searchField'] === 'createTime' && ($keyword = strtotime($jqGrid['searchString'])) !== false) {
                 $criteria->params = array(':keyword' => str_replace('keyword', $keyword, $keywordFormula[$jqGrid['searchOper']]));
                 if (date('H:i:s', $keyword) === '00:00:00') {
                     // visitor is looking for a precision by day, not by second
                     $criteria->condition = '(TO_DAYS(FROM_UNIXTIME(' . $field[$jqGrid['searchField']] . ',"%Y-%m-%d")) ' . $operation[$jqGrid['searchOper']] . ' TO_DAYS(FROM_UNIXTIME(:keyword,"%Y-%m-%d")))';
                 }
             }
         }
     }
     if ($company !== 'all') {
         $criteria->addCondition("`Project_Company`.`id`=:companyId");
         $criteria->params[':companyId'] = $company;
     }
     if ($priority === (string) Project::PRIORITY_HIGHEST) {
         $criteria->addCondition("`t`.`priority`=:priorityHighest");
         $criteria->params[':priorityHighest'] = Project::PRIORITY_HIGHEST;
     } else {
         if ($priority === (string) Project::PRIORITY_HIGH) {
             $criteria->addCondition("`t`.`priority`=:priorityHigh");
             $criteria->params[':priorityHigh'] = Project::PRIORITY_HIGH;
         } else {
             if ($priority === (string) Project::PRIORITY_MEDIUM) {
                 $criteria->addCondition("`t`.`priority`=:priorityMedium");
                 $criteria->params[':priorityMedium'] = Project::PRIORITY_MEDIUM;
             } else {
                 if ($priority === (string) Project::PRIORITY_LOW) {
                     $criteria->addCondition("`t`.`priority`=:priorityLow");
                     $criteria->params[':priorityLow'] = Project::PRIORITY_LOW;
                 } else {
                     if ($priority === (string) Project::PRIORITY_LOWEST) {
                         $criteria->addCondition("`t`.`priority`=:priorityLowest");
                         $criteria->params[':priorityLowest'] = Project::PRIORITY_LOWEST;
                     }
                 }
             }
         }
     }
     if ($state === 'closed') {
         $criteria->addCondition("`t`.`closeDate` IS NOT NULL");
     } else {
         if ($state === 'open') {
             $criteria->addCondition("(`t`.`closeDate` IS NULL OR TO_DAYS('" . MDate::formatToDb(time(), 'date') . "') < TO_DAYS(`t`.`closeDate`))");
         }
     }
     if (User::isClient()) {
         $criteria->addCondition("`Company_User2Company`.`userId`=:clientId AND `Company_User2Company`.`position`=:clientPosition");
         $criteria->params[':clientId'] = Yii::app()->user->id;
         $criteria->params[':clientPosition'] = Company::OWNER;
     }
     if (User::isConsultant()) {
         $criteria->addCondition("`Task_Consultant`.`id`=:consultantId");
         $criteria->params[':consultantId'] = Yii::app()->user->id;
     }
     // pagination
     $with = array();
     if (strpos($criteria->condition, 'Project_Company') !== false) {
         $with[] = 'allCompany';
     }
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with[] = 'allCompany.allUser2Company';
     }
     if (strpos($criteria->condition, 'Task_Consultant') !== false) {
         $with[] = 'allTask.allConsultant';
     }
     if (count($with) >= 1) {
         $pages = new CPagination(Project::model()->with($with)->count($criteria));
     } else {
         $pages = new CPagination(Project::model()->count($criteria));
     }
     $pages->pageSize = $jqGrid['pageSize'] !== null ? $jqGrid['pageSize'] : self::GRID_PAGE_SIZE;
     $pages->applyLimit($criteria);
     // sort
     $sort = new CSort('Project');
     $sort->attributes = array('closeDate' => array('asc' => "`t`.`closeDate`", 'desc' => "`t`.`closeDate` desc", 'label' => Project::model()->getAttributeLabel('Closed')), 'hourlyRate' => array('asc' => "`t`.`hourlyRate`", 'desc' => "`t`.`hourlyRate` desc", 'label' => Project::model()->getAttributeLabel('Rate')), 'openDate' => array('asc' => "`t`.`openDate`", 'desc' => "`t`.`openDate` desc", 'label' => Project::model()->getAttributeLabel('Opened')), 'priority' => array('asc' => "`t`.`priority`", 'desc' => "`t`.`priority` desc", 'label' => Project::model()->getAttributeLabel('priority')), 'title' => array('asc' => "`t`.`title`", 'desc' => "`t`.`title` desc", 'label' => Project::model()->getAttributeLabel('title')), 'company' => array('asc' => "`Project_Company`.`title`", 'desc' => "`Project_Company`.`title` desc", 'label' => Company2Project::model()->getAttributeLabel('companyId')));
     $sort->defaultOrder = "`t`.`closeDate` ASC, `t`.`priority` ASC, `t`.`createTime` DESC";
     $sort->applyOrder($criteria);
     // find all
     $with = array('allCompany' => array('select' => 'title'));
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with['allCompany.allUser2Company'] = array('select' => 'id');
     }
     if (strpos($criteria->condition, 'Task_Consultant') !== false) {
         $with['allTask.allConsultant'] = array('select' => 'id');
     }
     $together = strpos($criteria->condition, 'Project_Company') !== false || strpos($criteria->order, 'Project_Company') !== false || strpos($criteria->condition, 'Company_User2Company') !== false || strpos($criteria->condition, 'Task_Consultant') !== false;
     if ($together) {
         $models = Project::model()->with($with)->together()->findAll($criteria);
     } else {
         $models = Project::model()->with($with)->findAll($criteria);
     }
     // create resulting data array
     $data = array('page' => $pages->getCurrentPage() + 1, 'total' => $pages->getPageCount(), 'records' => $pages->getItemCount(), 'rows' => array());
     foreach ($models as $model) {
         $data['rows'][] = array('id' => $model->id, 'cell' => array(isset($model->allCompany[0]->id) ? CHtml::link(CHtml::encode($model->allCompany[0]->title), array('company/show', 'id' => $model->allCompany[0]->id)) : '', CHtml::encode($model->title), CHtml::encode($model->hourlyRate), CHtml::encode($model->getAttributeView('priority')), CHtml::encode(MDate::format($model->openDate, 'medium', null)), CHtml::encode(MDate::format($model->closeDate, 'medium', null)), CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first ui-corner-all', 'title' => Yii::t('link', 'Show'))) . CHtml::link('<span class="ui-icon ui-icon-pencil"></span>', array('update', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-last ui-corner-all', 'title' => Yii::t('link', 'Edit')))));
     }
     $this->printJson($data);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:101,代码来源:ProjectController.php

示例11: actionViewType

 public function actionViewType()
 {
     $artistId = Yii::app()->request->getParam('id');
     $artist = ArtistModel::model()->findByPk($artistId);
     $this->artist = $artist->name;
     $this->thumb = ArtistModel::model()->getAvatarUrl($artist->id, 150);
     $this->url = URLHelper::buildFriendlyURL("artist", $artist->id, $artist->url_key);
     if (!$artist) {
         $this->forward("/site/error", true);
     }
     $listType = Yii::app()->request->getParam('list', 'song');
     $countSongsOfArtist = $artist->song_count;
     $countClipsOfArtist = $artist->video_count;
     $countAlbumsOfArtist = $artist->album_count;
     $pageSize = Yii::app()->params['numberSongsPerPage'];
     if ($listType == 'song') {
         // in case that list songs of artist
         $songPages = new CPagination($countSongsOfArtist);
         $songPages->setPageSize($pageSize);
         $currentPage = $songPages->getCurrentPage();
         $songsOfArtist = WapSongModel::model()->getSongsSameSinger(0, $artist->id, $currentPage * $pageSize, $pageSize);
         $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'songsOfArtist' => $songsOfArtist, 'songPages' => $songPages));
     } elseif ($listType == 'clip') {
         // in case that list clips of artist
         $clipPages = new CPagination($countClipsOfArtist);
         $clipPages->setPageSize($pageSize);
         $currentPage = $clipPages->getCurrentPage();
         $clipsOfArtist = WapVideoModel::model()->getVideosSameArtist(0, $artist->id, $currentPage * $pageSize, $pageSize);
         $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'clipsOfArtist' => $clipsOfArtist, 'clipPages' => $clipPages));
     } else {
         // in case that list albums of artist
         $albumPages = new CPagination($countAlbumsOfArtist);
         $albumPages->setPageSize($pageSize);
         $currentPage = $albumPages->getCurrentPage();
         $albumsOfArtist = WapAlbumModel::model()->getAlbumsSameArtist(0, $artist->id, $currentPage * $pageSize, $pageSize);
         $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'albumsOfArtist' => $albumsOfArtist, 'albumPages' => $albumPages));
     }
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:38,代码来源:ArtistController.php

示例12: actionList

 /**
  * 群组列表
  */
 public function actionList($page = 1)
 {
     $count = IMGroup::model()->count(array('condition' => 'status = 0'));
     $pager = new CPagination($count);
     $pager->pageSize = Yii::app()->params['perPage'];
     if (empty($page)) {
         $pager->currentPage = 1;
     }
     $list = IMGroup::model()->findAll(array('condition' => 'status = 0', 'order' => 'groupId DESC', 'offset' => $pager->getCurrentPage() * $pager->getPageSize(), 'limit' => $pager->pageSize));
     $data = array();
     if (!empty($list)) {
         foreach ($list as $v) {
             $data[] = $v->attributes;
         }
     }
     $this->render('list', array('list' => $data, 'pager' => $pager));
 }
开发者ID:abinghu,项目名称:TTPhpServer,代码行数:20,代码来源:GroupController.php

示例13: actionGridData

 /**
  * Print out array of models for the jqGrid rows.
  */
 public function actionGridData()
 {
     if (!Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, Yii::t('http', 'Invalid request. Please do not repeat this request again.'));
         exit;
     }
     // specify request details
     $jqGrid = $this->processJqGridRequest();
     // specify filter parameters
     $state = isset($_GET['state']) ? $_GET['state'] : null;
     if ($state !== 'all' && $state !== 'closed' && $state !== 'open') {
         $state = 'all';
     }
     // criteria
     $criteria = new CDbCriteria();
     $criteria->group = "`t`.`id`";
     // required by together()
     $criteria->select = "`t`.contactName, `t`.createTime, `t`.deactivationTime, `t`.title, `t`.titleAbbr";
     //$criteria->select="`t`.`contactName`, `t`.`createTime`, `t`.`deactivationTime`, `t`.`title`, `t`.`titleAbbr`"; // uncomment in yii-1.1.2
     if ($jqGrid['searchField'] !== null && $jqGrid['searchString'] !== null && $jqGrid['searchOper'] !== null) {
         $field = array('contactName' => "`t`.`contactName`", 'createTime' => "`t`.`createTime`", 'deactivationTime' => "`t`.`deactivationTime`", 'title' => "`t`.`title`", 'titleAbbr' => "`t`.`titleAbbr`");
         $operation = $this->getJqGridOperationArray();
         $keywordFormula = $this->getJqGridKeywordFormulaArray();
         if (isset($field[$jqGrid['searchField']]) && isset($operation[$jqGrid['searchOper']])) {
             $criteria->condition = '(' . $field[$jqGrid['searchField']] . ' ' . $operation[$jqGrid['searchOper']] . ' :keyword)';
             $criteria->params = array(':keyword' => str_replace('keyword', $jqGrid['searchString'], $keywordFormula[$jqGrid['searchOper']]));
             // search by special field types
             if ($jqGrid['searchField'] === 'createTime' && ($keyword = strtotime($jqGrid['searchString'])) !== false) {
                 $criteria->params = array(':keyword' => str_replace('keyword', $keyword, $keywordFormula[$jqGrid['searchOper']]));
                 if (date('H:i:s', $keyword) === '00:00:00') {
                     // visitor is looking for a precision by day, not by second
                     $criteria->condition = '(TO_DAYS(FROM_UNIXTIME(' . $field[$jqGrid['searchField']] . ',"%Y-%m-%d")) ' . $operation[$jqGrid['searchOper']] . ' TO_DAYS(FROM_UNIXTIME(:keyword,"%Y-%m-%d")))';
                 }
             }
         }
     }
     if ($state === 'closed') {
         $criteria->addCondition("(`t`.`isActive` IS NULL OR `t`.`isActive`!=:isActive)");
         $criteria->params[':isActive'] = Company::IS_ACTIVE;
     } else {
         if ($state === 'open') {
             $criteria->addCondition("`t`.`isActive`=:isActive");
             $criteria->params[':isActive'] = Company::IS_ACTIVE;
         }
     }
     if (User::isClient()) {
         $criteria->addCondition("`Company_User2Company`.`userId`=:clientId AND `Company_User2Company`.`position`=:clientPosition");
         $criteria->params[':clientId'] = Yii::app()->user->id;
         $criteria->params[':clientPosition'] = Company::OWNER;
     }
     // pagination
     $with = array();
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with[] = 'allUser2Company';
     }
     if (count($with) >= 1) {
         $pages = new CPagination(Company::model()->with($with)->count($criteria));
     } else {
         $pages = new CPagination(Company::model()->count($criteria));
     }
     $pages->pageSize = $jqGrid['pageSize'] !== null ? $jqGrid['pageSize'] : self::GRID_PAGE_SIZE;
     $pages->applyLimit($criteria);
     // sort
     $sort = new CSort('Company');
     $sort->attributes = array('contactName' => array('asc' => "`t`.`contactName`", 'desc' => "`t`.`contactName` desc", 'label' => Company::model()->getAttributeLabel('contactName')), 'createTime' => array('asc' => "`t`.`createTime`", 'desc' => "`t`.`createTime` desc", 'label' => Company::model()->getAttributeLabel('Opened')), 'deactivationTime' => array('asc' => "`t`.`deactivationTime`", 'desc' => "`t`.`deactivationTime` desc", 'label' => Company::model()->getAttributeLabel('Closed')), 'title' => array('asc' => "`t`.`title`", 'desc' => "`t`.`title` desc", 'label' => Company::model()->getAttributeLabel('title')), 'titleAbbr' => array('asc' => "`t`.`titleAbbr`", 'desc' => "`t`.`titleAbbr` desc", 'label' => Company::model()->getAttributeLabel('Abbr')));
     $sort->defaultOrder = "`t`.`deactivationTime` ASC, `t`.`title` ASC";
     $sort->applyOrder($criteria);
     // find all
     $with = array();
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with['allUser2Company'] = array('select' => 'id');
     }
     $together = strpos($criteria->condition, 'Company_User2Company') !== false;
     if ($together) {
         $models = Company::model()->with($with)->together()->findAll($criteria);
     } else {
         $models = Company::model()->with($with)->findAll($criteria);
     }
     // create resulting data array
     $data = array('page' => $pages->getCurrentPage() + 1, 'total' => $pages->getPageCount(), 'records' => $pages->getItemCount(), 'rows' => array());
     foreach ($models as $model) {
         $data['rows'][] = array('id' => $model->id, 'cell' => array(CHtml::encode($model->title), CHtml::encode($model->titleAbbr), CHtml::encode($model->contactName), CHtml::encode(MDate::format($model->createTime, 'medium', null)), CHtml::encode(MDate::format($model->deactivationTime, 'medium', null)), CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first ui-corner-all', 'title' => Yii::t('link', 'Show'))) . CHtml::link('<span class="ui-icon ui-icon-pencil"></span>', array('update', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-last ui-corner-all', 'title' => Yii::t('link', 'Edit')))));
     }
     $this->printJson($data);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:88,代码来源:CompanyController.php

示例14: getCurrentPage

 public function getCurrentPage($recalculate = true)
 {
     $page = parent::getCurrentPage($recalculate);
     $page = $page ? ($page + 1) / $this->getPageSize() : $page;
     return (int) $page;
 }
开发者ID:maduhu,项目名称:openbay,代码行数:6,代码来源:Pagination.php

示例15: actionList

 public function actionList()
 {
     $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Content', 'All Content'))));
     $this->setLayout('default');
     $pageSize = Cii::getConfig('contentPaginationSize', 10);
     $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition('password = ""');
     $criteria->order = 'published DESC';
     $criteria->limit = $pageSize;
     $itemCount = Content::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = $pageSize;
     $criteria->offset = $criteria->limit * $pages->getCurrentPage();
     $data = Content::model()->findAll($criteria);
     $pages->applyLimit($criteria);
     $this->render('all', array('data' => $data, 'itemCount' => $itemCount, 'pages' => $pages));
 }
开发者ID:xl602,项目名称:CiiMS,代码行数:16,代码来源:ContentController.php


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