Esempio n. 1
0
 /**
  * 列出所有分类
  *
  * @param int $limit 每页条数
  * @param int $currentPage 当前页码
  * @return \stdClass
  */
 public function listCategories($limit = 10, $currentPage = 1)
 {
     $limit = $limit > 50 ? 50 : $limit;
     $limit = $limit < 10 ? 10 : $limit;
     $items = $this->getDI()->getModelsManager()->createBuilder()->from('Eva\\Wiki\\Models\\Category');
     $paginator = new Paginator(array("builder" => $items, "limit" => 100, "page" => $currentPage));
     $pager = $paginator->getPaginate();
     return $pager;
 }
Esempio n. 2
0
 public function findBlocks($query)
 {
     $builder = $this->getDI()->getModelsManager()->createBuilder();
     $builder->from(__CLASS__);
     $builder->orderBy('createdAt DESC');
     $paginator = new Paginator(array("builder" => $builder, "limit" => isset($query['limit']) ? $query['limit'] : 25, "page" => $query['page']));
     $paginator->setQuery($query);
     $pager = $paginator->getPaginate();
     return $pager;
 }
Esempio n. 3
0
 /**
  * @operationName("用户收藏文章列表")
  * @operationDescription("用户收藏文章列表")
  */
 public function starsAction()
 {
     $me = Login::getCurrentUser();
     $user = User::findFirstById($me['id']);
     $this->view->setVar('item', $user);
     $userId = $user->id;
     $query = array('page' => $this->request->getQuery('page', 'int', 1));
     $star = new Star();
     $starsItemQuery = $star->getStars($userId);
     $paginator = new \Eva\EvaEngine\Paginator(array("builder" => $starsItemQuery, "limit" => 5, "page" => $query['page']));
     $paginator->setQuery($query);
     $pager = $paginator->getPaginate();
     $this->view->setVar('pager', $pager);
 }
Esempio n. 4
0
 /**
  * @operationName("用户评论列表")
  * @operationDescription("用户评论列表")
  */
 public function commentsAction()
 {
     $me = Login::getCurrentUser();
     $user = User::findFirstById($me['id']);
     $this->view->setVar('item', $user);
     $comment = new Comment();
     $comments = $comment->findCommentsByUser($user);
     $paginator = new Paginator(array("builder" => $comments, "limit" => 10, "page" => 1));
     //        $paginator->setQuery($query);
     $pager = $paginator->getPaginate();
     $this->view->setVar('pager', $pager);
 }