热门收藏

对应API：{@link http://open.weibo.com/wiki/2/suggestions/favorites/hot suggestions/favorites/hot}

@param int $count 每页返回结果数，默认20。选填
@param int $page 返回页码，默认1。选填
@return array
765379
function hot_favorites( $page = 1, $count = 20 )
	{
		$params = array();
		$params['count'] = $count;
		$params['page'] = $page;
		return $this->oauth->get( 'suggestions/favorites/hot', $params);
	}
1246746
public function messages(int $count = 200) : array
    {
        $messages = [];

        $messageFields = $this->info($count, true);

        foreach ($messageFields->threadEvents as $message) {
            $messages[] = new Message($this->client, $message->messageEventDetail, $this);
        }

        return $messages;
    }
889274
public function actionList($sort = '', $page = 1, $limit = 20)
    {
        $group_id = \Yii::$app->request->get('group_id');
        $name = \Yii::$app->request->get('name');
        $is_system = \Yii::$app->request->get('is_system');
        $note = \Yii::$app->request->get('note');
        $status = \Yii::$app->request->get('status');
        $limit = intval($limit);
        $order = ExtHelpers::getOrder($sort, [
            'group_id',
            'name',
            'note',
            'status'
        ], [], 'group_id DESC');

        $condition = '1';
        $params = [];
        if ($group_id) {
            $condition .= ' and group_id=:group_id';
            $params[':group_id'] = $group_id;
        }
        if ($name) {
            $condition .= ' and name like :name';
            $params[':name'] = '%' . $name . '%';
        }
        if (is_numeric($is_system)) {
            $condition .= ' and is_system=:is_system';
            $params[':is_system'] = $is_system;
        }
        if ($note) {
            $condition .= ' and note like :note';
            $params[':note'] = '%' . $note . '%';
        }
        if (is_numeric($status)) {
            $condition .= ' and status=:status';
            $params[':status'] = $status;
        }
        $data = DpAdminGroup::getListByCondition($condition, $params, $order, $page, $limit);

        return [
            'total' => $data['pagination']['totalCount'],
            'list' => $data['list'],
        ];
    }
896165
public function getAll(int $page = 1, int $limit = 25)
    {
        return $this->match(new Criteria([], [], ($page - 1) * $limit, $limit));
    }
347420
public function iterNextPage($count = 3)
    {
        if ($this->getPage() == 1 && $this->getPagesCount() >= $count * 2) {
            $count *= 2;
        }
        $pages = [];
        foreach (range(1, $count) as $i) {
            $page = $this->getPage() + $i;
            if ($page <= $this->getPagesCount()) {
                $pages[] = $page;
            }
        }

        return $pages;
    }
943661
private function createCollectionPaginator(Collection $collection, $page, $count)
    {
        return $this->createPaginator(new DoctrineCollectionAdapter($collection), $page, $count);
    }
425685
public function stream_read($count) {
    assert(isset($this->client));
    return $this->client->read($count);
  }
391414
public function listData($list, $page = 1, $size = 10)
    {
        $reData['totalPages'] = (int)$list->lastPage();
        $reData['totalCount'] = (int)$list->total();
        $reData['page'] = (int)$page;
        $reData['limit'] = (int)$size;
        $reData['count'] = (int)$list->count();

        if ($page == 1) {
            $reData['firstPage'] = true; //是否为首页
            $reData['hasPrePage'] = false; //是否有上一页
            $reData['prePage'] = 0; //上一页的页数
            if ($reData['totalPages'] == 1) {
                $reData['hasNextPage'] = false; //是否有下一页
                $reData['nextPage'] = 0;
            } else {
                $reData['hasNextPage'] = true; //是否有下一页
                $reData['nextPage'] = 2; //下一页的页数
            }
        } else {
            $reData['firstPage'] = false; //是否为首页
            if ($reData['totalPages'] == 1) {
                $reData['hasPrePage'] = false; //是否有上一页
                $reData['hasNextPage'] = false; //是否有下一页
                $reData['prePage'] = 1; //上一页的页数
                $reData['nextPage'] = 0; //下一页的页数
            } elseif ($page < $reData['totalPages']) {
                $reData['hasPrePage'] = true; //是否有上一页
                $reData['hasNextPage'] = true; //是否有下一页
                $reData['prePage'] = $page - 1; //上一页的页数
                $reData['nextPage'] = $page + 1; //下一页的页数
            } else {
                $reData['hasPrePage'] = true; //是否有上一页
                $reData['hasNextPage'] = false; //是否有下一页
                $reData['prePage'] = $page - 1; //上一页的页数
                $reData['nextPage'] = 0; //下一页的页数
            }
        }

        if ($page == $reData['totalPages']) {
            $reData['lastPage'] = true; //是否是最末页
        } else {
            $reData['lastPage'] = false; //是否是最末页
        }

        $reData['data'] = $list->toArray()['data'];

        return $reData;
    }
699328
public function actionIndex($page = 1)
    {
        $this->trigger(self::EVENT_BEFORE_RECENT_SHOW);

        $data['page'] = (int) $page;
        $data['route'] = '/' . $this->getRoute();

        $finder = new VideoFinder();
        $data['videos'] = $finder->getNewVideos($page);
        $data['total_items'] = $finder->totalCount();

        $pagination = new Pagination([
            'totalCount' => $data['total_items'],
            'defaultPageSize' => Module::getInstance()->settings->get('items_per_page', 20),
            'pageSize' => Module::getInstance()->settings->get('items_per_page', 20),
            'route' => $data['route'],
            'forcePageParam' => false,
        ]);

        $settings = Yii::$app->settings->getAll();
        $settings['videos'] = Module::getInstance()->settings->getAll();

        $this->trigger(self::EVENT_AFTER_RECENT_SHOW);

        return $this->render('recent', [
            'data' => $data,
            'settings' => $settings,
            'pagination' => $pagination,
        ]);
    }
405810
public function display($page)
    {
        $this->totalPage = ceil($this->count / $this->size);
        if ($page * 1 <= 0) {
            $this->page = 1;
        } else if ($page > $this->totalPage) {
            $this->page = $this->totalPage;
        } else {
            $this->page = $page * 1;
        }

        $data = [];//用于分页显示的数据
        if ($this->totalPage <= $this->displayLength) {
            $data = range(1, $this->totalPage);
        } else {
            $half = intval($this->displayLength / 2);
            $start = max(1, $this->page - $half);
            $end = min($this->page + $half - 1, $this->totalPage);
            //当前分页向后 -halt 小于0，说明不够，往后补足
            if ($this->page - $half <= 0) {
                $end = $end + abs($this->page - $half) + 1;
                if ($this->displayLength % 2 !== 0) $end++; //非偶数，会算少1，加上
            }
            //当前分页向前+ halt 大于分页数，说明不够，往前补足
            if ($this->page + $half > $this->totalPage) {
                $start = $start - ($half - ($this->totalPage - $this->page)) + 1;
                if ($this->displayLength % 2 !== 0) $start--; //非偶数，会算少1，加上
            }

            $data = range($start, $end);
        }
        /**
         * 分页html
         */
        $html = '<ul class="'.$this->ulClass.'">';
        //first
        if($this->showFirstLast){
            $html .= "<li class='{$this->itemClass} {$this->firstClass}'><a href='{$this->url}&p=1'>$this->first</a></li>";
        }

        foreach ($data as $k => $v) {

            //pre
            if ($k == 0 && $this->showPrevNext) {
                $prev = $this->page - 1;
                $prev = $prev <= 0 ? 1 : $prev;
                if ($prev == $this->page) {
                    $html .= "<li class='{$this->itemClass} {$this->preClass}'><a href='javascript:void(0);'>$this->prev</a></li>";
                } else {
                    $html .= "<li class='{$this->itemClass} {$this->preClass}'><a href='{$this->url}&p=$prev'>$this->prev</a></li>";
                }
            }
            $html .= "<li class='{$this->itemClass} ".($v==$this->page?$this->activeClass:'')."'><a href='{$this->url}&p=$v'>$v</a></li>";

            if ($k == count($data) - 1 && $this->showPrevNext) {
                if($this->totalPage > $this->displayLength && ($this->totalPage-$this->page > $this->displayLength)){
                    $html .= "<li class='{$this->itemClass} middle'>...</li>";
                    $html .= "<li class='{$this->itemClass}'><a href='{$this->url}&p=$this->totalPage'>$this->totalPage</a></li>";
                }
                //next
                $next = $this->page + 1;
                $next = $this->page >= $this->totalPage ? $this->totalPage : $next;
                if ($next == $this->page) {
                    $html .= "<li class='{$this->itemClass} {$this->nextClass}'><a href='javascript:void(0)'>$this->next</a></li>";
                } else {
                    $html .= "<li class='{$this->itemClass} {$this->nextClass}'><a href='{$this->url}&p=$next'>$this->next</a></li>";
                }
            }
        }
        //last
        if($this->showFirstLast){
            $html .= "<li class='{$this->itemClass} {$this->lastClass}'><a href='{$this->url}&p=$this->totalPage'>$this->last</a></li>";
        }
        $html .= '</ul>';

        return $html;

    }
112773
public function assertPager($count)
    {
        \PHPUnit_Framework_Assert::assertCount(
            $count + ($offset = 2),
            $pages = $this->findPager()->findAll('xpath', '/li'),
            sprintf('The number of pages "%d" does not match "%d".', count($pages) - $offset, $count)
        );
    }
170324
public function getMaterials($type, $all = true, $page = 1, $count = 20) {
		$offset = ($page - 1) * $count;
		$data = $this->getData('/cgi-bin/material/batchget_material', [
			'access_token' => $this->getAccessToken(),
		], Json::encode([
			'type' => $type,
			'offset' => $offset,
			'count' => $count,
		]));

		if($this->errcode == 0) {
			if($all && $offset + $data['item_count'] < $data['total_count']) {
				if($_data = $this->getMaterials($type, $all, $page + 1, $count)) {
					$data['item_count'] += $_data['item_count'];
					$data['item'] = array_merge($data['item'], $_data['item']);
				}
			}

			return $data;
		}

		return [];
	}
847998
function get_tags( $uid = NULL, $page = 1, $count = 20 )
	{
		$params = array();
		if ( $uid ) {
			$params['uid'] = $uid;
		} else {
			$user_info = $this->get_uid();
			$params['uid'] = $user_info['uid'];
		}
		$this->id_format( $params['uid'] );
		$params['page'] = $page;
		$params['count'] = $count;
		return $this->oauth->get( 'tags', $params );
	}
208686
protected function displayPage(SwatNoteBookPage $page, $count = 0)
    {
        echo '<tr class="swat-radio-note-book-option-row">';
        echo '<td>';

        $radio = new SwatHtmlTag('input');
        $radio->type = 'radio';
        $radio->name = $this->id;
        $radio->id = $this->id . '_' . $page->id;
        $radio->value = $this->id . '_' . $page->id;

        if ($page->id == $this->selected_page) {
            $radio->checked = 'checked';
        }

        echo '<span class="swat-radio-wrapper">';
        $radio->display();
        echo '<span class="swat-radio-shim"></span>';
        echo '</span>';

        echo '</td>';
        echo '<td>';

        $label = new SwatHtmlTag('label');
        $label->for = $this->id . '_' . $page->id;
        $label->setContent($page->title, $page->title_content_type);
        $label->display();

        echo '</td>';
        echo '</tr>';

        echo '<tr class="swat-radio-note-book-page-row">';
        echo '<td></td>';

        $td = new SwatHtmlTag('td');
        $td->class = 'swat-radio-note-book-page';

        if ($page->id == $this->selected_page) {
            $td->class .= ' selected';
        }

        $td->open();
        echo '<div class="swat-radio-note-book-page-container">';
        $page->display();
        echo '</div>';
        $td->close();

        echo '</tr>';
    }
6662
public static function multiPage(int $page ,array $C , int $pagesize = 10 ):array
    {
        if(!self::is_indexArray($C)){
            throw new \Exception('Tools multiPage throw : $C must is indexed array!');
        }
        //区间数组
        $scopeC = array();
        //区间指针记录
        $scopePointInteger = 0;
        //记录在数轴上个区间位置
        foreach($C as $k => $v){
            $scopeC[$k] = array($scopePointInteger ,$scopePointInteger + $v);
            $scopePointInteger += intval($v);
        }

//        if($scopePointInteger <= 0 ){
//            throw new \Exception('Tools multiPage throw : sum value of array $C must be greater than 0!');
//        }

        $count = $scopePointInteger;
        //print_r($scopeC);
        //最大页数
        $maxPage = ceil($count / $pagesize);
        //实际分页数据区间
        $OriginScopeL = ($page - 1) * $pagesize;
        $OriginScopeR = $OriginScopeL + $pagesize;

        //初始化limit 数组 , 使其下标同 $C一致
        $ScopeLimit = array();
        for($i=0;$i < count($C);$i++){
            $ScopeLimit[$i] = false;
        }
        foreach ($scopeC as $key => $value) {
            if($value[1] <= $OriginScopeL){
                //不取 0 ~ 起始点的数据
                //$ScopeLimit[$key] = false;
            }else{
                //起始点以后的数据
                //获取起始点位置 , 起始点大于阶段的起始点的时候需要借位 ， 反之等于当前区间的第一位 针对limit 等于 0 , ?
                $start = $value[0] > $OriginScopeL ? 0 : $OriginScopeL - $value[0];
                //该区间的结束点 针对Limit
                $maxEnd = $C[$key] - $start;
                //获取结束点 位置 , 看结束点是否大于区间结束点
                if($OriginScopeR > $value[1]){
                    $end = $maxEnd;
                    $ScopeLimit[$key] = ' limit '.$start.','.$end;
                }else{
                    //反之 等于本区间结束点
                    //取差值
                    $Borrow = $value[1] - $OriginScopeR;
                    //取剩余数
                    $end = $maxEnd - $Borrow;
                    $ScopeLimit[$key] = ' limit '.$start.','.$end;
                    //echo $ScopeLimit[$key];
                    break;
                }
            }
        }

        return [
            'page' => $page,
            'pagesize' => $pagesize,
            'count' => $count,
            'maxpage' => $maxPage,
            'limit' => $ScopeLimit
        ];

    }
1297640
public function getCustomers($page = '')
    {
        $customerObjects = [];
        $customers = $this->getCustomerResource()->getAll($page);

        if ($customers instanceof \Exception) {
            throw $customers;
        }

        foreach ($customers as $customer) {
            $customerObject = new Customer($this->getCustomerResource());
            $customerObjects[] = $customerObject->_setAttributes($customer);
        }

        return $customerObjects;
    }
133160
public function lists($offset = 0, $count = 10, $statusList = array())
    {
        $params = array(
            'offset' => $offset,
            'count' => $count,
            'status_list' => $statusList,
        );

        $result = $this->http->jsonPost(self::API_LIST, $params);

        return $result['card_id_list'];
    }