/** * Prints a full page navigation including previous and next page links with a list of all pages in between. * * @param string $prevtext Insert here the linktext like 'previous page' * @param string $nexttext Insert here the linktext like 'next page' * @param bool $oneImagePage set to true if there is only one image page as, for instance, in flash themes * @param string $nextprev set to true to get the 'next' and 'prev' links printed * @param string $class Insert here the CSS-class name you want to style the link with (default is "pagelist") * @param string $id Insert here the CSS-ID name if you want to style the link with this * @param bool $firstlast Add links to the first and last pages of you gallery * @param int $navlen Number of navigation links to show (0 for all pages). Works best if the number is odd. */ function printPageListWithNav($prevtext, $nexttext, $oneImagePage = false, $nextprev = true, $class = 'pagelist', $id = NULL, $firstlast = true, $navlen = 9) { $total = getTotalPages($oneImagePage); $current = getCurrentPage(); if ($total < 2) { $class .= ' disabled_nav'; } if ($navlen == 0) { $navlen = $total; } $extralinks = 2; if ($firstlast) { $extralinks = $extralinks + 2; } $len = floor(($navlen - $extralinks) / 2); $j = max(round($extralinks / 2), min($current - $len - (2 - round($extralinks / 2)), $total - $navlen + $extralinks - 1)); $ilim = min($total, max($navlen - round($extralinks / 2), $current + floor($len))); $k1 = round(($j - 2) / 2) + 1; $k2 = $total - round(($total - $ilim) / 2); echo "<div" . ($id ? " id=\"{$id}\"" : "") . " class=\"{$class}\">\n"; echo "<ul class=\"{$class}\">\n"; if ($nextprev) { echo "<li class=\"prev\">"; printPrevPageLink($prevtext, gettext("Previous Page")); echo "</li>\n"; } if ($firstlast) { echo '<li class="' . ($current == 1 ? 'current' : 'first') . '">'; if ($current == 1) { echo '1'; } else { printLink(getPageURL(1, $total), 1, gettext("Page 1")); } echo "</li>\n"; if ($j > 2) { echo "<li>"; printLink(getPageURL($k1, $total), $j - 1 > 2 ? '...' : $k1, sprintf(ngettext('Page %u', 'Page %u', $k1), $k1)); echo "</li>\n"; } } for ($i = $j; $i <= $ilim; $i++) { echo "<li" . ($i == $current ? " class=\"current\"" : "") . ">"; if ($i == $current) { $title = sprintf(ngettext('Page %1$u (Current Page)', 'Page %1$u (Current Page)', $i), $i); echo $i; } else { $title = sprintf(ngettext('Page %1$u', 'Page %1$u', $i), $i); printLink(getPageURL($i, $total), $i, $title); } echo "</li>\n"; } if ($i < $total) { echo "<li>"; printLink(getPageURL($k2, $total), $total - $i > 1 ? '...' : $k2, sprintf(ngettext('Page %u', 'Page %u', $k2), $k2)); echo "</li>\n"; } if ($firstlast && $i <= $total) { echo "\n <li class=\"last\">"; if ($current == $total) { echo $total; } else { printLink(getPageURL($total, $total), $total, sprintf(ngettext('Page {%u}', 'Page {%u}', $total), $total)); } echo "</li>"; } if ($nextprev) { echo "<li class=\"next\">"; printNextPageLink($nexttext, gettext("Next Page")); echo "</li>\n"; } echo "</ul>\n"; echo "</div>\n"; }
/** * Prints a full page navigation including previous and next page links with a list of all pages in between. * * @param string $prevtext Insert here the linktext like 'previous page' * @param string $nexttext Insert here the linktext like 'next page' * @param bool $oneImagePage set to true if there is only one image page as, for instance, in flash themes * @param string $nextprev set to true to get the 'next' and 'prev' links printed * @param string $class Insert here the CSS-class name you want to style the link with (default is "pagelist") * @param string $id Insert here the CSS-ID name if you want to style the link with this */ function printPageListWithNav($prevtext, $nexttext, $oneImagePage = false, $nextprev = true, $class = 'pagelist', $id = NULL) { $total = getTotalPages($oneImagePage); if ($total < 2) { $class .= ' disabled_nav'; } echo "<div" . ($id ? " id=\"{$id}\"" : "") . " class=\"{$class}\">"; $current = getCurrentPage(); echo "\n<ul class=\"{$class}\">"; if ($nextprev) { echo "\n <li class=\"prev\">"; printPrevPageLink($prevtext, gettext("Previous Page")); echo "</li>"; } $j = max(1, min($current - 3, $total - 6)); if ($j != 1) { echo "\n <li>"; printLink(getPageURL($k = max($j - 4, 1), $total), '...', "Page {$k}"); echo '</li>'; } for ($i = $j; $i <= min($total, $j + 6); $i++) { echo "\n <li" . ($i == $current ? " class=\"current\"" : "") . ">"; printLink(getPageURL($i, $total), $i, "Page {$i}" . ($i == $current ? ' ' . gettext("(Current Page)") : "")); echo "</li>"; } if ($i <= $total) { echo "\n <li>"; printLink(getPageURL($k = min($j + 10, $total), $total), '...', "Page {$k}"); echo '</li>'; } if ($nextprev) { echo "\n <li class=\"next\">"; printNextPageLink($nexttext, gettext("Next Page")); echo "</li>"; } echo "\n</ul>"; echo "\n</div>\n"; }