123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <?php
- require_once 'Pager/Common.php';
- class Pager_Jumping extends Pager_Common
- {
-
-
- function Pager_Jumping($options = array())
- {
- $err = $this->setOptions($options);
- if ($err !== PAGER_OK) {
- return $this->raiseError($this->errorMessage($err), $err);
- }
- $this->build();
- }
-
-
-
- function getPageIdByOffset($index)
- {
- if (!isset($this->_pageData)) {
- $this->_generatePageData();
- }
- if (($index % $this->_perPage) > 0) {
- $pageID = ceil((float)$index / (float)$this->_perPage);
- } else {
- $pageID = $index / $this->_perPage;
- }
- return $pageID;
- }
-
-
-
- function getPageRangeByPageId($pageid = null)
- {
- $pageid = isset($pageid) ? (int)$pageid : $this->_currentPage;
- if (isset($this->_pageData[$pageid]) || is_null($this->_itemData)) {
-
-
- $start = ((($pageid + (($this->_delta - ($pageid % $this->_delta))) % $this->_delta) / $this->_delta) - 1) * $this->_delta +1;
- return array(
- max($start, 1),
- min($start+$this->_delta-1, $this->_totalPages)
- );
- } else {
- return array(0, 0);
- }
- }
-
-
-
- function getLinks($pageID=null, $next_html='')
- {
-
- if (!empty($next_html)) {
- $back_html = $pageID;
- $pageID = null;
- } else {
- $back_html = '';
- }
- if (!is_null($pageID)) {
- $this->links = '';
- if ($this->_totalPages > $this->_delta) {
- $this->links .= $this->_printFirstPage();
- }
- $_sav = $this->_currentPage;
- $this->_currentPage = $pageID;
- $this->links .= $this->_getBackLink('', $back_html);
- $this->links .= $this->_getPageLinks();
- $this->links .= $this->_getNextLink('', $next_html);
- if ($this->_totalPages > $this->_delta) {
- $this->links .= $this->_printLastPage();
- }
- }
- $back = str_replace(' ', '', $this->_getBackLink());
- $next = str_replace(' ', '', $this->_getNextLink());
- $pages = $this->_getPageLinks();
- $first = $this->_printFirstPage();
- $last = $this->_printLastPage();
- $all = $this->links;
- $linkTags = $this->linkTags;
- $linkTagsRaw = $this->linkTagsRaw;
- if (!is_null($pageID)) {
- $this->_currentPage = $_sav;
- }
- return array(
- $back,
- $pages,
- trim($next),
- $first,
- $last,
- $all,
- $linkTags,
- 'back' => $back,
- 'pages' => $pages,
- 'next' => $next,
- 'first' => $first,
- 'last' => $last,
- 'all' => $all,
- 'linktags' => $linkTags,
- 'linkTagsRaw' => $linkTagsRaw,
- );
- }
-
-
-
- function _getPageLinks($url = '')
- {
-
-
- if (!empty($url)) {
- $this->_path = $url;
- }
-
- if ($this->_clearIfVoid && ($this->_totalPages < 2)) {
- return '';
- }
- $links = '';
- $limits = $this->getPageRangeByPageId($this->_currentPage);
- for ($i=$limits[0]; $i<=min($limits[1], $this->_totalPages); $i++) {
- if ($i != $this->_currentPage) {
- $this->range[$i] = false;
- $this->_linkData[$this->_urlVar] = $i;
- $links .= $this->_renderLink(str_replace('%d', $i, $this->_altPage), $i);
- } else {
- $this->range[$i] = true;
- $links .= $this->_curPageSpanPre . $i . $this->_curPageSpanPost;
- }
- $links .= $this->_spacesBefore
- . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : '');
- }
- return $links;
- }
-
- }
- ?>
|