Ejemplo n.º 1
0
 static function getPrevNewsPageURL()
 {
     $page = getCurrentNewsPage();
     if ($page != 1) {
         if ($page - 1 == 1) {
             return rewrite_path(urlencode(ZENPAGE_NEWS), "/index.php?p=" . ZENPAGE_NEWS);
         } else {
             return getNewsBaseURL() . getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath() . ($page - 1);
         }
     } else {
         return false;
     }
 }
/**
 * Prints the full news page navigation with prev/next links and the page number list
 *
 * @param string $next The next page link text
 * @param string $prev The prev page link text
 * @param bool $nextprev If the prev/next links should be printed
 * @param string $class The CSS class for the disabled link
 * @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.
 *
 * @return string
 */
function printNewsPageListWithNav($next, $prev, $nextprev = true, $class = 'pagelist', $firstlast = true, $navlen = 9)
{
    global $_zp_zenpage;
    $total = ceil($_zp_zenpage->getTotalArticles() / ZP_ARTICLES_PER_PAGE);
    $current = $_zp_zenpage->getCurrentNewsPage();
    if ($total > 1) {
        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 "<ul class=\"{$class}\">\n";
        if ($nextprev) {
            echo "<li class=\"prev\">";
            printPrevNewsPageLink($prev);
            echo "</li>\n";
        }
        if ($firstlast) {
            echo '<li class="' . ($current == 1 ? 'current' : 'first') . '">';
            if ($current == 1) {
                echo "1";
            } else {
                if ($_zp_zenpage->news_on_index) {
                    echo "<a href='" . html_encode(getNewsIndexURL()) . "' title='" . gettext("Page") . " 1'>1</a>";
                } else {
                    echo "<a href='" . getNewsBaseURL() . html_encode(getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath()) . "1' title='" . gettext("Page") . " 1'>1</a>";
                }
            }
            echo "</li>\n";
            if ($j > 2) {
                echo "<li>";
                $linktext = $j - 1 > 2 ? '...' : $k1;
                echo "<a href=\"" . getNewsBaseURL() . html_encode(getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath()) . $k1 . "\" title=\"" . sprintf(ngettext('Page %u', 'Page %u', $k1), $k1) . "\">" . $linktext . "</a>";
                echo "</li>\n";
            }
        }
        for ($i = $j; $i <= $ilim; $i++) {
            echo "<li" . ($i == $current ? " class=\"current\"" : "") . ">";
            if ($i == $current) {
                echo $i;
            } else {
                echo "<a href='" . getNewsBaseURL() . html_encode(getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath()) . $i . "' title='" . sprintf(ngettext('Page %1$u', 'Page %1$u', $i), $i) . "'>" . $i . "</a>";
            }
            echo "</li>\n";
        }
        if ($i < $total) {
            echo "<li>";
            $linktext = $total - $i > 1 ? '...' : $k2;
            echo "<a href='" . getNewsBaseURL() . html_encode(getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath()) . $k2 . "' title='" . sprintf(ngettext('Page %u', 'Page %u', $k2), $k2) . "'>" . $linktext . "</a>";
            echo "</li>\n";
        }
        if ($firstlast && $i <= $total) {
            echo "\n  <li class=\"last\">";
            if ($current == $total) {
                echo $total;
            } else {
                echo "<a href=\"" . getNewsBaseURL() . html_encode(getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath()) . $total . "\" title=\"" . sprintf(ngettext('Page {%u}', 'Page {%u}', $total), $total) . "\">" . $total . "</a>";
            }
            echo "</li>\n";
        }
        if ($nextprev) {
            echo "<li class=\"next\">";
            printNextNewsPageLink($next);
            echo "</li>\n";
        }
        echo "</ul>\n";
    }
}
Ejemplo n.º 3
0
 private function getPrevNewsPageURL()
 {
     $page = getCurrentNewsPage();
     if ($page != 1) {
         return getNewsBaseURL() . getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath() . ($page - 1);
     } else {
         return false;
     }
 }