示例#1
0
文件: Pagination.php 项目: noikiy/PD
 public function render()
 {
     $results = parent::render();
     if ($this->num_pages < 2) {
         return '';
     }
     $output = array();
     if ($this->page > 1) {
         $output[] = '<a href="' . str_replace('{page}', $this->page - 1, $this->url) . '">' . $this->text_prev . '</a>';
     } else {
         $output[] = $this->text_prev;
     }
     if ($this->page > 3) {
         $output[] = '..';
     }
     foreach ($results as $result) {
         if ($result == $this->page) {
             $output[] = $result;
         } else {
             $output[] = '<a href="' . str_replace('{page}', $result, $this->url) . '">' . $result . '</a>';
         }
     }
     if ($this->num_pages > 5 && $this->page > 3 && $this->page < $this->num_pages - 2) {
         $output[] = '..';
     }
     $output[] = '<input type="text" />';
     $output[] = '{of}';
     $output[] = $this->num_pages;
     if ($this->page < $this->num_pages) {
         $output[] = '<a href="' . str_replace('{page}', $this->page + 1, $this->url) . '">' . $this->text_next . '</a>';
     } else {
         $output[] = $this->text_next;
     }
     return implode('&nbsp;', $output);
 }
示例#2
0
文件: Pagination.php 项目: noikiy/PD
 public function render()
 {
     $results = parent::render();
     if ($this->num_pages < 2) {
         return;
     }
     $output = '';
     if ($this->page > 1) {
         $output .= ' <a href="' . str_replace('{page}', 1, $this->url) . '">' . $this->text_first . '</a> <a href="' . str_replace('{page}', $this->page - 1, $this->url) . '">' . $this->text_prev . '</a> ';
     }
     foreach ($results as $result) {
         if ($result === null) {
             $output .= ' <a href="javascript:void(0);"> ... </a> ';
         } elseif ($result == $this->page) {
             $output .= ' <a class="number current" href="' . str_replace('{page}', $result, $this->url) . '">' . $result . '</a> ';
         } else {
             $output .= ' <a class="number" href="' . str_replace('{page}', $result, $this->url) . '">' . $result . '</a> ';
         }
     }
     if ($this->page < $this->num_pages) {
         $output .= ' <a href="' . str_replace('{page}', $this->page + 1, $this->url) . '">' . $this->text_next . '</a> <a href="' . str_replace('{page}', $this->num_pages, $this->url) . '">' . $this->text_last . '</a> ';
     }
     return $output;
 }