Пример #1
0
 /**
  * 登录日志列表
  * 
  * @param type $page
  * @param type $page_size
  * @param array $params
  * @return type 
  */
 public function getLoginLogByPage($page, $page_size, array $params)
 {
     $admin_login_model = new AdminLoginModel();
     $total = $admin_login_model->getLoginLogCount($params);
     $page = Star_Page::setPage($page, $page_size, $total);
     $page_info = array('total' => $total, 'page' => $page, 'page_size' => $page_size);
     $page_data = Star_Page::show($page_info);
     $login_logs = $admin_login_model->getLoginLogByPage($page, $page_size, $params);
     return array('page' => $page_data, 'total' => $total, 'login_logs' => $login_logs);
 }
Пример #2
0
 /**
  * 显示分页
  * @param array $page_info
  * @return void|Ambigous <string, mixed>
  */
 public static function show(array $page_info)
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     self::$instance->init($page_info);
     $page = self::$instance->page;
     $last_page = self::$instance->last_page;
     //总页数为1不显示分页
     if ($last_page <= 1) {
         return;
     }
     $average = self::$instance->average();
     $show_page_start = $page - $average;
     $show_page_end = $page + $average;
     if ($show_page_start > 0 || $show_page_end <= self::$instance->last_page) {
         if ($show_page_start < 0 && $show_page_end < self::$instance->last_page) {
             $show_page_end = 1 - $show_page_start + $show_page_end;
             $show_page_start = 1;
         }
         if ($show_page_end > self::$instance->last_page && $show_page_start > 0) {
             $show_page_start = $show_page_start - ($show_page_end - self::$instance->last_page);
             $show_page_end = self::$instance->last_page;
         }
     }
     $show_page_start = $show_page_start < 1 ? 1 : $show_page_start;
     $show_page_end = $show_page_end > self::$instance->last_page ? self::$instance->last_page : $show_page_end;
     $result = self::$instance->getFirstPage();
     $result .= self::$instance->getPrePage();
     for ($i = $show_page_start; $i <= $show_page_end; $i++) {
         $result .= self::produceLink($i, $i);
     }
     $result .= self::$instance->getNextPage();
     $result .= self::$instance->getLastPage();
     return $result;
 }