Exemplo n.º 1
0
 static function printNewsNavigation($nexttext, $prevtext)
 {
     global $_zp_zenpage_total_pages;
     $total = ceil(getTotalArticles() / getOption("zenpage_articles_per_page"));
     $current = getCurrentNewsPage();
     if ($total > 1) {
         $j = max(1, min($current - 3, $total - 6));
         if ($j != 1) {
             echo '<div class="nav-cell">';
             echo "<span class='valign'>";
             echo "<a href=\"" . getNewsBaseURL() . getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath() . max($j - 4, 1) . "\">...</a>";
             echo "</span></div>\n";
         }
         for ($i = $j; $i <= min($total, $j + 6); $i++) {
             if ($i == $current) {
                 echo '<div class="nav-cell current">';
                 echo "<span class='valign'>";
                 echo $i;
                 echo "</span></div>\n";
             } else {
                 echo '<div class="nav-cell">';
                 echo "<span class='valign'>";
                 echo "<a href='" . getNewsBaseURL() . getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath() . $i . "' >" . $i . "</a>";
                 echo "</span></div>\n";
             }
         }
         if ($i <= $total) {
             echo '<div class="nav-cell">';
             echo "<span class='valign'>";
             echo "<a href=\"" . getNewsBaseURL() . getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath() . min($j + 10, $total) . "\">...</a>";
             echo "</span></div>\n";
         }
         $prevUrl = self::getPrevNewsPageURL();
         if ($prevUrl) {
             $prevnext['prev'] = "<a href='{$prevUrl}'>{$prevtext}</a>";
         }
         $nextUrl = getNextNewsPageURL();
         if ($nextUrl && $current < $total) {
             $prevnext['next'] = "<a href='{$nextUrl}'>{$nexttext}</a>";
         }
         return $prevnext;
     }
 }
Exemplo n.º 2
0
 function printNewsPageListWithNav($next = 'next &raquo;', $prev = '&laquo; prev', $nextprev = true, $class = 'pagelist')
 {
     global $_zp_zenpage_total_pages;
     $total = ceil(getTotalArticles() / getOption("zenpage_articles_per_page"));
     $current = getCurrentNewsPage();
     echo "<ul class=\"{$class}\">";
     if ($nextprev) {
         echo "<li class=\"prev\">";
         $this->printPrevNewsPageLink($prev);
         echo "</li>";
     }
     $j = max(1, min($current - 3, $total - 6));
     if ($j != 1) {
         echo "\n <li>";
         echo "<a href=\"" . getNewsBaseURL() . getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath() . max($j - 4, 1) . "\">...</a>";
         echo '</li>';
     }
     for ($i = $j; $i <= min($total, $j + 6); $i++) {
         if ($i == $current) {
             echo "<li class='current'><a>" . $i . "</a></li>\n";
         } else {
             echo "<li><a href='" . getNewsBaseURL() . getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath() . $i . "' title='" . gettext("Page") . " " . $i . "'>" . $i . "</a></li>\n";
         }
     }
     if ($i <= $total) {
         echo "\n <li>";
         echo "<a href=\"" . getNewsBaseURL() . getNewsCategoryPathNav() . getNewsArchivePathNav() . getNewsPagePath() . min($j + 10, $total) . "\">...</a>";
         echo '</li>';
     }
     if ($nextprev) {
         if ($current < $total) {
             echo "<li class='next'>";
             printNextNewsPageLink($next);
             echo "</li>";
         } else {
             echo "<li class='next'><a>{$next}</a></li>";
         }
     }
     echo "</ul>";
 }
Exemplo n.º 3
0
<?php

global $_zp_themeroot, $_zp_current_album;
$total = ceil(getTotalArticles() / getOption("zenpage_articles_per_page"));
$current = getCurrentNewsPage();
$prevUrl = NewsUtil::getPrevNewsPageURL();
if ($current < $total) {
    $nextUrl = getNextNewsPageURL();
}
?>
<div id="list">
	<div id="navigation" <?php 
echo $prevUrl ? "next='" . $prevUrl . "'" : "";
echo $nextUrl ? "prev='" . $nextUrl . "'" : "";
?>
>
		<div id="bar">	
			<div class="nav-cell filler"><span>&nbsp;</span></div>
			<?php 
$nextText = "<div id='news-nav-prev' class='news-nav-scroll opa60'><img src='{$_zp_themeroot}/resources/images/arrow_up.png' width='16' height='16'/></div>";
$prevText = "<div id='news-nav-next' class='news-nav-scroll opa60 {$cls}'><img src='{$_zp_themeroot}/resources/images/arrow_down.png' width='16' height='16'/></div>";
$prevNext = NewsUtil::printNewsNavigation($prevText, $nextText);
?>
			<div class="nav-cell filler end"><span>&nbsp;</span></div>
		</div>
		<div id="nav">
			<div class="prev"><?php 
echo isset($prevNext['prev']) ? $prevNext['prev'] : "<div id='news-nav-prev' class='proxy'></div>";
?>
</div>
			<div class="next"><?php 
/**
 * Gets the LIMIT and OFFSET for the query that gets the news articles
 *
 * @param int $articles_per_page The number of articles to get
 * @param bool $ignorepagination If pagination should be ingored so always with the first is started (false is default)
 * @return string
 */
function getLimitAndOffset($articles_per_page, $ignorepagination = false)
{
    deprecated_function_notify(gettext('Use the Zenpage class method instead.'));
    global $_zp_zenpage_total_pages;
    if (strstr(dirname($_SERVER['REQUEST_URI']), '/' . PLUGIN_FOLDER . '/zenpage')) {
        $page = getCurrentAdminNewsPage();
    } else {
        $page = getCurrentNewsPage();
    }
    if (!empty($articles_per_page)) {
        $_zp_zenpage_total_pages = ceil(getTotalArticles() / $articles_per_page);
    }
    if ($ignorepagination) {
        $offset = 0;
    } else {
        $offset = ($page - 1) * $articles_per_page;
    }
    // Prevent sql limit/offset error when saving plugin options and on the plugins page
    if (empty($articles_per_page)) {
        $limit = "";
    } else {
        $limit = " LIMIT " . $offset . "," . $articles_per_page;
    }
    return $limit;
}