取分页数据.

@param \wulaphp\router\UrlParsedInfo $paging
@param string|int                    $total
@param array                         $args

@return array
165277
private function getPageInfo($paging, $total, $args) {
        $cur = $paging->page;
        $per = isset ($args ['limit']) ? intval($args ['limit']) : 10;
        if (!$per) {
            $per = 10;
        }

        $tp = ceil($total / $per); // 一共有多少页

        $pager ['total']  = $tp;
        $pager ['ctotal'] = $total;
        $pager ['first']  = '#';
        $pager ['prev']   = '#';
        $pager ['next']   = '#';
        $pager ['last']   = '#';

        if ($tp < 2) {
            return $pager;
        }

        $loop = true;
        if (isset ($args ['loop']) && empty ($args ['loop'])) {
            $loop = false;
        }
        $pages = [];
        if ($cur == 1) { // 当前在第一页
            $pager ['first'] = '#';
            $pager ['prev']  = '#';
        } else {
            $pager ['first'] = $paging->base(1);
            $pager ['prev']  = $cur == 2 ? $paging->base(1) : $paging->base($cur - 1);
        }
        // 向前后各多少页
        $pp = isset ($args ['pp']) ? intval($args ['pp']) : 10;
        $sp = $pp % 2 == 0 ? $pp / 2 : ($pp - 1) / 2;
        if ($cur <= $sp) {
            $start = 1;
            $end   = $pp;
            $end   = $end > $tp ? $tp : $end;
        } else {
            $start = $cur - $sp;
            $end   = $cur + $sp;
            if ($pp % 2 == 0) {
                $end -= 1;
            }
            if ($end >= $tp) {
                $start -= ($end - $tp);
                $start > 0 or $start = 1;
                $end = $tp;
            }
        }
        for ($i = $start; $i <= $end; $i++) {
            if ($i == $cur) {
                $pages[ $i ] = $pager [ $i ] = '#';
            } else {
                $pages[ $i ] = $pager [ $i ] = $paging->base($i);
            }
        }
        if ($cur == $tp) {
            $pager ['next'] = '#';
            $pager ['last'] = '#';
        } else {
            $pager ['next'] = $paging->base($cur + 1);
            $pager ['last'] = $paging->base($tp);
        }
        if (!$loop) {
            $pages['pages'] = $pages;
        }

        return $pager;
    }
489613
public static function getPageCount($args = array())
    {
        $instance = Post\Factory::create(get_called_class());

        $posts_per_page = $instance->getPostsPerPage();
        $criteria = array(
            'post_type'=>$instance->getPostType(),
            'posts_per_page'=>-1
        );
        $criteria = array_merge($criteria, $args);

        $query = new \WP_Query($criteria);
        $n = 0;
        while ($query->have_posts()) {
            $n++;
            $query->next_post();
        }

        return ceil($n / $posts_per_page);
    }
1215408
public static function make(array $items, $total, $perPage = 15, $pageName = 'page', $page = null)
    {
        if (is_null($page)) {
            $page = static::resolveCurrentPage($pageName);
        }

        $path = static::resolveCurrentPath($pageName);

        return new static($items, $total, $perPage, $page, compact('path', 'pageName'));
    }
894883
public function paginate(Query $query, array $countFields = [], $total = false)
    {
        $limit = $this->defaultLimit;
        if (in_array((integer)$this->request->getQuery('l', 0), $this->limits)) {
            $limit = (integer)$this->request->getQuery('l');
            $this->activeLimit = $limit;
        }
        if (!$this->activeLimit) {
            $lastLimit = $this->request->getSession()->read(join('.', [
                'LIMIT_' . $this->request->getParam('plugin'),
                $this->controller->getName(),
                $this->action
            ]));
            if ($lastLimit) {
                $limit = $lastLimit;
            }
            $this->activeLimit = $limit;
        }
        $this->request = $this->request->withData('l', $limit);

        if ($total === false) {
            $countQuery = clone $query;
            if (!empty($countFields)) {
                $countQuery->select($countFields);
            }
            $total = $countQuery->count();
        }

        if ($limit !== null && $total !== null) {
            $pages = ceil($total / $limit);
            if ($this->page > $pages) {
                $this->page = $pages;
            }
            if ($this->page < 1) {
                $this->page = 1;
            }
            $offset = ($this->page > 1) ? ($this->page - 1) * $limit : 0;
            $from = ($offset > 0) ? $offset + 1 : 1;
            $to = (($from + $limit - 1) > $total) ? $total : $from + $limit - 1;

            $query->limit($limit)->offset($offset);

            $this->paginationParams = [
                'from' => ($total === 0) ? 0 : $from,
                'page' => $this->page,
                'pages' => ($total === 0) ? 1 : $pages,
                'to' => $to,
                'total' => $total,
                'defaultLimit' => $this->defaultLimit,
                'limits' => array_combine($this->limits, $this->limits),
                'passParams' => []
            ];

            if (!empty($this->_passParams)) {
                $this->paginationParams['passParams'] = $this->_passParams;
            }
        }

        return $query;
    }
1262910
public function url( array $args = [] ) {
		$url = $this->siteurl;
		if ( $args ) {
			$url = add_query_arg( $args, $url );
		}

		return $url;
	}
1310886
public function paginate()
    {
        $this->total = $this->dataSource->getTotal($this->source);

        if (
            ($this->getPagesCount() > 0 && $this->getPage() > $this->getPagesCount()) ||
            $this->getPage() <= 0
        ) {
            $this->handler->wrongPageCallback();
        }

        $this->data = $this->dataSource->applyLimit(
            $this->source,
            $this->getPage(),
            $this->getPageSize()
        );

        return $this->data;
    }
818578
public static function page($total, $perPage)
        {
            $page = (null === request()->getCrudNumPage()) ? 1 : request()->getCrudNumPage();

            // The page will be validated and adjusted if it is less than one or greater
            // than the last page. For example, if the current page is not an integer or
            // less than one, one will be returned. If the current page is greater than
            // the last page, the last page will be returned.
            if (is_numeric($page) && $page > $last = ceil($total / $perPage)) {
                return ($last > 0) ? $last : 1;
            }

            return (static::valid($page)) ? $page : 1;
        }
470483
public function url( array $args = [] ) {
		$url = get_permalink( $this->ID );
		if ( $args ) {
			$url = add_query_arg( $args, $url );
		}

		return $url;

	}
130408
public function totalPages()
    {
        $maxrows      = (($m = $this->getParameter('RowsPerPage')) !== null)?$m:$this->getLocal('MaxRows');
        $totalrecords = (($m = $this->getParameter('TotalRecords')) !== null)?$m:$this->getLocal('TotalRecords');

        if (empty($totalrecords))
            return 0;
        if(empty($maxrows))
            throw new FiltererException('filter \'paging-total-pages\' requires the MaxRows template variable to be set');

        $totalpages = intval(($totalrecords-1)/$maxrows)+1;

        return $totalpages;
    }
1260963
public function totalPage($page_id, $begin_date, $end_date)
    {
        $url = "https://api.weixin.qq.com/shakearound/statistics/page?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['page_id' => $page_id, 'begin_date' => $begin_date, 'end_date' => $end_date]);
    }
204698
public function afterFetch(&$args) {
        $results = &$args[1];
        $scaler = new Garp_Image_Scaler();
        $templateUrl = (string)$scaler->getScaledUrl('%d', '%s');
        $templates = array_keys(Zend_Registry::get('config')->image->template->toArray());
        $iterator = new Garp_Db_Table_Rowset_Iterator(
            $results,
            function ($result) use ($templates, $templateUrl) {
                if (!isset($result->id)) {
                    return;
                }
                $result->setVirtual(
                    'urls',
                    array_reduce(
                        $templates,
                        function ($acc, $cur) use ($templateUrl, $result) {
                            $acc[$cur] = sprintf($templateUrl, $cur, $result->id);
                            return $acc;
                        },
                        array()
                    )
                );
            }
        );
        $iterator->walk();
    }
28878
public function getPager($route, $routePrm, $total, $page, $nbPerPage)
    {
        return new Pager($this, $route, $routePrm, $total, $page, $nbPerPage);
    }
1122517
public function getAvailablePage ($total_count, $current_page = 1, $limit = PagerUtility::DISP_PER_PAGE, $options = []) {
 		$max_page = PagerUtility::GetMaxPage($total_count, $limit);
 		return ($current_page <= $max_page) ? $current_page : $max_page;
 	}
1003523
public function fetchSingle(...$args)
    { 
        $args[] = QB::limit(1);
        $select = $this->select($args);
        return $select->fetch();
    }
951845
public function all($arguments)
    {
        if (isset($arguments[0]['orderBy'])) {
            $exp = [];
            $exp = explode(' ', $arguments[0]['orderBy']);
            $this->orderBy($this->quoteIdentifier($exp[0]), (isset($exp[1])) ? strtoupper($exp[1]) : 'ASC');
        } else {
            $this->orderBy(self::cyrus()->getKeyName());
        }

        // applying limit
        if (isset($arguments[0]['limit'])) {
            $start = '0';
            $offset = $arguments[0]['limit'];

            if (strpos($arguments[0]['limit'], ',') == true) {
                list($start, $offset) = explode(',', $arguments[0]['limit']);
            }
            $this->limit($start, $offset);
        }

        // applying pagination limit
        if (isset($arguments[0]['paginate']) || method_exists(self::cyrus(), 'pageLimit')) {
            $page = $offset = $start = '';
            $offset = self::cyrus()->perPage; //how many items to show per page
            $limit = !isset($arguments[0]['paginate']['limit']) ?
                self::cyrus()->pageLimit() :
                $arguments[0]['paginate']['limit'];

            $page = ($limit !== '') ? $limit : 0;

            if ($page) {
                $start = ($page - 1) * $offset; //first item to display on this page
            } else {
                $start = 0; //if no page var is given, set start to 0
            }

            $this->limit(intval($start), intval($offset));
        }

        // applying group by
        if (isset($arguments[0]['groupBy'])) {
            $this->groupBy(explode(',', $arguments[0]['groupBy']));
        }

        return $this->select('all')->findAll();
    }
177418
public function get_pagination_arg($key)
    {
        if ('page' == $key) {
            return $this->get_pagenum();
        }

        if (isset($this->pagination_args[$key])) {
            return $this->pagination_args[$key];
        }
    }
401693
private static function getPageCount($totalCount, $pageSize)
    {
        $totalCount = $totalCount < 0 ? 0 : (int)$totalCount;
        return ceil($totalCount / $pageSize);
    }