From 8ccfdc2d1ace8eff0c29f18c128501e5b0b97736 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sat, 31 May 2008 22:30:57 +0000 Subject: [PATCH] Added the new pagination method. git-svn-id: http://svn.cleancode.org/svn/pickles@19 4d10bc64-7434-11dc-a737-d2d0f8310089 --- smarty/function.draw_pagination.php | 0 smarty/function.pagination.php | 53 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100755 smarty/function.draw_pagination.php create mode 100755 smarty/function.pagination.php diff --git a/smarty/function.draw_pagination.php b/smarty/function.draw_pagination.php new file mode 100755 index 0000000..e69de29 diff --git a/smarty/function.pagination.php b/smarty/function.pagination.php new file mode 100755 index 0000000..12a95a4 --- /dev/null +++ b/smarty/function.pagination.php @@ -0,0 +1,53 @@ +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 .= ' '; + $pagination .= $current != $total ? '' . $first . '' : $first; + $pagination .= ''; + */ + + $pagination .= $current != 1 ? '' . $prev . '' : '' . $prev . ''; + + for ($i = 1; $i <= $total; $i++) { + $pagination .= $i != $current ? '' . $i . '' : '' . $i . ''; + } + + $pagination .= $current != $total ? '' . $next . '' : '' . $next . ''; + + /* + $pagination .= ' '; + $pagination .= $current != 1 ? '' . $last . '' : $last; + $pagination .= ' '; + */ + + return '