From b7060b33ef317eeac576c504b1fb840d4471e411 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 12 Oct 2014 14:28:08 -0400 Subject: Add pagination/column sorting for search and completed tasks --- app/helpers.php | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'app/helpers.php') diff --git a/app/helpers.php b/app/helpers.php index 622d0ce3..c9f2f8ab 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -590,3 +590,65 @@ function u($controller, $action, array $params = array(), $csrf = false) return $html; } + +/** + * Pagination links + * + * @param array $pagination Pagination information + * @return string + */ +function paginate(array $pagination) +{ + extract($pagination); + + $html = ''; + + return $html; +} + +/** + * Column sorting (work with pagination) + * + * @param string $label Column title + * @param string $column SQL column name + * @param array $pagination Pagination information + * @return string + */ +function order($label, $column, array $pagination) +{ + extract($pagination); + + $prefix = ''; + + if ($order === $column) { + $prefix = $direction === 'DESC' ? '▼ ' : '▲ '; + $direction = $direction === 'DESC' ? 'ASC' : 'DESC'; + } + + $order = $column; + + return $prefix.a($label, $controller, $action, $params + compact('offset', 'order', 'direction')); +} -- cgit v1.2.3