public function PageNavigation(array $url, $count_all, $per_page, $cur_page = 1, $i = 0, array $options = array()) { $default_options = array("link_script" => ''); $options = array_merge($default_options, $options); if (!$i) { $i = $per_page; } if ((int) $cur_page <= 0) { $cur_page = 1; } $current_show_sub = self::$show_sub; $this_2 = $this->_clone(); $this_2->tpl->load_template('navigation.tpl'); $no_prev = false; $no_next = false; $cstart = ((int) $cur_page - 1) * $per_page; $i += $cstart; if (isset($cstart) and $cstart != "" and $cstart > 0) { $prev = $cstart / $per_page; if ($prev > 1) { $page_url = $this_2->GetUrl($url, array(), array("page" => $prev), array(), $options); } else { $page_url = $this_2->GetUrl($url, array(), array(), array(), $options); } $this_2->Set("<a {$options['link_script']} href=\"" . $page_url . "\">", "[prev-link]"); $this_2->Set("</a>", "[/prev-link]"); } else { $no_prev = TRUE; } if ($per_page) { if ($count_all > $per_page) { $enpages_count = @ceil($count_all / $per_page); $pages = ""; $cstart = $cstart / $per_page + 1; if ($enpages_count <= 10) { for ($j = 1; $j <= $enpages_count; $j++) { if ($j > 1) { $page_url = $this_2->GetUrl($url, array(), array("page" => $j), array(), $options); } else { $page_url = $this_2->GetUrl($url, array(), array(), array(), $options); } if ($j != $cstart) { $pages .= "<a {$options['link_script']} href=\"" . $page_url . "\">{$j}</a> "; } else { $pages .= "<span>{$j}</span> "; } } } else { $start = 1; $end = 10; $nav_prefix = "... "; if ($cstart > 0) { if ($cstart > 5) { $start = $cstart - 4; $end = $start + 8; if ($end >= $enpages_count) { $start = $enpages_count - 9; $end = $enpages_count - 1; $nav_prefix = ""; } else { $nav_prefix = "... "; } } } if ($start >= 2) { $pages .= "<a {$options['link_script']} href=\"" . $this_2->GetUrl($url, array(), array(), array(), $options) . "\">1</a> ... "; } for ($j = $start; $j <= $end; $j++) { if ($j > 1) { $page_url = $this_2->GetUrl($url, array(), array("page" => $j), array(), $options); } else { $page_url = $this_2->GetUrl($url, array(), array(), array(), $options); } if ($j != $cstart) { $pages .= "<a {$options['link_script']} href=\"" . $page_url . "\">{$j}</a> "; } else { $pages .= "<span>{$j}</span> "; } } if ($cstart != $enpages_count) { $pages .= $nav_prefix . "<a {$options['link_script']} href=\"" . $this_2->GetUrl($url, array(), array("page" => $enpages_count), array(), $options) . "\">{$enpages_count}</a>"; } else { $pages .= "<span>{$enpages_count}</span> "; } } } $this_2->Set($pages, '{pages}'); } if ($per_page and $per_page < $count_all and $i < $count_all) { $next_page = @floor($i / $per_page) + 1; $this_2->Set("<a {$options['link_script']} href=\"" . $this_2->GetUrl($url, array(), array("page" => $next_page), array(), $options) . "\">", "[next-link]"); $this_2->Set("</a>", "[/next-link]"); } else { $no_next = TRUE; } if (!$no_prev or !$no_next) { $this_2->Compile('PageNavigation'); } $this->tpl->result['PageNavigation'] = $this_2->tpl->result['PageNavigation']; unset($this_2); self::$show_sub = $current_show_sub; return $this; }