Exemple #1
0
function do_comment_pages($total, $current, $reverse = true)
{
    global $db, $globals;
    if (!$globals['comments_page_size'] || $total <= $globals['comments_page_size'] * $globals['comments_page_threshold']) {
        return;
    }
    $index_limit = 10;
    if ($globals['base_story_url'] = 'story/') {
        $query = $globals['link_permalink'];
    } else {
        $query = preg_replace('/\\/[0-9]+(#.*)$/', '', $_SERVER['QUERY_STRING']);
        if (!empty($query)) {
            $query = htmlspecialchars($query);
            $query = "?{$query}";
        }
    }
    $total_pages = ceil($total / $globals['comments_page_size']);
    if (!$current) {
        if ($reverse) {
            $current = $total_pages;
        } else {
            $current = 1;
        }
    }
    $start = max($current - intval($index_limit / 2), 1);
    $end = $start + $index_limit - 1;
    echo '<div class="pages">';
    if ($current == 1) {
        echo '<span class="nextprev">&#171; ' . _('anterior') . '</span>';
    } else {
        $i = $current - 1;
        echo '<a href="' . get_comment_page_url($i, $total_pages, $query) . '">&#171; ' . _('anterior') . '</a>';
    }
    $dots_before = $dots_after = false;
    for ($i = 1; $i <= $total_pages; $i++) {
        if ($i == $current) {
            echo '<span class="current">' . $i . '</span>';
        } else {
            if ($total_pages < 7 || abs($i - $current) < 3 || $i < 3 || abs($i - $total_pages) < 2) {
                echo '<a href="' . get_comment_page_url($i, $total_pages, $query) . '" title="' . _('ir a página') . " {$i}" . '">' . $i . '</a>';
            } else {
                if ($i < $current && !$dots_before) {
                    $dots_before = true;
                    echo '<span>...</span>';
                } elseif ($i > $current && !$dots_after) {
                    $dots_after = true;
                    echo '<span>...</span>';
                }
            }
        }
    }
    if ($current < $total_pages) {
        $i = $current + 1;
        echo '<a href="' . get_comment_page_url($i, $total_pages, $query) . '">&#187; ' . _('siguiente') . '</a>';
    } else {
        echo '<span class="nextprev">&#187; ' . _('siguiente') . '</span>';
    }
    echo "</div>\n";
}
Exemple #2
0
function do_comment_pages($total, $current)
{
    global $db, $globals;
    if (!$globals['comments_page_size'] || $total <= $globals['comments_page_size']) {
        return;
    }
    $query = $globals['link_permalink'];
    $total_pages = ceil($total / $globals['comments_page_size']);
    if (!$current) {
        $current = 1;
    }
    echo '<div class="pages">';
    if ($current == 1) {
        echo '<span class="nextprev">&#171;</span>';
    } else {
        $i = $current - 1;
        echo '<a href="' . get_comment_page_url($i, $total_pages, $query) . '">&#171;</a>';
    }
    $dots_before = $dots_after = false;
    for ($i = 1; $i <= $total_pages; $i++) {
        if ($i == $current) {
            echo '<span class="current">' . $i . '</span>';
        } else {
            if ($total_pages < 5 || $i < 2 || abs($i - $total_pages) < 1) {
                echo '<a href="' . get_comment_page_url($i, $total_pages, $query) . '" title="' . _('ir a página') . " {$i}" . '">' . $i . '</a>';
            } else {
                if ($i < $current && !$dots_before) {
                    $dots_before = true;
                    echo '<span class="empty">...</span>';
                } elseif ($i > $current && !$dots_after) {
                    $dots_after = true;
                    echo '<span class="empty">...</span>';
                }
            }
        }
    }
    if ($current < $total_pages) {
        $i = $current + 1;
        echo '<a href="' . get_comment_page_url($i, $total_pages, $query) . '">&#187;</a>';
    } else {
        echo '<span class="nextprev">&#187;</span>';
    }
    echo "</div>\n";
}
Exemple #3
0
function do_comment_pages($total, $current, $reverse = true)
{
    global $db, $globals;
    if (!$globals['comments_page_size'] || $total <= $globals['comments_page_size'] * $globals['comments_page_threshold']) {
        return;
    }
    if (!empty($globals['base_story_url'])) {
        $query = $globals['permalink'] . $globals['page_base'];
    } else {
        $query = preg_replace('/\\/[0-9]+(#.*)*$/', '', $_SERVER['QUERY_STRING']);
        if (!empty($query)) {
            $query = htmlspecialchars($query);
            $query = "?{$query}";
        }
    }
    $total_pages = ceil($total / $globals['comments_page_size']);
    if (!$current) {
        if ($reverse) {
            $current = $total_pages;
        } else {
            $current = 1;
        }
    }
    echo '<div class="pages">';
    if ($current == 1) {
        echo '<span class="nextprev">&#171;</span>';
    } else {
        $i = $current - 1;
        echo '<a href="' . get_comment_page_url($i, $total_pages, $query, $reverse) . '" rel="prev">&#171;</a>';
    }
    $dots_before = $dots_after = false;
    for ($i = 1; $i <= $total_pages; $i++) {
        if ($i == $current) {
            echo '<span class="current">' . $i . '</span>';
        } else {
            if ($total_pages < 7 || abs($i - $current) < 1 || $i < 3 || abs($i - $total_pages) < 2) {
                echo '<a href="' . get_comment_page_url($i, $total_pages, $query, $reverse) . '" title="' . _('ir a página') . " {$i}" . '">' . $i . '</a>';
            } else {
                if ($i < $current && !$dots_before) {
                    $dots_before = true;
                    echo '<span>&hellip;</span>';
                } elseif ($i > $current && !$dots_after) {
                    $dots_after = true;
                    echo '<span>&hellip;</span>';
                }
            }
        }
    }
    if ($current < $total_pages) {
        $i = $current + 1;
        echo '<a href="' . get_comment_page_url($i, $total_pages, $query, $reverse) . '" rel="next">&#187;</a>';
    } else {
        echo '<span class="nextprev">&#187;</span>';
    }
    echo '</div>';
}
Exemple #4
0
function do_comment_pages($total, $current, $reverse = true)
{
    global $db, $globals;
    if (!$globals['comments_page_size'] || $total <= $globals['comments_page_size'] * $globals['comments_page_threshold']) {
        return;
    }
    $query = $globals['permalink'] . $globals['page_base'];
    $total_pages = ceil($total / $globals['comments_page_size']);
    if (!$current) {
        if ($reverse) {
            $current = $total_pages;
        } else {
            $current = 1;
        }
    }
    echo '<div class="pages">';
    // MDOMENECH
    $go_prev = _('previous');
    $go_next = _('next');
    echo '<ul class="pagination">';
    if ($current == 1) {
        echo '<li><span class="nextprev">' . $go_prev . '</span></li>';
    } else {
        $i = $current - 1;
        echo '<li><a href="' . get_comment_page_url($i, $total_pages, $query, $reverse) . '" rel="prev">' . $go_prev . '</a></li>';
    }
    $dots_before = $dots_after = false;
    for ($i = 1; $i <= $total_pages; $i++) {
        if ($i == $current) {
            echo '<li><span class="current">' . $i . '</span></li>';
        } else {
            if ($total_pages < 7 || abs($i - $current) < 1 || $i < 3 || abs($i - $total_pages) < 2) {
                echo '<li><a href="' . get_comment_page_url($i, $total_pages, $query, $reverse) . '" title="' . _('ir a página') . " {$i}" . '">' . $i . '</a></li>';
            } else {
                if ($i < $current && !$dots_before) {
                    $dots_before = true;
                    echo '<li><span><i class="fa fa-ellipsis-h"></i></span></li>';
                } elseif ($i > $current && !$dots_after) {
                    $dots_after = true;
                    echo '<li><span><i class="fa fa-ellipsis-h"></i></span></li>';
                }
            }
        }
    }
    if ($current < $total_pages) {
        $i = $current + 1;
        echo '<li><a href="' . get_comment_page_url($i, $total_pages, $query, $reverse) . '" rel="next">' . $go_next . '</a></li>';
    } else {
        echo '<li><span class="nextprev">' . $go_next . '</span></li>';
    }
    echo '</ul><!-- pagination -->';
    echo '</div>';
}
Exemple #5
0
function do_comment_pages($total, $current) {
	global $db, $globals;

	if ( ! $globals['comments_page_size'] || $total <= $globals['comments_page_size']*$globals['comments_page_threshold']) return;
	
	if (! empty($globals['base_story_url'])) {
		$query = $globals['link_permalink'];
	} else {
		$query=preg_replace('/\/[0-9]+(#.*)$/', '', $_SERVER['QUERY_STRING']);
		if(!empty($query)) {
			$query = htmlspecialchars($query);
			$query = "?$query";
		}
	}

	$total_pages=ceil($total/$globals['comments_page_size']);
	if (! $current) $current = 1;
	
	echo '<div class="pages">';

	if($current==1) {
		echo '<span class="nextprev">&#171;</span>';
	} else {
		$i = $current-1;
		echo '<a href="'.get_comment_page_url($i, $total_pages, $query).'">&#171;</a>';
	}

	$dots_before = $dots_after = false;
	for ($i=1;$i<=$total_pages;$i++) {
		if($i==$current) {
			echo '<span class="current">'.$i.'</span>';
		} else {
			if ($total_pages < 5 || $i < 2 || abs($i-$total_pages) < 1) {
				echo '<a href="'.get_comment_page_url($i, $total_pages, $query).'" title="'._('ir a página')." $i".'">'.$i.'</a>';
			} else {
				if ($i<$current && !$dots_before) {
					$dots_before = true;
					echo '<span class="empty">...</span>';
				} elseif ($i>$current && !$dots_after) {
					$dots_after = true;
					echo '<span class="empty">...</span>';
				}
			}
		}
	}

	if($current<$total_pages) {
		$i = $current+1;
		echo '<a href="'.get_comment_page_url($i, $total_pages, $query).'">&#187;</a>';
	} else {
		echo '<span class="nextprev">&#187;</span>';
	}
	echo "</div>\n";

}