53 lines
1.5 KiB
PHP
Executable file
53 lines
1.5 KiB
PHP
Executable file
<?php
|
|
|
|
function smarty_function_pagination($params, &$smarty) {
|
|
if (empty($params['current'])) {
|
|
$smarty->trigger_error('assign: missing \'current\' parameter');
|
|
}
|
|
else if (empty($params['total'])) {
|
|
$smarty->trigger_error('assign: missing \'total\' parameter');
|
|
}
|
|
else if (empty($params['section'])) {
|
|
$smarty->trigger_error('assign: missing \'section\' parameter');
|
|
}
|
|
else {
|
|
$current =& $params['current'];
|
|
$total =& $params['total'];
|
|
$section =& $params['section'];
|
|
|
|
$pagination = null;
|
|
|
|
// « = double
|
|
// &lsaquo = single
|
|
|
|
$first = '« First';
|
|
$last = 'Last »';
|
|
|
|
$prev = '« Previous';
|
|
$next = 'Next »';
|
|
|
|
/*
|
|
$pagination .= ' <span class="pagination">';
|
|
$pagination .= $current != $total ? '<a href="/blog/first">' . $first . '</a>' : $first;
|
|
$pagination .= '</span>';
|
|
*/
|
|
|
|
$pagination .= $current != 1 ? '<a href="/' . $section . '/' . ($current - 1) . '">' . $prev . '</a>' : '<span class="prev">' . $prev . '</span>';
|
|
|
|
for ($i = 1; $i <= $total; $i++) {
|
|
$pagination .= $i != $current ? '<a href="/' . $section . '/' . $i . '">' . $i . '</a>' : '<span class="current">' . $i . '</span>';
|
|
}
|
|
|
|
$pagination .= $current != $total ? '<a href="/' . $section . '/' . ($current + 1) . '">' . $next . '</a>' : '<span class="next">' . $next . '</span>';
|
|
|
|
/*
|
|
$pagination .= ' <span class="pagination">';
|
|
$pagination .= $current != 1 ? '<a href="/blog/last">' . $last . '</a>' : $last;
|
|
$pagination .= '</span> ';
|
|
*/
|
|
|
|
return '<div id="pagination">' . $pagination . '</pagination>';
|
|
}
|
|
}
|
|
|
|
?>
|