From: cash Date: Thu, 9 Dec 2010 02:05:37 +0000 (+0000) Subject: Updated pagination to use semantic html X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=d366d495d1e77b88fccc47a1bdf2220438bb0ddc;p=lorea%2Felgg.git Updated pagination to use semantic html git-svn-id: http://code.elgg.org/elgg/trunk@7573 36083f99-b078-4883-b0ff-0f9b5a30f544 --- diff --git a/views/default/css/screen.php b/views/default/css/screen.php index 6092aa5aa..1e9c41391 100644 --- a/views/default/css/screen.php +++ b/views/default/css/screen.php @@ -796,82 +796,37 @@ li.navigation-more ul li { /* *************************************** PAGINATION *************************************** */ -.pagination { - margin:5px 0 5px 0; - padding:5px 0; -} -.pagination .pagination-number { - display:block; - float:left; - background:#ffffff; - border:1px solid #4690d6; +.elgg-pagination { + margin: 10px 0; + display: block; text-align: center; - color:#4690d6; - font-size: 12px; - font-weight: normal; - margin:0 6px 0 0; - padding:0px 4px; - cursor: pointer; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; } -.pagination .pagination-number:hover { - background:#4690d6; - color:white; - text-decoration: none; -} -.pagination .pagination-more { - display:block; - float:left; - background:#ffffff; - border:1px solid #ffffff; +.elgg-pagination li { + display: inline; + margin: 0 6px 0 0; text-align: center; - color:#4690d6; - font-size: 12px; - font-weight: normal; - margin:0 6px 0 0; - padding:0px 4px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; } -.pagination .pagination-previous, -.pagination .pagination-next { - display:block; - float:left; - border:1px solid #cccccc; - color:#4690d6; - text-align: center; - font-size: 12px; - font-weight: normal; - margin:0 6px 0 0; - padding:0px 4px; - cursor: pointer; +.elgg-pagination a, .elgg-pagination span { + padding: 2px 6px; -webkit-border-radius: 4px; -moz-border-radius: 4px; + color: #4690d6; + border: 1px solid #4690d6; + font-size: 12px; } -.pagination .pagination-previous:hover, -.pagination .pagination-next:hover { - background:#4690d6; - border:1px solid #4690d6; - color:white; +.elgg-pagination a:hover { + background: #4690d6; + color: white; text-decoration: none; } -.pagination .pagination-currentpage { - display:block; - float:left; - background:#4690d6; - border:1px solid #4690d6; - text-align: center; - color:white; - font-size: 12px; - font-weight: bold; - margin:0 6px 0 0; - padding:0px 4px; - cursor: pointer; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; +.elgg-pagination .inactive { + color: #CCCCCC; + border-color: #CCCCCC; +} +.elgg-pagination .active { + color: #555555; + border-color: #555555; } - /* *************************************** ELGG TABBED PAGE NAVIGATION diff --git a/views/default/navigation/pagination.php b/views/default/navigation/pagination.php index fc15470bc..9fcd8153e 100644 --- a/views/default/navigation/pagination.php +++ b/views/default/navigation/pagination.php @@ -12,99 +12,106 @@ * @uses string $vars['baseurl'] Base URL to use in links */ -$offset = (int) elgg_get_array_value('offset', $vars, 0); +if (elgg_in_context('widget')) { + // widgets do not show pagination + return true; +} + +$offset = abs((int) elgg_get_array_value('offset', $vars, 0)); // because you can say $vars['limit'] = 0 if (!$limit = (int) elgg_get_array_value('limit', $vars, 10)) { $limit = 10; } + $count = (int) elgg_get_array_value('count', $vars, 0); $word = elgg_get_array_value('word', $vars, 'offset'); -$baseurl = elgg_get_array_value('baseurl', $vars, current_page_url()); +$base_url = elgg_get_array_value('baseurl', $vars, current_page_url()); + +$num_pages = elgg_get_array_value('num_pages', $vars, 10); +$delta = ceil($num_pages / 2); -$totalpages = ceil($count / $limit); -$currentpage = ceil($offset / $limit) + 1; +if ($count <= $limit && $offset == 0) { + // no need for pagination + return true; +} -//only display if there is content to paginate through or if we already have an offset -if (($count > $limit || $offset > 0) && elgg_get_context() != 'widget') { +$total_pages = ceil($count / $limit); +$current_page = ceil($offset / $limit) + 1; + +$pages = new stdClass(); +$pages->prev = array( + 'text' => '« ' . elgg_echo('previous'), + 'href' => '', +); +$pages->next = array( + 'text' => elgg_echo('next') . ' »', + 'href' => '', +); +$pages->items = array(); + +// Add pages before the current page +if ($current_page > 1) { + $prev_offset = $offset - $limit; + if ($prev_offset < 0) { + $prev_offset = 0; + } - ?> + $pages->prev['href'] = elgg_http_add_url_query_elements($base_url, array($word => $prev_offset)); - - ';