/**
  * 首页方法
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $page = $request->getParameter('page', 'intval');
     $pagesize = 10;
     if ($page <= 0) {
         $page = 1;
     }
     $total = 1000;
     //初始化分页类
     $pageHandler = new Page($total, $pagesize, $page);
     //获取分页数据
     $pageData = $pageHandler->getPageData(DEFAULT_PAGE_STYLE);
     //组合分页HTML代码
     if ($pageData) {
         $pagemenu = '<ul class="pagination">';
         $pagemenu .= '<li><a href="' . $pageData['prev'] . '" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>';
         foreach ($pageData['list'] as $key => $value) {
             if ($key == $page) {
                 $pagemenu .= '<li class="active"><a href="#fakelink">' . $key . '</a></li> ';
             } else {
                 $pagemenu .= '<li><a href="' . $value . '">' . $key . '</a></li> ';
             }
         }
         $pagemenu .= '<li><a href="' . $pageData['next'] . '" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>';
         $pagemenu .= '</ul>';
     }
     $this->assign('pagemenu', $pagemenu);
     //设置视图
     $this->setView('article_page');
 }
 /**
  * 对数据进行分页
  * @param int 总记录数 $total
  */
 protected function getPageData($total)
 {
     $pageHandler = new Page($total, $this->getPagesize(), $this->getPage(), 3);
     //获取分页数据
     $pageData = $pageHandler->getPageData(DEFAULT_PAGE_STYLE);
     if (!empty($pageData)) {
         $pagemenu = '<ul class="page">';
         if ($pageData['prev'] != '#') {
             $pagemenu .= '<li class="prev"><a href="' . $pageData['prev'] . '"><span class="icon icon_page_prev"></span></a></li>';
         }
         foreach ($pageData['list'] as $key => $value) {
             if ($value == '#') {
                 $pagemenu .= '<li class="num current">' . $key . '</li>';
             } else {
                 $pagemenu .= '<li class="num"><a href="' . $value . '">' . $key . '</a></li>';
             }
         }
         if ($pageData['next'] != '#') {
             $pagemenu .= '<li class="next"><a href="' . $pageData['next'] . '"><span class="icon icon_page_next"></span></a></li>';
         }
         $pagemenu .= '</ul>';
         $this->assign('pagemenu', $pagemenu);
     }
 }
Beispiel #3
0
 /**
  * 首页方法
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $page = $request->getParameter('page', 'intval');
     $pagesize = 10;
     if ($page <= 0) {
         $page = 1;
     }
     $model = Loader::model('article');
     $conditions = array("id" => ">300");
     $total = $model->count($conditions);
     $items = $model->getItems($conditions, "id, url, title", null, $page, $pagesize);
     //初始化分页类
     $pageHandler = new Page($total, $pagesize, $page);
     //获取分页数据
     $pageData = $pageHandler->getPageData(DEFAULT_PAGE_STYLE);
     //组合分页HTML代码
     if ($pageData) {
         $pagemenu = '<ul class="pagination">';
         $pagemenu .= '<li><a href="' . $pageData['prev'] . '" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>';
         foreach ($pageData['list'] as $key => $value) {
             if ($key == $page) {
                 $pagemenu .= '<li class="active"><a href="#fakelink">' . $key . '</a></li> ';
             } else {
                 $pagemenu .= '<li><a href="' . $value . '">' . $key . '</a></li> ';
             }
         }
         $pagemenu .= '<li><a href="' . $pageData['next'] . '" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>';
         $pagemenu .= '</ul>';
         $pagemenu .= '<div class="page-input"><input type="text" class="form-control input-sm" value="' . $this->page . '"> ';
         $pagemenu .= '<a href="javascript:void(0);" class="btn btn-primary btn-sm" url="' . $pageData['url'] . '" id="page-goto">确定</a></div> ';
     }
     $this->assign('pagemenu', $pagemenu);
     $this->assign('items', $items);
     //设置视图
     $this->setView('article_page');
 }
 /**
  * 首页列表
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $this->page = $request->getParameter('page', 'intval');
     if ($this->page <= 0) {
         $this->page = 1;
     }
     $service = Beans::get($this->getServiceBean());
     $total = $service->count($this->getConditions());
     $items = $service->getItems($this->getConditions(), $this->getFields(), $this->getOrder(), $this->getPage(), $this->getPagesize(), $this->getGroup(), $this->getHaving());
     //初始化分页类
     $pageHandler = new Page($total, $this->getPagesize(), $this->getPage(), 4);
     //获取分页数据
     $pageData = $pageHandler->getPageData(DEFAULT_PAGE_STYLE);
     //组合分页HTML代码
     if ($pageData) {
         $pagemenu = '<ul>';
         $pagemenu .= '<li class="previous"><a class="fui-arrow-left" href="' . $pageData['prev'] . '"></a></li> ';
         foreach ($pageData['list'] as $key => $value) {
             if ($key == $this->page) {
                 $pagemenu .= '<li class="active"><a href="#fakelink">' . $key . '</a></li> ';
             } else {
                 $pagemenu .= '<li><a href="' . $value . '">' . $key . '</a></li> ';
             }
         }
         $pagemenu .= '<li class="next"><a class="fui-arrow-right" href="' . $pageData['next'] . '"></a></li> ';
         $pagemenu .= '</ul>';
         $pagemenu .= '<div class="page-input"><input type="text" class="form-control input-sm" value="' . $this->page . '"> ';
         $pagemenu .= '<a href="javascript:void(0);" class="btn btn-primary btn-sm" url="' . $pageData['url'] . '" id="page-goto">确定</a></div> ';
     }
     $this->assign('pagemenu', $pagemenu);
     $this->assign('items', $items);
 }
 /**
  * 首页列表
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $this->page = $request->getParameter('page', 'intval');
     if ($this->page <= 0) {
         $this->page = 1;
     }
     $service = Beans::get($this->getServiceBean());
     $total = $service->count($this->getConditions());
     $items = $service->getItems($this->getConditions(), $this->getFields(), $this->getOrder(), $this->getPage(), $this->getPagesize(), $this->getGroup(), $this->getHaving());
     //初始化分页类
     $pageHandler = new Page($total, $this->getPagesize(), $this->getPage(), 4);
     //获取分页数据
     $pageData = $pageHandler->getPageData(DEFAULT_PAGE_STYLE);
     //组合分页HTML代码
     if ($pageData) {
         $pagemenu = '<ul class="pagination blog-pagination">';
         $pagemenu .= '<li><a href="' . $pageData['prev'] . '">PREV</a></li> ';
         foreach ($pageData['list'] as $key => $value) {
             if ($key == $this->page) {
                 $pagemenu .= '<li class="active"><a href="#fakelink">' . $key . '</a></li> ';
             } else {
                 $pagemenu .= '<li><a href="' . $value . '">' . $key . '</a></li> ';
             }
         }
         $pagemenu .= '<li><a href="' . $pageData['next'] . '">NEXT</a></li> ';
         $pagemenu .= '</ul>';
     }
     $this->assign('pagemenu', $pagemenu);
     $this->assign('items', $items);
 }