diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2012-08-25 14:34:48 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2012-10-17 23:33:18 +0200 |
commit | 5ea662f649833f50483da544b513ca102e390fd8 (patch) | |
tree | 5f68c6cba723723929b76ca0c21f1f6b717e4b16 /phpBB/includes/functions.php | |
parent | fa5753de707e0b24c686cf75a7ae9d261bc2a8f2 (diff) | |
download | forums-5ea662f649833f50483da544b513ca102e390fd8.tar forums-5ea662f649833f50483da544b513ca102e390fd8.tar.gz forums-5ea662f649833f50483da544b513ca102e390fd8.tar.bz2 forums-5ea662f649833f50483da544b513ca102e390fd8.tar.xz forums-5ea662f649833f50483da544b513ca102e390fd8.zip |
[ticket/11014] Restore template vars for next/previous links
They were dropped while the function was refactored:
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.
PHPBB3-11014
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 08dd03504c..4e5be20dbf 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2177,6 +2177,45 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam '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); + } } /** |