Example #1
0
 /**
  *  跳转
  * @return \System\Library\Link
  */
 public final function link()
 {
     $link = new \System\Library\Link();
     $link->init();
     $link->view = $this->getView();
     return $link;
 }
Example #2
0
 /**
  * 分页显示输出
  * @access public
  */
 public function show()
 {
     if (0 == $this->totalRows) {
         return '';
     }
     $p = $this->varPage;
     if ($this->parameter && is_string($this->parameter)) {
         parse_str($this->parameter, $parameter);
     } elseif (is_array($this->parameter)) {
         $parameter = $this->parameter;
     } elseif (empty($this->parameter)) {
         $var = !empty($_POST) ? $_POST : $_GET;
         if (empty($var)) {
             $parameter = array();
         } else {
             $parameter = $var;
         }
     }
     $parameter[$p] = '__PAGE__';
     $link = new \System\Library\Link();
     $url = $link->getOrdinaryUrl($parameter);
     $nowCoolPage = ceil($this->nowPage / $this->rollPage);
     //上下翻页字符串
     $upRow = $this->nowPage - 1;
     $downRow = $this->nowPage + 1;
     if ($upRow > 0) {
         $upPage = "<a href='" . str_replace('__PAGE__', $upRow, $url) . "'>" . $this->config['prev'] . "</a>";
     } else {
         $upPage = '';
     }
     if ($downRow <= $this->totalPages) {
         $downPage = "<a href='" . str_replace('__PAGE__', $downRow, $url) . "'>" . $this->config['next'] . "</a>";
     } else {
         $downPage = '';
     }
     if ($nowCoolPage == 1) {
         $theFirst = '';
         $prePage = '';
     } else {
         $preRow = $this->nowPage - $this->rollPage;
         $prePage = "<a href='" . str_replace('__PAGE__', $preRow, $url) . "' >上" . $this->rollPage . "页</a>";
         $theFirst = "<a href='" . str_replace('__PAGE__', 1, $url) . "' >" . $this->config['first'] . "</a>";
     }
     if ($nowCoolPage == $this->coolPages) {
         $nextPage = '';
         $theEnd = '';
     } else {
         $nextRow = $this->nowPage + $this->rollPage;
         $theEndRow = $this->totalPages;
         $nextPage = "<a href='" . str_replace('__PAGE__', $nextRow, $url) . "' >下" . $this->rollPage . "页</a>";
         $theEnd = "<a href='" . str_replace('__PAGE__', $theEndRow, $url) . "' >" . $this->config['last'] . "</a>";
     }
     // 1 2 3 4 5
     $linkPage = "";
     for ($i = 1; $i <= $this->rollPage; $i++) {
         $page = ($nowCoolPage - 1) * $this->rollPage + $i;
         if ($page != $this->nowPage) {
             if ($page <= $this->totalPages) {
                 $calss = $i == 1 ? "active" : "";
                 $linkPage .= "<li class='{$calss}'><a href='" . str_replace('__PAGE__', $page, $url) . "'>" . $page . "</a></li>";
             } else {
                 break;
             }
         } else {
             if ($this->totalPages != 1) {
                 $linkPage .= "<span class='current'>" . $page . "</span>";
             }
         }
     }
     //暂时固定
     $this->tmp = file_get_contents(WEB_TEMP_PATH . "/default/home" . "/blog_page.html", true);
     if (!$upPage && !$downPage && $linkPage) {
         $this->isShow = false;
     } else {
         $this->isShow = true;
     }
     $pageStr = str_replace(array('%header%', '%nowPage%', '%totalRow%', '%totalPage%', '%upPage%', '%downPage%', '%first%', '%prePage%', '%linkPage%', '%nextPage%', '%end%'), array($this->config['header'], $this->nowPage, $this->totalRows, $this->totalPages, $upPage, $downPage, $theFirst, $prePage, $linkPage, $nextPage, $theEnd), $this->tmp);
     //echo $pageStr;exit;
     return $pageStr;
 }