diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-10-22 17:44:34 -0400 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-10-22 17:44:34 -0400 |
commit | 6bf60ac5cb897511fe48dc2d28ddb3d02a44c410 (patch) | |
tree | 1bd10a972a0dfc5997def5d376ecc478c97130db /phpBB/includes/functions.php | |
parent | b3fdf8a0463438e1e86979a5a4e50611228aea52 (diff) | |
parent | b0bfe724fbb7cb69fa8eed2643bebe44c60482ad (diff) | |
download | forums-6bf60ac5cb897511fe48dc2d28ddb3d02a44c410.tar forums-6bf60ac5cb897511fe48dc2d28ddb3d02a44c410.tar.gz forums-6bf60ac5cb897511fe48dc2d28ddb3d02a44c410.tar.bz2 forums-6bf60ac5cb897511fe48dc2d28ddb3d02a44c410.tar.xz forums-6bf60ac5cb897511fe48dc2d28ddb3d02a44c410.zip |
Merge PR #971 branch 'nickvergessen/ticket/11018' into develop
* nickvergessen/ticket/11018:
[ticket/11014] Fix old pagination assignment
[ticket/11018] Fix several paginations in ACP
[ticket/11014] Fix IF statements for new template pagination
[ticket/11014] Fix text for previous/next links in Subsilver2
[ticket/11023] Fix additional whitespaces that were added by PHPBB3-10968
[ticket/11018] Always display previous/next links if we can display one
[ticket/11014] Restore template vars for next/previous links
[ticket/11018] Swap prev/next links on pagination to the old order
[ticket/11067] Copy prosilver CSS to adm, so the pagination looks the same
[ticket/11018] Fix minor issues with CSS in prosilver
[ticket/11018] Attempt to fix li.pagination alignment issue
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b255d41241..43b81f3f26 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2171,14 +2171,14 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam $end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; } - if ($on_page != $total_pages) + if ($on_page != 1) { $template->assign_block_vars($block_var_name, array( 'PAGE_NUMBER' => '', - 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page), + 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page), 'S_IS_CURRENT' => false, - 'S_IS_PREV' => false, - 'S_IS_NEXT' => true, + 'S_IS_PREV' => true, + 'S_IS_NEXT' => false, 'S_IS_ELLIPSIS' => false, )); } @@ -2225,17 +2225,56 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam } while ($at_page <= $total_pages); - if ($on_page != 1) + if ($on_page != $total_pages) { $template->assign_block_vars($block_var_name, array( 'PAGE_NUMBER' => '', - 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page), + 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page), 'S_IS_CURRENT' => false, - 'S_IS_PREV' => true, - 'S_IS_NEXT' => false, + 'S_IS_PREV' => false, + 'S_IS_NEXT' => true, 'S_IS_ELLIPSIS' => false, )); } + + // If the block_var_name is a nested block, we will use the last (most + // inner) block as a prefix for the template variables. If the last block + // name is pagination, the prefix is empty. If the rest of the + // block_var_name is not empty, we will modify the last row of that block + // and add our pagination items. + $tpl_block_name = $tpl_prefix = ''; + if (strrpos($block_var_name, '.') !== false) + { + $tpl_block_name = substr($block_var_name, 0, strrpos($block_var_name, '.')); + $tpl_prefix = strtoupper(substr($block_var_name, strrpos($block_var_name, '.') + 1)); + } + else + { + $tpl_prefix = strtoupper($block_var_name); + } + $tpl_prefix = ($tpl_prefix == 'PAGINATION') ? '' : $tpl_prefix . '_'; + + $previous_page = ($on_page != 1) ? $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page) : ''; + + $template_array = array( + $tpl_prefix . 'BASE_URL' => $base_url, + 'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url), + $tpl_prefix . 'PER_PAGE' => $per_page, + $tpl_prefix . 'PREVIOUS_PAGE' => $previous_page, + $tpl_prefix . 'PREV_PAGE' => $previous_page, + $tpl_prefix . 'NEXT_PAGE' => ($on_page != $total_pages) ? $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page) : '', + $tpl_prefix . 'TOTAL_PAGES' => $total_pages, + $tpl_prefix . 'CURRENT_PAGE' => $on_page, + ); + + if ($tpl_block_name) + { + $template->alter_block_array($tpl_block_name, $template_array, true, 'change'); + } + else + { + $template->assign_vars($template_array); + } } /** @@ -2260,7 +2299,6 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star $template->assign_vars(array( 'PER_PAGE' => $per_page, 'ON_PAGE' => $on_page, - 'A_BASE_URL' => addslashes($base_url), )); |